Commit from m3o/m3o action

This commit is contained in:
m3o-actions
2022-03-09 20:15:45 +00:00
parent 2eb4296382
commit c4eb97765e
24 changed files with 1221 additions and 1221 deletions

View File

@@ -4,65 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/app/api](https
Endpoints:
## Run
Run an app from source
[https://m3o.com/app/api#Run](https://m3o.com/app/api#Run)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/app"
)
// Run an app from source
func RunAnApp() {
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
rsp, err := appService.Run(&app.RunRequest{
Branch: "master",
Name: "helloworld",
Port: 8080,
Region: "europe-west1",
Repo: "github.com/asim/helloworld",
})
fmt.Println(rsp, err)
}
```
## Regions
Return the support regions
[https://m3o.com/app/api#Regions](https://m3o.com/app/api#Regions)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/app"
)
// Return the support regions
func ListRegions() {
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
rsp, err := appService.Regions(&app.RegionsRequest{
})
fmt.Println(rsp, err)
}
```
## Status
Get the status of an app
@@ -230,3 +171,62 @@ func ListTheApps() {
}
```
## Run
Run an app from source
[https://m3o.com/app/api#Run](https://m3o.com/app/api#Run)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/app"
)
// Run an app from source
func RunAnApp() {
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
rsp, err := appService.Run(&app.RunRequest{
Branch: "master",
Name: "helloworld",
Port: 8080,
Region: "europe-west1",
Repo: "github.com/asim/helloworld",
})
fmt.Println(rsp, err)
}
```
## Regions
Return the support regions
[https://m3o.com/app/api#Regions](https://m3o.com/app/api#Regions)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/app"
)
// Return the support regions
func ListRegions() {
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
rsp, err := appService.Regions(&app.RegionsRequest{
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,33 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/cache/api](htt
Endpoints:
## ListKeys
List all the available keys
[https://m3o.com/cache/api#ListKeys](https://m3o.com/cache/api#ListKeys)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/cache"
)
// List all the available keys
func ListTheKeys() {
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
rsp, err := cacheService.ListKeys(&cache.ListKeysRequest{
})
fmt.Println(rsp, err)
}
```
## Set
Set an item in the cache. Overwrites any existing value already set.
@@ -174,3 +147,30 @@ Value: 2,
}
```
## ListKeys
List all the available keys
[https://m3o.com/cache/api#ListKeys](https://m3o.com/cache/api#ListKeys)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/cache"
)
// List all the available keys
func ListTheKeys() {
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
rsp, err := cacheService.ListKeys(&cache.ListKeysRequest{
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,35 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/chat/api](http
Endpoints:
## Create
Create a new chat room
[https://m3o.com/chat/api#Create](https://m3o.com/chat/api#Create)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/chat"
)
// Create a new chat room
func CreateAnewChat() {
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
rsp, err := chatService.Create(&chat.CreateRequest{
Description: "The general chat room",
Name: "general",
})
fmt.Println(rsp, err)
}
```
## Invite
Invite a user to a chat room
@@ -132,12 +103,12 @@ func JoinAroom() {
}
}
```
## Leave
## Kick
Leave a chat room
Kick a user from a chat room
[https://m3o.com/chat/api#Leave](https://m3o.com/chat/api#Leave)
[https://m3o.com/chat/api#Kick](https://m3o.com/chat/api#Kick)
```go
package example
@@ -149,10 +120,39 @@ import(
"go.m3o.com/chat"
)
// Leave a chat room
func LeaveAroom() {
// Kick a user from a chat room
func KickAuserFromAroom() {
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
rsp, err := chatService.Leave(&chat.LeaveRequest{
rsp, err := chatService.Kick(&chat.KickRequest{
})
fmt.Println(rsp, err)
}
```
## Create
Create a new chat room
[https://m3o.com/chat/api#Create](https://m3o.com/chat/api#Create)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/chat"
)
// Create a new chat room
func CreateAnewChat() {
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
rsp, err := chatService.Create(&chat.CreateRequest{
Description: "The general chat room",
Name: "general",
})
fmt.Println(rsp, err)
@@ -240,12 +240,12 @@ func GetChatHistory() {
}
```
## Kick
## Leave
Kick a user from a chat room
Leave a chat room
[https://m3o.com/chat/api#Kick](https://m3o.com/chat/api#Kick)
[https://m3o.com/chat/api#Leave](https://m3o.com/chat/api#Leave)
```go
package example
@@ -257,10 +257,10 @@ import(
"go.m3o.com/chat"
)
// Kick a user from a chat room
func KickAuserFromAroom() {
// Leave a chat room
func LeaveAroom() {
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
rsp, err := chatService.Kick(&chat.KickRequest{
rsp, err := chatService.Leave(&chat.LeaveRequest{
})
fmt.Println(rsp, err)

View File

@@ -4,6 +4,66 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/comments/api](
Endpoints:
## Update
Update a comment
[https://m3o.com/comments/api#Update](https://m3o.com/comments/api#Update)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/comments"
)
// Update a comment
func UpdateAcomment() {
commentsService := comments.NewCommentsService(os.Getenv("M3O_API_TOKEN"))
rsp, err := commentsService.Update(&comments.UpdateRequest{
Comment: &comments.Comment{
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
Subject: "Update Comment",
Text: "Updated comment text",
},
})
fmt.Println(rsp, err)
}
```
## Delete
Delete a comment
[https://m3o.com/comments/api#Delete](https://m3o.com/comments/api#Delete)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/comments"
)
// Delete a comment
func DeleteAcomment() {
commentsService := comments.NewCommentsService(os.Getenv("M3O_API_TOKEN"))
rsp, err := commentsService.Delete(&comments.DeleteRequest{
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
})
fmt.Println(rsp, err)
}
```
## Events
Subscribe to comments events
@@ -128,63 +188,3 @@ func ListAllComments() {
}
```
## Update
Update a comment
[https://m3o.com/comments/api#Update](https://m3o.com/comments/api#Update)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/comments"
)
// Update a comment
func UpdateAcomment() {
commentsService := comments.NewCommentsService(os.Getenv("M3O_API_TOKEN"))
rsp, err := commentsService.Update(&comments.UpdateRequest{
Comment: &comments.Comment{
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
Subject: "Update Comment",
Text: "Updated comment text",
},
})
fmt.Println(rsp, err)
}
```
## Delete
Delete a comment
[https://m3o.com/comments/api#Delete](https://m3o.com/comments/api#Delete)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/comments"
)
// Delete a comment
func DeleteAcomment() {
commentsService := comments.NewCommentsService(os.Getenv("M3O_API_TOKEN"))
rsp, err := commentsService.Delete(&comments.DeleteRequest{
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,6 +4,61 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/crypto/api](ht
Endpoints:
## History
Returns the history for the previous close
[https://m3o.com/crypto/api#History](https://m3o.com/crypto/api#History)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/crypto"
)
// Returns the history for the previous close
func GetPreviousClose() {
cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN"))
rsp, err := cryptoService.History(&crypto.HistoryRequest{
Symbol: "BTCUSD",
})
fmt.Println(rsp, err)
}
```
## Symbols
Returns the full list of supported symbols
[https://m3o.com/crypto/api#Symbols](https://m3o.com/crypto/api#Symbols)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/crypto"
)
// Returns the full list of supported symbols
func GetListOfAllSupportedSymbols() {
cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN"))
rsp, err := cryptoService.Symbols(&crypto.SymbolsRequest{
})
fmt.Println(rsp, err)
}
```
## News
Get news related to a currency
@@ -88,58 +143,3 @@ func GetAcryptocurrencyQuote() {
}
```
## History
Returns the history for the previous close
[https://m3o.com/crypto/api#History](https://m3o.com/crypto/api#History)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/crypto"
)
// Returns the history for the previous close
func GetPreviousClose() {
cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN"))
rsp, err := cryptoService.History(&crypto.HistoryRequest{
Symbol: "BTCUSD",
})
fmt.Println(rsp, err)
}
```
## Symbols
Returns the full list of supported symbols
[https://m3o.com/crypto/api#Symbols](https://m3o.com/crypto/api#Symbols)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/crypto"
)
// Returns the full list of supported symbols
func GetListOfAllSupportedSymbols() {
cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN"))
rsp, err := cryptoService.Symbols(&crypto.SymbolsRequest{
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,12 +4,12 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/db/api](https:
Endpoints:
## RenameTable
## ListTables
Rename a table
List tables in the DB
[https://m3o.com/db/api#RenameTable](https://m3o.com/db/api#RenameTable)
[https://m3o.com/db/api#ListTables](https://m3o.com/db/api#ListTables)
```go
package example
@@ -21,12 +21,44 @@ import(
"go.m3o.com/db"
)
// Rename a table
func RenameTable() {
// List tables in the DB
func ListTables() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.RenameTable(&db.RenameTableRequest{
From: "examples2",
To: "examples3",
rsp, err := dbService.ListTables(&db.ListTablesRequest{
})
fmt.Println(rsp, err)
}
```
## Create
Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
[https://m3o.com/db/api#Create](https://m3o.com/db/api#Create)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/db"
)
// Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
func CreateArecord() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Create(&db.CreateRequest{
Record: map[string]interface{}{
"id": "1",
"name": "Jane",
"age": 42,
"isActive": true,
},
Table: "example",
})
fmt.Println(rsp, err)
@@ -117,68 +149,6 @@ func DropTable() {
})
fmt.Println(rsp, err)
}
```
## Count
Count records in a table
[https://m3o.com/db/api#Count](https://m3o.com/db/api#Count)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/db"
)
// Count records in a table
func CountEntriesInAtable() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Count(&db.CountRequest{
Table: "example",
})
fmt.Println(rsp, err)
}
```
## Create
Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
[https://m3o.com/db/api#Create](https://m3o.com/db/api#Create)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/db"
)
// Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
func CreateArecord() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Create(&db.CreateRequest{
Record: map[string]interface{}{
"age": 42,
"isActive": true,
"id": "1",
"name": "Jane",
},
Table: "example",
})
fmt.Println(rsp, err)
}
```
## Update
@@ -241,12 +211,12 @@ func TruncateTable() {
}
```
## ListTables
## Count
List tables in the DB
Count records in a table
[https://m3o.com/db/api#ListTables](https://m3o.com/db/api#ListTables)
[https://m3o.com/db/api#Count](https://m3o.com/db/api#Count)
```go
package example
@@ -258,10 +228,40 @@ import(
"go.m3o.com/db"
)
// List tables in the DB
func ListTables() {
// Count records in a table
func CountEntriesInAtable() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.ListTables(&db.ListTablesRequest{
rsp, err := dbService.Count(&db.CountRequest{
Table: "example",
})
fmt.Println(rsp, err)
}
```
## RenameTable
Rename a table
[https://m3o.com/db/api#RenameTable](https://m3o.com/db/api#RenameTable)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/db"
)
// Rename a table
func RenameTable() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.RenameTable(&db.RenameTableRequest{
From: "examples2",
To: "examples3",
})
fmt.Println(rsp, err)

View File

@@ -12,10 +12,10 @@ func main() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Create(&db.CreateRequest{
Record: map[string]interface{}{
"name": "Jane",
"age": 42,
"isActive": true,
"id": "1",
"name": "Jane",
},
Table: "example",
})

View File

@@ -4,6 +4,38 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/email/api](htt
Endpoints:
## Send
Send an email by passing in from, to, subject, and a text or html body
[https://m3o.com/email/api#Send](https://m3o.com/email/api#Send)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/email"
)
// Send an email by passing in from, to, subject, and a text or html body
func SendEmail() {
emailService := email.NewEmailService(os.Getenv("M3O_API_TOKEN"))
rsp, err := emailService.Send(&email.SendRequest{
From: "Awesome Dot Com",
Subject: "Email verification",
TextBody: `Hi there,
Please verify your email by clicking this link: $micro_verification_link`,
})
fmt.Println(rsp, err)
}
```
## Parse
Parse an RFC5322 address e.g "Joe Blogs <joe@example.com>"
@@ -60,35 +92,3 @@ func ValidateEmail() {
}
```
## Send
Send an email by passing in from, to, subject, and a text or html body
[https://m3o.com/email/api#Send](https://m3o.com/email/api#Send)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/email"
)
// Send an email by passing in from, to, subject, and a text or html body
func SendEmail() {
emailService := email.NewEmailService(os.Getenv("M3O_API_TOKEN"))
rsp, err := emailService.Send(&email.SendRequest{
From: "Awesome Dot Com",
Subject: "Email verification",
TextBody: `Hi there,
Please verify your email by clicking this link: $micro_verification_link`,
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,6 +4,36 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/emoji/api](htt
Endpoints:
## Print
Print text and renders the emojis with aliases e.g
let's grab a :beer: becomes let's grab a 🍺
[https://m3o.com/emoji/api#Print](https://m3o.com/emoji/api#Print)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/emoji"
)
// Print text and renders the emojis with aliases e.g
// let's grab a :beer: becomes let's grab a 🍺
func PrintTextIncludingEmoji() {
emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN"))
rsp, err := emojiService.Print(&emoji.PrintRequest{
Text: "let's grab a :beer:",
})
fmt.Println(rsp, err)
}
```
## Find
Find an emoji by its alias e.g :beer:
@@ -59,33 +89,3 @@ func GetFlagByCountryCode() {
}
```
## Print
Print text and renders the emojis with aliases e.g
let's grab a :beer: becomes let's grab a 🍺
[https://m3o.com/emoji/api#Print](https://m3o.com/emoji/api#Print)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/emoji"
)
// Print text and renders the emojis with aliases e.g
// let's grab a :beer: becomes let's grab a 🍺
func PrintTextIncludingEmoji() {
emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN"))
rsp, err := emojiService.Print(&emoji.PrintRequest{
Text: "let's grab a :beer:",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,39 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/event/api](htt
Endpoints:
## Publish
Publish a event to the event stream.
[https://m3o.com/event/api#Publish](https://m3o.com/event/api#Publish)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/event"
)
// Publish a event to the event stream.
func PublishAnEvent() {
eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN"))
rsp, err := eventService.Publish(&event.PublishRequest{
Message: map[string]interface{}{
"id": "1",
"type": "signup",
"user": "john",
},
Topic: "user",
})
fmt.Println(rsp, err)
}
```
## Consume
Consume events from a given topic.
@@ -106,3 +73,36 @@ func ReadEventsOnAtopic() {
}
```
## Publish
Publish a event to the event stream.
[https://m3o.com/event/api#Publish](https://m3o.com/event/api#Publish)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/event"
)
// Publish a event to the event stream.
func PublishAnEvent() {
eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN"))
rsp, err := eventService.Publish(&event.PublishRequest{
Message: map[string]interface{}{
"type": "signup",
"user": "john",
"id": "1",
},
Topic: "user",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/forex/api](htt
Endpoints:
## Price
Get the latest price for a given forex ticker
[https://m3o.com/forex/api#Price](https://m3o.com/forex/api#Price)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/forex"
)
// Get the latest price for a given forex ticker
func GetAnFxPrice() {
forexService := forex.NewForexService(os.Getenv("M3O_API_TOKEN"))
rsp, err := forexService.Price(&forex.PriceRequest{
Symbol: "GBPUSD",
})
fmt.Println(rsp, err)
}
```
## Quote
Get the latest quote for the forex
@@ -60,31 +88,3 @@ func GetPreviousClose() {
}
```
## Price
Get the latest price for a given forex ticker
[https://m3o.com/forex/api#Price](https://m3o.com/forex/api#Price)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/forex"
)
// Get the latest price for a given forex ticker
func GetAnFxPrice() {
forexService := forex.NewForexService(os.Getenv("M3O_API_TOKEN"))
rsp, err := forexService.Price(&forex.PriceRequest{
Symbol: "GBPUSD",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,6 +4,65 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/function/api](
Endpoints:
## Update
Update a function. Downloads the source, builds and redeploys
[https://m3o.com/function/api#Update](https://m3o.com/function/api#Update)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/function"
)
// Update a function. Downloads the source, builds and redeploys
func UpdateAfunction() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.Update(&function.UpdateRequest{
Name: "helloworld",
})
fmt.Println(rsp, err)
}
```
## Call
Call a function by name
[https://m3o.com/function/api#Call](https://m3o.com/function/api#Call)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/function"
)
// Call a function by name
func CallAfunction() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.Call(&function.CallRequest{
Name: "helloworld",
Request: map[string]interface{}{
"name": "Alice",
},
})
fmt.Println(rsp, err)
}
```
## List
List all the deployed functions
@@ -29,6 +88,123 @@ func ListFunctions() {
})
fmt.Println(rsp, err)
}
```
## Regions
Return a list of supported regions
[https://m3o.com/function/api#Regions](https://m3o.com/function/api#Regions)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/function"
)
// Return a list of supported regions
func ListRegions() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.Regions(&function.RegionsRequest{
})
fmt.Println(rsp, err)
}
```
## Proxy
Return the backend url for proxying
[https://m3o.com/function/api#Proxy](https://m3o.com/function/api#Proxy)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/function"
)
// Return the backend url for proxying
func ProxyUrl() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.Proxy(&function.ProxyRequest{
Id: "helloworld",
})
fmt.Println(rsp, err)
}
```
## Deploy
Deploy a group of functions
[https://m3o.com/function/api#Deploy](https://m3o.com/function/api#Deploy)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/function"
)
// Deploy a group of functions
func DeployAfunction() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.Deploy(&function.DeployRequest{
Branch: "main",
Entrypoint: "Helloworld",
Name: "helloworld",
Region: "europe-west1",
Repo: "https://github.com/m3o/m3o",
Runtime: "go116",
Subfolder: "examples/go-function",
})
fmt.Println(rsp, err)
}
```
## Delete
Delete a function by name
[https://m3o.com/function/api#Delete](https://m3o.com/function/api#Delete)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/function"
)
// Delete a function by name
func DeleteAfunction() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.Delete(&function.DeleteRequest{
Name: "helloworld",
})
fmt.Println(rsp, err)
}
```
## Describe
@@ -57,33 +233,6 @@ func DescribeFunctionStatus() {
})
fmt.Println(rsp, err)
}
```
## Regions
Return a list of supported regions
[https://m3o.com/function/api#Regions](https://m3o.com/function/api#Regions)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/function"
)
// Return a list of supported regions
func ListRegions() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.Regions(&function.RegionsRequest{
})
fmt.Println(rsp, err)
}
```
## Reserve
@@ -141,152 +290,3 @@ func ListRuntimes() {
}
```
## Deploy
Deploy a group of functions
[https://m3o.com/function/api#Deploy](https://m3o.com/function/api#Deploy)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/function"
)
// Deploy a group of functions
func DeployAfunction() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.Deploy(&function.DeployRequest{
Branch: "main",
Entrypoint: "Helloworld",
Name: "helloworld",
Region: "europe-west1",
Repo: "https://github.com/m3o/m3o",
Runtime: "go116",
Subfolder: "examples/go-function",
})
fmt.Println(rsp, err)
}
```
## Update
Update a function. Downloads the source, builds and redeploys
[https://m3o.com/function/api#Update](https://m3o.com/function/api#Update)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/function"
)
// Update a function. Downloads the source, builds and redeploys
func UpdateAfunction() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.Update(&function.UpdateRequest{
Name: "helloworld",
})
fmt.Println(rsp, err)
}
```
## Call
Call a function by name
[https://m3o.com/function/api#Call](https://m3o.com/function/api#Call)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/function"
)
// Call a function by name
func CallAfunction() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.Call(&function.CallRequest{
Name: "helloworld",
Request: map[string]interface{}{
"name": "Alice",
},
})
fmt.Println(rsp, err)
}
```
## Delete
Delete a function by name
[https://m3o.com/function/api#Delete](https://m3o.com/function/api#Delete)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/function"
)
// Delete a function by name
func DeleteAfunction() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.Delete(&function.DeleteRequest{
Name: "helloworld",
})
fmt.Println(rsp, err)
}
```
## Proxy
Return the backend url for proxying
[https://m3o.com/function/api#Proxy](https://m3o.com/function/api#Proxy)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/function"
)
// Return the backend url for proxying
func ProxyUrl() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.Proxy(&function.ProxyRequest{
Id: "helloworld",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,6 +4,47 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/lists/api](htt
Endpoints:
## Events
Subscribe to lists events
[https://m3o.com/lists/api#Events](https://m3o.com/lists/api#Events)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/lists"
)
// Subscribe to lists events
func SubscribeToEvents() {
listsService := lists.NewListsService(os.Getenv("M3O_API_TOKEN"))
stream, err := listsService.Events(&lists.EventsRequest{
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
})
if err != nil {
fmt.Println(err)
return
}
for {
rsp, err := stream.Recv()
if err != nil {
fmt.Println(err)
return
}
fmt.Println(rsp)
}
}
```
## Create
Create a new list
@@ -144,44 +185,3 @@ func DeleteAlist() {
}
```
## Events
Subscribe to lists events
[https://m3o.com/lists/api#Events](https://m3o.com/lists/api#Events)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/lists"
)
// Subscribe to lists events
func SubscribeToEvents() {
listsService := lists.NewListsService(os.Getenv("M3O_API_TOKEN"))
stream, err := listsService.Events(&lists.EventsRequest{
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
})
if err != nil {
fmt.Println(err)
return
}
for {
rsp, err := stream.Recv()
if err != nil {
fmt.Println(err)
return
}
fmt.Println(rsp)
}
}
```

View File

@@ -4,6 +4,42 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/location/api](
Endpoints:
## Save
Save an entity's current position
[https://m3o.com/location/api#Save](https://m3o.com/location/api#Save)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/location"
)
// Save an entity's current position
func SaveAnEntity() {
locationService := location.NewLocationService(os.Getenv("M3O_API_TOKEN"))
rsp, err := locationService.Save(&location.SaveRequest{
Entity: &location.Entity{
Id: "1",
Location: &location.Point{
Latitude: 51.511061,
Longitude: -0.120022,
Timestamp: 1622802761,
},
Type: "bike",
},
})
fmt.Println(rsp, err)
}
```
## Read
Read an entity by its ID
@@ -66,39 +102,3 @@ Type: "bike",
}
```
## Save
Save an entity's current position
[https://m3o.com/location/api#Save](https://m3o.com/location/api#Save)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/location"
)
// Save an entity's current position
func SaveAnEntity() {
locationService := location.NewLocationService(os.Getenv("M3O_API_TOKEN"))
rsp, err := locationService.Save(&location.SaveRequest{
Entity: &location.Entity{
Id: "1",
Location: &location.Point{
Latitude: 51.511061,
Longitude: -0.120022,
Timestamp: 1622802761,
},
Type: "bike",
},
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,39 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/mq/api](https:
Endpoints:
## Publish
Publish a message. Specify a topic to group messages for a specific topic.
[https://m3o.com/mq/api#Publish](https://m3o.com/mq/api#Publish)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/mq"
)
// Publish a message. Specify a topic to group messages for a specific topic.
func PublishAmessage() {
mqService := mq.NewMqService(os.Getenv("M3O_API_TOKEN"))
rsp, err := mqService.Publish(&mq.PublishRequest{
Message: map[string]interface{}{
"id": "1",
"type": "signup",
"user": "john",
},
Topic: "events",
})
fmt.Println(rsp, err)
}
```
## Subscribe
Subscribe to messages for a given topic.
@@ -78,3 +45,36 @@ func SubscribeToAtopic() {
}
}
```
## Publish
Publish a message. Specify a topic to group messages for a specific topic.
[https://m3o.com/mq/api#Publish](https://m3o.com/mq/api#Publish)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/mq"
)
// Publish a message. Specify a topic to group messages for a specific topic.
func PublishAmessage() {
mqService := mq.NewMqService(os.Getenv("M3O_API_TOKEN"))
rsp, err := mqService.Publish(&mq.PublishRequest{
Message: map[string]interface{}{
"id": "1",
"type": "signup",
"user": "john",
},
Topic: "events",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,61 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/nft/api](https
Endpoints:
## Asset
Get a single asset by the contract
[https://m3o.com/nft/api#Asset](https://m3o.com/nft/api#Asset)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/nft"
)
// Get a single asset by the contract
func GetAsingleAsset() {
nftService := nft.NewNftService(os.Getenv("M3O_API_TOKEN"))
rsp, err := nftService.Asset(&nft.AssetRequest{
})
fmt.Println(rsp, err)
}
```
## Collection
Get a collection by its slug
[https://m3o.com/nft/api#Collection](https://m3o.com/nft/api#Collection)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/nft"
)
// Get a collection by its slug
func GetAsingleCollection() {
nftService := nft.NewNftService(os.Getenv("M3O_API_TOKEN"))
rsp, err := nftService.Collection(&nft.CollectionRequest{
Slug: "doodles-official",
})
fmt.Println(rsp, err)
}
```
## Assets
Return a list of assets
@@ -144,3 +89,58 @@ func ListCollections() {
}
```
## Asset
Get a single asset by the contract
[https://m3o.com/nft/api#Asset](https://m3o.com/nft/api#Asset)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/nft"
)
// Get a single asset by the contract
func GetAsingleAsset() {
nftService := nft.NewNftService(os.Getenv("M3O_API_TOKEN"))
rsp, err := nftService.Asset(&nft.AssetRequest{
})
fmt.Println(rsp, err)
}
```
## Collection
Get a collection by its slug
[https://m3o.com/nft/api#Collection](https://m3o.com/nft/api#Collection)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/nft"
)
// Get a collection by its slug
func GetAsingleCollection() {
nftService := nft.NewNftService(os.Getenv("M3O_API_TOKEN"))
rsp, err := nftService.Collection(&nft.CollectionRequest{
Slug: "doodles-official",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,6 +4,47 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/notes/api](htt
Endpoints:
## Events
Subscribe to notes events
[https://m3o.com/notes/api#Events](https://m3o.com/notes/api#Events)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/notes"
)
// Subscribe to notes events
func SubscribeToEvents() {
notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN"))
stream, err := notesService.Events(&notes.EventsRequest{
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
})
if err != nil {
fmt.Println(err)
return
}
for {
rsp, err := stream.Recv()
if err != nil {
fmt.Println(err)
return
}
fmt.Println(rsp)
}
}
```
## Create
Create a new note
@@ -148,44 +189,3 @@ func DeleteAnote() {
}
```
## Events
Subscribe to notes events
[https://m3o.com/notes/api#Events](https://m3o.com/notes/api#Events)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/notes"
)
// Subscribe to notes events
func SubscribeToEvents() {
notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN"))
stream, err := notesService.Events(&notes.EventsRequest{
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
})
if err != nil {
fmt.Println(err)
return
}
for {
rsp, err := stream.Recv()
if err != nil {
fmt.Println(err)
return
}
fmt.Println(rsp)
}
}
```

View File

@@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/search/api](ht
Endpoints:
## DeleteIndex
Delete an index by name
[https://m3o.com/search/api#DeleteIndex](https://m3o.com/search/api#DeleteIndex)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/search"
)
// Delete an index by name
func DeleteAnIndex() {
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
rsp, err := searchService.DeleteIndex(&search.DeleteIndexRequest{
Index: "customers",
})
fmt.Println(rsp, err)
}
```
## Index
Index a record i.e. insert a document to search for.
@@ -26,9 +54,9 @@ func IndexArecord() {
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
rsp, err := searchService.Index(&search.IndexRequest{
Data: map[string]interface{}{
"starsign": "Leo",
"name": "John Doe",
"age": 37,
"starsign": "Leo",
},
Index: "customers",
@@ -181,31 +209,3 @@ func CreateAnIndex() {
}
```
## DeleteIndex
Delete an index by name
[https://m3o.com/search/api#DeleteIndex](https://m3o.com/search/api#DeleteIndex)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/search"
)
// Delete an index by name
func DeleteAnIndex() {
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
rsp, err := searchService.DeleteIndex(&search.DeleteIndexRequest{
Index: "customers",
})
fmt.Println(rsp, err)
}
```

View File

@@ -12,9 +12,9 @@ func main() {
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
rsp, err := searchService.Index(&search.IndexRequest{
Data: map[string]interface{}{
"starsign": "Leo",
"name": "John Doe",
"age": 37,
"starsign": "Leo",
},
Index: "customers",
})

View File

@@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/space/api](htt
Endpoints:
## Download
Download an object via a presigned url
[https://m3o.com/space/api#Download](https://m3o.com/space/api#Download)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/space"
)
// Download an object via a presigned url
func DownloadAnObject() {
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
rsp, err := spaceService.Download(&space.DownloadRequest{
Name: "images/file.jpg",
})
fmt.Println(rsp, err)
}
```
## Upload
Upload a large object (> 10MB). Returns a time limited presigned URL to be used for uploading the object
@@ -232,3 +204,31 @@ func ReadAnObject() {
}
```
## Download
Download an object via a presigned url
[https://m3o.com/space/api#Download](https://m3o.com/space/api#Download)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/space"
)
// Download an object via a presigned url
func DownloadAnObject() {
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
rsp, err := spaceService.Download(&space.DownloadRequest{
Name: "images/file.jpg",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,6 +4,65 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/sunnah/api](ht
Endpoints:
## Collections
Get a list of available collections. A collection is
a compilation of hadiths collected and written by an author.
[https://m3o.com/sunnah/api#Collections](https://m3o.com/sunnah/api#Collections)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/sunnah"
)
// Get a list of available collections. A collection is
// a compilation of hadiths collected and written by an author.
func ListAvailableCollections() {
sunnahService := sunnah.NewSunnahService(os.Getenv("M3O_API_TOKEN"))
rsp, err := sunnahService.Collections(&sunnah.CollectionsRequest{
})
fmt.Println(rsp, err)
}
```
## Books
Get a list of books from within a collection. A book can contain many chapters
each with its own hadiths.
[https://m3o.com/sunnah/api#Books](https://m3o.com/sunnah/api#Books)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/sunnah"
)
// Get a list of books from within a collection. A book can contain many chapters
// each with its own hadiths.
func GetTheBooksWithinAcollection() {
sunnahService := sunnah.NewSunnahService(os.Getenv("M3O_API_TOKEN"))
rsp, err := sunnahService.Books(&sunnah.BooksRequest{
Collection: "bukhari",
})
fmt.Println(rsp, err)
}
```
## Chapters
Get all the chapters of a given book within a collection.
@@ -64,62 +123,3 @@ Collection: "bukhari",
}
```
## Collections
Get a list of available collections. A collection is
a compilation of hadiths collected and written by an author.
[https://m3o.com/sunnah/api#Collections](https://m3o.com/sunnah/api#Collections)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/sunnah"
)
// Get a list of available collections. A collection is
// a compilation of hadiths collected and written by an author.
func ListAvailableCollections() {
sunnahService := sunnah.NewSunnahService(os.Getenv("M3O_API_TOKEN"))
rsp, err := sunnahService.Collections(&sunnah.CollectionsRequest{
})
fmt.Println(rsp, err)
}
```
## Books
Get a list of books from within a collection. A book can contain many chapters
each with its own hadiths.
[https://m3o.com/sunnah/api#Books](https://m3o.com/sunnah/api#Books)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/sunnah"
)
// Get a list of books from within a collection. A book can contain many chapters
// each with its own hadiths.
func GetTheBooksWithinAcollection() {
sunnahService := sunnah.NewSunnahService(os.Getenv("M3O_API_TOKEN"))
rsp, err := sunnahService.Books(&sunnah.BooksRequest{
Collection: "bukhari",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,35 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/twitter/api](h
Endpoints:
## Timeline
Get the timeline for a given user
[https://m3o.com/twitter/api#Timeline](https://m3o.com/twitter/api#Timeline)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/twitter"
)
// Get the timeline for a given user
func GetAtwitterTimeline() {
twitterService := twitter.NewTwitterService(os.Getenv("M3O_API_TOKEN"))
rsp, err := twitterService.Timeline(&twitter.TimelineRequest{
Limit: 1,
Username: "m3oservices",
})
fmt.Println(rsp, err)
}
```
## Search
Search for tweets with a simple query
@@ -116,3 +87,32 @@ func GetAusersTwitterProfile() {
}
```
## Timeline
Get the timeline for a given user
[https://m3o.com/twitter/api#Timeline](https://m3o.com/twitter/api#Timeline)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/twitter"
)
// Get the timeline for a given user
func GetAtwitterTimeline() {
twitterService := twitter.NewTwitterService(os.Getenv("M3O_API_TOKEN"))
rsp, err := twitterService.Timeline(&twitter.TimelineRequest{
Limit: 1,
Username: "m3oservices",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,36 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/user/api](http
Endpoints:
## Update
Update the account username or email
[https://m3o.com/user/api#Update](https://m3o.com/user/api#Update)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Update the account username or email
func UpdateAnAccount() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.Update(&user.UpdateRequest{
Email: "joe+2@example.com",
Id: "user-1",
Username: "joe",
})
fmt.Println(rsp, err)
}
```
## Read
Read an account by id, username or email. Only one need to be specified.
@@ -149,12 +119,12 @@ NewPassword: "NewPassword1",
}
```
## Logout
## Delete
Logout a user account
Delete an account by id
[https://m3o.com/user/api#Logout](https://m3o.com/user/api#Logout)
[https://m3o.com/user/api#Delete](https://m3o.com/user/api#Delete)
```go
package example
@@ -166,105 +136,11 @@ import(
"go.m3o.com/user"
)
// Logout a user account
func LogAuserOut() {
// Delete an account by id
func DeleteUserAccount() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.Logout(&user.LogoutRequest{
SessionId: "df91a612-5b24-4634-99ff-240220ab8f55",
})
fmt.Println(rsp, err)
}
```
## List
List all users. Returns a paged list of results
[https://m3o.com/user/api#List](https://m3o.com/user/api#List)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// List all users. Returns a paged list of results
func ListAllUsers() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.List(&user.ListRequest{
Limit: 100,
Offset: 0,
})
fmt.Println(rsp, err)
}
```
## Create
Create a new user account. The email address and username for the account must be unique.
[https://m3o.com/user/api#Create](https://m3o.com/user/api#Create)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Create a new user account. The email address and username for the account must be unique.
func CreateAnAccount() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.Create(&user.CreateRequest{
Email: "joe@example.com",
Id: "user-1",
Password: "Password1",
Username: "joe",
})
fmt.Println(rsp, err)
}
```
## SendPasswordResetEmail
Send an email with a verification code to reset password.
Call "ResetPassword" endpoint once user provides the code.
[https://m3o.com/user/api#SendPasswordResetEmail](https://m3o.com/user/api#SendPasswordResetEmail)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Send an email with a verification code to reset password.
// Call "ResetPassword" endpoint once user provides the code.
func SendPasswordResetEmail() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.SendPasswordResetEmail(&user.SendPasswordResetEmailRequest{
Email: "joe@example.com",
FromName: "Awesome Dot Com",
Subject: "Password reset",
TextContent: `Hi there,
click here to reset your password: myapp.com/reset/code?=$code`,
rsp, err := userService.Delete(&user.DeleteRequest{
Id: "8b98acbe-0b6a-4d66-a414-5ffbf666786f",
})
fmt.Println(rsp, err)
@@ -300,6 +176,99 @@ Password: "Password1",
})
fmt.Println(rsp, err)
}
```
## Logout
Logout a user account
[https://m3o.com/user/api#Logout](https://m3o.com/user/api#Logout)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Logout a user account
func LogAuserOut() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.Logout(&user.LogoutRequest{
SessionId: "df91a612-5b24-4634-99ff-240220ab8f55",
})
fmt.Println(rsp, err)
}
```
## Update
Update the account username or email
[https://m3o.com/user/api#Update](https://m3o.com/user/api#Update)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Update the account username or email
func UpdateAnAccount() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.Update(&user.UpdateRequest{
Email: "joe+2@example.com",
Id: "user-1",
Username: "joe",
})
fmt.Println(rsp, err)
}
```
## SendMagicLink
Login using email only - Passwordless
[https://m3o.com/user/api#SendMagicLink](https://m3o.com/user/api#SendMagicLink)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Login using email only - Passwordless
func SendAmagicLink() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.SendMagicLink(&user.SendMagicLinkRequest{
Address: "www.example.com",
Email: "joe@example.com",
Endpoint: "verifytoken",
FromName: "Awesome Dot Com",
Subject: "MagicLink to access your account",
TextContent: `Hi there,
Click here to access your account $micro_verification_link`,
})
fmt.Println(rsp, err)
}
```
## VerifyToken
@@ -334,6 +303,35 @@ func VerifyAtoken() {
})
fmt.Println(rsp, err)
}
```
## List
List all users. Returns a paged list of results
[https://m3o.com/user/api#List](https://m3o.com/user/api#List)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// List all users. Returns a paged list of results
func ListAllUsers() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.List(&user.ListRequest{
Limit: 100,
Offset: 0,
})
fmt.Println(rsp, err)
}
```
## UpdatePassword
@@ -365,6 +363,99 @@ UserId: "user-1",
})
fmt.Println(rsp, err)
}
```
## SendPasswordResetEmail
Send an email with a verification code to reset password.
Call "ResetPassword" endpoint once user provides the code.
[https://m3o.com/user/api#SendPasswordResetEmail](https://m3o.com/user/api#SendPasswordResetEmail)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Send an email with a verification code to reset password.
// Call "ResetPassword" endpoint once user provides the code.
func SendPasswordResetEmail() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.SendPasswordResetEmail(&user.SendPasswordResetEmailRequest{
Email: "joe@example.com",
FromName: "Awesome Dot Com",
Subject: "Password reset",
TextContent: `Hi there,
click here to reset your password: myapp.com/reset/code?=$code`,
})
fmt.Println(rsp, err)
}
```
## Create
Create a new user account. The email address and username for the account must be unique.
[https://m3o.com/user/api#Create](https://m3o.com/user/api#Create)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Create a new user account. The email address and username for the account must be unique.
func CreateAnAccount() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.Create(&user.CreateRequest{
Email: "joe@example.com",
Id: "user-1",
Password: "Password1",
Username: "joe",
})
fmt.Println(rsp, err)
}
```
## VerifyEmail
Verify the email address of an account from a token sent in an email to the user.
[https://m3o.com/user/api#VerifyEmail](https://m3o.com/user/api#VerifyEmail)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Verify the email address of an account from a token sent in an email to the user.
func VerifyEmail() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.VerifyEmail(&user.VerifyEmailRequest{
Token: "012345",
})
fmt.Println(rsp, err)
}
```
## ReadSession
@@ -393,41 +484,6 @@ func ReadAsessionByTheSessionId() {
})
fmt.Println(rsp, err)
}
```
## SendMagicLink
Login using email only - Passwordless
[https://m3o.com/user/api#SendMagicLink](https://m3o.com/user/api#SendMagicLink)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Login using email only - Passwordless
func SendAmagicLink() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.SendMagicLink(&user.SendMagicLinkRequest{
Address: "www.example.com",
Email: "joe@example.com",
Endpoint: "verifytoken",
FromName: "Awesome Dot Com",
Subject: "MagicLink to access your account",
TextContent: `Hi there,
Click here to access your account $micro_verification_link`,
})
fmt.Println(rsp, err)
}
```
## SendVerificationEmail
@@ -477,59 +533,3 @@ Please verify your email by clicking this link: $micro_verification_link`,
}
```
## Delete
Delete an account by id
[https://m3o.com/user/api#Delete](https://m3o.com/user/api#Delete)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Delete an account by id
func DeleteUserAccount() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.Delete(&user.DeleteRequest{
Id: "8b98acbe-0b6a-4d66-a414-5ffbf666786f",
})
fmt.Println(rsp, err)
}
```
## VerifyEmail
Verify the email address of an account from a token sent in an email to the user.
[https://m3o.com/user/api#VerifyEmail](https://m3o.com/user/api#VerifyEmail)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Verify the email address of an account from a token sent in an email to the user.
func VerifyEmail() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.VerifyEmail(&user.VerifyEmailRequest{
Token: "012345",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/youtube/api](h
Endpoints:
## Embed
Embed a YouTube video
[https://m3o.com/youtube/api#Embed](https://m3o.com/youtube/api#Embed)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/youtube"
)
// Embed a YouTube video
func EmbedAyoutubeVideo() {
youtubeService := youtube.NewYoutubeService(os.Getenv("M3O_API_TOKEN"))
rsp, err := youtubeService.Embed(&youtube.EmbedRequest{
Url: "https://www.youtube.com/watch?v=GWRWZu7XsJ0",
})
fmt.Println(rsp, err)
}
```
## Search
Search for videos on YouTube
@@ -60,3 +32,31 @@ func SearchForVideos() {
}
```
## Embed
Embed a YouTube video
[https://m3o.com/youtube/api#Embed](https://m3o.com/youtube/api#Embed)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/youtube"
)
// Embed a YouTube video
func EmbedAyoutubeVideo() {
youtubeService := youtube.NewYoutubeService(os.Getenv("M3O_API_TOKEN"))
rsp, err := youtubeService.Embed(&youtube.EmbedRequest{
Url: "https://www.youtube.com/watch?v=GWRWZu7XsJ0",
})
fmt.Println(rsp, err)
}
```