mirror of
https://github.com/kevin-DL/m3o-go.git
synced 2026-01-11 18:44:26 +00:00
Commit from m3o/m3o action
This commit is contained in:
@@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/app/api](https
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Delete
|
||||
|
||||
Delete an app
|
||||
|
||||
|
||||
[https://m3o.com/app/api#Delete](https://m3o.com/app/api#Delete)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/app"
|
||||
)
|
||||
|
||||
// Delete an app
|
||||
func DeleteAnApp() {
|
||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := appService.Delete(&app.DeleteRequest{
|
||||
Name: "helloworld",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Reserve
|
||||
|
||||
Reserve apps beyond the free quota. Call Run after.
|
||||
@@ -202,31 +230,3 @@ func UpdateAnApp() {
|
||||
|
||||
}
|
||||
```
|
||||
## Delete
|
||||
|
||||
Delete an app
|
||||
|
||||
|
||||
[https://m3o.com/app/api#Delete](https://m3o.com/app/api#Delete)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/app"
|
||||
)
|
||||
|
||||
// Delete an app
|
||||
func DeleteAnApp() {
|
||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := appService.Delete(&app.DeleteRequest{
|
||||
Name: "helloworld",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
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:
|
||||
|
||||
## 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 a value (if it's a number). If key not found it is equivalent to set.
|
||||
|
||||
|
||||
[https://m3o.com/cache/api#Decrement](https://m3o.com/cache/api#Decrement)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/cache"
|
||||
)
|
||||
|
||||
// Decrement a value (if it's a number). If key not found it is equivalent to set.
|
||||
func DecrementAvalue() {
|
||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := cacheService.Decrement(&cache.DecrementRequest{
|
||||
Key: "counter",
|
||||
Value: 2,
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## ListKeys
|
||||
|
||||
List all the available keys
|
||||
|
||||
|
||||
[https://m3o.com/cache/api#ListKeys](https://m3o.com/cache/api#ListKeys)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/cache"
|
||||
)
|
||||
|
||||
// List all the available keys
|
||||
func ListTheKeys() {
|
||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := cacheService.ListKeys(&cache.ListKeysRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Set
|
||||
|
||||
Set an item in the cache. Overwrites any existing value already set.
|
||||
@@ -174,3 +89,88 @@ func DeleteAvalue() {
|
||||
|
||||
}
|
||||
```
|
||||
## 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 a value (if it's a number). If key not found it is equivalent to set.
|
||||
|
||||
|
||||
[https://m3o.com/cache/api#Decrement](https://m3o.com/cache/api#Decrement)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/cache"
|
||||
)
|
||||
|
||||
// Decrement a value (if it's a number). If key not found it is equivalent to set.
|
||||
func DecrementAvalue() {
|
||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := cacheService.Decrement(&cache.DecrementRequest{
|
||||
Key: "counter",
|
||||
Value: 2,
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## ListKeys
|
||||
|
||||
List all the available keys
|
||||
|
||||
|
||||
[https://m3o.com/cache/api#ListKeys](https://m3o.com/cache/api#ListKeys)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/cache"
|
||||
)
|
||||
|
||||
// List all the available keys
|
||||
func ListTheKeys() {
|
||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := cacheService.ListKeys(&cache.ListKeysRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,6 +4,60 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/chat/api](http
|
||||
|
||||
Endpoints:
|
||||
|
||||
## 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)
|
||||
|
||||
}
|
||||
```
|
||||
## Kick
|
||||
|
||||
Kick a user from a chat room
|
||||
|
||||
|
||||
[https://m3o.com/chat/api#Kick](https://m3o.com/chat/api#Kick)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/chat"
|
||||
)
|
||||
|
||||
// Kick a user from a chat room
|
||||
func KickAuserFromAroom() {
|
||||
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := chatService.Kick(&chat.KickRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Leave
|
||||
|
||||
Leave a chat room
|
||||
@@ -29,6 +83,33 @@ func LeaveAroom() {
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## List
|
||||
|
||||
List available chats
|
||||
|
||||
|
||||
[https://m3o.com/chat/api#List](https://m3o.com/chat/api#List)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/chat"
|
||||
)
|
||||
|
||||
// List available chats
|
||||
func ListChatRooms() {
|
||||
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := chatService.List(&chat.ListRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Delete
|
||||
@@ -56,33 +137,6 @@ func DeleteAchat() {
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Invite
|
||||
|
||||
Invite a user to a chat room
|
||||
|
||||
|
||||
[https://m3o.com/chat/api#Invite](https://m3o.com/chat/api#Invite)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/chat"
|
||||
)
|
||||
|
||||
// Invite a user to a chat room
|
||||
func InviteAuser() {
|
||||
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := chatService.Invite(&chat.InviteRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Send
|
||||
@@ -115,116 +169,6 @@ Text: "Hey whats up?",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Kick
|
||||
|
||||
Kick a user from a chat room
|
||||
|
||||
|
||||
[https://m3o.com/chat/api#Kick](https://m3o.com/chat/api#Kick)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/chat"
|
||||
)
|
||||
|
||||
// Kick a user from a chat room
|
||||
func KickAuserFromAroom() {
|
||||
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := chatService.Kick(&chat.KickRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## New
|
||||
|
||||
Create a new chat room
|
||||
|
||||
|
||||
[https://m3o.com/chat/api#New](https://m3o.com/chat/api#New)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/chat"
|
||||
)
|
||||
|
||||
// Create a new chat room
|
||||
func CreateAnewChat() {
|
||||
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := chatService.New(&chat.NewRequest{
|
||||
Description: "The general chat room",
|
||||
Name: "general",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## List
|
||||
|
||||
List available chats
|
||||
|
||||
|
||||
[https://m3o.com/chat/api#List](https://m3o.com/chat/api#List)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/chat"
|
||||
)
|
||||
|
||||
// List available chats
|
||||
func ListChatRooms() {
|
||||
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := chatService.List(&chat.ListRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## History
|
||||
|
||||
List the messages in a chat
|
||||
|
||||
|
||||
[https://m3o.com/chat/api#History](https://m3o.com/chat/api#History)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/chat"
|
||||
)
|
||||
|
||||
// List the messages in a chat
|
||||
func GetChatHistory() {
|
||||
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := chatService.History(&chat.HistoryRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Join
|
||||
@@ -267,3 +211,59 @@ func JoinAroom() {
|
||||
}
|
||||
}
|
||||
```
|
||||
## New
|
||||
|
||||
Create a new chat room
|
||||
|
||||
|
||||
[https://m3o.com/chat/api#New](https://m3o.com/chat/api#New)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/chat"
|
||||
)
|
||||
|
||||
// Create a new chat room
|
||||
func CreateAnewChat() {
|
||||
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := chatService.New(&chat.NewRequest{
|
||||
Description: "The general chat room",
|
||||
Name: "general",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Invite
|
||||
|
||||
Invite a user to a chat room
|
||||
|
||||
|
||||
[https://m3o.com/chat/api#Invite](https://m3o.com/chat/api#Invite)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/chat"
|
||||
)
|
||||
|
||||
// Invite a user to a chat room
|
||||
func InviteAuser() {
|
||||
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := chatService.Invite(&chat.InviteRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,62 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/contact/api](h
|
||||
|
||||
Endpoints:
|
||||
|
||||
## List
|
||||
|
||||
|
||||
|
||||
|
||||
[https://m3o.com/contact/api#List](https://m3o.com/contact/api#List)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/contact"
|
||||
)
|
||||
|
||||
//
|
||||
func ListContactsWithDefaultOffsetAndLimitDefaultLimitIs20() {
|
||||
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := contactService.List(&contact.ListRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## List
|
||||
|
||||
|
||||
|
||||
|
||||
[https://m3o.com/contact/api#List](https://m3o.com/contact/api#List)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/contact"
|
||||
)
|
||||
|
||||
//
|
||||
func ListContactsWithSpecificOffsetAndLimit() {
|
||||
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := contactService.List(&contact.ListRequest{
|
||||
Limit: 1,
|
||||
Offset: 1,
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Create
|
||||
|
||||
|
||||
@@ -217,3 +161,59 @@ func DeleteAcontact() {
|
||||
|
||||
}
|
||||
```
|
||||
## List
|
||||
|
||||
|
||||
|
||||
|
||||
[https://m3o.com/contact/api#List](https://m3o.com/contact/api#List)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/contact"
|
||||
)
|
||||
|
||||
//
|
||||
func ListContactsWithDefaultOffsetAndLimitDefaultLimitIs20() {
|
||||
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := contactService.List(&contact.ListRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## List
|
||||
|
||||
|
||||
|
||||
|
||||
[https://m3o.com/contact/api#List](https://m3o.com/contact/api#List)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/contact"
|
||||
)
|
||||
|
||||
//
|
||||
func ListContactsWithSpecificOffsetAndLimit() {
|
||||
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := contactService.List(&contact.ListRequest{
|
||||
Limit: 1,
|
||||
Offset: 1,
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,6 +4,35 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/currency/api](
|
||||
|
||||
Endpoints:
|
||||
|
||||
## History
|
||||
|
||||
Returns the historic rates for a currency on a given date
|
||||
|
||||
|
||||
[https://m3o.com/currency/api#History](https://m3o.com/currency/api#History)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/currency"
|
||||
)
|
||||
|
||||
// Returns the historic rates for a currency on a given date
|
||||
func HistoricRatesForAcurrency() {
|
||||
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := currencyService.History(¤cy.HistoryRequest{
|
||||
Code: "USD",
|
||||
Date: "2021-05-30",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Codes
|
||||
|
||||
Codes returns the supported currency codes for the API
|
||||
@@ -118,32 +147,3 @@ To: "GBP",
|
||||
|
||||
}
|
||||
```
|
||||
## History
|
||||
|
||||
Returns the historic rates for a currency on a given date
|
||||
|
||||
|
||||
[https://m3o.com/currency/api#History](https://m3o.com/currency/api#History)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/currency"
|
||||
)
|
||||
|
||||
// Returns the historic rates for a currency on a given date
|
||||
func HistoricRatesForAcurrency() {
|
||||
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := currencyService.History(¤cy.HistoryRequest{
|
||||
Code: "USD",
|
||||
Date: "2021-05-30",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,40 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/db/api](https:
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Create
|
||||
|
||||
Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
|
||||
|
||||
|
||||
[https://m3o.com/db/api#Create](https://m3o.com/db/api#Create)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/db"
|
||||
)
|
||||
|
||||
// Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
|
||||
func CreateArecord() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.Create(&db.CreateRequest{
|
||||
Record: map[string]interface{}{
|
||||
"name": "Jane",
|
||||
"age": 42,
|
||||
"isActive": true,
|
||||
"id": "1",
|
||||
},
|
||||
Table: "example",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Update
|
||||
|
||||
Update a record in the database. Include an "id" in the record to update.
|
||||
@@ -60,71 +26,14 @@ func UpdateArecord() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.Update(&db.UpdateRequest{
|
||||
Record: map[string]interface{}{
|
||||
"id": "1",
|
||||
"age": 43,
|
||||
"id": "1",
|
||||
},
|
||||
Table: "example",
|
||||
|
||||
})
|
||||
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)
|
||||
|
||||
}
|
||||
```
|
||||
## DropTable
|
||||
|
||||
Drop a table in the DB
|
||||
|
||||
|
||||
[https://m3o.com/db/api#DropTable](https://m3o.com/db/api#DropTable)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/db"
|
||||
)
|
||||
|
||||
// Drop a table in the DB
|
||||
func DropTable() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.DropTable(&db.DropTableRequest{
|
||||
Table: "example",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Count
|
||||
@@ -180,6 +89,40 @@ func ListTables() {
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Create
|
||||
|
||||
Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
|
||||
|
||||
|
||||
[https://m3o.com/db/api#Create](https://m3o.com/db/api#Create)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/db"
|
||||
)
|
||||
|
||||
// Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
|
||||
func CreateArecord() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.Create(&db.CreateRequest{
|
||||
Record: map[string]interface{}{
|
||||
"isActive": true,
|
||||
"id": "1",
|
||||
"name": "Jane",
|
||||
"age": 42,
|
||||
},
|
||||
Table: "example",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Read
|
||||
@@ -268,3 +211,60 @@ func TruncateTable() {
|
||||
|
||||
}
|
||||
```
|
||||
## 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)
|
||||
|
||||
}
|
||||
```
|
||||
## 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)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -12,10 +12,10 @@ func main() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.Create(&db.CreateRequest{
|
||||
Record: map[string]interface{}{
|
||||
"age": 42,
|
||||
"isActive": true,
|
||||
"id": "1",
|
||||
"name": "Jane",
|
||||
"age": 42,
|
||||
},
|
||||
Table: "example",
|
||||
})
|
||||
|
||||
@@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/email/api](htt
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Validate
|
||||
|
||||
Validate an email address format
|
||||
|
||||
|
||||
[https://m3o.com/email/api#Validate](https://m3o.com/email/api#Validate)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/email"
|
||||
)
|
||||
|
||||
// Validate an email address format
|
||||
func ValidateEmail() {
|
||||
emailService := email.NewEmailService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := emailService.Validate(&email.ValidateRequest{
|
||||
Address: "joe@example.com",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Send
|
||||
|
||||
Send an email by passing in from, to, subject, and a text or html body
|
||||
@@ -64,31 +92,3 @@ func ParseEmail() {
|
||||
|
||||
}
|
||||
```
|
||||
## Validate
|
||||
|
||||
Validate an email address format
|
||||
|
||||
|
||||
[https://m3o.com/email/api#Validate](https://m3o.com/email/api#Validate)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/email"
|
||||
)
|
||||
|
||||
// Validate an email address format
|
||||
func ValidateEmail() {
|
||||
emailService := email.NewEmailService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := emailService.Validate(&email.ValidateRequest{
|
||||
Address: "joe@example.com",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/emoji/api](htt
|
||||
|
||||
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
|
||||
|
||||
Get the flag for a country. Requires country code e.g GB for great britain
|
||||
@@ -119,3 +91,31 @@ To: "+44782669123",
|
||||
|
||||
}
|
||||
```
|
||||
## 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,39 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/event/api](htt
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Publish
|
||||
|
||||
Publish a event to the event stream.
|
||||
|
||||
|
||||
[https://m3o.com/event/api#Publish](https://m3o.com/event/api#Publish)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/event"
|
||||
)
|
||||
|
||||
// Publish a event to the event stream.
|
||||
func PublishAnEvent() {
|
||||
eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := eventService.Publish(&event.PublishRequest{
|
||||
Message: map[string]interface{}{
|
||||
"user": "john",
|
||||
"id": "1",
|
||||
"type": "signup",
|
||||
},
|
||||
Topic: "user",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Consume
|
||||
|
||||
Consume events from a given topic.
|
||||
@@ -106,3 +73,36 @@ func ReadEventsOnAtopic() {
|
||||
|
||||
}
|
||||
```
|
||||
## Publish
|
||||
|
||||
Publish a event to the event stream.
|
||||
|
||||
|
||||
[https://m3o.com/event/api#Publish](https://m3o.com/event/api#Publish)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/event"
|
||||
)
|
||||
|
||||
// Publish a event to the event stream.
|
||||
func PublishAnEvent() {
|
||||
eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := eventService.Publish(&event.PublishRequest{
|
||||
Message: map[string]interface{}{
|
||||
"id": "1",
|
||||
"type": "signup",
|
||||
"user": "john",
|
||||
},
|
||||
Topic: "user",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -12,9 +12,9 @@ func main() {
|
||||
eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := eventService.Publish(&event.PublishRequest{
|
||||
Message: map[string]interface{}{
|
||||
"id": "1",
|
||||
"type": "signup",
|
||||
"user": "john",
|
||||
"id": "1",
|
||||
},
|
||||
Topic: "user",
|
||||
})
|
||||
|
||||
@@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/forex/api](htt
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Price
|
||||
|
||||
Get the latest price for a given forex ticker
|
||||
|
||||
|
||||
[https://m3o.com/forex/api#Price](https://m3o.com/forex/api#Price)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/forex"
|
||||
)
|
||||
|
||||
// Get the latest price for a given forex ticker
|
||||
func GetAnFxPrice() {
|
||||
forexService := forex.NewForexService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := forexService.Price(&forex.PriceRequest{
|
||||
Symbol: "GBPUSD",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Quote
|
||||
|
||||
Get the latest quote for the forex
|
||||
@@ -88,3 +60,31 @@ func GetPreviousClose() {
|
||||
|
||||
}
|
||||
```
|
||||
## Price
|
||||
|
||||
Get the latest price for a given forex ticker
|
||||
|
||||
|
||||
[https://m3o.com/forex/api#Price](https://m3o.com/forex/api#Price)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/forex"
|
||||
)
|
||||
|
||||
// Get the latest price for a given forex ticker
|
||||
func GetAnFxPrice() {
|
||||
forexService := forex.NewForexService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := forexService.Price(&forex.PriceRequest{
|
||||
Symbol: "GBPUSD",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,6 +4,33 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/id/api](https:
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Types
|
||||
|
||||
List the types of IDs available. No query params needed.
|
||||
|
||||
|
||||
[https://m3o.com/id/api#Types](https://m3o.com/id/api#Types)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/id"
|
||||
)
|
||||
|
||||
// List the types of IDs available. No query params needed.
|
||||
func ListTheTypesOfIdsAvailable() {
|
||||
idService := id.NewIdService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := idService.Types(&id.TypesRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Generate
|
||||
|
||||
Generate a unique ID. Defaults to uuid.
|
||||
@@ -116,30 +143,3 @@ func GenerateAbigflakeId() {
|
||||
|
||||
}
|
||||
```
|
||||
## Types
|
||||
|
||||
List the types of IDs available. No query params needed.
|
||||
|
||||
|
||||
[https://m3o.com/id/api#Types](https://m3o.com/id/api#Types)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/id"
|
||||
)
|
||||
|
||||
// List the types of IDs available. No query params needed.
|
||||
func ListTheTypesOfIdsAvailable() {
|
||||
idService := id.NewIdService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := idService.Types(&id.TypesRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/image/api](htt
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Delete
|
||||
|
||||
Delete an image previously uploaded.
|
||||
|
||||
|
||||
[https://m3o.com/image/api#Delete](https://m3o.com/image/api#Delete)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/image"
|
||||
)
|
||||
|
||||
// Delete an image previously uploaded.
|
||||
func DeleteAnUploadedImage() {
|
||||
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := imageService.Delete(&image.DeleteRequest{
|
||||
Url: "https://cdn.m3ocontent.com/micro/images/micro/41e23b39-48dd-42b6-9738-79a313414bb8/cat.png",
|
||||
|
||||
})
|
||||
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.
|
||||
@@ -228,31 +256,3 @@ Url: "somewebsite.com/cat.png",
|
||||
|
||||
}
|
||||
```
|
||||
## Delete
|
||||
|
||||
Delete an image previously uploaded.
|
||||
|
||||
|
||||
[https://m3o.com/image/api#Delete](https://m3o.com/image/api#Delete)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/image"
|
||||
)
|
||||
|
||||
// Delete an image previously uploaded.
|
||||
func DeleteAnUploadedImage() {
|
||||
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := imageService.Delete(&image.DeleteRequest{
|
||||
Url: "https://cdn.m3ocontent.com/micro/images/micro/41e23b39-48dd-42b6-9738-79a313414bb8/cat.png",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/location/api](
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Read
|
||||
|
||||
Read an entity by its ID
|
||||
|
||||
|
||||
[https://m3o.com/location/api#Read](https://m3o.com/location/api#Read)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/location"
|
||||
)
|
||||
|
||||
// Read an entity by its ID
|
||||
func GetLocationById() {
|
||||
locationService := location.NewLocationService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := locationService.Read(&location.ReadRequest{
|
||||
Id: "1",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Search
|
||||
|
||||
Search for entities in a given radius
|
||||
@@ -74,31 +102,3 @@ func SaveAnEntity() {
|
||||
|
||||
}
|
||||
```
|
||||
## Read
|
||||
|
||||
Read an entity by its ID
|
||||
|
||||
|
||||
[https://m3o.com/location/api#Read](https://m3o.com/location/api#Read)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/location"
|
||||
)
|
||||
|
||||
// Read an entity by its ID
|
||||
func GetLocationById() {
|
||||
locationService := location.NewLocationService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := locationService.Read(&location.ReadRequest{
|
||||
Id: "1",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -26,9 +26,9 @@ func PublishAmessage() {
|
||||
mqService := mq.NewMqService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := mqService.Publish(&mq.PublishRequest{
|
||||
Message: map[string]interface{}{
|
||||
"user": "john",
|
||||
"id": "1",
|
||||
"type": "signup",
|
||||
"user": "john",
|
||||
},
|
||||
Topic: "events",
|
||||
|
||||
|
||||
@@ -12,9 +12,9 @@ func main() {
|
||||
mqService := mq.NewMqService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := mqService.Publish(&mq.PublishRequest{
|
||||
Message: map[string]interface{}{
|
||||
"id": "1",
|
||||
"type": "signup",
|
||||
"user": "john",
|
||||
"id": "1",
|
||||
},
|
||||
Topic: "events",
|
||||
})
|
||||
|
||||
@@ -4,63 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/notes/api](htt
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Create
|
||||
|
||||
Create a new note
|
||||
|
||||
|
||||
[https://m3o.com/notes/api#Create](https://m3o.com/notes/api#Create)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/notes"
|
||||
)
|
||||
|
||||
// Create a new note
|
||||
func CreateAnote() {
|
||||
notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := notesService.Create(¬es.CreateRequest{
|
||||
Text: "This is my note",
|
||||
Title: "New Note",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Read
|
||||
|
||||
Read 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
|
||||
@@ -189,3 +132,60 @@ func SubscribeToEvents() {
|
||||
}
|
||||
}
|
||||
```
|
||||
## Create
|
||||
|
||||
Create a new note
|
||||
|
||||
|
||||
[https://m3o.com/notes/api#Create](https://m3o.com/notes/api#Create)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/notes"
|
||||
)
|
||||
|
||||
// Create a new note
|
||||
func CreateAnote() {
|
||||
notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := notesService.Create(¬es.CreateRequest{
|
||||
Text: "This is my note",
|
||||
Title: "New Note",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## 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)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/quran/api](htt
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Chapters
|
||||
|
||||
List the Chapters (surahs) of the Quran
|
||||
|
||||
|
||||
[https://m3o.com/quran/api#Chapters](https://m3o.com/quran/api#Chapters)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/quran"
|
||||
)
|
||||
|
||||
// List the Chapters (surahs) of the Quran
|
||||
func ListChapters() {
|
||||
quranService := quran.NewQuranService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := quranService.Chapters(&quran.ChaptersRequest{
|
||||
Language: "en",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Summary
|
||||
|
||||
Get a summary for a given chapter (surah)
|
||||
@@ -120,3 +92,31 @@ func SearchTheQuran() {
|
||||
|
||||
}
|
||||
```
|
||||
## Chapters
|
||||
|
||||
List the Chapters (surahs) of the Quran
|
||||
|
||||
|
||||
[https://m3o.com/quran/api#Chapters](https://m3o.com/quran/api#Chapters)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/quran"
|
||||
)
|
||||
|
||||
// List the Chapters (surahs) of the Quran
|
||||
func ListChapters() {
|
||||
quranService := quran.NewQuranService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := quranService.Chapters(&quran.ChaptersRequest{
|
||||
Language: "en",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/search/api](ht
|
||||
|
||||
Endpoints:
|
||||
|
||||
## DeleteIndex
|
||||
|
||||
Delete an index by name
|
||||
|
||||
|
||||
[https://m3o.com/search/api#DeleteIndex](https://m3o.com/search/api#DeleteIndex)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/search"
|
||||
)
|
||||
|
||||
// Delete an index by name
|
||||
func DeleteAnIndex() {
|
||||
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := searchService.DeleteIndex(&search.DeleteIndexRequest{
|
||||
Index: "customers",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Index
|
||||
|
||||
Index a document i.e. insert a document to search for.
|
||||
@@ -184,31 +212,3 @@ func CreateAnIndex() {
|
||||
|
||||
}
|
||||
```
|
||||
## DeleteIndex
|
||||
|
||||
Delete an index by name
|
||||
|
||||
|
||||
[https://m3o.com/search/api#DeleteIndex](https://m3o.com/search/api#DeleteIndex)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/search"
|
||||
)
|
||||
|
||||
// Delete an index by name
|
||||
func DeleteAnIndex() {
|
||||
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := searchService.DeleteIndex(&search.DeleteIndexRequest{
|
||||
Index: "customers",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -13,9 +13,9 @@ func main() {
|
||||
rsp, err := searchService.Index(&search.IndexRequest{
|
||||
Document: &search.Document{
|
||||
Contents: map[string]interface{}{
|
||||
"starsign": "Leo",
|
||||
"name": "John Doe",
|
||||
"age": 37,
|
||||
"starsign": "Leo",
|
||||
},
|
||||
Id: "1234",
|
||||
},
|
||||
|
||||
@@ -4,120 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/space/api](htt
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Read
|
||||
|
||||
Read an object in space
|
||||
|
||||
|
||||
[https://m3o.com/space/api#Read](https://m3o.com/space/api#Read)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/space"
|
||||
)
|
||||
|
||||
// Read an object in space
|
||||
func ReadAnObject() {
|
||||
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := spaceService.Read(&space.ReadRequest{
|
||||
Name: "images/file.jpg",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Download
|
||||
|
||||
Download an object via a presigned url
|
||||
|
||||
|
||||
[https://m3o.com/space/api#Download](https://m3o.com/space/api#Download)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/space"
|
||||
)
|
||||
|
||||
// Download an object via a presigned url
|
||||
func DownloadAnObject() {
|
||||
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := spaceService.Download(&space.DownloadRequest{
|
||||
Name: "images/file.jpg",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Upload
|
||||
|
||||
Upload a large object (> 10MB). Returns a time limited presigned URL to be used for uploading the object
|
||||
|
||||
|
||||
[https://m3o.com/space/api#Upload](https://m3o.com/space/api#Upload)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/space"
|
||||
)
|
||||
|
||||
// Upload a large object (> 10MB). Returns a time limited presigned URL to be used for uploading the object
|
||||
func UploadAnObject() {
|
||||
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := spaceService.Upload(&space.UploadRequest{
|
||||
Name: "images/file.jpg",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Create
|
||||
|
||||
Create an object. Returns error if object with this name already exists. Max object size of 10MB, see Upload endpoint for larger objects. If you want to update an existing object use the `Update` endpoint
|
||||
|
||||
|
||||
[https://m3o.com/space/api#Create](https://m3o.com/space/api#Create)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/space"
|
||||
)
|
||||
|
||||
// Create an object. Returns error if object with this name already exists. Max object size of 10MB, see Upload endpoint for larger objects. If you want to update an existing object use the `Update` endpoint
|
||||
func CreateAnObject() {
|
||||
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := spaceService.Create(&space.CreateRequest{
|
||||
Name: "images/file.jpg",
|
||||
Object: "<file bytes>",
|
||||
Visibility: "public",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Update
|
||||
|
||||
Update an object. If an object with this name does not exist, creates a new one.
|
||||
@@ -232,3 +118,117 @@ func HeadAnObject() {
|
||||
|
||||
}
|
||||
```
|
||||
## Read
|
||||
|
||||
Read an object in space
|
||||
|
||||
|
||||
[https://m3o.com/space/api#Read](https://m3o.com/space/api#Read)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/space"
|
||||
)
|
||||
|
||||
// Read an object in space
|
||||
func ReadAnObject() {
|
||||
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := spaceService.Read(&space.ReadRequest{
|
||||
Name: "images/file.jpg",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Download
|
||||
|
||||
Download an object via a presigned url
|
||||
|
||||
|
||||
[https://m3o.com/space/api#Download](https://m3o.com/space/api#Download)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/space"
|
||||
)
|
||||
|
||||
// Download an object via a presigned url
|
||||
func DownloadAnObject() {
|
||||
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := spaceService.Download(&space.DownloadRequest{
|
||||
Name: "images/file.jpg",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Upload
|
||||
|
||||
Upload a large object (> 10MB). Returns a time limited presigned URL to be used for uploading the object
|
||||
|
||||
|
||||
[https://m3o.com/space/api#Upload](https://m3o.com/space/api#Upload)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/space"
|
||||
)
|
||||
|
||||
// Upload a large object (> 10MB). Returns a time limited presigned URL to be used for uploading the object
|
||||
func UploadAnObject() {
|
||||
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := spaceService.Upload(&space.UploadRequest{
|
||||
Name: "images/file.jpg",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Create
|
||||
|
||||
Create an object. Returns error if object with this name already exists. Max object size of 10MB, see Upload endpoint for larger objects. If you want to update an existing object use the `Update` endpoint
|
||||
|
||||
|
||||
[https://m3o.com/space/api#Create](https://m3o.com/space/api#Create)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/space"
|
||||
)
|
||||
|
||||
// Create an object. Returns error if object with this name already exists. Max object size of 10MB, see Upload endpoint for larger objects. If you want to update an existing object use the `Update` endpoint
|
||||
func CreateAnObject() {
|
||||
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := spaceService.Create(&space.CreateRequest{
|
||||
Name: "images/file.jpg",
|
||||
Object: "<file bytes>",
|
||||
Visibility: "public",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,38 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/stock/api](htt
|
||||
|
||||
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
|
||||
|
||||
Get the last price for a given stock ticker
|
||||
@@ -121,3 +89,35 @@ 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,6 +4,37 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/stream/api](ht
|
||||
|
||||
Endpoints:
|
||||
|
||||
## CreateChannel
|
||||
|
||||
Create a channel with a given name and description. Channels are created automatically but
|
||||
this allows you to specify a description that's persisted for the lifetime of the channel.
|
||||
|
||||
|
||||
[https://m3o.com/stream/api#CreateChannel](https://m3o.com/stream/api#CreateChannel)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/stream"
|
||||
)
|
||||
|
||||
// Create a channel with a given name and description. Channels are created automatically but
|
||||
// this allows you to specify a description that's persisted for the lifetime of the channel.
|
||||
func CreateChannel() {
|
||||
streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := streamService.CreateChannel(&stream.CreateChannelRequest{
|
||||
Description: "The channel for all things",
|
||||
Name: "general",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## SendMessage
|
||||
|
||||
Send a message to the stream.
|
||||
@@ -88,34 +119,3 @@ func ListChannels() {
|
||||
|
||||
}
|
||||
```
|
||||
## CreateChannel
|
||||
|
||||
Create a channel with a given name and description. Channels are created automatically but
|
||||
this allows you to specify a description that's persisted for the lifetime of the channel.
|
||||
|
||||
|
||||
[https://m3o.com/stream/api#CreateChannel](https://m3o.com/stream/api#CreateChannel)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/stream"
|
||||
)
|
||||
|
||||
// Create a channel with a given name and description. Channels are created automatically but
|
||||
// this allows you to specify a description that's persisted for the lifetime of the channel.
|
||||
func CreateChannel() {
|
||||
streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := streamService.CreateChannel(&stream.CreateChannelRequest{
|
||||
Description: "The channel for all things",
|
||||
Name: "general",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/user/api](http
|
||||
|
||||
Endpoints:
|
||||
|
||||
## 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)
|
||||
|
||||
}
|
||||
```
|
||||
## UpdatePassword
|
||||
|
||||
Update the account password
|
||||
@@ -61,81 +33,6 @@ 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)
|
||||
|
||||
}
|
||||
```
|
||||
## 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)
|
||||
|
||||
}
|
||||
```
|
||||
## Read
|
||||
@@ -222,12 +119,18 @@ func ReadAccountByEmail() {
|
||||
|
||||
}
|
||||
```
|
||||
## Delete
|
||||
## SendVerificationEmail
|
||||
|
||||
Delete an account by id
|
||||
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#Delete](https://m3o.com/user/api#Delete)
|
||||
[https://m3o.com/user/api#SendVerificationEmail](https://m3o.com/user/api#SendVerificationEmail)
|
||||
|
||||
```go
|
||||
package example
|
||||
@@ -239,26 +142,36 @@ import(
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Delete an account by id
|
||||
func DeleteUserAccount() {
|
||||
// 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.Delete(&user.DeleteRequest{
|
||||
Id: "8b98acbe-0b6a-4d66-a414-5ffbf666786f",
|
||||
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)
|
||||
|
||||
}
|
||||
```
|
||||
## VerifyToken
|
||||
## Logout
|
||||
|
||||
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.
|
||||
Logout a user account
|
||||
|
||||
|
||||
[https://m3o.com/user/api#VerifyToken](https://m3o.com/user/api#VerifyToken)
|
||||
[https://m3o.com/user/api#Logout](https://m3o.com/user/api#Logout)
|
||||
|
||||
```go
|
||||
package example
|
||||
@@ -270,14 +183,11 @@ import(
|
||||
"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() {
|
||||
// Logout a user account
|
||||
func LogAuserOut() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.VerifyToken(&user.VerifyTokenRequest{
|
||||
Token: "EdsUiidouJJJLldjlloofUiorkojflsWWdld",
|
||||
rsp, err := userService.Logout(&user.LogoutRequest{
|
||||
SessionId: "df91a612-5b24-4634-99ff-240220ab8f55",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
@@ -346,12 +256,15 @@ Password: "Password1",
|
||||
|
||||
}
|
||||
```
|
||||
## List
|
||||
## VerifyToken
|
||||
|
||||
List all users. Returns a paged list of results
|
||||
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#List](https://m3o.com/user/api#List)
|
||||
[https://m3o.com/user/api#VerifyToken](https://m3o.com/user/api#VerifyToken)
|
||||
|
||||
```go
|
||||
package example
|
||||
@@ -363,75 +276,14 @@ import(
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// List all users. Returns a paged list of results
|
||||
func ListAllUsers() {
|
||||
// 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.List(&user.ListRequest{
|
||||
Limit: 100,
|
||||
Offset: 0,
|
||||
|
||||
})
|
||||
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)
|
||||
|
||||
}
|
||||
```
|
||||
## 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`,
|
||||
rsp, err := userService.VerifyToken(&user.VerifyTokenRequest{
|
||||
Token: "EdsUiidouJJJLldjlloofUiorkojflsWWdld",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
@@ -533,3 +385,151 @@ NewPassword: "NewPassword1",
|
||||
|
||||
}
|
||||
```
|
||||
## 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)
|
||||
|
||||
}
|
||||
```
|
||||
## 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)
|
||||
|
||||
}
|
||||
```
|
||||
## Delete
|
||||
|
||||
Delete an account by id
|
||||
|
||||
|
||||
[https://m3o.com/user/api#Delete](https://m3o.com/user/api#Delete)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Delete an account by id
|
||||
func DeleteUserAccount() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.Delete(&user.DeleteRequest{
|
||||
Id: "8b98acbe-0b6a-4d66-a414-5ffbf666786f",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## List
|
||||
|
||||
List all users. Returns a paged list of results
|
||||
|
||||
|
||||
[https://m3o.com/user/api#List](https://m3o.com/user/api#List)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// List all users. Returns a paged list of results
|
||||
func ListAllUsers() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.List(&user.ListRequest{
|
||||
Limit: 100,
|
||||
Offset: 0,
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## SendMagicLink
|
||||
|
||||
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)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user