mirror of
https://github.com/kevin-DL/m3o-go.git
synced 2026-01-11 10:34:27 +00:00
Commit from m3o/m3o action
This commit is contained in:
@@ -24,7 +24,7 @@ type ContactService struct {
|
|||||||
client *client.Client
|
client *client.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
// Create a contact
|
||||||
func (t *ContactService) Create(request *CreateRequest) (*CreateResponse, error) {
|
func (t *ContactService) Create(request *CreateRequest) (*CreateResponse, error) {
|
||||||
|
|
||||||
rsp := &CreateResponse{}
|
rsp := &CreateResponse{}
|
||||||
@@ -32,7 +32,7 @@ func (t *ContactService) Create(request *CreateRequest) (*CreateResponse, error)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
// Delete a contact
|
||||||
func (t *ContactService) Delete(request *DeleteRequest) (*DeleteResponse, error) {
|
func (t *ContactService) Delete(request *DeleteRequest) (*DeleteResponse, error) {
|
||||||
|
|
||||||
rsp := &DeleteResponse{}
|
rsp := &DeleteResponse{}
|
||||||
@@ -40,7 +40,7 @@ func (t *ContactService) Delete(request *DeleteRequest) (*DeleteResponse, error)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
// List contacts
|
||||||
func (t *ContactService) List(request *ListRequest) (*ListResponse, error) {
|
func (t *ContactService) List(request *ListRequest) (*ListResponse, error) {
|
||||||
|
|
||||||
rsp := &ListResponse{}
|
rsp := &ListResponse{}
|
||||||
@@ -48,7 +48,7 @@ func (t *ContactService) List(request *ListRequest) (*ListResponse, error) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
// Read contact details
|
||||||
func (t *ContactService) Read(request *ReadRequest) (*ReadResponse, error) {
|
func (t *ContactService) Read(request *ReadRequest) (*ReadResponse, error) {
|
||||||
|
|
||||||
rsp := &ReadResponse{}
|
rsp := &ReadResponse{}
|
||||||
@@ -56,7 +56,7 @@ func (t *ContactService) Read(request *ReadRequest) (*ReadResponse, error) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
// Update a contact
|
||||||
func (t *ContactService) Update(request *UpdateRequest) (*UpdateResponse, error) {
|
func (t *ContactService) Update(request *UpdateRequest) (*UpdateResponse, error) {
|
||||||
|
|
||||||
rsp := &UpdateResponse{}
|
rsp := &UpdateResponse{}
|
||||||
|
|||||||
@@ -4,6 +4,90 @@ 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
|
||||||
@@ -146,87 +230,3 @@ 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)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|||||||
170
examples/cache/README.md
vendored
170
examples/cache/README.md
vendored
@@ -4,91 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/cache/api](htt
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
## Get
|
|
||||||
|
|
||||||
Get an item from the cache by key. If key is not found, an empty response is returned.
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/cache/api#Get](https://m3o.com/cache/api#Get)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/cache"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Get an item from the cache by key. If key is not found, an empty response is returned.
|
|
||||||
func GetAvalue() {
|
|
||||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := cacheService.Get(&cache.GetRequest{
|
|
||||||
Key: "foo",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Delete
|
|
||||||
|
|
||||||
Delete a value from the cache. If key not found a success response is returned.
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/cache/api#Delete](https://m3o.com/cache/api#Delete)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/cache"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Delete a value from the cache. If key not found a success response is returned.
|
|
||||||
func DeleteAvalue() {
|
|
||||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := cacheService.Delete(&cache.DeleteRequest{
|
|
||||||
Key: "foo",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Increment
|
|
||||||
|
|
||||||
Increment a value (if it's a number). If key not found it is equivalent to set.
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/cache/api#Increment](https://m3o.com/cache/api#Increment)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/cache"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Increment a value (if it's a number). If key not found it is equivalent to set.
|
|
||||||
func IncrementAvalue() {
|
|
||||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := cacheService.Increment(&cache.IncrementRequest{
|
|
||||||
Key: "counter",
|
|
||||||
Value: 2,
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Decrement
|
## Decrement
|
||||||
|
|
||||||
Decrement a value (if it's a number). If key not found it is equivalent to set.
|
Decrement a value (if it's a number). If key not found it is equivalent to set.
|
||||||
@@ -174,3 +89,88 @@ Value: "bar",
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
## Get
|
||||||
|
|
||||||
|
Get an item from the cache by key. If key is not found, an empty response is returned.
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/cache/api#Get](https://m3o.com/cache/api#Get)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/cache"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Get an item from the cache by key. If key is not found, an empty response is returned.
|
||||||
|
func GetAvalue() {
|
||||||
|
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := cacheService.Get(&cache.GetRequest{
|
||||||
|
Key: "foo",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Delete
|
||||||
|
|
||||||
|
Delete a value from the cache. If key not found a success response is returned.
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/cache/api#Delete](https://m3o.com/cache/api#Delete)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/cache"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Delete a value from the cache. If key not found a success response is returned.
|
||||||
|
func DeleteAvalue() {
|
||||||
|
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := cacheService.Delete(&cache.DeleteRequest{
|
||||||
|
Key: "foo",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Increment
|
||||||
|
|
||||||
|
Increment a value (if it's a number). If key not found it is equivalent to set.
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/cache/api#Increment](https://m3o.com/cache/api#Increment)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/cache"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Increment a value (if it's a number). If key not found it is equivalent to set.
|
||||||
|
func IncrementAvalue() {
|
||||||
|
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := cacheService.Increment(&cache.IncrementRequest{
|
||||||
|
Key: "counter",
|
||||||
|
Value: 2,
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
@@ -33,6 +33,100 @@ Name: "general",
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
## Delete
|
||||||
|
|
||||||
|
Delete a chat room
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/chat/api#Delete](https://m3o.com/chat/api#Delete)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/chat"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Delete a chat room
|
||||||
|
func DeleteAchat() {
|
||||||
|
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := chatService.Delete(&chat.DeleteRequest{
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## History
|
||||||
|
|
||||||
|
List the messages in a chat
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/chat/api#History](https://m3o.com/chat/api#History)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/chat"
|
||||||
|
)
|
||||||
|
|
||||||
|
// List the messages in a chat
|
||||||
|
func GetChatHistory() {
|
||||||
|
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := chatService.History(&chat.HistoryRequest{
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Join
|
||||||
|
|
||||||
|
Join a chat room
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/chat/api#Join](https://m3o.com/chat/api#Join)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/chat"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Join a chat room
|
||||||
|
func JoinAroom() {
|
||||||
|
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
|
||||||
|
stream, err := chatService.Join(&chat.JoinRequest{
|
||||||
|
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for {
|
||||||
|
rsp, err := stream.Recv()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println(rsp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
## List
|
## List
|
||||||
|
|
||||||
List available chats
|
List available chats
|
||||||
@@ -117,100 +211,6 @@ Text: "Hey whats up?",
|
|||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## History
|
|
||||||
|
|
||||||
List the messages in a chat
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/chat/api#History](https://m3o.com/chat/api#History)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/chat"
|
|
||||||
)
|
|
||||||
|
|
||||||
// List the messages in a chat
|
|
||||||
func GetChatHistory() {
|
|
||||||
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := chatService.History(&chat.HistoryRequest{
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Join
|
|
||||||
|
|
||||||
Join a chat room
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/chat/api#Join](https://m3o.com/chat/api#Join)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/chat"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Join a chat room
|
|
||||||
func JoinAroom() {
|
|
||||||
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
|
|
||||||
stream, err := chatService.Join(&chat.JoinRequest{
|
|
||||||
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
for {
|
|
||||||
rsp, err := stream.Recv()
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Println(rsp)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Delete
|
|
||||||
|
|
||||||
Delete a chat room
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/chat/api#Delete](https://m3o.com/chat/api#Delete)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/chat"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Delete a chat room
|
|
||||||
func DeleteAchat() {
|
|
||||||
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := chatService.Delete(&chat.DeleteRequest{
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Kick
|
## Kick
|
||||||
|
|||||||
@@ -4,6 +4,93 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/comments/api](
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
|
## 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 a comment
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/comments/api#Update](https://m3o.com/comments/api#Update)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/comments"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Update a comment
|
||||||
|
func UpdateAcomment() {
|
||||||
|
commentsService := comments.NewCommentsService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := commentsService.Update(&comments.UpdateRequest{
|
||||||
|
Comment: &comments.Comment{
|
||||||
|
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
|
||||||
|
Subject: "Update Comment",
|
||||||
|
Text: "Updated comment text",
|
||||||
|
},
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Delete
|
||||||
|
|
||||||
|
Delete a comment
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/comments/api#Delete](https://m3o.com/comments/api#Delete)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/comments"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Delete a comment
|
||||||
|
func DeleteAcomment() {
|
||||||
|
commentsService := comments.NewCommentsService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := commentsService.Delete(&comments.DeleteRequest{
|
||||||
|
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
## Events
|
## Events
|
||||||
|
|
||||||
Subscribe to comments events
|
Subscribe to comments events
|
||||||
@@ -101,90 +188,3 @@ func ReadAcomment() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## 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 a comment
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/comments/api#Update](https://m3o.com/comments/api#Update)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/comments"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Update a comment
|
|
||||||
func UpdateAcomment() {
|
|
||||||
commentsService := comments.NewCommentsService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := commentsService.Update(&comments.UpdateRequest{
|
|
||||||
Comment: &comments.Comment{
|
|
||||||
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
|
|
||||||
Subject: "Update Comment",
|
|
||||||
Text: "Updated comment text",
|
|
||||||
},
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Delete
|
|
||||||
|
|
||||||
Delete a comment
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/comments/api#Delete](https://m3o.com/comments/api#Delete)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/comments"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Delete a comment
|
|
||||||
func DeleteAcomment() {
|
|
||||||
commentsService := comments.NewCommentsService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := commentsService.Delete(&comments.DeleteRequest{
|
|
||||||
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|||||||
@@ -4,9 +4,59 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/contact/api](h
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
|
## Create
|
||||||
|
|
||||||
|
Create a contact
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/contact/api#Create](https://m3o.com/contact/api#Create)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/contact"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Create a contact
|
||||||
|
func CreateAcontact() {
|
||||||
|
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := contactService.Create(&contact.CreateRequest{
|
||||||
|
Addresses: []contact.Address{
|
||||||
|
contact.Address{
|
||||||
|
Label: "company address",
|
||||||
|
Location: "123 street address",
|
||||||
|
}},
|
||||||
|
Birthday: "1995-01-01",
|
||||||
|
Emails: []contact.Email{
|
||||||
|
contact.Email{
|
||||||
|
Address: "home@example.com",
|
||||||
|
Label: "home",
|
||||||
|
}},
|
||||||
|
Links: []contact.Link{
|
||||||
|
contact.Link{
|
||||||
|
Label: "blog",
|
||||||
|
Url: "https://blog.joe.me",
|
||||||
|
}},
|
||||||
|
Name: "joe",
|
||||||
|
Note: "this person is very important",
|
||||||
|
Phones: []contact.Phone{
|
||||||
|
contact.Phone{
|
||||||
|
Label: "home",
|
||||||
|
Number: "010-12345678",
|
||||||
|
}},
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
## Update
|
## Update
|
||||||
|
|
||||||
|
Update a contact
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/contact/api#Update](https://m3o.com/contact/api#Update)
|
[https://m3o.com/contact/api#Update](https://m3o.com/contact/api#Update)
|
||||||
@@ -21,7 +71,7 @@ import(
|
|||||||
"go.m3o.com/contact"
|
"go.m3o.com/contact"
|
||||||
)
|
)
|
||||||
|
|
||||||
//
|
// Update a contact
|
||||||
func UpdateAcontact() {
|
func UpdateAcontact() {
|
||||||
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := contactService.Update(&contact.UpdateRequest{
|
rsp, err := contactService.Update(&contact.UpdateRequest{
|
||||||
@@ -57,7 +107,7 @@ contact.Phone{
|
|||||||
```
|
```
|
||||||
## Read
|
## Read
|
||||||
|
|
||||||
|
Read contact details
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/contact/api#Read](https://m3o.com/contact/api#Read)
|
[https://m3o.com/contact/api#Read](https://m3o.com/contact/api#Read)
|
||||||
@@ -72,7 +122,7 @@ import(
|
|||||||
"go.m3o.com/contact"
|
"go.m3o.com/contact"
|
||||||
)
|
)
|
||||||
|
|
||||||
//
|
// Read contact details
|
||||||
func GetAcontact() {
|
func GetAcontact() {
|
||||||
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := contactService.Read(&contact.ReadRequest{
|
rsp, err := contactService.Read(&contact.ReadRequest{
|
||||||
@@ -85,7 +135,7 @@ func GetAcontact() {
|
|||||||
```
|
```
|
||||||
## Delete
|
## Delete
|
||||||
|
|
||||||
|
Delete a contact
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/contact/api#Delete](https://m3o.com/contact/api#Delete)
|
[https://m3o.com/contact/api#Delete](https://m3o.com/contact/api#Delete)
|
||||||
@@ -100,7 +150,7 @@ import(
|
|||||||
"go.m3o.com/contact"
|
"go.m3o.com/contact"
|
||||||
)
|
)
|
||||||
|
|
||||||
//
|
// Delete a contact
|
||||||
func DeleteAcontact() {
|
func DeleteAcontact() {
|
||||||
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := contactService.Delete(&contact.DeleteRequest{
|
rsp, err := contactService.Delete(&contact.DeleteRequest{
|
||||||
@@ -113,7 +163,7 @@ func DeleteAcontact() {
|
|||||||
```
|
```
|
||||||
## List
|
## List
|
||||||
|
|
||||||
|
List contacts
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/contact/api#List](https://m3o.com/contact/api#List)
|
[https://m3o.com/contact/api#List](https://m3o.com/contact/api#List)
|
||||||
@@ -128,7 +178,7 @@ import(
|
|||||||
"go.m3o.com/contact"
|
"go.m3o.com/contact"
|
||||||
)
|
)
|
||||||
|
|
||||||
//
|
// List contacts
|
||||||
func ListContactsWithDefaultOffsetAndLimitDefaultLimitIs20() {
|
func ListContactsWithDefaultOffsetAndLimitDefaultLimitIs20() {
|
||||||
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := contactService.List(&contact.ListRequest{
|
rsp, err := contactService.List(&contact.ListRequest{
|
||||||
@@ -140,7 +190,7 @@ func ListContactsWithDefaultOffsetAndLimitDefaultLimitIs20() {
|
|||||||
```
|
```
|
||||||
## List
|
## List
|
||||||
|
|
||||||
|
List contacts
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/contact/api#List](https://m3o.com/contact/api#List)
|
[https://m3o.com/contact/api#List](https://m3o.com/contact/api#List)
|
||||||
@@ -155,7 +205,7 @@ import(
|
|||||||
"go.m3o.com/contact"
|
"go.m3o.com/contact"
|
||||||
)
|
)
|
||||||
|
|
||||||
//
|
// List contacts
|
||||||
func ListContactsWithSpecificOffsetAndLimit() {
|
func ListContactsWithSpecificOffsetAndLimit() {
|
||||||
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := contactService.List(&contact.ListRequest{
|
rsp, err := contactService.List(&contact.ListRequest{
|
||||||
@@ -167,53 +217,3 @@ Offset: 1,
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Create
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/contact/api#Create](https://m3o.com/contact/api#Create)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/contact"
|
|
||||||
)
|
|
||||||
|
|
||||||
//
|
|
||||||
func CreateAcontact() {
|
|
||||||
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := contactService.Create(&contact.CreateRequest{
|
|
||||||
Addresses: []contact.Address{
|
|
||||||
contact.Address{
|
|
||||||
Label: "company address",
|
|
||||||
Location: "123 street address",
|
|
||||||
}},
|
|
||||||
Birthday: "1995-01-01",
|
|
||||||
Emails: []contact.Email{
|
|
||||||
contact.Email{
|
|
||||||
Address: "home@example.com",
|
|
||||||
Label: "home",
|
|
||||||
}},
|
|
||||||
Links: []contact.Link{
|
|
||||||
contact.Link{
|
|
||||||
Label: "blog",
|
|
||||||
Url: "https://blog.joe.me",
|
|
||||||
}},
|
|
||||||
Name: "joe",
|
|
||||||
Note: "this person is very important",
|
|
||||||
Phones: []contact.Phone{
|
|
||||||
contact.Phone{
|
|
||||||
Label: "home",
|
|
||||||
Number: "010-12345678",
|
|
||||||
}},
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
"go.m3o.com/contact"
|
"go.m3o.com/contact"
|
||||||
)
|
)
|
||||||
|
|
||||||
//
|
// Create a contact
|
||||||
func main() {
|
func main() {
|
||||||
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := contactService.Create(&contact.CreateRequest{
|
rsp, err := contactService.Create(&contact.CreateRequest{
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
"go.m3o.com/contact"
|
"go.m3o.com/contact"
|
||||||
)
|
)
|
||||||
|
|
||||||
//
|
// Delete a contact
|
||||||
func main() {
|
func main() {
|
||||||
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := contactService.Delete(&contact.DeleteRequest{
|
rsp, err := contactService.Delete(&contact.DeleteRequest{
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
"go.m3o.com/contact"
|
"go.m3o.com/contact"
|
||||||
)
|
)
|
||||||
|
|
||||||
//
|
// List contacts
|
||||||
func main() {
|
func main() {
|
||||||
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := contactService.List(&contact.ListRequest{})
|
rsp, err := contactService.List(&contact.ListRequest{})
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
"go.m3o.com/contact"
|
"go.m3o.com/contact"
|
||||||
)
|
)
|
||||||
|
|
||||||
//
|
// List contacts
|
||||||
func main() {
|
func main() {
|
||||||
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := contactService.List(&contact.ListRequest{
|
rsp, err := contactService.List(&contact.ListRequest{
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
"go.m3o.com/contact"
|
"go.m3o.com/contact"
|
||||||
)
|
)
|
||||||
|
|
||||||
//
|
// Read contact details
|
||||||
func main() {
|
func main() {
|
||||||
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := contactService.Read(&contact.ReadRequest{
|
rsp, err := contactService.Read(&contact.ReadRequest{
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
"go.m3o.com/contact"
|
"go.m3o.com/contact"
|
||||||
)
|
)
|
||||||
|
|
||||||
//
|
// Update a contact
|
||||||
func main() {
|
func main() {
|
||||||
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := contactService.Update(&contact.UpdateRequest{
|
rsp, err := contactService.Update(&contact.UpdateRequest{
|
||||||
|
|||||||
@@ -4,66 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/db/api](https:
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
## 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)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## 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)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## ListTables
|
## ListTables
|
||||||
|
|
||||||
List tables in the DB
|
List tables in the DB
|
||||||
@@ -89,6 +29,35 @@ func ListTables() {
|
|||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## RenameTable
|
||||||
|
|
||||||
|
Rename a table
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/db/api#RenameTable](https://m3o.com/db/api#RenameTable)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/db"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Rename a table
|
||||||
|
func RenameTable() {
|
||||||
|
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := dbService.RenameTable(&db.RenameTableRequest{
|
||||||
|
From: "examples2",
|
||||||
|
To: "examples3",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Create
|
## Create
|
||||||
@@ -123,35 +92,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
|
||||||
@@ -239,12 +179,12 @@ func CountEntriesInAtable() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## RenameTable
|
## Update
|
||||||
|
|
||||||
Rename a table
|
Update a record in the database. Include an "id" in the record to update.
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/db/api#RenameTable](https://m3o.com/db/api#RenameTable)
|
[https://m3o.com/db/api#Update](https://m3o.com/db/api#Update)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
package example
|
package example
|
||||||
@@ -256,12 +196,72 @@ import(
|
|||||||
"go.m3o.com/db"
|
"go.m3o.com/db"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Rename a table
|
// Update a record in the database. Include an "id" in the record to update.
|
||||||
func RenameTable() {
|
func UpdateArecord() {
|
||||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := dbService.RenameTable(&db.RenameTableRequest{
|
rsp, err := dbService.Update(&db.UpdateRequest{
|
||||||
From: "examples2",
|
Record: map[string]interface{}{
|
||||||
To: "examples3",
|
"age": 43,
|
||||||
|
"id": "1",
|
||||||
|
},
|
||||||
|
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)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## 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)
|
||||||
|
|||||||
@@ -4,38 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/email/api](htt
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
## Send
|
|
||||||
|
|
||||||
Send an email by passing in from, to, subject, and a text or html body
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/email/api#Send](https://m3o.com/email/api#Send)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/email"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Send an email by passing in from, to, subject, and a text or html body
|
|
||||||
func SendEmail() {
|
|
||||||
emailService := email.NewEmailService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := emailService.Send(&email.SendRequest{
|
|
||||||
From: "Awesome Dot Com",
|
|
||||||
Subject: "Email verification",
|
|
||||||
TextBody: `Hi there,
|
|
||||||
|
|
||||||
Please verify your email by clicking this link: $micro_verification_link`,
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Parse
|
## Parse
|
||||||
|
|
||||||
Parse an RFC5322 address e.g "Joe Blogs <joe@example.com>"
|
Parse an RFC5322 address e.g "Joe Blogs <joe@example.com>"
|
||||||
@@ -92,3 +60,35 @@ func ValidateEmail() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
## Send
|
||||||
|
|
||||||
|
Send an email by passing in from, to, subject, and a text or html body
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/email/api#Send](https://m3o.com/email/api#Send)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/email"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Send an email by passing in from, to, subject, and a text or html body
|
||||||
|
func SendEmail() {
|
||||||
|
emailService := email.NewEmailService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := emailService.Send(&email.SendRequest{
|
||||||
|
From: "Awesome Dot Com",
|
||||||
|
Subject: "Email verification",
|
||||||
|
TextBody: `Hi there,
|
||||||
|
|
||||||
|
Please verify your email by clicking this link: $micro_verification_link`,
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
@@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/emoji/api](htt
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
|
## Find
|
||||||
|
|
||||||
|
Find an emoji by its alias e.g :beer:
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/emoji/api#Find](https://m3o.com/emoji/api#Find)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/emoji"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Find an emoji by its alias e.g :beer:
|
||||||
|
func FindEmoji() {
|
||||||
|
emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := emojiService.Find(&emoji.FindRequest{
|
||||||
|
Alias: ":beer:",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
## Flag
|
## Flag
|
||||||
|
|
||||||
Get the flag for a country. Requires country code e.g GB for great britain
|
Get the flag for a country. Requires country code e.g GB for great britain
|
||||||
@@ -61,31 +89,3 @@ func PrintTextIncludingEmoji() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Find
|
|
||||||
|
|
||||||
Find an emoji by its alias e.g :beer:
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/emoji/api#Find](https://m3o.com/emoji/api#Find)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/emoji"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Find an emoji by its alias e.g :beer:
|
|
||||||
func FindEmoji() {
|
|
||||||
emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := emojiService.Find(&emoji.FindRequest{
|
|
||||||
Alias: ":beer:",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|||||||
@@ -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,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/event/api](htt
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
## Read
|
|
||||||
|
|
||||||
Read stored events
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/event/api#Read](https://m3o.com/event/api#Read)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/event"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Read stored events
|
|
||||||
func ReadEventsOnAtopic() {
|
|
||||||
eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := eventService.Read(&event.ReadRequest{
|
|
||||||
Topic: "user",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Publish
|
## Publish
|
||||||
|
|
||||||
Publish a event to the event stream.
|
Publish a event to the event stream.
|
||||||
@@ -54,9 +26,9 @@ func PublishAnEvent() {
|
|||||||
eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN"))
|
eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := eventService.Publish(&event.PublishRequest{
|
rsp, err := eventService.Publish(&event.PublishRequest{
|
||||||
Message: map[string]interface{}{
|
Message: map[string]interface{}{
|
||||||
"id": "1",
|
|
||||||
"type": "signup",
|
"type": "signup",
|
||||||
"user": "john",
|
"user": "john",
|
||||||
|
"id": "1",
|
||||||
},
|
},
|
||||||
Topic: "user",
|
Topic: "user",
|
||||||
|
|
||||||
@@ -106,3 +78,31 @@ func ConsumeFromAtopic() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
## Read
|
||||||
|
|
||||||
|
Read stored events
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/event/api#Read](https://m3o.com/event/api#Read)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/event"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Read stored events
|
||||||
|
func ReadEventsOnAtopic() {
|
||||||
|
eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := eventService.Read(&event.ReadRequest{
|
||||||
|
Topic: "user",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
@@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/forex/api](htt
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
|
## Price
|
||||||
|
|
||||||
|
Get the latest price for a given forex ticker
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/forex/api#Price](https://m3o.com/forex/api#Price)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/forex"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Get the latest price for a given forex ticker
|
||||||
|
func GetAnFxPrice() {
|
||||||
|
forexService := forex.NewForexService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := forexService.Price(&forex.PriceRequest{
|
||||||
|
Symbol: "GBPUSD",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
## Quote
|
## Quote
|
||||||
|
|
||||||
Get the latest quote for the forex
|
Get the latest quote for the forex
|
||||||
@@ -60,31 +88,3 @@ func GetPreviousClose() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Price
|
|
||||||
|
|
||||||
Get the latest price for a given forex ticker
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/forex/api#Price](https://m3o.com/forex/api#Price)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/forex"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Get the latest price for a given forex ticker
|
|
||||||
func GetAnFxPrice() {
|
|
||||||
forexService := forex.NewForexService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := forexService.Price(&forex.PriceRequest{
|
|
||||||
Symbol: "GBPUSD",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|||||||
@@ -4,12 +4,12 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/function/api](
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
## Proxy
|
## Call
|
||||||
|
|
||||||
Return the backend url for proxying
|
Call a function by name
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/function/api#Proxy](https://m3o.com/function/api#Proxy)
|
[https://m3o.com/function/api#Call](https://m3o.com/function/api#Call)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
package example
|
package example
|
||||||
@@ -21,73 +21,14 @@ import(
|
|||||||
"go.m3o.com/function"
|
"go.m3o.com/function"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Return the backend url for proxying
|
// Call a function by name
|
||||||
func ProxyUrl() {
|
func CallAfunction() {
|
||||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := functionService.Proxy(&function.ProxyRequest{
|
rsp, err := functionService.Call(&function.CallRequest{
|
||||||
Id: "helloworld",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Deploy
|
|
||||||
|
|
||||||
Deploy a group of functions
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/function/api#Deploy](https://m3o.com/function/api#Deploy)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/function"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Deploy a group of functions
|
|
||||||
func DeployAfunction() {
|
|
||||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := functionService.Deploy(&function.DeployRequest{
|
|
||||||
Branch: "main",
|
|
||||||
Entrypoint: "Helloworld",
|
|
||||||
Name: "helloworld",
|
|
||||||
Region: "europe-west1",
|
|
||||||
Repo: "https://github.com/m3o/m3o",
|
|
||||||
Runtime: "go116",
|
|
||||||
Subfolder: "examples/go-function",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Update
|
|
||||||
|
|
||||||
Update a function. Downloads the source, builds and redeploys
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/function/api#Update](https://m3o.com/function/api#Update)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/function"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Update a function. Downloads the source, builds and redeploys
|
|
||||||
func UpdateAfunction() {
|
|
||||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := functionService.Update(&function.UpdateRequest{
|
|
||||||
Name: "helloworld",
|
Name: "helloworld",
|
||||||
|
Request: map[string]interface{}{
|
||||||
|
"name": "Alice",
|
||||||
|
},
|
||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
@@ -176,12 +117,12 @@ func ReserveAfunction() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Call
|
## Deploy
|
||||||
|
|
||||||
Call a function by name
|
Deploy a group of functions
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/function/api#Call](https://m3o.com/function/api#Call)
|
[https://m3o.com/function/api#Deploy](https://m3o.com/function/api#Deploy)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
package example
|
package example
|
||||||
@@ -193,14 +134,73 @@ import(
|
|||||||
"go.m3o.com/function"
|
"go.m3o.com/function"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Call a function by name
|
// Deploy a group of functions
|
||||||
func CallAfunction() {
|
func DeployAfunction() {
|
||||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := functionService.Call(&function.CallRequest{
|
rsp, err := functionService.Deploy(&function.DeployRequest{
|
||||||
|
Branch: "main",
|
||||||
|
Entrypoint: "Helloworld",
|
||||||
|
Name: "helloworld",
|
||||||
|
Region: "europe-west1",
|
||||||
|
Repo: "https://github.com/m3o/m3o",
|
||||||
|
Runtime: "go116",
|
||||||
|
Subfolder: "examples/go-function",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Update
|
||||||
|
|
||||||
|
Update a function. Downloads the source, builds and redeploys
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/function/api#Update](https://m3o.com/function/api#Update)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/function"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Update a function. Downloads the source, builds and redeploys
|
||||||
|
func UpdateAfunction() {
|
||||||
|
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := functionService.Update(&function.UpdateRequest{
|
||||||
Name: "helloworld",
|
Name: "helloworld",
|
||||||
Request: map[string]interface{}{
|
|
||||||
"name": "Alice",
|
})
|
||||||
},
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Proxy
|
||||||
|
|
||||||
|
Return the backend url for proxying
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/function/api#Proxy](https://m3o.com/function/api#Proxy)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/function"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Return the backend url for proxying
|
||||||
|
func ProxyUrl() {
|
||||||
|
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := functionService.Proxy(&function.ProxyRequest{
|
||||||
|
Id: "helloworld",
|
||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|||||||
@@ -4,125 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/image/api](htt
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
## Resize
|
|
||||||
|
|
||||||
Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters.
|
|
||||||
If one of width or height is 0, the image aspect ratio is preserved.
|
|
||||||
Optional cropping.
|
|
||||||
To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
|
|
||||||
with each parameter as a form field.
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/image/api#Resize](https://m3o.com/image/api#Resize)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/image"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters.
|
|
||||||
// If one of width or height is 0, the image aspect ratio is preserved.
|
|
||||||
// Optional cropping.
|
|
||||||
// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
|
|
||||||
// with each parameter as a form field.
|
|
||||||
func Base64toHostedImage() {
|
|
||||||
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := imageService.Resize(&image.ResizeRequest{
|
|
||||||
Base64: "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==",
|
|
||||||
Height: 100,
|
|
||||||
Name: "cat.png",
|
|
||||||
Width: 100,
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Resize
|
|
||||||
|
|
||||||
Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters.
|
|
||||||
If one of width or height is 0, the image aspect ratio is preserved.
|
|
||||||
Optional cropping.
|
|
||||||
To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
|
|
||||||
with each parameter as a form field.
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/image/api#Resize](https://m3o.com/image/api#Resize)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/image"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters.
|
|
||||||
// If one of width or height is 0, the image aspect ratio is preserved.
|
|
||||||
// Optional cropping.
|
|
||||||
// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
|
|
||||||
// with each parameter as a form field.
|
|
||||||
func Base64toBase64image() {
|
|
||||||
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := imageService.Resize(&image.ResizeRequest{
|
|
||||||
Base64: "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==",
|
|
||||||
Height: 100,
|
|
||||||
Width: 100,
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Resize
|
|
||||||
|
|
||||||
Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters.
|
|
||||||
If one of width or height is 0, the image aspect ratio is preserved.
|
|
||||||
Optional cropping.
|
|
||||||
To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
|
|
||||||
with each parameter as a form field.
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/image/api#Resize](https://m3o.com/image/api#Resize)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/image"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters.
|
|
||||||
// If one of width or height is 0, the image aspect ratio is preserved.
|
|
||||||
// Optional cropping.
|
|
||||||
// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
|
|
||||||
// with each parameter as a form field.
|
|
||||||
func Base64toBase64imageWithCropping() {
|
|
||||||
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := imageService.Resize(&image.ResizeRequest{
|
|
||||||
Base64: "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==",
|
|
||||||
CropOptions: &image.CropOptions{
|
|
||||||
Height: 50,
|
|
||||||
Width: 50,
|
|
||||||
},
|
|
||||||
Height: 100,
|
|
||||||
Width: 100,
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Convert
|
## Convert
|
||||||
|
|
||||||
Convert an image from one format (jpeg, png etc.) to an other either on the fly (from base64 to base64),
|
Convert an image from one format (jpeg, png etc.) to an other either on the fly (from base64 to base64),
|
||||||
@@ -256,3 +137,122 @@ func DeleteAnUploadedImage() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
## Resize
|
||||||
|
|
||||||
|
Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters.
|
||||||
|
If one of width or height is 0, the image aspect ratio is preserved.
|
||||||
|
Optional cropping.
|
||||||
|
To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
|
||||||
|
with each parameter as a form field.
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/image/api#Resize](https://m3o.com/image/api#Resize)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/image"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters.
|
||||||
|
// If one of width or height is 0, the image aspect ratio is preserved.
|
||||||
|
// Optional cropping.
|
||||||
|
// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
|
||||||
|
// with each parameter as a form field.
|
||||||
|
func Base64toHostedImage() {
|
||||||
|
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := imageService.Resize(&image.ResizeRequest{
|
||||||
|
Base64: "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==",
|
||||||
|
Height: 100,
|
||||||
|
Name: "cat.png",
|
||||||
|
Width: 100,
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Resize
|
||||||
|
|
||||||
|
Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters.
|
||||||
|
If one of width or height is 0, the image aspect ratio is preserved.
|
||||||
|
Optional cropping.
|
||||||
|
To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
|
||||||
|
with each parameter as a form field.
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/image/api#Resize](https://m3o.com/image/api#Resize)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/image"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters.
|
||||||
|
// If one of width or height is 0, the image aspect ratio is preserved.
|
||||||
|
// Optional cropping.
|
||||||
|
// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
|
||||||
|
// with each parameter as a form field.
|
||||||
|
func Base64toBase64image() {
|
||||||
|
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := imageService.Resize(&image.ResizeRequest{
|
||||||
|
Base64: "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==",
|
||||||
|
Height: 100,
|
||||||
|
Width: 100,
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Resize
|
||||||
|
|
||||||
|
Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters.
|
||||||
|
If one of width or height is 0, the image aspect ratio is preserved.
|
||||||
|
Optional cropping.
|
||||||
|
To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
|
||||||
|
with each parameter as a form field.
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/image/api#Resize](https://m3o.com/image/api#Resize)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/image"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters.
|
||||||
|
// If one of width or height is 0, the image aspect ratio is preserved.
|
||||||
|
// Optional cropping.
|
||||||
|
// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
|
||||||
|
// with each parameter as a form field.
|
||||||
|
func Base64toBase64imageWithCropping() {
|
||||||
|
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := imageService.Resize(&image.ResizeRequest{
|
||||||
|
Base64: "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==",
|
||||||
|
CropOptions: &image.CropOptions{
|
||||||
|
Height: 50,
|
||||||
|
Width: 50,
|
||||||
|
},
|
||||||
|
Height: 100,
|
||||||
|
Width: 100,
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
@@ -4,6 +4,42 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/location/api](
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
|
## Save
|
||||||
|
|
||||||
|
Save an entity's current position
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/location/api#Save](https://m3o.com/location/api#Save)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/location"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Save an entity's current position
|
||||||
|
func SaveAnEntity() {
|
||||||
|
locationService := location.NewLocationService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := locationService.Save(&location.SaveRequest{
|
||||||
|
Entity: &location.Entity{
|
||||||
|
Id: "1",
|
||||||
|
Location: &location.Point{
|
||||||
|
Latitude: 51.511061,
|
||||||
|
Longitude: -0.120022,
|
||||||
|
Timestamp: 1622802761,
|
||||||
|
},
|
||||||
|
Type: "bike",
|
||||||
|
},
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
## Read
|
## Read
|
||||||
|
|
||||||
Read an entity by its ID
|
Read an entity by its ID
|
||||||
@@ -66,39 +102,3 @@ Type: "bike",
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Save
|
|
||||||
|
|
||||||
Save an entity's current position
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/location/api#Save](https://m3o.com/location/api#Save)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/location"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Save an entity's current position
|
|
||||||
func SaveAnEntity() {
|
|
||||||
locationService := location.NewLocationService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := locationService.Save(&location.SaveRequest{
|
|
||||||
Entity: &location.Entity{
|
|
||||||
Id: "1",
|
|
||||||
Location: &location.Point{
|
|
||||||
Latitude: 51.511061,
|
|
||||||
Longitude: -0.120022,
|
|
||||||
Timestamp: 1622802761,
|
|
||||||
},
|
|
||||||
Type: "bike",
|
|
||||||
},
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|||||||
@@ -4,33 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/memegen/api](h
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
## Templates
|
|
||||||
|
|
||||||
List the available templates
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/memegen/api#Templates](https://m3o.com/memegen/api#Templates)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/memegen"
|
|
||||||
)
|
|
||||||
|
|
||||||
// List the available templates
|
|
||||||
func MemeTemplates() {
|
|
||||||
memegenService := memegen.NewMemegenService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := memegenService.Templates(&memegen.TemplatesRequest{
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Generate
|
## Generate
|
||||||
|
|
||||||
Generate a meme using a template
|
Generate a meme using a template
|
||||||
@@ -59,3 +32,30 @@ func GenerateAmeme() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
## Templates
|
||||||
|
|
||||||
|
List the available templates
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/memegen/api#Templates](https://m3o.com/memegen/api#Templates)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/memegen"
|
||||||
|
)
|
||||||
|
|
||||||
|
// List the available templates
|
||||||
|
func MemeTemplates() {
|
||||||
|
memegenService := memegen.NewMemegenService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := memegenService.Templates(&memegen.TemplatesRequest{
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
@@ -26,9 +26,9 @@ func PublishAmessage() {
|
|||||||
mqService := mq.NewMqService(os.Getenv("M3O_API_TOKEN"))
|
mqService := mq.NewMqService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := mqService.Publish(&mq.PublishRequest{
|
rsp, err := mqService.Publish(&mq.PublishRequest{
|
||||||
Message: map[string]interface{}{
|
Message: map[string]interface{}{
|
||||||
"user": "john",
|
|
||||||
"id": "1",
|
"id": "1",
|
||||||
"type": "signup",
|
"type": "signup",
|
||||||
|
"user": "john",
|
||||||
},
|
},
|
||||||
Topic: "events",
|
Topic: "events",
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,61 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/notes/api](htt
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
|
## Read
|
||||||
|
|
||||||
|
Read a note
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/notes/api#Read](https://m3o.com/notes/api#Read)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/notes"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Read a note
|
||||||
|
func ReadAnote() {
|
||||||
|
notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := notesService.Read(¬es.ReadRequest{
|
||||||
|
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## List
|
||||||
|
|
||||||
|
List all the notes
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/notes/api#List](https://m3o.com/notes/api#List)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/notes"
|
||||||
|
)
|
||||||
|
|
||||||
|
// List all the notes
|
||||||
|
func ListAllNotes() {
|
||||||
|
notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := notesService.List(¬es.ListRequest{
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
## Update
|
## Update
|
||||||
|
|
||||||
Update a note
|
Update a note
|
||||||
@@ -134,58 +189,3 @@ Title: "New Note",
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Read
|
|
||||||
|
|
||||||
Read a note
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/notes/api#Read](https://m3o.com/notes/api#Read)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/notes"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Read a note
|
|
||||||
func ReadAnote() {
|
|
||||||
notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := notesService.Read(¬es.ReadRequest{
|
|
||||||
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## List
|
|
||||||
|
|
||||||
List all the notes
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/notes/api#List](https://m3o.com/notes/api#List)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/notes"
|
|
||||||
)
|
|
||||||
|
|
||||||
// List all the notes
|
|
||||||
func ListAllNotes() {
|
|
||||||
notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := notesService.List(¬es.ListRequest{
|
|
||||||
|
|
||||||
})
|
|
||||||
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,41 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/routing/api](h
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
|
## Eta
|
||||||
|
|
||||||
|
Get the eta for a route from origin to destination. The eta is an estimated time based on car routes
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/routing/api#Eta](https://m3o.com/routing/api#Eta)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/routing"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Get the eta for a route from origin to destination. The eta is an estimated time based on car routes
|
||||||
|
func EtaFromPointAtoPointB() {
|
||||||
|
routingService := routing.NewRoutingService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := routingService.Eta(&routing.EtaRequest{
|
||||||
|
Destination: &routing.Point{
|
||||||
|
Latitude: 52.529407,
|
||||||
|
Longitude: 13.397634,
|
||||||
|
},
|
||||||
|
Origin: &routing.Point{
|
||||||
|
Latitude: 52.517037,
|
||||||
|
Longitude: 13.38886,
|
||||||
|
},
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
## Directions
|
## Directions
|
||||||
|
|
||||||
Turn by turn directions from a start point to an end point including maneuvers and bearings
|
Turn by turn directions from a start point to an end point including maneuvers and bearings
|
||||||
@@ -74,38 +109,3 @@ Origin: &routing.Point{
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Eta
|
|
||||||
|
|
||||||
Get the eta for a route from origin to destination. The eta is an estimated time based on car routes
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/routing/api#Eta](https://m3o.com/routing/api#Eta)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/routing"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Get the eta for a route from origin to destination. The eta is an estimated time based on car routes
|
|
||||||
func EtaFromPointAtoPointB() {
|
|
||||||
routingService := routing.NewRoutingService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := routingService.Eta(&routing.EtaRequest{
|
|
||||||
Destination: &routing.Point{
|
|
||||||
Latitude: 52.529407,
|
|
||||||
Longitude: 13.397634,
|
|
||||||
},
|
|
||||||
Origin: &routing.Point{
|
|
||||||
Latitude: 52.517037,
|
|
||||||
Longitude: 13.38886,
|
|
||||||
},
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|||||||
@@ -4,6 +4,36 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/rss/api](https
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
|
## Add
|
||||||
|
|
||||||
|
Add a new RSS feed with a name, url, and category
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/rss/api#Add](https://m3o.com/rss/api#Add)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/rss"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Add a new RSS feed with a name, url, and category
|
||||||
|
func AddAnewFeed() {
|
||||||
|
rssService := rss.NewRssService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := rssService.Add(&rss.AddRequest{
|
||||||
|
Category: "news",
|
||||||
|
Name: "bbc",
|
||||||
|
Url: "http://feeds.bbci.co.uk/news/rss.xml",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
## Feed
|
## Feed
|
||||||
|
|
||||||
Get an RSS feed by name. If no name is given, all feeds are returned. Default limit is 25 entries.
|
Get an RSS feed by name. If no name is given, all feeds are returned. Default limit is 25 entries.
|
||||||
@@ -87,33 +117,3 @@ func RemoveAfeed() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Add
|
|
||||||
|
|
||||||
Add a new RSS feed with a name, url, and category
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/rss/api#Add](https://m3o.com/rss/api#Add)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/rss"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Add a new RSS feed with a name, url, and category
|
|
||||||
func AddAnewFeed() {
|
|
||||||
rssService := rss.NewRssService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := rssService.Add(&rss.AddRequest{
|
|
||||||
Category: "news",
|
|
||||||
Name: "bbc",
|
|
||||||
Url: "http://feeds.bbci.co.uk/news/rss.xml",
|
|
||||||
|
|
||||||
})
|
|
||||||
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{}{
|
||||||
|
"name": "John Doe",
|
||||||
"age": 37,
|
"age": 37,
|
||||||
"starsign": "Leo",
|
"starsign": "Leo",
|
||||||
"name": "John Doe",
|
|
||||||
},
|
},
|
||||||
Index: "customers",
|
Index: "customers",
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -4,6 +4,36 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/space/api](htt
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
|
## Create
|
||||||
|
|
||||||
|
Create an object. Returns error if object with this name already exists. Max object size of 10MB, see Upload endpoint for larger objects. If you want to update an existing object use the `Update` endpoint
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/space/api#Create](https://m3o.com/space/api#Create)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/space"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Create an object. Returns error if object with this name already exists. Max object size of 10MB, see Upload endpoint for larger objects. If you want to update an existing object use the `Update` endpoint
|
||||||
|
func CreateAnObject() {
|
||||||
|
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := spaceService.Create(&space.CreateRequest{
|
||||||
|
Name: "images/file.jpg",
|
||||||
|
Object: "<file bytes>",
|
||||||
|
Visibility: "public",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
## Update
|
## Update
|
||||||
|
|
||||||
Update an object. If an object with this name does not exist, creates a new one.
|
Update an object. If an object with this name does not exist, creates a new one.
|
||||||
@@ -202,33 +232,3 @@ func UploadAnObject() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Create
|
|
||||||
|
|
||||||
Create an object. Returns error if object with this name already exists. Max object size of 10MB, see Upload endpoint for larger objects. If you want to update an existing object use the `Update` endpoint
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/space/api#Create](https://m3o.com/space/api#Create)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/space"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Create an object. Returns error if object with this name already exists. Max object size of 10MB, see Upload endpoint for larger objects. If you want to update an existing object use the `Update` endpoint
|
|
||||||
func CreateAnObject() {
|
|
||||||
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := spaceService.Create(&space.CreateRequest{
|
|
||||||
Name: "images/file.jpg",
|
|
||||||
Object: "<file bytes>",
|
|
||||||
Visibility: "public",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|||||||
@@ -4,6 +4,38 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/stock/api](htt
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
|
## OrderBook
|
||||||
|
|
||||||
|
Get the historic order book and each trade by timestamp
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/stock/api#OrderBook](https://m3o.com/stock/api#OrderBook)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/stock"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Get the historic order book and each trade by timestamp
|
||||||
|
func OrderBookHistory() {
|
||||||
|
stockService := stock.NewStockService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := stockService.OrderBook(&stock.OrderBookRequest{
|
||||||
|
Date: "2020-10-01",
|
||||||
|
End: "2020-10-01T11:00:00Z",
|
||||||
|
Limit: 3,
|
||||||
|
Start: "2020-10-01T10:00:00Z",
|
||||||
|
Stock: "AAPL",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
## Price
|
## Price
|
||||||
|
|
||||||
Get the last price for a given stock ticker
|
Get the last price for a given stock ticker
|
||||||
@@ -89,35 +121,3 @@ Stock: "AAPL",
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## OrderBook
|
|
||||||
|
|
||||||
Get the historic order book and each trade by timestamp
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/stock/api#OrderBook](https://m3o.com/stock/api#OrderBook)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/stock"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Get the historic order book and each trade by timestamp
|
|
||||||
func OrderBookHistory() {
|
|
||||||
stockService := stock.NewStockService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := stockService.OrderBook(&stock.OrderBookRequest{
|
|
||||||
Date: "2020-10-01",
|
|
||||||
End: "2020-10-01T11:00:00Z",
|
|
||||||
Limit: 3,
|
|
||||||
Start: "2020-10-01T10:00:00Z",
|
|
||||||
Stock: "AAPL",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|||||||
@@ -4,33 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/time/api](http
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
## Now
|
|
||||||
|
|
||||||
Get the current time
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/time/api#Now](https://m3o.com/time/api#Now)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/time"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Get the current time
|
|
||||||
func ReturnsCurrentTimeOptionallyWithLocation() {
|
|
||||||
timeService := time.NewTimeService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := timeService.Now(&time.NowRequest{
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Zone
|
## Zone
|
||||||
|
|
||||||
Get the timezone info for a specific location
|
Get the timezone info for a specific location
|
||||||
@@ -59,3 +32,30 @@ func GetTheTimezoneInfoForAspecificLocation() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
## Now
|
||||||
|
|
||||||
|
Get the current time
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/time/api#Now](https://m3o.com/time/api#Now)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Get the current time
|
||||||
|
func ReturnsCurrentTimeOptionallyWithLocation() {
|
||||||
|
timeService := time.NewTimeService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := timeService.Now(&time.NowRequest{
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
@@ -4,35 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/twitter/api](h
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
## Timeline
|
|
||||||
|
|
||||||
Get the timeline for a given user
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/twitter/api#Timeline](https://m3o.com/twitter/api#Timeline)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/twitter"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Get the timeline for a given user
|
|
||||||
func GetAtwitterTimeline() {
|
|
||||||
twitterService := twitter.NewTwitterService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := twitterService.Timeline(&twitter.TimelineRequest{
|
|
||||||
Limit: 1,
|
|
||||||
Username: "m3oservices",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Search
|
## Search
|
||||||
|
|
||||||
Search for tweets with a simple query
|
Search for tweets with a simple query
|
||||||
@@ -116,3 +87,32 @@ func GetAusersTwitterProfile() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
## Timeline
|
||||||
|
|
||||||
|
Get the timeline for a given user
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/twitter/api#Timeline](https://m3o.com/twitter/api#Timeline)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/twitter"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Get the timeline for a given user
|
||||||
|
func GetAtwitterTimeline() {
|
||||||
|
twitterService := twitter.NewTwitterService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := twitterService.Timeline(&twitter.TimelineRequest{
|
||||||
|
Limit: 1,
|
||||||
|
Username: "m3oservices",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
@@ -4,33 +4,6 @@ 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
|
||||||
@@ -85,3 +58,30 @@ 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,392 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/user/api](http
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
## 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)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## 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)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## UpdatePassword
|
|
||||||
|
|
||||||
Update the account password
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/user/api#UpdatePassword](https://m3o.com/user/api#UpdatePassword)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/user"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Update the account password
|
|
||||||
func UpdateTheAccountPassword() {
|
|
||||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := userService.UpdatePassword(&user.UpdatePasswordRequest{
|
|
||||||
ConfirmPassword: "Password2",
|
|
||||||
NewPassword: "Password2",
|
|
||||||
OldPassword: "Password1",
|
|
||||||
UserId: "user-1",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## List
|
|
||||||
|
|
||||||
List all users. Returns a paged list of results
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/user/api#List](https://m3o.com/user/api#List)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/user"
|
|
||||||
)
|
|
||||||
|
|
||||||
// List all users. Returns a paged list of results
|
|
||||||
func ListAllUsers() {
|
|
||||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := userService.List(&user.ListRequest{
|
|
||||||
Limit: 100,
|
|
||||||
Offset: 0,
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## 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)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## 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)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## 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)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## VerifyToken
|
|
||||||
|
|
||||||
Check whether the token attached to MagicLink is valid or not.
|
|
||||||
Ideally, you need to call this endpoint from your http request
|
|
||||||
handler that handles the endpoint which is specified in the
|
|
||||||
SendMagicLink request.
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/user/api#VerifyToken](https://m3o.com/user/api#VerifyToken)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/user"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Check whether the token attached to MagicLink is valid or not.
|
|
||||||
// Ideally, you need to call this endpoint from your http request
|
|
||||||
// handler that handles the endpoint which is specified in the
|
|
||||||
// SendMagicLink request.
|
|
||||||
func VerifyAtoken() {
|
|
||||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := userService.VerifyToken(&user.VerifyTokenRequest{
|
|
||||||
Token: "EdsUiidouJJJLldjlloofUiorkojflsWWdld",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## SendVerificationEmail
|
|
||||||
|
|
||||||
Send a verification email to a user.
|
|
||||||
Email "from" will be 'noreply@email.m3ocontent.com'.
|
|
||||||
The verification link will be injected in the email
|
|
||||||
as a template variable, $micro_verification_link e.g
|
|
||||||
'Welcome to M3O! Use the link below to verify your email: $micro_verification_link'
|
|
||||||
The variable will be replaced with a url similar to:
|
|
||||||
'https://user.m3o.com/user/verify?token=a-verification-token&redirectUrl=your-redir-url'
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/user/api#SendVerificationEmail](https://m3o.com/user/api#SendVerificationEmail)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/user"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Send a verification email to a user.
|
|
||||||
// Email "from" will be 'noreply@email.m3ocontent.com'.
|
|
||||||
// The verification link will be injected in the email
|
|
||||||
// as a template variable, $micro_verification_link e.g
|
|
||||||
// 'Welcome to M3O! Use the link below to verify your email: $micro_verification_link'
|
|
||||||
// The variable will be replaced with a url similar to:
|
|
||||||
// 'https://user.m3o.com/user/verify?token=a-verification-token&redirectUrl=your-redir-url'
|
|
||||||
func SendVerificationEmail() {
|
|
||||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := userService.SendVerificationEmail(&user.SendVerificationEmailRequest{
|
|
||||||
Email: "joe@example.com",
|
|
||||||
FailureRedirectUrl: "https://m3o.com/verification-failed",
|
|
||||||
FromName: "Awesome Dot Com",
|
|
||||||
RedirectUrl: "https://m3o.com",
|
|
||||||
Subject: "Email verification",
|
|
||||||
TextContent: `Hi there,
|
|
||||||
|
|
||||||
Please verify your email by clicking this link: $micro_verification_link`,
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## SendPasswordResetEmail
|
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Delete
|
## Delete
|
||||||
|
|
||||||
Delete an account by id
|
Delete an account by id
|
||||||
@@ -447,6 +61,162 @@ Username: "joe",
|
|||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
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)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## List
|
||||||
|
|
||||||
|
List all users. Returns a paged list of results
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/user/api#List](https://m3o.com/user/api#List)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/user"
|
||||||
|
)
|
||||||
|
|
||||||
|
// List all users. Returns a paged list of results
|
||||||
|
func ListAllUsers() {
|
||||||
|
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := userService.List(&user.ListRequest{
|
||||||
|
Limit: 100,
|
||||||
|
Offset: 0,
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## VerifyToken
|
||||||
|
|
||||||
|
Check whether the token attached to MagicLink is valid or not.
|
||||||
|
Ideally, you need to call this endpoint from your http request
|
||||||
|
handler that handles the endpoint which is specified in the
|
||||||
|
SendMagicLink request.
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/user/api#VerifyToken](https://m3o.com/user/api#VerifyToken)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/user"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Check whether the token attached to MagicLink is valid or not.
|
||||||
|
// Ideally, you need to call this endpoint from your http request
|
||||||
|
// handler that handles the endpoint which is specified in the
|
||||||
|
// SendMagicLink request.
|
||||||
|
func VerifyAtoken() {
|
||||||
|
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := userService.VerifyToken(&user.VerifyTokenRequest{
|
||||||
|
Token: "EdsUiidouJJJLldjlloofUiorkojflsWWdld",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## ResetPassword
|
||||||
|
|
||||||
|
Reset password with the code sent by the "SendPasswordResetEmail" endpoint.
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/user/api#ResetPassword](https://m3o.com/user/api#ResetPassword)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/user"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Reset password with the code sent by the "SendPasswordResetEmail" endpoint.
|
||||||
|
func ResetPassword() {
|
||||||
|
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := userService.ResetPassword(&user.ResetPasswordRequest{
|
||||||
|
Code: "012345",
|
||||||
|
ConfirmPassword: "NewPassword1",
|
||||||
|
Email: "joe@example.com",
|
||||||
|
NewPassword: "NewPassword1",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## 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)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Read
|
## Read
|
||||||
@@ -533,3 +303,233 @@ func ReadAccountByEmail() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
## UpdatePassword
|
||||||
|
|
||||||
|
Update the account password
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/user/api#UpdatePassword](https://m3o.com/user/api#UpdatePassword)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/user"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Update the account password
|
||||||
|
func UpdateTheAccountPassword() {
|
||||||
|
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := userService.UpdatePassword(&user.UpdatePasswordRequest{
|
||||||
|
ConfirmPassword: "Password2",
|
||||||
|
NewPassword: "Password2",
|
||||||
|
OldPassword: "Password1",
|
||||||
|
UserId: "user-1",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## SendVerificationEmail
|
||||||
|
|
||||||
|
Send a verification email to a user.
|
||||||
|
Email "from" will be 'noreply@email.m3ocontent.com'.
|
||||||
|
The verification link will be injected in the email
|
||||||
|
as a template variable, $micro_verification_link e.g
|
||||||
|
'Welcome to M3O! Use the link below to verify your email: $micro_verification_link'
|
||||||
|
The variable will be replaced with a url similar to:
|
||||||
|
'https://user.m3o.com/user/verify?token=a-verification-token&redirectUrl=your-redir-url'
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/user/api#SendVerificationEmail](https://m3o.com/user/api#SendVerificationEmail)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/user"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Send a verification email to a user.
|
||||||
|
// Email "from" will be 'noreply@email.m3ocontent.com'.
|
||||||
|
// The verification link will be injected in the email
|
||||||
|
// as a template variable, $micro_verification_link e.g
|
||||||
|
// 'Welcome to M3O! Use the link below to verify your email: $micro_verification_link'
|
||||||
|
// The variable will be replaced with a url similar to:
|
||||||
|
// 'https://user.m3o.com/user/verify?token=a-verification-token&redirectUrl=your-redir-url'
|
||||||
|
func SendVerificationEmail() {
|
||||||
|
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := userService.SendVerificationEmail(&user.SendVerificationEmailRequest{
|
||||||
|
Email: "joe@example.com",
|
||||||
|
FailureRedirectUrl: "https://m3o.com/verification-failed",
|
||||||
|
FromName: "Awesome Dot Com",
|
||||||
|
RedirectUrl: "https://m3o.com",
|
||||||
|
Subject: "Email verification",
|
||||||
|
TextContent: `Hi there,
|
||||||
|
|
||||||
|
Please verify your email by clicking this link: $micro_verification_link`,
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## VerifyEmail
|
||||||
|
|
||||||
|
Verify the email address of an account from a token sent in an email to the user.
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/user/api#VerifyEmail](https://m3o.com/user/api#VerifyEmail)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/user"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Verify the email address of an account from a token sent in an email to the user.
|
||||||
|
func VerifyEmail() {
|
||||||
|
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := userService.VerifyEmail(&user.VerifyEmailRequest{
|
||||||
|
Token: "012345",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Login
|
||||||
|
|
||||||
|
Login using username or email. The response will return a new session for successful login,
|
||||||
|
401 in the case of login failure and 500 for any other error
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/user/api#Login](https://m3o.com/user/api#Login)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/user"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Login using username or email. The response will return a new session for successful login,
|
||||||
|
// 401 in the case of login failure and 500 for any other error
|
||||||
|
func LogAuserIn() {
|
||||||
|
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := userService.Login(&user.LoginRequest{
|
||||||
|
Email: "joe@example.com",
|
||||||
|
Password: "Password1",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## 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)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## 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)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user