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,90 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/app/api](https
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
## Status
|
|
||||||
|
|
||||||
Get the status of an app
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/app/api#Status](https://m3o.com/app/api#Status)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/app"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Get the status of an app
|
|
||||||
func GetTheStatusOfAnApp() {
|
|
||||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := appService.Status(&app.StatusRequest{
|
|
||||||
Name: "helloworld",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## 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 the app. The latest source code will be downloaded, built and deployed.
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/app/api#Update](https://m3o.com/app/api#Update)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/app"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Update the app. The latest source code will be downloaded, built and deployed.
|
|
||||||
func UpdateAnApp() {
|
|
||||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := appService.Update(&app.UpdateRequest{
|
|
||||||
Name: "helloworld",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Delete
|
## Delete
|
||||||
|
|
||||||
Delete an app
|
Delete an app
|
||||||
@@ -230,3 +146,87 @@ func ListRegions() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
## Status
|
||||||
|
|
||||||
|
Get the status of an app
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/app/api#Status](https://m3o.com/app/api#Status)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/app"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Get the status of an app
|
||||||
|
func GetTheStatusOfAnApp() {
|
||||||
|
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := appService.Status(&app.StatusRequest{
|
||||||
|
Name: "helloworld",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## 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 the app. The latest source code will be downloaded, built and deployed.
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/app/api#Update](https://m3o.com/app/api#Update)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/app"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Update the app. The latest source code will be downloaded, built and deployed.
|
||||||
|
func UpdateAnApp() {
|
||||||
|
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := appService.Update(&app.UpdateRequest{
|
||||||
|
Name: "helloworld",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
112
examples/cache/README.md
vendored
112
examples/cache/README.md
vendored
@@ -4,6 +4,62 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/cache/api](htt
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
|
## Decrement
|
||||||
|
|
||||||
|
Decrement a value (if it's a number). If key not found it is equivalent to set.
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/cache/api#Decrement](https://m3o.com/cache/api#Decrement)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/cache"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Decrement a value (if it's a number). If key not found it is equivalent to set.
|
||||||
|
func DecrementAvalue() {
|
||||||
|
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := cacheService.Decrement(&cache.DecrementRequest{
|
||||||
|
Key: "counter",
|
||||||
|
Value: 2,
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## ListKeys
|
||||||
|
|
||||||
|
List all the available keys
|
||||||
|
|
||||||
|
|
||||||
|
[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
|
||||||
|
|
||||||
Set an item in the cache. Overwrites any existing value already set.
|
Set an item in the cache. Overwrites any existing value already set.
|
||||||
@@ -118,59 +174,3 @@ Value: 2,
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Decrement
|
|
||||||
|
|
||||||
Decrement a value (if it's a number). If key not found it is equivalent to set.
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/cache/api#Decrement](https://m3o.com/cache/api#Decrement)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/cache"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Decrement a value (if it's a number). If key not found it is equivalent to set.
|
|
||||||
func DecrementAvalue() {
|
|
||||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := cacheService.Decrement(&cache.DecrementRequest{
|
|
||||||
Key: "counter",
|
|
||||||
Value: 2,
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## 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,12 +4,12 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/chat/api](http
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
## Invite
|
## Create
|
||||||
|
|
||||||
Invite a user to a chat room
|
Create a new chat room
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/chat/api#Invite](https://m3o.com/chat/api#Invite)
|
[https://m3o.com/chat/api#Create](https://m3o.com/chat/api#Create)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
package example
|
package example
|
||||||
@@ -21,42 +21,12 @@ import(
|
|||||||
"go.m3o.com/chat"
|
"go.m3o.com/chat"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Invite a user to a chat room
|
// Create a new chat room
|
||||||
func InviteAuser() {
|
func CreateAnewChat() {
|
||||||
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := chatService.Invite(&chat.InviteRequest{
|
rsp, err := chatService.Create(&chat.CreateRequest{
|
||||||
|
Description: "The general chat room",
|
||||||
})
|
Name: "general",
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Send
|
|
||||||
|
|
||||||
Connect to a chat to receive a stream of messages
|
|
||||||
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)
|
fmt.Println(rsp, err)
|
||||||
@@ -128,35 +98,6 @@ func KickAuserFromAroom() {
|
|||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Create
|
|
||||||
|
|
||||||
Create a new chat room
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/chat/api#Create](https://m3o.com/chat/api#Create)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/chat"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Create a new chat room
|
|
||||||
func CreateAnewChat() {
|
|
||||||
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := chatService.Create(&chat.CreateRequest{
|
|
||||||
Description: "The general chat room",
|
|
||||||
Name: "general",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## List
|
## List
|
||||||
@@ -211,6 +152,65 @@ func DeleteAchat() {
|
|||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Invite
|
||||||
|
|
||||||
|
Invite a user to a chat room
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/chat/api#Invite](https://m3o.com/chat/api#Invite)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/chat"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Invite a user to a chat room
|
||||||
|
func InviteAuser() {
|
||||||
|
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := chatService.Invite(&chat.InviteRequest{
|
||||||
|
|
||||||
|
})
|
||||||
|
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
|
## History
|
||||||
|
|||||||
@@ -4,6 +4,89 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/comments/api](
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
|
## Create
|
||||||
|
|
||||||
|
Create a new comment
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/comments/api#Create](https://m3o.com/comments/api#Create)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/comments"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Create a new comment
|
||||||
|
func CreateAcomment() {
|
||||||
|
commentsService := comments.NewCommentsService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := commentsService.Create(&comments.CreateRequest{
|
||||||
|
Text: "This is my comment",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Read
|
||||||
|
|
||||||
|
Read a comment
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/comments/api#Read](https://m3o.com/comments/api#Read)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/comments"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Read a comment
|
||||||
|
func ReadAcomment() {
|
||||||
|
commentsService := comments.NewCommentsService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := commentsService.Read(&comments.ReadRequest{
|
||||||
|
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## List
|
||||||
|
|
||||||
|
List all the comments
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/comments/api#List](https://m3o.com/comments/api#List)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/comments"
|
||||||
|
)
|
||||||
|
|
||||||
|
// List all the comments
|
||||||
|
func ListAllComments() {
|
||||||
|
commentsService := comments.NewCommentsService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := commentsService.List(&comments.ListRequest{
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
## Update
|
## Update
|
||||||
|
|
||||||
Update a comment
|
Update a comment
|
||||||
@@ -105,86 +188,3 @@ func SubscribeToEvents() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Create
|
|
||||||
|
|
||||||
Create a new comment
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/comments/api#Create](https://m3o.com/comments/api#Create)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/comments"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Create a new comment
|
|
||||||
func CreateAcomment() {
|
|
||||||
commentsService := comments.NewCommentsService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := commentsService.Create(&comments.CreateRequest{
|
|
||||||
Text: "This is my comment",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Read
|
|
||||||
|
|
||||||
Read a comment
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/comments/api#Read](https://m3o.com/comments/api#Read)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/comments"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Read a comment
|
|
||||||
func ReadAcomment() {
|
|
||||||
commentsService := comments.NewCommentsService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := commentsService.Read(&comments.ReadRequest{
|
|
||||||
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## List
|
|
||||||
|
|
||||||
List all the comments
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/comments/api#List](https://m3o.com/comments/api#List)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/comments"
|
|
||||||
)
|
|
||||||
|
|
||||||
// List all the comments
|
|
||||||
func ListAllComments() {
|
|
||||||
commentsService := comments.NewCommentsService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := commentsService.List(&comments.ListRequest{
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|||||||
@@ -4,6 +4,62 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/contact/api](h
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
|
## List
|
||||||
|
|
||||||
|
List contacts
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/contact/api#List](https://m3o.com/contact/api#List)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/contact"
|
||||||
|
)
|
||||||
|
|
||||||
|
// List contacts
|
||||||
|
func ListContactsWithDefaultOffsetAndLimitDefaultLimitIs20() {
|
||||||
|
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := contactService.List(&contact.ListRequest{
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## List
|
||||||
|
|
||||||
|
List contacts
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/contact/api#List](https://m3o.com/contact/api#List)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/contact"
|
||||||
|
)
|
||||||
|
|
||||||
|
// List contacts
|
||||||
|
func ListContactsWithSpecificOffsetAndLimit() {
|
||||||
|
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := contactService.List(&contact.ListRequest{
|
||||||
|
Limit: 1,
|
||||||
|
Offset: 1,
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
## Create
|
## Create
|
||||||
|
|
||||||
Create a contact
|
Create a contact
|
||||||
@@ -161,59 +217,3 @@ func DeleteAcontact() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## List
|
|
||||||
|
|
||||||
List contacts
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/contact/api#List](https://m3o.com/contact/api#List)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/contact"
|
|
||||||
)
|
|
||||||
|
|
||||||
// List contacts
|
|
||||||
func ListContactsWithDefaultOffsetAndLimitDefaultLimitIs20() {
|
|
||||||
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := contactService.List(&contact.ListRequest{
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## List
|
|
||||||
|
|
||||||
List contacts
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/contact/api#List](https://m3o.com/contact/api#List)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/contact"
|
|
||||||
)
|
|
||||||
|
|
||||||
// List contacts
|
|
||||||
func ListContactsWithSpecificOffsetAndLimit() {
|
|
||||||
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := contactService.List(&contact.ListRequest{
|
|
||||||
Limit: 1,
|
|
||||||
Offset: 1,
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|||||||
@@ -4,61 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/crypto/api](ht
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
## History
|
|
||||||
|
|
||||||
Returns the history for the previous close
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/crypto/api#History](https://m3o.com/crypto/api#History)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/crypto"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Returns the history for the previous close
|
|
||||||
func GetPreviousClose() {
|
|
||||||
cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := cryptoService.History(&crypto.HistoryRequest{
|
|
||||||
Symbol: "BTCUSD",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Symbols
|
|
||||||
|
|
||||||
Returns the full list of supported symbols
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/crypto/api#Symbols](https://m3o.com/crypto/api#Symbols)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/crypto"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Returns the full list of supported symbols
|
|
||||||
func GetListOfAllSupportedSymbols() {
|
|
||||||
cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := cryptoService.Symbols(&crypto.SymbolsRequest{
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## News
|
## News
|
||||||
|
|
||||||
Get news related to a currency
|
Get news related to a currency
|
||||||
@@ -143,3 +88,58 @@ func GetAcryptocurrencyQuote() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
## History
|
||||||
|
|
||||||
|
Returns the history for the previous close
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/crypto/api#History](https://m3o.com/crypto/api#History)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/crypto"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Returns the history for the previous close
|
||||||
|
func GetPreviousClose() {
|
||||||
|
cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := cryptoService.History(&crypto.HistoryRequest{
|
||||||
|
Symbol: "BTCUSD",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Symbols
|
||||||
|
|
||||||
|
Returns the full list of supported symbols
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/crypto/api#Symbols](https://m3o.com/crypto/api#Symbols)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/crypto"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Returns the full list of supported symbols
|
||||||
|
func GetListOfAllSupportedSymbols() {
|
||||||
|
cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := cryptoService.Symbols(&crypto.SymbolsRequest{
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
@@ -4,33 +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
|
||||||
|
|
||||||
Rates returns the currency rates for a given code e.g USD
|
Rates returns the currency rates for a given code e.g USD
|
||||||
@@ -147,3 +120,30 @@ 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)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
@@ -4,12 +4,12 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/db/api](https:
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
## ListTables
|
## Update
|
||||||
|
|
||||||
List tables in the DB
|
Update a record in the database. Include an "id" in the record to update.
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/db/api#ListTables](https://m3o.com/db/api#ListTables)
|
[https://m3o.com/db/api#Update](https://m3o.com/db/api#Update)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
package example
|
package example
|
||||||
@@ -21,11 +21,101 @@ import(
|
|||||||
"go.m3o.com/db"
|
"go.m3o.com/db"
|
||||||
)
|
)
|
||||||
|
|
||||||
// List tables in the DB
|
// Update a record in the database. Include an "id" in the record to update.
|
||||||
func ListTables() {
|
func UpdateArecord() {
|
||||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := dbService.ListTables(&db.ListTablesRequest{
|
rsp, err := dbService.Update(&db.UpdateRequest{
|
||||||
|
Record: map[string]interface{}{
|
||||||
|
"id": "1",
|
||||||
|
"age": 43,
|
||||||
|
},
|
||||||
|
Table: "example",
|
||||||
|
|
||||||
|
})
|
||||||
|
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)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## 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)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
@@ -63,35 +153,6 @@ Table: "example",
|
|||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
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)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Delete
|
## Delete
|
||||||
@@ -121,94 +182,6 @@ Table: "example",
|
|||||||
})
|
})
|
||||||
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)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Update
|
|
||||||
|
|
||||||
Update a record in the database. Include an "id" in the record to update.
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/db/api#Update](https://m3o.com/db/api#Update)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/db"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Update a record in the database. Include an "id" in the record to update.
|
|
||||||
func UpdateArecord() {
|
|
||||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := dbService.Update(&db.UpdateRequest{
|
|
||||||
Record: map[string]interface{}{
|
|
||||||
"id": "1",
|
|
||||||
"age": 43,
|
|
||||||
},
|
|
||||||
Table: "example",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Truncate
|
|
||||||
|
|
||||||
Truncate the records in a table
|
|
||||||
|
|
||||||
|
|
||||||
[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)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Count
|
## Count
|
||||||
@@ -237,6 +210,33 @@ func CountEntriesInAtable() {
|
|||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## ListTables
|
||||||
|
|
||||||
|
List tables in the DB
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/db/api#ListTables](https://m3o.com/db/api#ListTables)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/db"
|
||||||
|
)
|
||||||
|
|
||||||
|
// List tables in the DB
|
||||||
|
func ListTables() {
|
||||||
|
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := dbService.ListTables(&db.ListTablesRequest{
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## RenameTable
|
## RenameTable
|
||||||
|
|||||||
@@ -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{}{
|
||||||
|
"name": "Jane",
|
||||||
"age": 42,
|
"age": 42,
|
||||||
"isActive": true,
|
"isActive": true,
|
||||||
"id": "1",
|
"id": "1",
|
||||||
"name": "Jane",
|
|
||||||
},
|
},
|
||||||
Table: "example",
|
Table: "example",
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -4,6 +4,33 @@ 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
|
||||||
@@ -98,30 +125,3 @@ 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,39 @@ 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.
|
||||||
@@ -73,36 +106,3 @@ func ReadEventsOnAtopic() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Publish
|
|
||||||
|
|
||||||
Publish a event to the event stream.
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/event/api#Publish](https://m3o.com/event/api#Publish)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/event"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Publish a event to the event stream.
|
|
||||||
func PublishAnEvent() {
|
|
||||||
eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := eventService.Publish(&event.PublishRequest{
|
|
||||||
Message: map[string]interface{}{
|
|
||||||
"type": "signup",
|
|
||||||
"user": "john",
|
|
||||||
"id": "1",
|
|
||||||
},
|
|
||||||
Topic: "user",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|||||||
@@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/function/api](
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
|
## 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)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
## Update
|
## Update
|
||||||
|
|
||||||
Update a function. Downloads the source, builds and redeploys
|
Update a function. Downloads the source, builds and redeploys
|
||||||
@@ -30,37 +58,6 @@ func UpdateAfunction() {
|
|||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Call
|
|
||||||
|
|
||||||
Call a function by name
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/function/api#Call](https://m3o.com/function/api#Call)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/function"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Call a function by name
|
|
||||||
func CallAfunction() {
|
|
||||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := functionService.Call(&function.CallRequest{
|
|
||||||
Name: "helloworld",
|
|
||||||
Request: map[string]interface{}{
|
|
||||||
"name": "Alice",
|
|
||||||
},
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## List
|
## List
|
||||||
@@ -115,6 +112,61 @@ func ListRegions() {
|
|||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
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)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Runtimes
|
||||||
|
|
||||||
|
Return a list of supported runtimes
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/function/api#Runtimes](https://m3o.com/function/api#Runtimes)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/function"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Return a list of supported runtimes
|
||||||
|
func ListRuntimes() {
|
||||||
|
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := functionService.Runtimes(&function.RuntimesRequest{
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Proxy
|
## Proxy
|
||||||
@@ -177,6 +229,37 @@ Subfolder: "examples/go-function",
|
|||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Call
|
||||||
|
|
||||||
|
Call a function by name
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/function/api#Call](https://m3o.com/function/api#Call)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/function"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Call a function by name
|
||||||
|
func CallAfunction() {
|
||||||
|
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := functionService.Call(&function.CallRequest{
|
||||||
|
Name: "helloworld",
|
||||||
|
Request: map[string]interface{}{
|
||||||
|
"name": "Alice",
|
||||||
|
},
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Delete
|
## Delete
|
||||||
@@ -207,86 +290,3 @@ 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)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## 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)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Runtimes
|
|
||||||
|
|
||||||
Return a list of supported runtimes
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/function/api#Runtimes](https://m3o.com/function/api#Runtimes)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/function"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Return a list of supported runtimes
|
|
||||||
func ListRuntimes() {
|
|
||||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := functionService.Runtimes(&function.RuntimesRequest{
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|||||||
@@ -4,47 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/lists/api](htt
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
## Events
|
|
||||||
|
|
||||||
Subscribe to lists events
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/lists/api#Events](https://m3o.com/lists/api#Events)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/lists"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Subscribe to lists events
|
|
||||||
func SubscribeToEvents() {
|
|
||||||
listsService := lists.NewListsService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
|
|
||||||
stream, err := listsService.Events(&lists.EventsRequest{
|
|
||||||
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
|
|
||||||
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
for {
|
|
||||||
rsp, err := stream.Recv()
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Println(rsp)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Create
|
## Create
|
||||||
|
|
||||||
Create a new list
|
Create a new list
|
||||||
@@ -185,3 +144,44 @@ func DeleteAlist() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
## Events
|
||||||
|
|
||||||
|
Subscribe to lists events
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/lists/api#Events](https://m3o.com/lists/api#Events)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/lists"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Subscribe to lists events
|
||||||
|
func SubscribeToEvents() {
|
||||||
|
listsService := lists.NewListsService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
|
||||||
|
stream, err := listsService.Events(&lists.EventsRequest{
|
||||||
|
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
|
||||||
|
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for {
|
||||||
|
rsp, err := stream.Recv()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println(rsp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
@@ -4,6 +4,39 @@ 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.
|
||||||
@@ -45,36 +78,3 @@ func SubscribeToAtopic() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Publish
|
|
||||||
|
|
||||||
Publish a message. Specify a topic to group messages for a specific topic.
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/mq/api#Publish](https://m3o.com/mq/api#Publish)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/mq"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Publish a message. Specify a topic to group messages for a specific topic.
|
|
||||||
func PublishAmessage() {
|
|
||||||
mqService := mq.NewMqService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := mqService.Publish(&mq.PublishRequest{
|
|
||||||
Message: map[string]interface{}{
|
|
||||||
"id": "1",
|
|
||||||
"type": "signup",
|
|
||||||
"user": "john",
|
|
||||||
},
|
|
||||||
Topic: "events",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|||||||
@@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/nft/api](https
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
|
## Collection
|
||||||
|
|
||||||
|
Get a collection by its slug
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/nft/api#Collection](https://m3o.com/nft/api#Collection)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/nft"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Get a collection by its slug
|
||||||
|
func GetAsingleCollection() {
|
||||||
|
nftService := nft.NewNftService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := nftService.Collection(&nft.CollectionRequest{
|
||||||
|
Slug: "doodles-official",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
## Assets
|
## Assets
|
||||||
|
|
||||||
Return a list of assets
|
Return a list of assets
|
||||||
@@ -116,31 +144,3 @@ func GetAsingleAsset() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Collection
|
|
||||||
|
|
||||||
Get a collection by its slug
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/nft/api#Collection](https://m3o.com/nft/api#Collection)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/nft"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Get a collection by its slug
|
|
||||||
func GetAsingleCollection() {
|
|
||||||
nftService := nft.NewNftService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := nftService.Collection(&nft.CollectionRequest{
|
|
||||||
Slug: "doodles-official",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|||||||
@@ -4,47 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/notes/api](htt
|
|||||||
|
|
||||||
Endpoints:
|
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
|
||||||
|
|
||||||
Create a new note
|
Create a new note
|
||||||
@@ -189,3 +148,44 @@ 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/ping/api](http
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
## Ip
|
|
||||||
|
|
||||||
Ping an IP address
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/ping/api#Ip](https://m3o.com/ping/api#Ip)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/ping"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Ping an IP address
|
|
||||||
func PingAnIp() {
|
|
||||||
pingService := ping.NewPingService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := pingService.Ip(&ping.IpRequest{
|
|
||||||
Address: "google.com",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Tcp
|
## Tcp
|
||||||
|
|
||||||
Ping a TCP port is open
|
Ping a TCP port is open
|
||||||
@@ -88,3 +60,31 @@ func CheckAurl() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
## Ip
|
||||||
|
|
||||||
|
Ping an IP address
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/ping/api#Ip](https://m3o.com/ping/api#Ip)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/ping"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Ping an IP address
|
||||||
|
func PingAnIp() {
|
||||||
|
pingService := ping.NewPingService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := pingService.Ip(&ping.IpRequest{
|
||||||
|
Address: "google.com",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
@@ -4,6 +4,35 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/place/api](htt
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
|
## Search
|
||||||
|
|
||||||
|
Search for places by text query
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/place/api#Search](https://m3o.com/place/api#Search)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/place"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Search for places by text query
|
||||||
|
func SearchForPlaces() {
|
||||||
|
placeService := place.NewPlaceService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := placeService.Search(&place.SearchRequest{
|
||||||
|
Location: "51.5074577,-0.1297515",
|
||||||
|
Query: "food",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
## Nearby
|
## Nearby
|
||||||
|
|
||||||
Find places nearby using a location
|
Find places nearby using a location
|
||||||
@@ -34,32 +63,3 @@ Type: "store",
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Search
|
|
||||||
|
|
||||||
Search for places by text query
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/place/api#Search](https://m3o.com/place/api#Search)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/place"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Search for places by text query
|
|
||||||
func SearchForPlaces() {
|
|
||||||
placeService := place.NewPlaceService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := placeService.Search(&place.SearchRequest{
|
|
||||||
Location: "51.5074577,-0.1297515",
|
|
||||||
Query: "food",
|
|
||||||
|
|
||||||
})
|
|
||||||
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:
|
||||||
|
|
||||||
|
## Summary
|
||||||
|
|
||||||
|
Get a summary for a given chapter (surah)
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/quran/api#Summary](https://m3o.com/quran/api#Summary)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/quran"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Get a summary for a given chapter (surah)
|
||||||
|
func GetChapterSummary() {
|
||||||
|
quranService := quran.NewQuranService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := quranService.Summary(&quran.SummaryRequest{
|
||||||
|
Chapter: 1,
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
## Verses
|
## Verses
|
||||||
|
|
||||||
Lookup the verses (ayahs) for a chapter including
|
Lookup the verses (ayahs) for a chapter including
|
||||||
@@ -92,31 +120,3 @@ func ListChapters() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Summary
|
|
||||||
|
|
||||||
Get a summary for a given chapter (surah)
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/quran/api#Summary](https://m3o.com/quran/api#Summary)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/quran"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Get a summary for a given chapter (surah)
|
|
||||||
func GetChapterSummary() {
|
|
||||||
quranService := quran.NewQuranService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := quranService.Summary(&quran.SummaryRequest{
|
|
||||||
Chapter: 1,
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|||||||
@@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/search/api](ht
|
|||||||
|
|
||||||
Endpoints:
|
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
|
||||||
|
|
||||||
Index a record i.e. insert a document to search for.
|
Index a record i.e. insert a document to search for.
|
||||||
@@ -209,3 +181,31 @@ 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)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
@@ -12,9 +12,9 @@ func main() {
|
|||||||
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
|
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := searchService.Index(&search.IndexRequest{
|
rsp, err := searchService.Index(&search.IndexRequest{
|
||||||
Data: map[string]interface{}{
|
Data: map[string]interface{}{
|
||||||
"starsign": "Leo",
|
|
||||||
"name": "John Doe",
|
"name": "John Doe",
|
||||||
"age": 37,
|
"age": 37,
|
||||||
|
"starsign": "Leo",
|
||||||
},
|
},
|
||||||
Index: "customers",
|
Index: "customers",
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -4,6 +4,62 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/space/api](htt
|
|||||||
|
|
||||||
Endpoints:
|
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
|
||||||
|
|
||||||
Upload a large object (> 10MB). Returns a time limited presigned URL to be used for uploading the object
|
Upload a large object (> 10MB). Returns a time limited presigned URL to be used for uploading the object
|
||||||
@@ -176,59 +232,3 @@ 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)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|||||||
@@ -4,6 +4,62 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/stock/api](htt
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
|
## Price
|
||||||
|
|
||||||
|
Get the last price for a given stock ticker
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/stock/api#Price](https://m3o.com/stock/api#Price)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/stock"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Get the last price for a given stock ticker
|
||||||
|
func GetAstockPrice() {
|
||||||
|
stockService := stock.NewStockService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := stockService.Price(&stock.PriceRequest{
|
||||||
|
Symbol: "AAPL",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Quote
|
||||||
|
|
||||||
|
Get the last quote for the stock
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/stock/api#Quote](https://m3o.com/stock/api#Quote)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/stock"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Get the last quote for the stock
|
||||||
|
func GetAstockQuote() {
|
||||||
|
stockService := stock.NewStockService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := stockService.Quote(&stock.QuoteRequest{
|
||||||
|
Symbol: "AAPL",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
## History
|
## History
|
||||||
|
|
||||||
Get the historic open-close for a given day
|
Get the historic open-close for a given day
|
||||||
@@ -65,59 +121,3 @@ Stock: "AAPL",
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Price
|
|
||||||
|
|
||||||
Get the last price for a given stock ticker
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/stock/api#Price](https://m3o.com/stock/api#Price)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/stock"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Get the last price for a given stock ticker
|
|
||||||
func GetAstockPrice() {
|
|
||||||
stockService := stock.NewStockService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := stockService.Price(&stock.PriceRequest{
|
|
||||||
Symbol: "AAPL",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Quote
|
|
||||||
|
|
||||||
Get the last quote for the stock
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/stock/api#Quote](https://m3o.com/stock/api#Quote)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/stock"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Get the last quote for the stock
|
|
||||||
func GetAstockQuote() {
|
|
||||||
stockService := stock.NewStockService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := stockService.Quote(&stock.QuoteRequest{
|
|
||||||
Symbol: "AAPL",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|||||||
@@ -4,6 +4,37 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/sunnah/api](ht
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
|
## Hadiths
|
||||||
|
|
||||||
|
Hadiths returns a list of hadiths and their corresponding text for a
|
||||||
|
given book within a collection.
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/sunnah/api#Hadiths](https://m3o.com/sunnah/api#Hadiths)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/sunnah"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Hadiths returns a list of hadiths and their corresponding text for a
|
||||||
|
// given book within a collection.
|
||||||
|
func ListTheHadithsInAbook() {
|
||||||
|
sunnahService := sunnah.NewSunnahService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := sunnahService.Hadiths(&sunnah.HadithsRequest{
|
||||||
|
Book: 1,
|
||||||
|
Collection: "bukhari",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
## Collections
|
## Collections
|
||||||
|
|
||||||
Get a list of available collections. A collection is
|
Get a list of available collections. A collection is
|
||||||
@@ -92,34 +123,3 @@ Collection: "bukhari",
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Hadiths
|
|
||||||
|
|
||||||
Hadiths returns a list of hadiths and their corresponding text for a
|
|
||||||
given book within a collection.
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/sunnah/api#Hadiths](https://m3o.com/sunnah/api#Hadiths)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/sunnah"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Hadiths returns a list of hadiths and their corresponding text for a
|
|
||||||
// given book within a collection.
|
|
||||||
func ListTheHadithsInAbook() {
|
|
||||||
sunnahService := sunnah.NewSunnahService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := sunnahService.Hadiths(&sunnah.HadithsRequest{
|
|
||||||
Book: 1,
|
|
||||||
Collection: "bukhari",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|||||||
@@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/twitter/api](h
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
## Search
|
|
||||||
|
|
||||||
Search for tweets with a simple query
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/twitter/api#Search](https://m3o.com/twitter/api#Search)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/twitter"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Search for tweets with a simple query
|
|
||||||
func SearchForTweets() {
|
|
||||||
twitterService := twitter.NewTwitterService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := twitterService.Search(&twitter.SearchRequest{
|
|
||||||
Query: "cats",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Trends
|
## Trends
|
||||||
|
|
||||||
Get the current global trending topics
|
Get the current global trending topics
|
||||||
@@ -116,3 +88,31 @@ Username: "m3oservices",
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
## Search
|
||||||
|
|
||||||
|
Search for tweets with a simple query
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/twitter/api#Search](https://m3o.com/twitter/api#Search)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/twitter"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Search for tweets with a simple query
|
||||||
|
func SearchForTweets() {
|
||||||
|
twitterService := twitter.NewTwitterService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := twitterService.Search(&twitter.SearchRequest{
|
||||||
|
Query: "cats",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
@@ -4,6 +4,33 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/url/api](https
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
|
## Proxy
|
||||||
|
|
||||||
|
Proxy returns the destination URL of a short URL.
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/url/api#Proxy](https://m3o.com/url/api#Proxy)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/url"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Proxy returns the destination URL of a short URL.
|
||||||
|
func ResolveAshortUrlToAlongDestinationUrl() {
|
||||||
|
urlService := url.NewUrlService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := urlService.Proxy(&url.ProxyRequest{
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
## List
|
## List
|
||||||
|
|
||||||
List all the shortened URLs
|
List all the shortened URLs
|
||||||
@@ -58,30 +85,3 @@ func ShortenAlongUrl() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Proxy
|
|
||||||
|
|
||||||
Proxy returns the destination URL of a short URL.
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/url/api#Proxy](https://m3o.com/url/api#Proxy)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/url"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Proxy returns the destination URL of a short URL.
|
|
||||||
func ResolveAshortUrlToAlongDestinationUrl() {
|
|
||||||
urlService := url.NewUrlService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := urlService.Proxy(&url.ProxyRequest{
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|||||||
@@ -4,6 +4,71 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/user/api](http
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
|
## SendMagicLink
|
||||||
|
|
||||||
|
Login using email only - Passwordless
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/user/api#SendMagicLink](https://m3o.com/user/api#SendMagicLink)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/user"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Login using email only - Passwordless
|
||||||
|
func SendAmagicLink() {
|
||||||
|
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := userService.SendMagicLink(&user.SendMagicLinkRequest{
|
||||||
|
Address: "www.example.com",
|
||||||
|
Email: "joe@example.com",
|
||||||
|
Endpoint: "verifytoken",
|
||||||
|
FromName: "Awesome Dot Com",
|
||||||
|
Subject: "MagicLink to access your account",
|
||||||
|
TextContent: `Hi there,
|
||||||
|
|
||||||
|
Click here to access your account $micro_verification_link`,
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## 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
|
||||||
|
|
||||||
Read an account by id, username or email. Only one need to be specified.
|
Read an account by id, username or email. Only one need to be specified.
|
||||||
@@ -88,12 +153,12 @@ func ReadAccountByEmail() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## ResetPassword
|
## VerifyEmail
|
||||||
|
|
||||||
Reset password with the code sent by the "SendPasswordResetEmail" endpoint.
|
Verify the email address of an account from a token sent in an email to the user.
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/user/api#ResetPassword](https://m3o.com/user/api#ResetPassword)
|
[https://m3o.com/user/api#VerifyEmail](https://m3o.com/user/api#VerifyEmail)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
package example
|
package example
|
||||||
@@ -105,14 +170,11 @@ import(
|
|||||||
"go.m3o.com/user"
|
"go.m3o.com/user"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Reset password with the code sent by the "SendPasswordResetEmail" endpoint.
|
// Verify the email address of an account from a token sent in an email to the user.
|
||||||
func ResetPassword() {
|
func VerifyEmail() {
|
||||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := userService.ResetPassword(&user.ResetPasswordRequest{
|
rsp, err := userService.VerifyEmail(&user.VerifyEmailRequest{
|
||||||
Code: "012345",
|
Token: "012345",
|
||||||
ConfirmPassword: "NewPassword1",
|
|
||||||
Email: "joe@example.com",
|
|
||||||
NewPassword: "NewPassword1",
|
|
||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
@@ -145,164 +207,6 @@ 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)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Logout
|
|
||||||
|
|
||||||
Logout a user account
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/user/api#Logout](https://m3o.com/user/api#Logout)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/user"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Logout a user account
|
|
||||||
func LogAuserOut() {
|
|
||||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := userService.Logout(&user.LogoutRequest{
|
|
||||||
SessionId: "df91a612-5b24-4634-99ff-240220ab8f55",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Update
|
|
||||||
|
|
||||||
Update the account username or email
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/user/api#Update](https://m3o.com/user/api#Update)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/user"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Update the account username or email
|
|
||||||
func UpdateAnAccount() {
|
|
||||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := userService.Update(&user.UpdateRequest{
|
|
||||||
Email: "joe+2@example.com",
|
|
||||||
Id: "user-1",
|
|
||||||
Username: "joe",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## SendMagicLink
|
|
||||||
|
|
||||||
Login using email only - Passwordless
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/user/api#SendMagicLink](https://m3o.com/user/api#SendMagicLink)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/user"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Login using email only - Passwordless
|
|
||||||
func SendAmagicLink() {
|
|
||||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := userService.SendMagicLink(&user.SendMagicLinkRequest{
|
|
||||||
Address: "www.example.com",
|
|
||||||
Email: "joe@example.com",
|
|
||||||
Endpoint: "verifytoken",
|
|
||||||
FromName: "Awesome Dot Com",
|
|
||||||
Subject: "MagicLink to access your account",
|
|
||||||
TextContent: `Hi there,
|
|
||||||
|
|
||||||
Click here to access your account $micro_verification_link`,
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## VerifyToken
|
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## List
|
## List
|
||||||
@@ -363,127 +267,6 @@ UserId: "user-1",
|
|||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## SendPasswordResetEmail
|
|
||||||
|
|
||||||
Send an email with a verification code to reset password.
|
|
||||||
Call "ResetPassword" endpoint once user provides the code.
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/user/api#SendPasswordResetEmail](https://m3o.com/user/api#SendPasswordResetEmail)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/user"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Send an email with a verification code to reset password.
|
|
||||||
// Call "ResetPassword" endpoint once user provides the code.
|
|
||||||
func SendPasswordResetEmail() {
|
|
||||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := userService.SendPasswordResetEmail(&user.SendPasswordResetEmailRequest{
|
|
||||||
Email: "joe@example.com",
|
|
||||||
FromName: "Awesome Dot Com",
|
|
||||||
Subject: "Password reset",
|
|
||||||
TextContent: `Hi there,
|
|
||||||
click here to reset your password: myapp.com/reset/code?=$code`,
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Create
|
|
||||||
|
|
||||||
Create a new user account. The email address and username for the account must be unique.
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/user/api#Create](https://m3o.com/user/api#Create)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/user"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Create a new user account. The email address and username for the account must be unique.
|
|
||||||
func CreateAnAccount() {
|
|
||||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := userService.Create(&user.CreateRequest{
|
|
||||||
Email: "joe@example.com",
|
|
||||||
Id: "user-1",
|
|
||||||
Password: "Password1",
|
|
||||||
Username: "joe",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## VerifyEmail
|
|
||||||
|
|
||||||
Verify the email address of an account from a token sent in an email to the user.
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/user/api#VerifyEmail](https://m3o.com/user/api#VerifyEmail)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/user"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Verify the email address of an account from a token sent in an email to the user.
|
|
||||||
func VerifyEmail() {
|
|
||||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := userService.VerifyEmail(&user.VerifyEmailRequest{
|
|
||||||
Token: "012345",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## ReadSession
|
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## SendVerificationEmail
|
## SendVerificationEmail
|
||||||
@@ -533,3 +316,220 @@ Please verify your email by clicking this link: $micro_verification_link`,
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
## 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)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## VerifyToken
|
||||||
|
|
||||||
|
Check whether the token attached to MagicLink is valid or not.
|
||||||
|
Ideally, you need to call this endpoint from your http request
|
||||||
|
handler that handles the endpoint which is specified in the
|
||||||
|
SendMagicLink request.
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/user/api#VerifyToken](https://m3o.com/user/api#VerifyToken)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/user"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Check whether the token attached to MagicLink is valid or not.
|
||||||
|
// Ideally, you need to call this endpoint from your http request
|
||||||
|
// handler that handles the endpoint which is specified in the
|
||||||
|
// SendMagicLink request.
|
||||||
|
func VerifyAtoken() {
|
||||||
|
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := userService.VerifyToken(&user.VerifyTokenRequest{
|
||||||
|
Token: "EdsUiidouJJJLldjlloofUiorkojflsWWdld",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Create
|
||||||
|
|
||||||
|
Create a new user account. The email address and username for the account must be unique.
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/user/api#Create](https://m3o.com/user/api#Create)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/user"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Create a new user account. The email address and username for the account must be unique.
|
||||||
|
func CreateAnAccount() {
|
||||||
|
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := userService.Create(&user.CreateRequest{
|
||||||
|
Email: "joe@example.com",
|
||||||
|
Id: "user-1",
|
||||||
|
Password: "Password1",
|
||||||
|
Username: "joe",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## SendPasswordResetEmail
|
||||||
|
|
||||||
|
Send an email with a verification code to reset password.
|
||||||
|
Call "ResetPassword" endpoint once user provides the code.
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/user/api#SendPasswordResetEmail](https://m3o.com/user/api#SendPasswordResetEmail)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/user"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Send an email with a verification code to reset password.
|
||||||
|
// Call "ResetPassword" endpoint once user provides the code.
|
||||||
|
func SendPasswordResetEmail() {
|
||||||
|
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := userService.SendPasswordResetEmail(&user.SendPasswordResetEmailRequest{
|
||||||
|
Email: "joe@example.com",
|
||||||
|
FromName: "Awesome Dot Com",
|
||||||
|
Subject: "Password reset",
|
||||||
|
TextContent: `Hi there,
|
||||||
|
click here to reset your password: myapp.com/reset/code?=$code`,
|
||||||
|
|
||||||
|
})
|
||||||
|
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)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## 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)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Logout
|
||||||
|
|
||||||
|
Logout a user account
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/user/api#Logout](https://m3o.com/user/api#Logout)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/user"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Logout a user account
|
||||||
|
func LogAuserOut() {
|
||||||
|
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := userService.Logout(&user.LogoutRequest{
|
||||||
|
SessionId: "df91a612-5b24-4634-99ff-240220ab8f55",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
@@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/youtube/api](h
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
## Search
|
|
||||||
|
|
||||||
Search for videos on YouTube
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/youtube/api#Search](https://m3o.com/youtube/api#Search)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/youtube"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Search for videos on YouTube
|
|
||||||
func SearchForVideos() {
|
|
||||||
youtubeService := youtube.NewYoutubeService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := youtubeService.Search(&youtube.SearchRequest{
|
|
||||||
Query: "donuts",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Embed
|
## Embed
|
||||||
|
|
||||||
Embed a YouTube video
|
Embed a YouTube video
|
||||||
@@ -60,3 +32,31 @@ func EmbedAyoutubeVideo() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
## Search
|
||||||
|
|
||||||
|
Search for videos on YouTube
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/youtube/api#Search](https://m3o.com/youtube/api#Search)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/youtube"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Search for videos on YouTube
|
||||||
|
func SearchForVideos() {
|
||||||
|
youtubeService := youtube.NewYoutubeService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := youtubeService.Search(&youtube.SearchRequest{
|
||||||
|
Query: "donuts",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user