mirror of
https://github.com/kevin-DL/m3o-go.git
synced 2026-01-11 18:44:26 +00:00
Commit from m3o/m3o action
This commit is contained in:
@@ -4,34 +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.
|
||||
@@ -230,3 +202,31 @@ 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)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
54
examples/cache/README.md
vendored
54
examples/cache/README.md
vendored
@@ -4,33 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/cache/api](htt
|
||||
|
||||
Endpoints:
|
||||
|
||||
## ListKeys
|
||||
|
||||
List all the available keys
|
||||
|
||||
|
||||
[https://m3o.com/cache/api#ListKeys](https://m3o.com/cache/api#ListKeys)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/cache"
|
||||
)
|
||||
|
||||
// List all the available keys
|
||||
func ListTheKeys() {
|
||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := cacheService.ListKeys(&cache.ListKeysRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Set
|
||||
|
||||
Set an item in the cache. Overwrites any existing value already set.
|
||||
@@ -174,3 +147,30 @@ Value: 2,
|
||||
|
||||
}
|
||||
```
|
||||
## ListKeys
|
||||
|
||||
List all the available keys
|
||||
|
||||
|
||||
[https://m3o.com/cache/api#ListKeys](https://m3o.com/cache/api#ListKeys)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/cache"
|
||||
)
|
||||
|
||||
// List all the available keys
|
||||
func ListTheKeys() {
|
||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := cacheService.ListKeys(&cache.ListKeysRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,6 +4,100 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/chat/api](http
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Join
|
||||
|
||||
Join a chat room
|
||||
|
||||
|
||||
[https://m3o.com/chat/api#Join](https://m3o.com/chat/api#Join)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/chat"
|
||||
)
|
||||
|
||||
// Join a chat room
|
||||
func JoinAroom() {
|
||||
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
||||
|
||||
stream, err := chatService.Join(&chat.JoinRequest{
|
||||
|
||||
})
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
for {
|
||||
rsp, err := stream.Recv()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println(rsp)
|
||||
}
|
||||
}
|
||||
```
|
||||
## 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)
|
||||
|
||||
}
|
||||
```
|
||||
## 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)
|
||||
|
||||
}
|
||||
```
|
||||
## Invite
|
||||
|
||||
Invite a user to a chat room
|
||||
@@ -29,6 +123,38 @@ func InviteAuser() {
|
||||
})
|
||||
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
|
||||
@@ -83,6 +209,33 @@ func KickAuserFromAroom() {
|
||||
})
|
||||
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)
|
||||
|
||||
}
|
||||
```
|
||||
## Create
|
||||
@@ -114,156 +267,3 @@ Name: "general",
|
||||
|
||||
}
|
||||
```
|
||||
## 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)
|
||||
|
||||
}
|
||||
```
|
||||
## Join
|
||||
|
||||
Join a chat room
|
||||
|
||||
|
||||
[https://m3o.com/chat/api#Join](https://m3o.com/chat/api#Join)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/chat"
|
||||
)
|
||||
|
||||
// Join a chat room
|
||||
func JoinAroom() {
|
||||
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
||||
|
||||
stream, err := chatService.Join(&chat.JoinRequest{
|
||||
|
||||
})
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
for {
|
||||
rsp, err := stream.Recv()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println(rsp)
|
||||
}
|
||||
}
|
||||
```
|
||||
## 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)
|
||||
|
||||
}
|
||||
```
|
||||
## 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)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,6 +4,75 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/comments/api](
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Events
|
||||
|
||||
Subscribe to comments events
|
||||
|
||||
|
||||
[https://m3o.com/comments/api#Events](https://m3o.com/comments/api#Events)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/comments"
|
||||
)
|
||||
|
||||
// Subscribe to comments events
|
||||
func SubscribeToEvents() {
|
||||
commentsService := comments.NewCommentsService(os.Getenv("M3O_API_TOKEN"))
|
||||
|
||||
stream, err := commentsService.Events(&comments.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 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
|
||||
@@ -119,72 +188,3 @@ func DeleteAcomment() {
|
||||
|
||||
}
|
||||
```
|
||||
## Events
|
||||
|
||||
Subscribe to comments events
|
||||
|
||||
|
||||
[https://m3o.com/comments/api#Events](https://m3o.com/comments/api#Events)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/comments"
|
||||
)
|
||||
|
||||
// Subscribe to comments events
|
||||
func SubscribeToEvents() {
|
||||
commentsService := comments.NewCommentsService(os.Getenv("M3O_API_TOKEN"))
|
||||
|
||||
stream, err := commentsService.Events(&comments.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 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)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/crypto/api](ht
|
||||
|
||||
Endpoints:
|
||||
|
||||
## News
|
||||
|
||||
Get news related to a currency
|
||||
|
||||
|
||||
[https://m3o.com/crypto/api#News](https://m3o.com/crypto/api#News)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/crypto"
|
||||
)
|
||||
|
||||
// Get news related to a currency
|
||||
func GetCryptocurrencyNews() {
|
||||
cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := cryptoService.News(&crypto.NewsRequest{
|
||||
Symbol: "BTCUSD",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Price
|
||||
|
||||
Get the last price for a given crypto ticker
|
||||
@@ -88,31 +116,3 @@ func GetPreviousClose() {
|
||||
|
||||
}
|
||||
```
|
||||
## News
|
||||
|
||||
Get news related to a currency
|
||||
|
||||
|
||||
[https://m3o.com/crypto/api#News](https://m3o.com/crypto/api#News)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/crypto"
|
||||
)
|
||||
|
||||
// Get news related to a currency
|
||||
func GetCryptocurrencyNews() {
|
||||
cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := cryptoService.News(&crypto.NewsRequest{
|
||||
Symbol: "BTCUSD",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,12 +4,12 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/db/api](https:
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Update
|
||||
## Truncate
|
||||
|
||||
Update a record in the database. Include an "id" in the record to update.
|
||||
Truncate the records in a table
|
||||
|
||||
|
||||
[https://m3o.com/db/api#Update](https://m3o.com/db/api#Update)
|
||||
[https://m3o.com/db/api#Truncate](https://m3o.com/db/api#Truncate)
|
||||
|
||||
```go
|
||||
package example
|
||||
@@ -21,15 +21,11 @@ import(
|
||||
"go.m3o.com/db"
|
||||
)
|
||||
|
||||
// Update a record in the database. Include an "id" in the record to update.
|
||||
func UpdateArecord() {
|
||||
// Truncate the records in a table
|
||||
func TruncateTable() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.Update(&db.UpdateRequest{
|
||||
Record: map[string]interface{}{
|
||||
"id": "1",
|
||||
"age": 43,
|
||||
},
|
||||
Table: "example",
|
||||
rsp, err := dbService.Truncate(&db.TruncateRequest{
|
||||
Table: "example",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
@@ -90,6 +86,124 @@ To: "examples3",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Read
|
||||
|
||||
Read data from a table. Lookup can be by ID or via querying any field in the record.
|
||||
|
||||
|
||||
[https://m3o.com/db/api#Read](https://m3o.com/db/api#Read)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/db"
|
||||
)
|
||||
|
||||
// Read data from a table. Lookup can be by ID or via querying any field in the record.
|
||||
func ReadRecords() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.Read(&db.ReadRequest{
|
||||
Query: "age == 43",
|
||||
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)
|
||||
|
||||
}
|
||||
```
|
||||
## 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)
|
||||
|
||||
}
|
||||
```
|
||||
## 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
|
||||
@@ -154,117 +268,3 @@ Table: "example",
|
||||
|
||||
}
|
||||
```
|
||||
## Read
|
||||
|
||||
Read data from a table. Lookup can be by ID or via querying any field in the record.
|
||||
|
||||
|
||||
[https://m3o.com/db/api#Read](https://m3o.com/db/api#Read)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/db"
|
||||
)
|
||||
|
||||
// Read data from a table. Lookup can be by ID or via querying any field in the record.
|
||||
func ReadRecords() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.Read(&db.ReadRequest{
|
||||
Query: "age == 43",
|
||||
Table: "example",
|
||||
|
||||
})
|
||||
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 the records in a table
|
||||
|
||||
|
||||
[https://m3o.com/db/api#Truncate](https://m3o.com/db/api#Truncate)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/db"
|
||||
)
|
||||
|
||||
// Truncate the records in a table
|
||||
func TruncateTable() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.Truncate(&db.TruncateRequest{
|
||||
Table: "example",
|
||||
|
||||
})
|
||||
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)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -12,10 +12,10 @@ func main() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.Create(&db.CreateRequest{
|
||||
Record: map[string]interface{}{
|
||||
"id": "1",
|
||||
"name": "Jane",
|
||||
"age": 42,
|
||||
"isActive": true,
|
||||
"id": "1",
|
||||
"name": "Jane",
|
||||
},
|
||||
Table: "example",
|
||||
})
|
||||
|
||||
@@ -4,36 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/emoji/api](htt
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Print
|
||||
|
||||
Print text and renders the emojis with aliases e.g
|
||||
let's grab a :beer: becomes let's grab a 🍺
|
||||
|
||||
|
||||
[https://m3o.com/emoji/api#Print](https://m3o.com/emoji/api#Print)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/emoji"
|
||||
)
|
||||
|
||||
// Print text and renders the emojis with aliases e.g
|
||||
// let's grab a :beer: becomes let's grab a 🍺
|
||||
func PrintTextIncludingEmoji() {
|
||||
emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := emojiService.Print(&emoji.PrintRequest{
|
||||
Text: "let's grab a :beer:",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Find
|
||||
|
||||
Find an emoji by its alias e.g :beer:
|
||||
@@ -89,3 +59,33 @@ func GetFlagByCountryCode() {
|
||||
|
||||
}
|
||||
```
|
||||
## Print
|
||||
|
||||
Print text and renders the emojis with aliases e.g
|
||||
let's grab a :beer: becomes let's grab a 🍺
|
||||
|
||||
|
||||
[https://m3o.com/emoji/api#Print](https://m3o.com/emoji/api#Print)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/emoji"
|
||||
)
|
||||
|
||||
// Print text and renders the emojis with aliases e.g
|
||||
// let's grab a :beer: becomes let's grab a 🍺
|
||||
func PrintTextIncludingEmoji() {
|
||||
emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := emojiService.Print(&emoji.PrintRequest{
|
||||
Text: "let's grab a :beer:",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,33 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/evchargers/api
|
||||
|
||||
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 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,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/file/api](http
|
||||
|
||||
Endpoints:
|
||||
|
||||
## List
|
||||
|
||||
List files by their project and optionally a path.
|
||||
|
||||
|
||||
[https://m3o.com/file/api#List](https://m3o.com/file/api#List)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/file"
|
||||
)
|
||||
|
||||
// List files by their project and optionally a path.
|
||||
func ListFiles() {
|
||||
fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := fileService.List(&file.ListRequest{
|
||||
Project: "examples",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Read
|
||||
|
||||
Read a file by path
|
||||
@@ -94,31 +122,3 @@ func SaveFile() {
|
||||
|
||||
}
|
||||
```
|
||||
## List
|
||||
|
||||
List files by their project and optionally a path.
|
||||
|
||||
|
||||
[https://m3o.com/file/api#List](https://m3o.com/file/api#List)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/file"
|
||||
)
|
||||
|
||||
// List files by their project and optionally a path.
|
||||
func ListFiles() {
|
||||
fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := fileService.List(&file.ListRequest{
|
||||
Project: "examples",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/forex/api](htt
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Price
|
||||
|
||||
Get the latest price for a given forex ticker
|
||||
|
||||
|
||||
[https://m3o.com/forex/api#Price](https://m3o.com/forex/api#Price)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/forex"
|
||||
)
|
||||
|
||||
// Get the latest price for a given forex ticker
|
||||
func GetAnFxPrice() {
|
||||
forexService := forex.NewForexService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := forexService.Price(&forex.PriceRequest{
|
||||
Symbol: "GBPUSD",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Quote
|
||||
|
||||
Get the latest quote for the forex
|
||||
@@ -88,3 +60,31 @@ func GetPreviousClose() {
|
||||
|
||||
}
|
||||
```
|
||||
## Price
|
||||
|
||||
Get the latest price for a given forex ticker
|
||||
|
||||
|
||||
[https://m3o.com/forex/api#Price](https://m3o.com/forex/api#Price)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/forex"
|
||||
)
|
||||
|
||||
// Get the latest price for a given forex ticker
|
||||
func GetAnFxPrice() {
|
||||
forexService := forex.NewForexService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := forexService.Price(&forex.PriceRequest{
|
||||
Symbol: "GBPUSD",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,12 +4,12 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/function/api](
|
||||
|
||||
Endpoints:
|
||||
|
||||
## List
|
||||
## Call
|
||||
|
||||
List all the deployed functions
|
||||
Call a function by name
|
||||
|
||||
|
||||
[https://m3o.com/function/api#List](https://m3o.com/function/api#List)
|
||||
[https://m3o.com/function/api#Call](https://m3o.com/function/api#Call)
|
||||
|
||||
```go
|
||||
package example
|
||||
@@ -21,11 +21,15 @@ import(
|
||||
"go.m3o.com/function"
|
||||
)
|
||||
|
||||
// List all the deployed functions
|
||||
func ListFunctions() {
|
||||
// Call a function by name
|
||||
func CallAfunction() {
|
||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := functionService.List(&function.ListRequest{
|
||||
|
||||
rsp, err := functionService.Call(&function.CallRequest{
|
||||
Name: "helloworld",
|
||||
Request: map[string]interface{}{
|
||||
"name": "Alice",
|
||||
},
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
@@ -57,6 +61,34 @@ func DeleteAfunction() {
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## 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
|
||||
@@ -84,6 +116,34 @@ func ListRegions() {
|
||||
})
|
||||
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
|
||||
@@ -176,12 +236,12 @@ func UpdateAfunction() {
|
||||
|
||||
}
|
||||
```
|
||||
## Call
|
||||
## List
|
||||
|
||||
Call a function by name
|
||||
List all the deployed functions
|
||||
|
||||
|
||||
[https://m3o.com/function/api#Call](https://m3o.com/function/api#Call)
|
||||
[https://m3o.com/function/api#List](https://m3o.com/function/api#List)
|
||||
|
||||
```go
|
||||
package example
|
||||
@@ -193,71 +253,11 @@ import(
|
||||
"go.m3o.com/function"
|
||||
)
|
||||
|
||||
// Call a function by name
|
||||
func CallAfunction() {
|
||||
// List all the deployed functions
|
||||
func ListFunctions() {
|
||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := functionService.Call(&function.CallRequest{
|
||||
Name: "helloworld",
|
||||
Request: map[string]interface{}{
|
||||
"name": "Alice",
|
||||
},
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## 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)
|
||||
|
||||
}
|
||||
```
|
||||
## 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",
|
||||
|
||||
rsp, err := functionService.List(&function.ListRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
|
||||
@@ -4,6 +4,33 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/id/api](https:
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Types
|
||||
|
||||
List the types of IDs available. No query params needed.
|
||||
|
||||
|
||||
[https://m3o.com/id/api#Types](https://m3o.com/id/api#Types)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/id"
|
||||
)
|
||||
|
||||
// List the types of IDs available. No query params needed.
|
||||
func ListTheTypesOfIdsAvailable() {
|
||||
idService := id.NewIdService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := idService.Types(&id.TypesRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Generate
|
||||
|
||||
Generate a unique ID. Defaults to uuid.
|
||||
@@ -116,30 +143,3 @@ func GenerateAbigflakeId() {
|
||||
|
||||
}
|
||||
```
|
||||
## Types
|
||||
|
||||
List the types of IDs available. No query params needed.
|
||||
|
||||
|
||||
[https://m3o.com/id/api#Types](https://m3o.com/id/api#Types)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/id"
|
||||
)
|
||||
|
||||
// List the types of IDs available. No query params needed.
|
||||
func ListTheTypesOfIdsAvailable() {
|
||||
idService := id.NewIdService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := idService.Types(&id.TypesRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -12,9 +12,9 @@ func main() {
|
||||
mqService := mq.NewMqService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := mqService.Publish(&mq.PublishRequest{
|
||||
Message: map[string]interface{}{
|
||||
"id": "1",
|
||||
"type": "signup",
|
||||
"user": "john",
|
||||
"id": "1",
|
||||
},
|
||||
Topic: "events",
|
||||
})
|
||||
|
||||
@@ -89,3 +89,58 @@ func ListCollections() {
|
||||
|
||||
}
|
||||
```
|
||||
## Asset
|
||||
|
||||
|
||||
|
||||
|
||||
[https://m3o.com/nft/api#Asset](https://m3o.com/nft/api#Asset)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/nft"
|
||||
)
|
||||
|
||||
//
|
||||
func GetAsingleAsset() {
|
||||
nftService := nft.NewNftService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := nftService.Asset(&nft.AssetRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Collection
|
||||
|
||||
|
||||
|
||||
|
||||
[https://m3o.com/nft/api#Collection](https://m3o.com/nft/api#Collection)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/nft"
|
||||
)
|
||||
|
||||
//
|
||||
func GetAsingleCollection() {
|
||||
nftService := nft.NewNftService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := nftService.Collection(&nft.CollectionRequest{
|
||||
Slug: "doodles-official",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
15
examples/nft/asset/getASingleAsset/main.go
Executable file
15
examples/nft/asset/getASingleAsset/main.go
Executable file
@@ -0,0 +1,15 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/nft"
|
||||
)
|
||||
|
||||
//
|
||||
func main() {
|
||||
nftService := nft.NewNftService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := nftService.Asset(&nft.AssetRequest{})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
17
examples/nft/collection/getASingleCollection/main.go
Executable file
17
examples/nft/collection/getASingleCollection/main.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/nft"
|
||||
)
|
||||
|
||||
//
|
||||
func main() {
|
||||
nftService := nft.NewNftService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := nftService.Collection(&nft.CollectionRequest{
|
||||
Slug: "doodles-official",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
@@ -4,6 +4,47 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/notes/api](htt
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Events
|
||||
|
||||
Subscribe to notes events
|
||||
|
||||
|
||||
[https://m3o.com/notes/api#Events](https://m3o.com/notes/api#Events)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/notes"
|
||||
)
|
||||
|
||||
// Subscribe to notes events
|
||||
func SubscribeToEvents() {
|
||||
notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN"))
|
||||
|
||||
stream, err := notesService.Events(¬es.EventsRequest{
|
||||
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
|
||||
|
||||
})
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
for {
|
||||
rsp, err := stream.Recv()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println(rsp)
|
||||
}
|
||||
}
|
||||
```
|
||||
## Create
|
||||
|
||||
Create a new note
|
||||
@@ -148,44 +189,3 @@ func DeleteAnote() {
|
||||
|
||||
}
|
||||
```
|
||||
## Events
|
||||
|
||||
Subscribe to notes events
|
||||
|
||||
|
||||
[https://m3o.com/notes/api#Events](https://m3o.com/notes/api#Events)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/notes"
|
||||
)
|
||||
|
||||
// Subscribe to notes events
|
||||
func SubscribeToEvents() {
|
||||
notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN"))
|
||||
|
||||
stream, err := notesService.Events(¬es.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)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/postcode/api](
|
||||
|
||||
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 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,67 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/search/api](ht
|
||||
|
||||
Endpoints:
|
||||
|
||||
## DeleteIndex
|
||||
|
||||
Delete an index by name
|
||||
|
||||
|
||||
[https://m3o.com/search/api#DeleteIndex](https://m3o.com/search/api#DeleteIndex)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/search"
|
||||
)
|
||||
|
||||
// Delete an index by name
|
||||
func DeleteAnIndex() {
|
||||
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := searchService.DeleteIndex(&search.DeleteIndexRequest{
|
||||
Index: "customers",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Index
|
||||
|
||||
Index a record i.e. insert a document to search for.
|
||||
|
||||
|
||||
[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
|
||||
@@ -148,64 +209,3 @@ func CreateAnIndex() {
|
||||
|
||||
}
|
||||
```
|
||||
## DeleteIndex
|
||||
|
||||
Delete an index by name
|
||||
|
||||
|
||||
[https://m3o.com/search/api#DeleteIndex](https://m3o.com/search/api#DeleteIndex)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/search"
|
||||
)
|
||||
|
||||
// Delete an index by name
|
||||
func DeleteAnIndex() {
|
||||
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := searchService.DeleteIndex(&search.DeleteIndexRequest{
|
||||
Index: "customers",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## 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)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,120 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/space/api](htt
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Read
|
||||
|
||||
Read an object in space
|
||||
|
||||
|
||||
[https://m3o.com/space/api#Read](https://m3o.com/space/api#Read)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/space"
|
||||
)
|
||||
|
||||
// Read an object in space
|
||||
func ReadAnObject() {
|
||||
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := spaceService.Read(&space.ReadRequest{
|
||||
Name: "images/file.jpg",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Download
|
||||
|
||||
Download an object via a presigned url
|
||||
|
||||
|
||||
[https://m3o.com/space/api#Download](https://m3o.com/space/api#Download)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/space"
|
||||
)
|
||||
|
||||
// Download an object via a presigned url
|
||||
func DownloadAnObject() {
|
||||
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := spaceService.Download(&space.DownloadRequest{
|
||||
Name: "images/file.jpg",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Upload
|
||||
|
||||
Upload a large object (> 10MB). Returns a time limited presigned URL to be used for uploading the object
|
||||
|
||||
|
||||
[https://m3o.com/space/api#Upload](https://m3o.com/space/api#Upload)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/space"
|
||||
)
|
||||
|
||||
// Upload a large object (> 10MB). Returns a time limited presigned URL to be used for uploading the object
|
||||
func UploadAnObject() {
|
||||
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := spaceService.Upload(&space.UploadRequest{
|
||||
Name: "images/file.jpg",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Create
|
||||
|
||||
Create an object. Returns error if object with this name already exists. Max object size of 10MB, see Upload endpoint for larger objects. If you want to update an existing object use the `Update` endpoint
|
||||
|
||||
|
||||
[https://m3o.com/space/api#Create](https://m3o.com/space/api#Create)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/space"
|
||||
)
|
||||
|
||||
// Create an object. Returns error if object with this name already exists. Max object size of 10MB, see Upload endpoint for larger objects. If you want to update an existing object use the `Update` endpoint
|
||||
func CreateAnObject() {
|
||||
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := spaceService.Create(&space.CreateRequest{
|
||||
Name: "images/file.jpg",
|
||||
Object: "<file bytes>",
|
||||
Visibility: "public",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Update
|
||||
|
||||
Update an object. If an object with this name does not exist, creates a new one.
|
||||
@@ -232,3 +118,117 @@ func HeadAnObject() {
|
||||
|
||||
}
|
||||
```
|
||||
## Read
|
||||
|
||||
Read an object in space
|
||||
|
||||
|
||||
[https://m3o.com/space/api#Read](https://m3o.com/space/api#Read)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/space"
|
||||
)
|
||||
|
||||
// Read an object in space
|
||||
func ReadAnObject() {
|
||||
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := spaceService.Read(&space.ReadRequest{
|
||||
Name: "images/file.jpg",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Download
|
||||
|
||||
Download an object via a presigned url
|
||||
|
||||
|
||||
[https://m3o.com/space/api#Download](https://m3o.com/space/api#Download)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/space"
|
||||
)
|
||||
|
||||
// Download an object via a presigned url
|
||||
func DownloadAnObject() {
|
||||
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := spaceService.Download(&space.DownloadRequest{
|
||||
Name: "images/file.jpg",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Upload
|
||||
|
||||
Upload a large object (> 10MB). Returns a time limited presigned URL to be used for uploading the object
|
||||
|
||||
|
||||
[https://m3o.com/space/api#Upload](https://m3o.com/space/api#Upload)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/space"
|
||||
)
|
||||
|
||||
// Upload a large object (> 10MB). Returns a time limited presigned URL to be used for uploading the object
|
||||
func UploadAnObject() {
|
||||
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := spaceService.Upload(&space.UploadRequest{
|
||||
Name: "images/file.jpg",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Create
|
||||
|
||||
Create an object. Returns error if object with this name already exists. Max object size of 10MB, see Upload endpoint for larger objects. If you want to update an existing object use the `Update` endpoint
|
||||
|
||||
|
||||
[https://m3o.com/space/api#Create](https://m3o.com/space/api#Create)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/space"
|
||||
)
|
||||
|
||||
// Create an object. Returns error if object with this name already exists. Max object size of 10MB, see Upload endpoint for larger objects. If you want to update an existing object use the `Update` endpoint
|
||||
func CreateAnObject() {
|
||||
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := spaceService.Create(&space.CreateRequest{
|
||||
Name: "images/file.jpg",
|
||||
Object: "<file bytes>",
|
||||
Visibility: "public",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,33 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/stream/api](ht
|
||||
|
||||
Endpoints:
|
||||
|
||||
## ListChannels
|
||||
|
||||
List all the active channels
|
||||
|
||||
|
||||
[https://m3o.com/stream/api#ListChannels](https://m3o.com/stream/api#ListChannels)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/stream"
|
||||
)
|
||||
|
||||
// List all the active channels
|
||||
func ListChannels() {
|
||||
streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := streamService.ListChannels(&stream.ListChannelsRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## CreateChannel
|
||||
|
||||
Create a channel with a given name and description. Channels are created automatically but
|
||||
@@ -119,3 +92,30 @@ func ListMessages() {
|
||||
|
||||
}
|
||||
```
|
||||
## ListChannels
|
||||
|
||||
List all the active channels
|
||||
|
||||
|
||||
[https://m3o.com/stream/api#ListChannels](https://m3o.com/stream/api#ListChannels)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/stream"
|
||||
)
|
||||
|
||||
// List all the active channels
|
||||
func ListChannels() {
|
||||
streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := streamService.ListChannels(&stream.ListChannelsRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,12 +4,12 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/user/api](http
|
||||
|
||||
Endpoints:
|
||||
|
||||
## UpdatePassword
|
||||
## Create
|
||||
|
||||
Update the account password
|
||||
Create a new user account. The email address and username for the account must be unique.
|
||||
|
||||
|
||||
[https://m3o.com/user/api#UpdatePassword](https://m3o.com/user/api#UpdatePassword)
|
||||
[https://m3o.com/user/api#Create](https://m3o.com/user/api#Create)
|
||||
|
||||
```go
|
||||
package example
|
||||
@@ -21,14 +21,101 @@ import(
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Update the account password
|
||||
func UpdateTheAccountPassword() {
|
||||
// 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.UpdatePassword(&user.UpdatePasswordRequest{
|
||||
ConfirmPassword: "Password2",
|
||||
NewPassword: "Password2",
|
||||
OldPassword: "Password1",
|
||||
UserId: "user-1",
|
||||
rsp, err := userService.Create(&user.CreateRequest{
|
||||
Email: "joe@example.com",
|
||||
Id: "user-1",
|
||||
Password: "Password1",
|
||||
Username: "joe",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## VerifyEmail
|
||||
|
||||
Verify the email address of an account from a token sent in an email to the user.
|
||||
|
||||
|
||||
[https://m3o.com/user/api#VerifyEmail](https://m3o.com/user/api#VerifyEmail)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Verify the email address of an account from a token sent in an email to the user.
|
||||
func VerifyEmail() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.VerifyEmail(&user.VerifyEmailRequest{
|
||||
Token: "012345",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## 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)
|
||||
|
||||
}
|
||||
```
|
||||
## 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)
|
||||
@@ -82,12 +169,12 @@ Please verify your email by clicking this link: $micro_verification_link`,
|
||||
|
||||
}
|
||||
```
|
||||
## VerifyEmail
|
||||
## Delete
|
||||
|
||||
Verify the email address of an account from a token sent in an email to the user.
|
||||
Delete an account by id
|
||||
|
||||
|
||||
[https://m3o.com/user/api#VerifyEmail](https://m3o.com/user/api#VerifyEmail)
|
||||
[https://m3o.com/user/api#Delete](https://m3o.com/user/api#Delete)
|
||||
|
||||
```go
|
||||
package example
|
||||
@@ -99,11 +186,105 @@ import(
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Verify the email address of an account from a token sent in an email to the user.
|
||||
func VerifyEmail() {
|
||||
// Delete an account by id
|
||||
func DeleteUserAccount() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.VerifyEmail(&user.VerifyEmailRequest{
|
||||
Token: "012345",
|
||||
rsp, err := userService.Delete(&user.DeleteRequest{
|
||||
Id: "8b98acbe-0b6a-4d66-a414-5ffbf666786f",
|
||||
|
||||
})
|
||||
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)
|
||||
|
||||
}
|
||||
```
|
||||
## 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)
|
||||
|
||||
}
|
||||
```
|
||||
## 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)
|
||||
@@ -136,34 +317,6 @@ func LogAuserOut() {
|
||||
})
|
||||
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)
|
||||
|
||||
}
|
||||
```
|
||||
## SendMagicLink
|
||||
@@ -201,12 +354,12 @@ Click here to access your account $micro_verification_link`,
|
||||
|
||||
}
|
||||
```
|
||||
## Create
|
||||
## Update
|
||||
|
||||
Create a new user account. The email address and username for the account must be unique.
|
||||
Update the account username or email
|
||||
|
||||
|
||||
[https://m3o.com/user/api#Create](https://m3o.com/user/api#Create)
|
||||
[https://m3o.com/user/api#Update](https://m3o.com/user/api#Update)
|
||||
|
||||
```go
|
||||
package example
|
||||
@@ -218,13 +371,12 @@ import(
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Create a new user account. The email address and username for the account must be unique.
|
||||
func CreateAnAccount() {
|
||||
// Update the account username or email
|
||||
func UpdateAnAccount() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.Create(&user.CreateRequest{
|
||||
Email: "joe@example.com",
|
||||
rsp, err := userService.Update(&user.UpdateRequest{
|
||||
Email: "joe+2@example.com",
|
||||
Id: "user-1",
|
||||
Password: "Password1",
|
||||
Username: "joe",
|
||||
|
||||
})
|
||||
@@ -232,13 +384,12 @@ Username: "joe",
|
||||
|
||||
}
|
||||
```
|
||||
## SendPasswordResetEmail
|
||||
## UpdatePassword
|
||||
|
||||
Send an email with a verification code to reset password.
|
||||
Call "ResetPassword" endpoint once user provides the code.
|
||||
Update the account password
|
||||
|
||||
|
||||
[https://m3o.com/user/api#SendPasswordResetEmail](https://m3o.com/user/api#SendPasswordResetEmail)
|
||||
[https://m3o.com/user/api#UpdatePassword](https://m3o.com/user/api#UpdatePassword)
|
||||
|
||||
```go
|
||||
package example
|
||||
@@ -250,44 +401,14 @@ import(
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Send an email with a verification code to reset password.
|
||||
// Call "ResetPassword" endpoint once user provides the code.
|
||||
func SendPasswordResetEmail() {
|
||||
// Update the account password
|
||||
func UpdateTheAccountPassword() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.SendPasswordResetEmail(&user.SendPasswordResetEmailRequest{
|
||||
Email: "joe@example.com",
|
||||
FromName: "Awesome Dot Com",
|
||||
Subject: "Password reset",
|
||||
TextContent: `Hi there,
|
||||
click here to reset your password: myapp.com/reset/code?=$code`,
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## 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.UpdatePassword(&user.UpdatePasswordRequest{
|
||||
ConfirmPassword: "Password2",
|
||||
NewPassword: "Password2",
|
||||
OldPassword: "Password1",
|
||||
UserId: "user-1",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
@@ -378,12 +499,13 @@ func ReadAccountByEmail() {
|
||||
|
||||
}
|
||||
```
|
||||
## ResetPassword
|
||||
## SendPasswordResetEmail
|
||||
|
||||
Reset password with the code sent by the "SendPasswordResetEmail" endpoint.
|
||||
Send an email with a verification code to reset password.
|
||||
Call "ResetPassword" endpoint once user provides the code.
|
||||
|
||||
|
||||
[https://m3o.com/user/api#ResetPassword](https://m3o.com/user/api#ResetPassword)
|
||||
[https://m3o.com/user/api#SendPasswordResetEmail](https://m3o.com/user/api#SendPasswordResetEmail)
|
||||
|
||||
```go
|
||||
package example
|
||||
@@ -395,138 +517,16 @@ import(
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Reset password with the code sent by the "SendPasswordResetEmail" endpoint.
|
||||
func ResetPassword() {
|
||||
// Send an email with a verification code to reset password.
|
||||
// Call "ResetPassword" endpoint once user provides the code.
|
||||
func SendPasswordResetEmail() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.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)
|
||||
|
||||
}
|
||||
```
|
||||
## 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)
|
||||
|
||||
}
|
||||
```
|
||||
## 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)
|
||||
|
||||
}
|
||||
```
|
||||
## 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{
|
||||
rsp, err := userService.SendPasswordResetEmail(&user.SendPasswordResetEmailRequest{
|
||||
Email: "joe@example.com",
|
||||
Password: "Password1",
|
||||
FromName: "Awesome Dot Com",
|
||||
Subject: "Password reset",
|
||||
TextContent: `Hi there,
|
||||
click here to reset your password: myapp.com/reset/code?=$code`,
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
@@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/weather/api](h
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Now
|
||||
|
||||
Get the current weather report for a location by postcode, city, zip code, ip address
|
||||
|
||||
|
||||
[https://m3o.com/weather/api#Now](https://m3o.com/weather/api#Now)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/weather"
|
||||
)
|
||||
|
||||
// Get the current weather report for a location by postcode, city, zip code, ip address
|
||||
func GetCurrentWeather() {
|
||||
weatherService := weather.NewWeatherService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := weatherService.Now(&weather.NowRequest{
|
||||
Location: "london",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Forecast
|
||||
|
||||
Get the weather forecast for the next 1-10 days
|
||||
@@ -33,31 +61,3 @@ Location: "London",
|
||||
|
||||
}
|
||||
```
|
||||
## Now
|
||||
|
||||
Get the current weather report for a location by postcode, city, zip code, ip address
|
||||
|
||||
|
||||
[https://m3o.com/weather/api#Now](https://m3o.com/weather/api#Now)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/weather"
|
||||
)
|
||||
|
||||
// Get the current weather report for a location by postcode, city, zip code, ip address
|
||||
func GetCurrentWeather() {
|
||||
weatherService := weather.NewWeatherService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := weatherService.Now(&weather.NowRequest{
|
||||
Location: "london",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
71
nft/nft.go
71
nft/nft.go
@@ -5,7 +5,9 @@ import (
|
||||
)
|
||||
|
||||
type Nft interface {
|
||||
Asset(*AssetRequest) (*AssetResponse, error)
|
||||
Assets(*AssetsRequest) (*AssetsResponse, error)
|
||||
Collection(*CollectionRequest) (*CollectionResponse, error)
|
||||
Collections(*CollectionsRequest) (*CollectionsResponse, error)
|
||||
Create(*CreateRequest) (*CreateResponse, error)
|
||||
}
|
||||
@@ -22,6 +24,14 @@ type NftService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
//
|
||||
func (t *NftService) Asset(request *AssetRequest) (*AssetResponse, error) {
|
||||
|
||||
rsp := &AssetResponse{}
|
||||
return rsp, t.client.Call("nft", "Asset", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Return a list of assets
|
||||
func (t *NftService) Assets(request *AssetsRequest) (*AssetsResponse, error) {
|
||||
|
||||
@@ -30,6 +40,14 @@ func (t *NftService) Assets(request *AssetsRequest) (*AssetsResponse, error) {
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
func (t *NftService) Collection(request *CollectionRequest) (*CollectionResponse, error) {
|
||||
|
||||
rsp := &CollectionResponse{}
|
||||
return rsp, t.client.Call("nft", "Collection", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Get a list of collections
|
||||
func (t *NftService) Collections(request *CollectionsRequest) (*CollectionsResponse, error) {
|
||||
|
||||
@@ -75,6 +93,17 @@ type Asset struct {
|
||||
Sales int32 `json:"sales"`
|
||||
// the token id
|
||||
TokenId string `json:"token_id"`
|
||||
// traits associated with the item
|
||||
Traits []map[string]interface{} `json:"traits"`
|
||||
}
|
||||
|
||||
type AssetRequest struct {
|
||||
ContractAddress string `json:"contract_address"`
|
||||
TokenId string `json:"token_id"`
|
||||
}
|
||||
|
||||
type AssetResponse struct {
|
||||
Asset *Asset `json:"asset"`
|
||||
}
|
||||
|
||||
type AssetsRequest struct {
|
||||
@@ -96,12 +125,44 @@ type AssetsResponse struct {
|
||||
}
|
||||
|
||||
type Collection struct {
|
||||
CreatedAt string `json:"created_at"`
|
||||
Description string `json:"description"`
|
||||
ImageUrl string `json:"image_url"`
|
||||
Name string `json:"name"`
|
||||
// image used in the banner for the collection
|
||||
BannerImageUrl string `json:"banner_image_url"`
|
||||
// creation time
|
||||
CreatedAt string `json:"created_at"`
|
||||
// description of the collection
|
||||
Description string `json:"description"`
|
||||
// approved editors for this collection
|
||||
Editors []string `json:"editors"`
|
||||
// external link to the original website for the collection
|
||||
ExternalLink string `json:"external_link"`
|
||||
// an image for the collection
|
||||
ImageUrl string `json:"image_url"`
|
||||
// name of the collection
|
||||
Name string `json:"name"`
|
||||
// the payment tokens accepted for this collection
|
||||
PaymentTokens *Token `json:"payment_tokens"`
|
||||
// payout address for the collection's royalties
|
||||
PayoutAddress string `json:"payout_address"`
|
||||
Slug string `json:"slug"`
|
||||
// a list of the contracts associated with this collection
|
||||
PrimaryAssetContracts *Contract `json:"primary_asset_contracts"`
|
||||
// the collection's approval status on OpenSea
|
||||
SafelistRequestStatus string `json:"safelist_request_status"`
|
||||
// the fees that get paid out when a sale is made
|
||||
SellerFees string `json:"seller_fees"`
|
||||
// collection slug
|
||||
Slug string `json:"slug"`
|
||||
// sales statistics associated with the collection
|
||||
Stats map[string]interface{} `json:"stats"`
|
||||
// listing of all the trait types available within this collection
|
||||
Traits map[string]interface{} `json:"traits"`
|
||||
}
|
||||
|
||||
type CollectionRequest struct {
|
||||
Slug string `json:"slug"`
|
||||
}
|
||||
|
||||
type CollectionResponse struct {
|
||||
Collection *Collection `json:"collection"`
|
||||
}
|
||||
|
||||
type CollectionsRequest struct {
|
||||
|
||||
Reference in New Issue
Block a user