Commit from m3o/m3o action

This commit is contained in:
m3o-actions
2022-03-03 14:14:33 +00:00
parent 2b02492525
commit dadeda6bb0
24 changed files with 1182 additions and 1182 deletions

View File

@@ -4,62 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/app/api](https
Endpoints:
## Delete
Delete an app
[https://m3o.com/app/api#Delete](https://m3o.com/app/api#Delete)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/app"
)
// Delete an app
func DeleteAnApp() {
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
rsp, err := appService.Delete(&app.DeleteRequest{
Name: "helloworld",
})
fmt.Println(rsp, err)
}
```
## Reserve
Reserve apps beyond the free quota. Call Run after.
[https://m3o.com/app/api#Reserve](https://m3o.com/app/api#Reserve)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/app"
)
// Reserve apps beyond the free quota. Call Run after.
func ReserveAppName() {
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
rsp, err := appService.Reserve(&app.ReserveRequest{
Name: "helloworld",
})
fmt.Println(rsp, err)
}
```
## List
List all the apps
@@ -230,3 +174,59 @@ func UpdateAnApp() {
}
```
## Delete
Delete an app
[https://m3o.com/app/api#Delete](https://m3o.com/app/api#Delete)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/app"
)
// Delete an app
func DeleteAnApp() {
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
rsp, err := appService.Delete(&app.DeleteRequest{
Name: "helloworld",
})
fmt.Println(rsp, err)
}
```
## Reserve
Reserve apps beyond the free quota. Call Run after.
[https://m3o.com/app/api#Reserve](https://m3o.com/app/api#Reserve)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/app"
)
// Reserve apps beyond the free quota. Call Run after.
func ReserveAppName() {
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
rsp, err := appService.Reserve(&app.ReserveRequest{
Name: "helloworld",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,6 +4,35 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/cache/api](htt
Endpoints:
## Decrement
Decrement a value (if it's a number). If key not found it is equivalent to set.
[https://m3o.com/cache/api#Decrement](https://m3o.com/cache/api#Decrement)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/cache"
)
// Decrement a value (if it's a number). If key not found it is equivalent to set.
func DecrementAvalue() {
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
rsp, err := cacheService.Decrement(&cache.DecrementRequest{
Key: "counter",
Value: 2,
})
fmt.Println(rsp, err)
}
```
## ListKeys
List all the available keys
@@ -145,32 +174,3 @@ Value: 2,
}
```
## Decrement
Decrement a value (if it's a number). If key not found it is equivalent to set.
[https://m3o.com/cache/api#Decrement](https://m3o.com/cache/api#Decrement)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/cache"
)
// Decrement a value (if it's a number). If key not found it is equivalent to set.
func DecrementAvalue() {
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
rsp, err := cacheService.Decrement(&cache.DecrementRequest{
Key: "counter",
Value: 2,
})
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)
}
```
## Send
Connect to a chat to receive a stream of messages
@@ -63,6 +34,33 @@ Text: "Hey whats up?",
})
fmt.Println(rsp, err)
}
```
## History
List the messages in a chat
[https://m3o.com/chat/api#History](https://m3o.com/chat/api#History)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/chat"
)
// List the messages in a chat
func GetChatHistory() {
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
rsp, err := chatService.History(&chat.HistoryRequest{
})
fmt.Println(rsp, err)
}
```
## Leave
@@ -92,12 +90,12 @@ func LeaveAroom() {
}
```
## List
## Create
List available chats
Create a new chat room
[https://m3o.com/chat/api#List](https://m3o.com/chat/api#List)
[https://m3o.com/chat/api#Create](https://m3o.com/chat/api#Create)
```go
package example
@@ -109,11 +107,13 @@ import(
"go.m3o.com/chat"
)
// List available chats
func ListChatRooms() {
// Create a new chat room
func CreateAnewChat() {
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
rsp, err := chatService.List(&chat.ListRequest{
rsp, err := chatService.Create(&chat.CreateRequest{
Description: "The general chat room",
Name: "general",
})
fmt.Println(rsp, err)
@@ -171,33 +171,6 @@ func InviteAuser() {
})
fmt.Println(rsp, err)
}
```
## History
List the messages in a chat
[https://m3o.com/chat/api#History](https://m3o.com/chat/api#History)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/chat"
)
// List the messages in a chat
func GetChatHistory() {
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
rsp, err := chatService.History(&chat.HistoryRequest{
})
fmt.Println(rsp, err)
}
```
## Join
@@ -267,3 +240,30 @@ func KickAuserFromAroom() {
}
```
## List
List available chats
[https://m3o.com/chat/api#List](https://m3o.com/chat/api#List)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/chat"
)
// List available chats
func ListChatRooms() {
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
rsp, err := chatService.List(&chat.ListRequest{
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,62 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/comments/api](
Endpoints:
## Create
Create a new comment
[https://m3o.com/comments/api#Create](https://m3o.com/comments/api#Create)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/comments"
)
// Create a new comment
func CreateAcomment() {
commentsService := comments.NewCommentsService(os.Getenv("M3O_API_TOKEN"))
rsp, err := commentsService.Create(&comments.CreateRequest{
Text: "This is my comment",
})
fmt.Println(rsp, err)
}
```
## Read
Read a comment
[https://m3o.com/comments/api#Read](https://m3o.com/comments/api#Read)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/comments"
)
// Read a comment
func ReadAcomment() {
commentsService := comments.NewCommentsService(os.Getenv("M3O_API_TOKEN"))
rsp, err := commentsService.Read(&comments.ReadRequest{
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
})
fmt.Println(rsp, err)
}
```
## List
List all the comments
@@ -188,3 +132,59 @@ func SubscribeToEvents() {
}
}
```
## Create
Create a new comment
[https://m3o.com/comments/api#Create](https://m3o.com/comments/api#Create)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/comments"
)
// Create a new comment
func CreateAcomment() {
commentsService := comments.NewCommentsService(os.Getenv("M3O_API_TOKEN"))
rsp, err := commentsService.Create(&comments.CreateRequest{
Text: "This is my comment",
})
fmt.Println(rsp, err)
}
```
## Read
Read a comment
[https://m3o.com/comments/api#Read](https://m3o.com/comments/api#Read)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/comments"
)
// Read a comment
func ReadAcomment() {
commentsService := comments.NewCommentsService(os.Getenv("M3O_API_TOKEN"))
rsp, err := commentsService.Read(&comments.ReadRequest{
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,6 +4,56 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/contact/api](h
Endpoints:
## Create
Create a contact
[https://m3o.com/contact/api#Create](https://m3o.com/contact/api#Create)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/contact"
)
// Create a contact
func CreateAcontact() {
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
rsp, err := contactService.Create(&contact.CreateRequest{
Addresses: []contact.Address{
contact.Address{
Label: "company address",
Location: "123 street address",
}},
Birthday: "1995-01-01",
Emails: []contact.Email{
contact.Email{
Address: "home@example.com",
Label: "home",
}},
Links: []contact.Link{
contact.Link{
Label: "blog",
Url: "https://blog.joe.me",
}},
Name: "joe",
Note: "this person is very important",
Phones: []contact.Phone{
contact.Phone{
Label: "home",
Number: "010-12345678",
}},
})
fmt.Println(rsp, err)
}
```
## Update
Update a contact
@@ -167,53 +217,3 @@ Offset: 1,
}
```
## Create
Create a contact
[https://m3o.com/contact/api#Create](https://m3o.com/contact/api#Create)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/contact"
)
// Create a contact
func CreateAcontact() {
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
rsp, err := contactService.Create(&contact.CreateRequest{
Addresses: []contact.Address{
contact.Address{
Label: "company address",
Location: "123 street address",
}},
Birthday: "1995-01-01",
Emails: []contact.Email{
contact.Email{
Address: "home@example.com",
Label: "home",
}},
Links: []contact.Link{
contact.Link{
Label: "blog",
Url: "https://blog.joe.me",
}},
Name: "joe",
Note: "this person is very important",
Phones: []contact.Phone{
contact.Phone{
Label: "home",
Number: "010-12345678",
}},
})
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,72 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/db/api](https:
Endpoints:
## 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{}{
"isActive": true,
"id": "1",
"name": "Jane",
"age": 42,
},
Table: "example",
})
fmt.Println(rsp, err)
}
```
## Update
Update a record in the database. Include an "id" in the record to update.
[https://m3o.com/db/api#Update](https://m3o.com/db/api#Update)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/db"
)
// Update a record in the database. Include an "id" in the record to update.
func UpdateArecord() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Update(&db.UpdateRequest{
Record: map[string]interface{}{
"id": "1",
"age": 43,
},
Table: "example",
})
fmt.Println(rsp, err)
}
```
## Truncate
Truncate the records in a table
@@ -151,6 +85,40 @@ func ListTables() {
})
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)
}
```
## Read
@@ -209,6 +177,38 @@ Table: "example",
})
fmt.Println(rsp, err)
}
```
## Update
Update a record in the database. Include an "id" in the record to update.
[https://m3o.com/db/api#Update](https://m3o.com/db/api#Update)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/db"
)
// Update a record in the database. Include an "id" in the record to update.
func UpdateArecord() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Update(&db.UpdateRequest{
Record: map[string]interface{}{
"id": "1",
"age": 43,
},
Table: "example",
})
fmt.Println(rsp, err)
}
```
## Count

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

@@ -26,9 +26,9 @@ func PublishAnEvent() {
eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN"))
rsp, err := eventService.Publish(&event.PublishRequest{
Message: map[string]interface{}{
"user": "john",
"id": "1",
"type": "signup",
"user": "john",
},
Topic: "user",

View File

@@ -4,6 +4,64 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/file/api](http
Endpoints:
## Read
Read a file by path
[https://m3o.com/file/api#Read](https://m3o.com/file/api#Read)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/file"
)
// Read a file by path
func ReadFile() {
fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN"))
rsp, err := fileService.Read(&file.ReadRequest{
Path: "/document/text-files/file.txt",
Project: "examples",
})
fmt.Println(rsp, err)
}
```
## Delete
Delete a file by project name/path
[https://m3o.com/file/api#Delete](https://m3o.com/file/api#Delete)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/file"
)
// Delete a file by project name/path
func DeleteFile() {
fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN"))
rsp, err := fileService.Delete(&file.DeleteRequest{
Path: "/document/text-files/file.txt",
Project: "examples",
})
fmt.Println(rsp, err)
}
```
## Save
Save a file
@@ -64,61 +122,3 @@ func ListFiles() {
}
```
## Read
Read a file by path
[https://m3o.com/file/api#Read](https://m3o.com/file/api#Read)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/file"
)
// Read a file by path
func ReadFile() {
fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN"))
rsp, err := fileService.Read(&file.ReadRequest{
Path: "/document/text-files/file.txt",
Project: "examples",
})
fmt.Println(rsp, err)
}
```
## Delete
Delete a file by project name/path
[https://m3o.com/file/api#Delete](https://m3o.com/file/api#Delete)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/file"
)
// Delete a file by project name/path
func DeleteFile() {
fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN"))
rsp, err := fileService.Delete(&file.DeleteRequest{
Path: "/document/text-files/file.txt",
Project: "examples",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,88 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/function/api](
Endpoints:
## 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)
}
```
## Runtimes
Return a list of supported runtimes
[https://m3o.com/function/api#Runtimes](https://m3o.com/function/api#Runtimes)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/function"
)
// Return a list of supported runtimes
func ListRuntimes() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.Runtimes(&function.RuntimesRequest{
})
fmt.Println(rsp, err)
}
```
## List
List all the deployed functions
[https://m3o.com/function/api#List](https://m3o.com/function/api#List)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/function"
)
// List all the deployed functions
func ListFunctions() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.List(&function.ListRequest{
})
fmt.Println(rsp, err)
}
```
## Update
Update a function. Downloads the source, builds and redeploys
@@ -143,6 +61,34 @@ Request: map[string]interface{}{
})
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
@@ -173,12 +119,12 @@ func DescribeFunctionStatus() {
}
```
## Regions
## Runtimes
Return a list of supported regions
Return a list of supported runtimes
[https://m3o.com/function/api#Regions](https://m3o.com/function/api#Regions)
[https://m3o.com/function/api#Runtimes](https://m3o.com/function/api#Runtimes)
```go
package example
@@ -190,42 +136,14 @@ import(
"go.m3o.com/function"
)
// Return a list of supported regions
func ListRegions() {
// Return a list of supported runtimes
func ListRuntimes() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.Regions(&function.RegionsRequest{
rsp, err := functionService.Runtimes(&function.RuntimesRequest{
})
fmt.Println(rsp, err)
}
```
## Reserve
Reserve function names and resources beyond free quota
[https://m3o.com/function/api#Reserve](https://m3o.com/function/api#Reserve)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/function"
)
// Reserve function names and resources beyond free quota
func ReserveAfunction() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.Reserve(&function.ReserveRequest{
Name: "helloworld",
})
fmt.Println(rsp, err)
}
```
## Proxy
@@ -290,3 +208,85 @@ Subfolder: "examples/go-function",
}
```
## 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
Reserve function names and resources beyond free quota
[https://m3o.com/function/api#Reserve](https://m3o.com/function/api#Reserve)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/function"
)
// Reserve function names and resources beyond free quota
func ReserveAfunction() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.Reserve(&function.ReserveRequest{
Name: "helloworld",
})
fmt.Println(rsp, err)
}
```
## List
List all the deployed functions
[https://m3o.com/function/api#List](https://m3o.com/function/api#List)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/function"
)
// List all the deployed functions
func ListFunctions() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.List(&function.ListRequest{
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,35 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/geocoding/api]
Endpoints:
## Reverse
Reverse lookup an address from gps coordinates
[https://m3o.com/geocoding/api#Reverse](https://m3o.com/geocoding/api#Reverse)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/geocoding"
)
// Reverse lookup an address from gps coordinates
func ReverseGeocodeLocation() {
geocodingService := geocoding.NewGeocodingService(os.Getenv("M3O_API_TOKEN"))
rsp, err := geocodingService.Reverse(&geocoding.ReverseRequest{
Latitude: 51.5123064,
Longitude: -0.1216235,
})
fmt.Println(rsp, err)
}
```
## Lookup
Lookup returns a geocoded address including normalized address and gps coordinates. All fields are optional, provide more to get more accurate results
@@ -64,3 +35,32 @@ Postcode: "wc2b",
}
```
## Reverse
Reverse lookup an address from gps coordinates
[https://m3o.com/geocoding/api#Reverse](https://m3o.com/geocoding/api#Reverse)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/geocoding"
)
// Reverse lookup an address from gps coordinates
func ReverseGeocodeLocation() {
geocodingService := geocoding.NewGeocodingService(os.Getenv("M3O_API_TOKEN"))
rsp, err := geocodingService.Reverse(&geocoding.ReverseRequest{
Latitude: 51.5123064,
Longitude: -0.1216235,
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,75 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/lists/api](htt
Endpoints:
## Delete
Delete a list
[https://m3o.com/lists/api#Delete](https://m3o.com/lists/api#Delete)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/lists"
)
// Delete a list
func DeleteAlist() {
listsService := lists.NewListsService(os.Getenv("M3O_API_TOKEN"))
rsp, err := listsService.Delete(&lists.DeleteRequest{
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
})
fmt.Println(rsp, err)
}
```
## 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
@@ -185,3 +116,72 @@ func UpdateAlist() {
}
```
## Delete
Delete a list
[https://m3o.com/lists/api#Delete](https://m3o.com/lists/api#Delete)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/lists"
)
// Delete a list
func DeleteAlist() {
listsService := lists.NewListsService(os.Getenv("M3O_API_TOKEN"))
rsp, err := listsService.Delete(&lists.DeleteRequest{
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
})
fmt.Println(rsp, err)
}
```
## 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,42 +4,6 @@ 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
@@ -102,3 +66,39 @@ 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,6 +4,39 @@ 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.
@@ -45,36 +78,3 @@ 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,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/otp/api](https
Endpoints:
## Generate
Generate an OTP (one time pass) code
[https://m3o.com/otp/api#Generate](https://m3o.com/otp/api#Generate)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/otp"
)
// Generate an OTP (one time pass) code
func GenerateOtp() {
otpService := otp.NewOtpService(os.Getenv("M3O_API_TOKEN"))
rsp, err := otpService.Generate(&otp.GenerateRequest{
Id: "asim@example.com",
})
fmt.Println(rsp, err)
}
```
## Validate
Validate the OTP code
@@ -33,31 +61,3 @@ Id: "asim@example.com",
}
```
## Generate
Generate an OTP (one time pass) code
[https://m3o.com/otp/api#Generate](https://m3o.com/otp/api#Generate)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/otp"
)
// Generate an OTP (one time pass) code
func GenerateOtp() {
otpService := otp.NewOtpService(os.Getenv("M3O_API_TOKEN"))
rsp, err := otpService.Generate(&otp.GenerateRequest{
Id: "asim@example.com",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/ping/api](http
Endpoints:
## Ip
Ping an IP address
[https://m3o.com/ping/api#Ip](https://m3o.com/ping/api#Ip)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/ping"
)
// Ping an IP address
func PingAnIp() {
pingService := ping.NewPingService(os.Getenv("M3O_API_TOKEN"))
rsp, err := pingService.Ip(&ping.IpRequest{
Address: "google.com",
})
fmt.Println(rsp, err)
}
```
## Tcp
Ping a TCP port is open
@@ -88,3 +60,31 @@ func CheckAurl() {
}
```
## Ip
Ping an IP address
[https://m3o.com/ping/api#Ip](https://m3o.com/ping/api#Ip)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/ping"
)
// Ping an IP address
func PingAnIp() {
pingService := ping.NewPingService(os.Getenv("M3O_API_TOKEN"))
rsp, err := pingService.Ip(&ping.IpRequest{
Address: "google.com",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,6 +4,41 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/routing/api](h
Endpoints:
## Eta
Get the eta for a route from origin to destination. The eta is an estimated time based on car routes
[https://m3o.com/routing/api#Eta](https://m3o.com/routing/api#Eta)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/routing"
)
// Get the eta for a route from origin to destination. The eta is an estimated time based on car routes
func EtaFromPointAtoPointB() {
routingService := routing.NewRoutingService(os.Getenv("M3O_API_TOKEN"))
rsp, err := routingService.Eta(&routing.EtaRequest{
Destination: &routing.Point{
Latitude: 52.529407,
Longitude: 13.397634,
},
Origin: &routing.Point{
Latitude: 52.517037,
Longitude: 13.38886,
},
})
fmt.Println(rsp, err)
}
```
## Directions
Turn by turn directions from a start point to an end point including maneuvers and bearings
@@ -74,38 +109,3 @@ Origin: &routing.Point{
}
```
## Eta
Get the eta for a route from origin to destination. The eta is an estimated time based on car routes
[https://m3o.com/routing/api#Eta](https://m3o.com/routing/api#Eta)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/routing"
)
// Get the eta for a route from origin to destination. The eta is an estimated time based on car routes
func EtaFromPointAtoPointB() {
routingService := routing.NewRoutingService(os.Getenv("M3O_API_TOKEN"))
rsp, err := routingService.Eta(&routing.EtaRequest{
Destination: &routing.Point{
Latitude: 52.529407,
Longitude: 13.397634,
},
Origin: &routing.Point{
Latitude: 52.517037,
Longitude: 13.38886,
},
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,39 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/search/api](ht
Endpoints:
## Index
Index a record i.e. insert a document to search for.
[https://m3o.com/search/api#Index](https://m3o.com/search/api#Index)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/search"
)
// Index a record i.e. insert a document to search for.
func IndexArecord() {
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
rsp, err := searchService.Index(&search.IndexRequest{
Data: map[string]interface{}{
"name": "John Doe",
"age": 37,
"starsign": "Leo",
},
Index: "customers",
})
fmt.Println(rsp, err)
}
```
## Search
Search for records in a given in index
@@ -209,3 +176,36 @@ func DeleteAnIndex() {
}
```
## Index
Index a record i.e. insert a document to search for.
[https://m3o.com/search/api#Index](https://m3o.com/search/api#Index)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/search"
)
// Index a record i.e. insert a document to search for.
func IndexArecord() {
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
rsp, err := searchService.Index(&search.IndexRequest{
Data: map[string]interface{}{
"name": "John Doe",
"age": 37,
"starsign": "Leo",
},
Index: "customers",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,6 +4,36 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/space/api](htt
Endpoints:
## Update
Update an object. If an object with this name does not exist, creates a new one.
[https://m3o.com/space/api#Update](https://m3o.com/space/api#Update)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/space"
)
// Update an object. If an object with this name does not exist, creates a new one.
func UpdateAnObject() {
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
rsp, err := spaceService.Update(&space.UpdateRequest{
Name: "images/file.jpg",
Object: "<file bytes>",
Visibility: "public",
})
fmt.Println(rsp, err)
}
```
## Delete
Delete an object from space
@@ -202,33 +232,3 @@ Visibility: "public",
}
```
## Update
Update an object. If an object with this name does not exist, creates a new one.
[https://m3o.com/space/api#Update](https://m3o.com/space/api#Update)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/space"
)
// Update an object. If an object with this name does not exist, creates a new one.
func UpdateAnObject() {
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
rsp, err := spaceService.Update(&space.UpdateRequest{
Name: "images/file.jpg",
Object: "<file bytes>",
Visibility: "public",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/stock/api](htt
Endpoints:
## Quote
Get the last quote for the stock
[https://m3o.com/stock/api#Quote](https://m3o.com/stock/api#Quote)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/stock"
)
// Get the last quote for the stock
func GetAstockQuote() {
stockService := stock.NewStockService(os.Getenv("M3O_API_TOKEN"))
rsp, err := stockService.Quote(&stock.QuoteRequest{
Symbol: "AAPL",
})
fmt.Println(rsp, err)
}
```
## History
Get the historic open-close for a given day
@@ -93,31 +121,3 @@ func GetAstockPrice() {
}
```
## Quote
Get the last quote for the stock
[https://m3o.com/stock/api#Quote](https://m3o.com/stock/api#Quote)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/stock"
)
// Get the last quote for the stock
func GetAstockQuote() {
stockService := stock.NewStockService(os.Getenv("M3O_API_TOKEN"))
rsp, err := stockService.Quote(&stock.QuoteRequest{
Symbol: "AAPL",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/stream/api](ht
Endpoints:
## ListMessages
List messages for a given channel
[https://m3o.com/stream/api#ListMessages](https://m3o.com/stream/api#ListMessages)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/stream"
)
// List messages for a given channel
func ListMessages() {
streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN"))
rsp, err := streamService.ListMessages(&stream.ListMessagesRequest{
Channel: "general",
})
fmt.Println(rsp, err)
}
```
## ListChannels
List all the active channels
@@ -119,3 +91,31 @@ Text: "Hey checkout this tweet https://twitter.com/m3oservices/status/1455291054
}
```
## ListMessages
List messages for a given channel
[https://m3o.com/stream/api#ListMessages](https://m3o.com/stream/api#ListMessages)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/stream"
)
// List messages for a given channel
func ListMessages() {
streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN"))
rsp, err := streamService.ListMessages(&stream.ListMessagesRequest{
Channel: "general",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,6 +4,33 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/url/api](https
Endpoints:
## Proxy
Proxy returns the destination URL of a short URL.
[https://m3o.com/url/api#Proxy](https://m3o.com/url/api#Proxy)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/url"
)
// Proxy returns the destination URL of a short URL.
func ResolveAshortUrlToAlongDestinationUrl() {
urlService := url.NewUrlService(os.Getenv("M3O_API_TOKEN"))
rsp, err := urlService.Proxy(&url.ProxyRequest{
})
fmt.Println(rsp, err)
}
```
## List
List all the shortened URLs
@@ -58,30 +85,3 @@ func ShortenAlongUrl() {
}
```
## Proxy
Proxy returns the destination URL of a short URL.
[https://m3o.com/url/api#Proxy](https://m3o.com/url/api#Proxy)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/url"
)
// Proxy returns the destination URL of a short URL.
func ResolveAshortUrlToAlongDestinationUrl() {
urlService := url.NewUrlService(os.Getenv("M3O_API_TOKEN"))
rsp, err := urlService.Proxy(&url.ProxyRequest{
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,12 +4,12 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/user/api](http
Endpoints:
## SendMagicLink
## ReadSession
Login using email only - Passwordless
Read a session by the session id. In the event it has expired or is not found and error is returned.
[https://m3o.com/user/api#SendMagicLink](https://m3o.com/user/api#SendMagicLink)
[https://m3o.com/user/api#ReadSession](https://m3o.com/user/api#ReadSession)
```go
package example
@@ -21,76 +21,11 @@ import(
"go.m3o.com/user"
)
// Login using email only - Passwordless
func SendAmagicLink() {
// Read a session by the session id. In the event it has expired or is not found and error is returned.
func ReadAsessionByTheSessionId() {
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)
}
```
## 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)
}
```
## 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",
rsp, err := userService.ReadSession(&user.ReadSessionRequest{
SessionId: "df91a612-5b24-4634-99ff-240220ab8f55",
})
fmt.Println(rsp, err)
@@ -128,12 +63,12 @@ Password: "Password1",
}
```
## List
## SendMagicLink
List all users. Returns a paged list of results
Login using email only - Passwordless
[https://m3o.com/user/api#List](https://m3o.com/user/api#List)
[https://m3o.com/user/api#SendMagicLink](https://m3o.com/user/api#SendMagicLink)
```go
package example
@@ -145,12 +80,18 @@ import(
"go.m3o.com/user"
)
// List all users. Returns a paged list of results
func ListAllUsers() {
// Login using email only - Passwordless
func SendAmagicLink() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.List(&user.ListRequest{
Limit: 100,
Offset: 0,
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)
@@ -186,115 +127,6 @@ UserId: "user-1",
})
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)
}
```
## VerifyToken
Check whether the token attached to MagicLink is valid or not.
Ideally, you need to call this endpoint from your http request
handler that handles the endpoint which is specified in the
SendMagicLink request.
[https://m3o.com/user/api#VerifyToken](https://m3o.com/user/api#VerifyToken)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Check whether the token attached to MagicLink is valid or not.
// Ideally, you need to call this endpoint from your http request
// handler that handles the endpoint which is specified in the
// SendMagicLink request.
func VerifyAtoken() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.VerifyToken(&user.VerifyTokenRequest{
Token: "EdsUiidouJJJLldjlloofUiorkojflsWWdld",
})
fmt.Println(rsp, err)
}
```
## SendVerificationEmail
Send a verification email to a user.
Email "from" will be 'noreply@email.m3ocontent.com'.
The verification link will be injected in the email
as a template variable, $micro_verification_link e.g
'Welcome to M3O! Use the link below to verify your email: $micro_verification_link'
The variable will be replaced with a url similar to:
'https://user.m3o.com/user/verify?token=a-verification-token&redirectUrl=your-redir-url'
[https://m3o.com/user/api#SendVerificationEmail](https://m3o.com/user/api#SendVerificationEmail)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Send a verification email to a user.
// Email "from" will be 'noreply@email.m3ocontent.com'.
// The verification link will be injected in the email
// as a template variable, $micro_verification_link e.g
// 'Welcome to M3O! Use the link below to verify your email: $micro_verification_link'
// The variable will be replaced with a url similar to:
// 'https://user.m3o.com/user/verify?token=a-verification-token&redirectUrl=your-redir-url'
func SendVerificationEmail() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.SendVerificationEmail(&user.SendVerificationEmailRequest{
Email: "joe@example.com",
FailureRedirectUrl: "https://m3o.com/verification-failed",
FromName: "Awesome Dot Com",
RedirectUrl: "https://m3o.com",
Subject: "Email verification",
TextContent: `Hi there,
Please verify your email by clicking this link: $micro_verification_link`,
})
fmt.Println(rsp, err)
}
```
## SendPasswordResetEmail
@@ -388,6 +220,143 @@ func VerifyEmail() {
})
fmt.Println(rsp, err)
}
```
## SendVerificationEmail
Send a verification email to a user.
Email "from" will be 'noreply@email.m3ocontent.com'.
The verification link will be injected in the email
as a template variable, $micro_verification_link e.g
'Welcome to M3O! Use the link below to verify your email: $micro_verification_link'
The variable will be replaced with a url similar to:
'https://user.m3o.com/user/verify?token=a-verification-token&redirectUrl=your-redir-url'
[https://m3o.com/user/api#SendVerificationEmail](https://m3o.com/user/api#SendVerificationEmail)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Send a verification email to a user.
// Email "from" will be 'noreply@email.m3ocontent.com'.
// The verification link will be injected in the email
// as a template variable, $micro_verification_link e.g
// 'Welcome to M3O! Use the link below to verify your email: $micro_verification_link'
// The variable will be replaced with a url similar to:
// 'https://user.m3o.com/user/verify?token=a-verification-token&redirectUrl=your-redir-url'
func SendVerificationEmail() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.SendVerificationEmail(&user.SendVerificationEmailRequest{
Email: "joe@example.com",
FailureRedirectUrl: "https://m3o.com/verification-failed",
FromName: "Awesome Dot Com",
RedirectUrl: "https://m3o.com",
Subject: "Email verification",
TextContent: `Hi there,
Please verify your email by clicking this link: $micro_verification_link`,
})
fmt.Println(rsp, err)
}
```
## 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)
}
```
## 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)
}
```
## VerifyToken
Check whether the token attached to MagicLink is valid or not.
Ideally, you need to call this endpoint from your http request
handler that handles the endpoint which is specified in the
SendMagicLink request.
[https://m3o.com/user/api#VerifyToken](https://m3o.com/user/api#VerifyToken)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Check whether the token attached to MagicLink is valid or not.
// Ideally, you need to call this endpoint from your http request
// handler that handles the endpoint which is specified in the
// SendMagicLink request.
func VerifyAtoken() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.VerifyToken(&user.VerifyTokenRequest{
Token: "EdsUiidouJJJLldjlloofUiorkojflsWWdld",
})
fmt.Println(rsp, err)
}
```
## Create
@@ -419,6 +388,36 @@ Username: "joe",
})
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)
}
```
## Read
@@ -505,12 +504,12 @@ func ReadAccountByEmail() {
}
```
## ReadSession
## List
Read a session by the session id. In the event it has expired or is not found and error is returned.
List all users. Returns a paged list of results
[https://m3o.com/user/api#ReadSession](https://m3o.com/user/api#ReadSession)
[https://m3o.com/user/api#List](https://m3o.com/user/api#List)
```go
package example
@@ -522,11 +521,12 @@ import(
"go.m3o.com/user"
)
// Read a session by the session id. In the event it has expired or is not found and error is returned.
func ReadAsessionByTheSessionId() {
// List all users. Returns a paged list of results
func ListAllUsers() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.ReadSession(&user.ReadSessionRequest{
SessionId: "df91a612-5b24-4634-99ff-240220ab8f55",
rsp, err := userService.List(&user.ListRequest{
Limit: 100,
Offset: 0,
})
fmt.Println(rsp, err)