mirror of
https://github.com/kevin-DL/m3o-go.git
synced 2026-01-11 10:34:27 +00:00
Commit from m3o/m3o action
This commit is contained in:
2
cache/cache.go
vendored
2
cache/cache.go
vendored
@@ -98,8 +98,6 @@ type DeleteResponse struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type GetRequest struct {
|
type GetRequest struct {
|
||||||
// Specify a default value returned in the event the value does not exist
|
|
||||||
DefaultValue string `json:"default_value"`
|
|
||||||
// The key to retrieve
|
// The key to retrieve
|
||||||
Key string `json:"key"`
|
Key string `json:"key"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/app/api](https
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
## Resolve
|
|
||||||
|
|
||||||
Resolve an app by id to its raw backend endpoint
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/app/api#Resolve](https://m3o.com/app/api#Resolve)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/app"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Resolve an app by id to its raw backend endpoint
|
|
||||||
func ResolveAppById() {
|
|
||||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := appService.Resolve(&app.ResolveRequest{
|
|
||||||
Id: "helloworld",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Update
|
## Update
|
||||||
|
|
||||||
Update the app. The latest source code will be downloaded, built and deployed.
|
Update the app. The latest source code will be downloaded, built and deployed.
|
||||||
@@ -230,3 +202,31 @@ func GetTheStatusOfAnApp() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
## Resolve
|
||||||
|
|
||||||
|
Resolve an app by id to its raw backend endpoint
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/app/api#Resolve](https://m3o.com/app/api#Resolve)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/app"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Resolve an app by id to its raw backend endpoint
|
||||||
|
func ResolveAppById() {
|
||||||
|
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := appService.Resolve(&app.ResolveRequest{
|
||||||
|
Id: "helloworld",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
@@ -4,121 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/chat/api](http
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
## Delete
|
|
||||||
|
|
||||||
Delete a chat room
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/chat/api#Delete](https://m3o.com/chat/api#Delete)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/chat"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Delete a chat room
|
|
||||||
func DeleteAchat() {
|
|
||||||
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := chatService.Delete(&chat.DeleteRequest{
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Send
|
|
||||||
|
|
||||||
Connect to a chat to receive a stream of messages
|
|
||||||
Send a message to a chat
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/chat/api#Send](https://m3o.com/chat/api#Send)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/chat"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Connect to a chat to receive a stream of messages
|
|
||||||
// Send a message to a chat
|
|
||||||
func SendAmessage() {
|
|
||||||
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := chatService.Send(&chat.SendRequest{
|
|
||||||
Client: "web",
|
|
||||||
Subject: "Random",
|
|
||||||
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)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## New
|
|
||||||
|
|
||||||
Create a new chat room
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/chat/api#New](https://m3o.com/chat/api#New)
|
|
||||||
|
|
||||||
```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.New(&chat.NewRequest{
|
|
||||||
Description: "The general chat room",
|
|
||||||
Name: "general",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## List
|
## List
|
||||||
|
|
||||||
List available chats
|
List available chats
|
||||||
@@ -171,6 +56,121 @@ func InviteAuser() {
|
|||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
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
|
||||||
|
|
||||||
|
Leave a chat room
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/chat/api#Leave](https://m3o.com/chat/api#Leave)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/chat"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Leave a chat room
|
||||||
|
func LeaveAroom() {
|
||||||
|
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := chatService.Leave(&chat.LeaveRequest{
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## New
|
||||||
|
|
||||||
|
Create a new chat room
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/chat/api#New](https://m3o.com/chat/api#New)
|
||||||
|
|
||||||
|
```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.New(&chat.NewRequest{
|
||||||
|
Description: "The general chat room",
|
||||||
|
Name: "general",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Send
|
||||||
|
|
||||||
|
Connect to a chat to receive a stream of messages
|
||||||
|
Send a message to a chat
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/chat/api#Send](https://m3o.com/chat/api#Send)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/chat"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Connect to a chat to receive a stream of messages
|
||||||
|
// Send a message to a chat
|
||||||
|
func SendAmessage() {
|
||||||
|
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := chatService.Send(&chat.SendRequest{
|
||||||
|
Client: "web",
|
||||||
|
Subject: "Random",
|
||||||
|
Text: "Hey whats up?",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Join
|
## Join
|
||||||
@@ -240,12 +240,12 @@ func KickAuserFromAroom() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Leave
|
## Delete
|
||||||
|
|
||||||
Leave a chat room
|
Delete a chat room
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/chat/api#Leave](https://m3o.com/chat/api#Leave)
|
[https://m3o.com/chat/api#Delete](https://m3o.com/chat/api#Delete)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
package example
|
package example
|
||||||
@@ -257,10 +257,10 @@ import(
|
|||||||
"go.m3o.com/chat"
|
"go.m3o.com/chat"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Leave a chat room
|
// Delete a chat room
|
||||||
func LeaveAroom() {
|
func DeleteAchat() {
|
||||||
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := chatService.Leave(&chat.LeaveRequest{
|
rsp, err := chatService.Delete(&chat.DeleteRequest{
|
||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|||||||
@@ -4,61 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/currency/api](
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
## Codes
|
|
||||||
|
|
||||||
Codes returns the supported currency codes for the API
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/currency/api#Codes](https://m3o.com/currency/api#Codes)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/currency"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Codes returns the supported currency codes for the API
|
|
||||||
func GetSupportedCodes() {
|
|
||||||
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := currencyService.Codes(¤cy.CodesRequest{
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Rates
|
|
||||||
|
|
||||||
Rates returns the currency rates for a given code e.g USD
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/currency/api#Rates](https://m3o.com/currency/api#Rates)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/currency"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Rates returns the currency rates for a given code e.g USD
|
|
||||||
func GetRatesForUsd() {
|
|
||||||
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := currencyService.Rates(¤cy.RatesRequest{
|
|
||||||
Code: "USD",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Convert
|
## Convert
|
||||||
|
|
||||||
Convert returns the currency conversion rate between two pairs e.g USD/GBP
|
Convert returns the currency conversion rate between two pairs e.g USD/GBP
|
||||||
@@ -147,3 +92,58 @@ Date: "2021-05-30",
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
## Codes
|
||||||
|
|
||||||
|
Codes returns the supported currency codes for the API
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/currency/api#Codes](https://m3o.com/currency/api#Codes)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/currency"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Codes returns the supported currency codes for the API
|
||||||
|
func GetSupportedCodes() {
|
||||||
|
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := currencyService.Codes(¤cy.CodesRequest{
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Rates
|
||||||
|
|
||||||
|
Rates returns the currency rates for a given code e.g USD
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/currency/api#Rates](https://m3o.com/currency/api#Rates)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/currency"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Rates returns the currency rates for a given code e.g USD
|
||||||
|
func GetRatesForUsd() {
|
||||||
|
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := currencyService.Rates(¤cy.RatesRequest{
|
||||||
|
Code: "USD",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
@@ -4,6 +4,66 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/db/api](https:
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
|
## DropTable
|
||||||
|
|
||||||
|
Drop a table in the DB
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/db/api#DropTable](https://m3o.com/db/api#DropTable)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/db"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Drop a table in the DB
|
||||||
|
func DropTable() {
|
||||||
|
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := dbService.DropTable(&db.DropTableRequest{
|
||||||
|
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)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
## Read
|
## Read
|
||||||
|
|
||||||
Read data from a table. Lookup can be by ID or via querying any field in the record.
|
Read data from a table. Lookup can be by ID or via querying any field in the record.
|
||||||
@@ -31,6 +91,35 @@ Table: "example",
|
|||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Delete
|
||||||
|
|
||||||
|
Delete a record in the database by id.
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/db/api#Delete](https://m3o.com/db/api#Delete)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/db"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Delete a record in the database by id.
|
||||||
|
func DeleteArecord() {
|
||||||
|
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := dbService.Delete(&db.DeleteRequest{
|
||||||
|
Id: "1",
|
||||||
|
Table: "example",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Truncate
|
## Truncate
|
||||||
@@ -59,34 +148,6 @@ func TruncateTable() {
|
|||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## DropTable
|
|
||||||
|
|
||||||
Drop a table in the DB
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/db/api#DropTable](https://m3o.com/db/api#DropTable)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/db"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Drop a table in the DB
|
|
||||||
func DropTable() {
|
|
||||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := dbService.DropTable(&db.DropTableRequest{
|
|
||||||
Table: "example",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Count
|
## Count
|
||||||
@@ -195,42 +256,10 @@ func CreateArecord() {
|
|||||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := dbService.Create(&db.CreateRequest{
|
rsp, err := dbService.Create(&db.CreateRequest{
|
||||||
Record: map[string]interface{}{
|
Record: map[string]interface{}{
|
||||||
"id": "1",
|
|
||||||
"name": "Jane",
|
"name": "Jane",
|
||||||
"age": 42,
|
"age": 42,
|
||||||
"isActive": true,
|
"isActive": true,
|
||||||
},
|
|
||||||
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",
|
"id": "1",
|
||||||
"age": 43,
|
|
||||||
},
|
},
|
||||||
Table: "example",
|
Table: "example",
|
||||||
|
|
||||||
@@ -239,32 +268,3 @@ Table: "example",
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Delete
|
|
||||||
|
|
||||||
Delete a record in the database by id.
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/db/api#Delete](https://m3o.com/db/api#Delete)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/db"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Delete a record in the database by id.
|
|
||||||
func DeleteArecord() {
|
|
||||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := dbService.Delete(&db.DeleteRequest{
|
|
||||||
Id: "1",
|
|
||||||
Table: "example",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|||||||
@@ -12,10 +12,10 @@ func main() {
|
|||||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := dbService.Create(&db.CreateRequest{
|
rsp, err := dbService.Create(&db.CreateRequest{
|
||||||
Record: map[string]interface{}{
|
Record: map[string]interface{}{
|
||||||
"age": 42,
|
|
||||||
"isActive": true,
|
|
||||||
"id": "1",
|
"id": "1",
|
||||||
"name": "Jane",
|
"name": "Jane",
|
||||||
|
"age": 42,
|
||||||
|
"isActive": true,
|
||||||
},
|
},
|
||||||
Table: "example",
|
Table: "example",
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -4,33 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/emoji/api](htt
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
## Flag
|
|
||||||
|
|
||||||
Get the flag for a country. Requires country code e.g GB for great britain
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/emoji/api#Flag](https://m3o.com/emoji/api#Flag)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/emoji"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Get the flag for a country. Requires country code e.g GB for great britain
|
|
||||||
func GetFlagByCountryCode() {
|
|
||||||
emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := emojiService.Flag(&emoji.FlagRequest{
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Print
|
## Print
|
||||||
|
|
||||||
Print text and renders the emojis with aliases e.g
|
Print text and renders the emojis with aliases e.g
|
||||||
@@ -119,3 +92,30 @@ func FindEmoji() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
## Flag
|
||||||
|
|
||||||
|
Get the flag for a country. Requires country code e.g GB for great britain
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/emoji/api#Flag](https://m3o.com/emoji/api#Flag)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/emoji"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Get the flag for a country. Requires country code e.g GB for great britain
|
||||||
|
func GetFlagByCountryCode() {
|
||||||
|
emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := emojiService.Flag(&emoji.FlagRequest{
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
@@ -4,33 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/evchargers/api
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
## ReferenceData
|
|
||||||
|
|
||||||
Retrieve reference data as used by this API and in conjunction with the Search endpoint
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/evchargers/api#ReferenceData](https://m3o.com/evchargers/api#ReferenceData)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/evchargers"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Retrieve reference data as used by this API and in conjunction with the Search endpoint
|
|
||||||
func GetReferenceData() {
|
|
||||||
evchargersService := evchargers.NewEvchargersService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := evchargersService.ReferenceData(&evchargers.ReferenceDataRequest{
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Search
|
## Search
|
||||||
|
|
||||||
Search by giving a coordinate and a max distance, or bounding box and optional filters
|
Search by giving a coordinate and a max distance, or bounding box and optional filters
|
||||||
@@ -125,3 +98,30 @@ Location: &evchargers.Coordinates{
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
## ReferenceData
|
||||||
|
|
||||||
|
Retrieve reference data as used by this API and in conjunction with the Search endpoint
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/evchargers/api#ReferenceData](https://m3o.com/evchargers/api#ReferenceData)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/evchargers"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Retrieve reference data as used by this API and in conjunction with the Search endpoint
|
||||||
|
func GetReferenceData() {
|
||||||
|
evchargersService := evchargers.NewEvchargersService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := evchargersService.ReferenceData(&evchargers.ReferenceDataRequest{
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
@@ -4,39 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/event/api](htt
|
|||||||
|
|
||||||
Endpoints:
|
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
|
||||||
|
|
||||||
Consume events from a given topic.
|
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{}{
|
||||||
|
"id": "1",
|
||||||
|
"type": "signup",
|
||||||
|
"user": "john",
|
||||||
|
},
|
||||||
|
Topic: "user",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
@@ -4,35 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/file/api](http
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
## 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
|
||||||
|
|
||||||
Save a file
|
Save a file
|
||||||
@@ -122,3 +93,32 @@ Project: "examples",
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
## 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)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
@@ -4,12 +4,12 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/function/api](
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
## List
|
## Deploy
|
||||||
|
|
||||||
List all the deployed functions
|
Deploy a group of functions
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/function/api#List](https://m3o.com/function/api#List)
|
[https://m3o.com/function/api#Deploy](https://m3o.com/function/api#Deploy)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
package example
|
package example
|
||||||
@@ -21,38 +21,18 @@ import(
|
|||||||
"go.m3o.com/function"
|
"go.m3o.com/function"
|
||||||
)
|
)
|
||||||
|
|
||||||
// List all the deployed functions
|
// Deploy a group of functions
|
||||||
func ListFunctions() {
|
func DeployAfunction() {
|
||||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := functionService.List(&function.ListRequest{
|
rsp, err := functionService.Deploy(&function.DeployRequest{
|
||||||
|
Branch: "main",
|
||||||
})
|
Entrypoint: "Helloworld",
|
||||||
fmt.Println(rsp, err)
|
Name: "helloworld",
|
||||||
|
Region: "europe-west1",
|
||||||
}
|
Repo: "https://github.com/m3o/m3o",
|
||||||
```
|
Runtime: "go116",
|
||||||
## Regions
|
Subfolder: "examples/go-function",
|
||||||
|
|
||||||
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)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
@@ -84,6 +64,34 @@ func UpdateAfunction() {
|
|||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
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)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Call
|
## Call
|
||||||
@@ -117,12 +125,12 @@ Request: map[string]interface{}{
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Describe
|
## List
|
||||||
|
|
||||||
Get the info for a deployed function
|
List all the deployed functions
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/function/api#Describe](https://m3o.com/function/api#Describe)
|
[https://m3o.com/function/api#List](https://m3o.com/function/api#List)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
package example
|
package example
|
||||||
@@ -134,102 +142,11 @@ import(
|
|||||||
"go.m3o.com/function"
|
"go.m3o.com/function"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Get the info for a deployed function
|
// List all the deployed functions
|
||||||
func DescribeFunctionStatus() {
|
func ListFunctions() {
|
||||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := functionService.Describe(&function.DescribeRequest{
|
rsp, err := functionService.List(&function.ListRequest{
|
||||||
Name: "helloworld",
|
|
||||||
|
|
||||||
})
|
|
||||||
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
|
|
||||||
|
|
||||||
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)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
@@ -263,3 +180,86 @@ func DeleteAfunction() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
## Describe
|
||||||
|
|
||||||
|
Get the info for a deployed function
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/function/api#Describe](https://m3o.com/function/api#Describe)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/function"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Get the info for a deployed function
|
||||||
|
func DescribeFunctionStatus() {
|
||||||
|
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := functionService.Describe(&function.DescribeRequest{
|
||||||
|
Name: "helloworld",
|
||||||
|
|
||||||
|
})
|
||||||
|
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
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
@@ -4,6 +4,35 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/geocoding/api]
|
|||||||
|
|
||||||
Endpoints:
|
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
|
||||||
|
|
||||||
Lookup returns a geocoded address including normalized address and gps coordinates. All fields are optional, provide more to get more accurate results
|
Lookup returns a geocoded address including normalized address and gps coordinates. All fields are optional, provide more to get more accurate results
|
||||||
@@ -35,32 +64,3 @@ 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)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|||||||
@@ -4,6 +4,42 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/location/api](
|
|||||||
|
|
||||||
Endpoints:
|
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
|
||||||
|
|
||||||
Read an entity by its ID
|
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)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|||||||
@@ -4,39 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/mq/api](https:
|
|||||||
|
|
||||||
Endpoints:
|
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
|
||||||
|
|
||||||
Subscribe to messages for a given topic.
|
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)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
@@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/nft/api](https
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
|
## Collections
|
||||||
|
|
||||||
|
Get a list of collections
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/nft/api#Collections](https://m3o.com/nft/api#Collections)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/nft"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Get a list of collections
|
||||||
|
func ListCollections() {
|
||||||
|
nftService := nft.NewNftService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := nftService.Collections(&nft.CollectionsRequest{
|
||||||
|
Limit: 1,
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
## Assets
|
## Assets
|
||||||
|
|
||||||
Return a list of assets
|
Return a list of assets
|
||||||
@@ -61,31 +89,3 @@ Name: "Guybrush Threepwood",
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Collections
|
|
||||||
|
|
||||||
Get a list of collections
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/nft/api#Collections](https://m3o.com/nft/api#Collections)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/nft"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Get a list of collections
|
|
||||||
func ListCollections() {
|
|
||||||
nftService := nft.NewNftService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := nftService.Collections(&nft.CollectionsRequest{
|
|
||||||
Limit: 1,
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|||||||
@@ -4,6 +4,35 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/notes/api](htt
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
|
## Create
|
||||||
|
|
||||||
|
Create a new note
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/notes/api#Create](https://m3o.com/notes/api#Create)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/notes"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Create a new note
|
||||||
|
func CreateAnote() {
|
||||||
|
notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := notesService.Create(¬es.CreateRequest{
|
||||||
|
Text: "This is my note",
|
||||||
|
Title: "New Note",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
## Read
|
## Read
|
||||||
|
|
||||||
Read a note
|
Read a note
|
||||||
@@ -160,32 +189,3 @@ func SubscribeToEvents() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Create
|
|
||||||
|
|
||||||
Create a new note
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/notes/api#Create](https://m3o.com/notes/api#Create)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/notes"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Create a new note
|
|
||||||
func CreateAnote() {
|
|
||||||
notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := notesService.Create(¬es.CreateRequest{
|
|
||||||
Text: "This is my note",
|
|
||||||
Title: "New Note",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|||||||
@@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/otp/api](https
|
|||||||
|
|
||||||
Endpoints:
|
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
|
||||||
|
|
||||||
Validate the OTP code
|
Validate the OTP code
|
||||||
@@ -61,3 +33,31 @@ 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)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
@@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/postcode/api](
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
## Validate
|
|
||||||
|
|
||||||
Validate a postcode.
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/postcode/api#Validate](https://m3o.com/postcode/api#Validate)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/postcode"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Validate a postcode.
|
|
||||||
func ReturnArandomPostcodeAndItsInformation() {
|
|
||||||
postcodeService := postcode.NewPostcodeService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := postcodeService.Validate(&postcode.ValidateRequest{
|
|
||||||
Postcode: "SW1A 2AA",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Lookup
|
## Lookup
|
||||||
|
|
||||||
Lookup a postcode to retrieve the related region, county, etc
|
Lookup a postcode to retrieve the related region, county, etc
|
||||||
@@ -87,3 +59,31 @@ func ReturnArandomPostcodeAndItsInformation() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
## Validate
|
||||||
|
|
||||||
|
Validate a postcode.
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/postcode/api#Validate](https://m3o.com/postcode/api#Validate)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/postcode"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Validate a postcode.
|
||||||
|
func ReturnArandomPostcodeAndItsInformation() {
|
||||||
|
postcodeService := postcode.NewPostcodeService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := postcodeService.Validate(&postcode.ValidateRequest{
|
||||||
|
Postcode: "SW1A 2AA",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
@@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/quran/api](htt
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
|
## Search
|
||||||
|
|
||||||
|
Search the Quran for any form of query or questions
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/quran/api#Search](https://m3o.com/quran/api#Search)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/quran"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Search the Quran for any form of query or questions
|
||||||
|
func SearchTheQuran() {
|
||||||
|
quranService := quran.NewQuranService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := quranService.Search(&quran.SearchRequest{
|
||||||
|
Query: "messenger",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
## Chapters
|
## Chapters
|
||||||
|
|
||||||
List the Chapters (surahs) of the Quran
|
List the Chapters (surahs) of the Quran
|
||||||
@@ -92,31 +120,3 @@ func GetVersesOfAchapter() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Search
|
|
||||||
|
|
||||||
Search the Quran for any form of query or questions
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/quran/api#Search](https://m3o.com/quran/api#Search)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/quran"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Search the Quran for any form of query or questions
|
|
||||||
func SearchTheQuran() {
|
|
||||||
quranService := quran.NewQuranService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := quranService.Search(&quran.SearchRequest{
|
|
||||||
Query: "messenger",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|||||||
@@ -4,62 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/search/api](ht
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
## CreateIndex
|
|
||||||
|
|
||||||
Create an index by name
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/search/api#CreateIndex](https://m3o.com/search/api#CreateIndex)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/search"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Create an index by name
|
|
||||||
func CreateAnIndex() {
|
|
||||||
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := searchService.CreateIndex(&search.CreateIndexRequest{
|
|
||||||
Index: "customers",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## 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
|
||||||
|
|
||||||
Index a document i.e. insert a document to search for.
|
Index a document i.e. insert a document to search for.
|
||||||
@@ -83,9 +27,9 @@ func IndexAdocument() {
|
|||||||
rsp, err := searchService.Index(&search.IndexRequest{
|
rsp, err := searchService.Index(&search.IndexRequest{
|
||||||
Document: &search.Document{
|
Document: &search.Document{
|
||||||
Contents: map[string]interface{}{
|
Contents: map[string]interface{}{
|
||||||
"name": "John Doe",
|
|
||||||
"age": 37,
|
"age": 37,
|
||||||
"starsign": "Leo",
|
"starsign": "Leo",
|
||||||
|
"name": "John Doe",
|
||||||
},
|
},
|
||||||
Id: "1234",
|
Id: "1234",
|
||||||
},
|
},
|
||||||
@@ -212,3 +156,59 @@ Index: "customers",
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
## CreateIndex
|
||||||
|
|
||||||
|
Create an index by name
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/search/api#CreateIndex](https://m3o.com/search/api#CreateIndex)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/search"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Create an index by name
|
||||||
|
func CreateAnIndex() {
|
||||||
|
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := searchService.CreateIndex(&search.CreateIndexRequest{
|
||||||
|
Index: "customers",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## 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)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
@@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/stream/api](ht
|
|||||||
|
|
||||||
Endpoints:
|
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
|
## ListChannels
|
||||||
|
|
||||||
List all the active channels
|
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)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
@@ -4,6 +4,35 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/sunnah/api](ht
|
|||||||
|
|
||||||
Endpoints:
|
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
|
## Books
|
||||||
|
|
||||||
Get a list of books from within a collection. A book can contain many chapters
|
Get a list of books from within a collection. A book can contain many chapters
|
||||||
@@ -94,32 +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)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|||||||
@@ -4,37 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/user/api](http
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
## ResetPassword
|
|
||||||
|
|
||||||
Reset password with the code sent by the "SendPasswordResetEmail" endpoint.
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/user/api#ResetPassword](https://m3o.com/user/api#ResetPassword)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/user"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Reset password with the code sent by the "SendPasswordResetEmail" endpoint.
|
|
||||||
func ResetPassword() {
|
|
||||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := userService.ResetPassword(&user.ResetPasswordRequest{
|
|
||||||
Code: "012345",
|
|
||||||
ConfirmPassword: "NewPassword1",
|
|
||||||
Email: "joe@example.com",
|
|
||||||
NewPassword: "NewPassword1",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Delete
|
## Delete
|
||||||
|
|
||||||
Delete an account by id
|
Delete an account by id
|
||||||
@@ -61,6 +30,98 @@ func DeleteUserAccount() {
|
|||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Login
|
||||||
|
|
||||||
|
Login using username or email. The response will return a new session for successful login,
|
||||||
|
401 in the case of login failure and 500 for any other error
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/user/api#Login](https://m3o.com/user/api#Login)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/user"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Login using username or email. The response will return a new session for successful login,
|
||||||
|
// 401 in the case of login failure and 500 for any other error
|
||||||
|
func LogAuserIn() {
|
||||||
|
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := userService.Login(&user.LoginRequest{
|
||||||
|
Email: "joe@example.com",
|
||||||
|
Password: "Password1",
|
||||||
|
|
||||||
|
})
|
||||||
|
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)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## 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
|
||||||
@@ -147,18 +208,12 @@ func ReadAccountByEmail() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## SendVerificationEmail
|
## VerifyEmail
|
||||||
|
|
||||||
Send a verification email to a user.
|
Verify the email address of an account from a token sent in an email to the 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)
|
[https://m3o.com/user/api#VerifyEmail](https://m3o.com/user/api#VerifyEmail)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
package example
|
package example
|
||||||
@@ -170,24 +225,42 @@ import(
|
|||||||
"go.m3o.com/user"
|
"go.m3o.com/user"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Send a verification email to a user.
|
// Verify the email address of an account from a token sent in an email to the user.
|
||||||
// Email "from" will be 'noreply@email.m3ocontent.com'.
|
func VerifyEmail() {
|
||||||
// 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"))
|
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := userService.SendVerificationEmail(&user.SendVerificationEmailRequest{
|
rsp, err := userService.VerifyEmail(&user.VerifyEmailRequest{
|
||||||
Email: "joe@example.com",
|
Token: "012345",
|
||||||
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)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## UpdatePassword
|
||||||
|
|
||||||
|
Update the account password
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/user/api#UpdatePassword](https://m3o.com/user/api#UpdatePassword)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/user"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Update the account password
|
||||||
|
func UpdateTheAccountPassword() {
|
||||||
|
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := userService.UpdatePassword(&user.UpdatePasswordRequest{
|
||||||
|
ConfirmPassword: "Password2",
|
||||||
|
NewPassword: "Password2",
|
||||||
|
OldPassword: "Password1",
|
||||||
|
UserId: "user-1",
|
||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
@@ -226,122 +299,6 @@ TextContent: `Hi there,
|
|||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
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
|
|
||||||
|
|
||||||
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#ReadSession](https://m3o.com/user/api#ReadSession)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"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() {
|
|
||||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := userService.ReadSession(&user.ReadSessionRequest{
|
|
||||||
SessionId: "df91a612-5b24-4634-99ff-240220ab8f55",
|
|
||||||
|
|
||||||
})
|
|
||||||
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)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## 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)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## SendMagicLink
|
## SendMagicLink
|
||||||
@@ -413,12 +370,18 @@ func VerifyAtoken() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Update
|
## SendVerificationEmail
|
||||||
|
|
||||||
Update the account username or email
|
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#Update](https://m3o.com/user/api#Update)
|
[https://m3o.com/user/api#SendVerificationEmail](https://m3o.com/user/api#SendVerificationEmail)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
package example
|
package example
|
||||||
@@ -430,75 +393,24 @@ import(
|
|||||||
"go.m3o.com/user"
|
"go.m3o.com/user"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Update the account username or email
|
// Send a verification email to a user.
|
||||||
func UpdateAnAccount() {
|
// 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"))
|
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := userService.Update(&user.UpdateRequest{
|
rsp, err := userService.SendVerificationEmail(&user.SendVerificationEmailRequest{
|
||||||
Email: "joe+2@example.com",
|
|
||||||
Id: "user-1",
|
|
||||||
Username: "joe",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## UpdatePassword
|
|
||||||
|
|
||||||
Update the account password
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/user/api#UpdatePassword](https://m3o.com/user/api#UpdatePassword)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/user"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Update the account password
|
|
||||||
func UpdateTheAccountPassword() {
|
|
||||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := userService.UpdatePassword(&user.UpdatePasswordRequest{
|
|
||||||
ConfirmPassword: "Password2",
|
|
||||||
NewPassword: "Password2",
|
|
||||||
OldPassword: "Password1",
|
|
||||||
UserId: "user-1",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Login
|
|
||||||
|
|
||||||
Login using username or email. The response will return a new session for successful login,
|
|
||||||
401 in the case of login failure and 500 for any other error
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/user/api#Login](https://m3o.com/user/api#Login)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/user"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Login using username or email. The response will return a new session for successful login,
|
|
||||||
// 401 in the case of login failure and 500 for any other error
|
|
||||||
func LogAuserIn() {
|
|
||||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := userService.Login(&user.LoginRequest{
|
|
||||||
Email: "joe@example.com",
|
Email: "joe@example.com",
|
||||||
Password: "Password1",
|
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)
|
fmt.Println(rsp, err)
|
||||||
@@ -533,3 +445,91 @@ func LogAuserOut() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
## ReadSession
|
||||||
|
|
||||||
|
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#ReadSession](https://m3o.com/user/api#ReadSession)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"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() {
|
||||||
|
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := userService.ReadSession(&user.ReadSessionRequest{
|
||||||
|
SessionId: "df91a612-5b24-4634-99ff-240220ab8f55",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## ResetPassword
|
||||||
|
|
||||||
|
Reset password with the code sent by the "SendPasswordResetEmail" endpoint.
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/user/api#ResetPassword](https://m3o.com/user/api#ResetPassword)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/user"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Reset password with the code sent by the "SendPasswordResetEmail" endpoint.
|
||||||
|
func ResetPassword() {
|
||||||
|
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := userService.ResetPassword(&user.ResetPasswordRequest{
|
||||||
|
Code: "012345",
|
||||||
|
ConfirmPassword: "NewPassword1",
|
||||||
|
Email: "joe@example.com",
|
||||||
|
NewPassword: "NewPassword1",
|
||||||
|
|
||||||
|
})
|
||||||
|
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)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user