Commit from m3o/m3o action

This commit is contained in:
m3o-actions
2022-02-21 14:54:04 +00:00
parent 39bb32658f
commit e2c7c21f71
22 changed files with 1267 additions and 1267 deletions

View File

@@ -4,91 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/cache/api](htt
Endpoints:
## Set
Set an item in the cache. Overwrites any existing value already set.
[https://m3o.com/cache/api#Set](https://m3o.com/cache/api#Set)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/cache"
)
// Set an item in the cache. Overwrites any existing value already set.
func SetAvalue() {
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
rsp, err := cacheService.Set(&cache.SetRequest{
Key: "foo",
Value: "bar",
})
fmt.Println(rsp, err)
}
```
## 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.
@@ -174,3 +89,88 @@ func ListTheKeys() {
}
```
## Set
Set an item in the cache. Overwrites any existing value already set.
[https://m3o.com/cache/api#Set](https://m3o.com/cache/api#Set)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/cache"
)
// Set an item in the cache. Overwrites any existing value already set.
func SetAvalue() {
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
rsp, err := cacheService.Set(&cache.SetRequest{
Key: "foo",
Value: "bar",
})
fmt.Println(rsp, err)
}
```
## 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)
}
```

View File

@@ -4,6 +4,119 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/chat/api](http
Endpoints:
## 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
Delete a chat room
[https://m3o.com/chat/api#Delete](https://m3o.com/chat/api#Delete)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/chat"
)
// Delete a chat room
func DeleteAchat() {
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
rsp, err := chatService.Delete(&chat.DeleteRequest{
})
fmt.Println(rsp, err)
}
```
## Send
Connect to a chat to receive a stream of messages
Send a message to a chat
[https://m3o.com/chat/api#Send](https://m3o.com/chat/api#Send)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/chat"
)
// Connect to a chat to receive a stream of messages
// Send a message to a chat
func SendAmessage() {
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
rsp, err := chatService.Send(&chat.SendRequest{
Client: "web",
Subject: "Random",
Text: "Hey whats up?",
})
fmt.Println(rsp, err)
}
```
## History
List the messages in a chat
[https://m3o.com/chat/api#History](https://m3o.com/chat/api#History)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/chat"
)
// List the messages in a chat
func GetChatHistory() {
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
rsp, err := chatService.History(&chat.HistoryRequest{
})
fmt.Println(rsp, err)
}
```
## Join
Join a chat room
@@ -69,60 +182,6 @@ func KickAuserFromAroom() {
})
fmt.Println(rsp, err)
}
```
## Leave
Leave a chat room
[https://m3o.com/chat/api#Leave](https://m3o.com/chat/api#Leave)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/chat"
)
// Leave a chat room
func LeaveAroom() {
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
rsp, err := chatService.Leave(&chat.LeaveRequest{
})
fmt.Println(rsp, err)
}
```
## History
List the messages in a chat
[https://m3o.com/chat/api#History](https://m3o.com/chat/api#History)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/chat"
)
// List the messages in a chat
func GetChatHistory() {
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
rsp, err := chatService.History(&chat.HistoryRequest{
})
fmt.Println(rsp, err)
}
```
## New
@@ -152,60 +211,6 @@ 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)
}
```
## 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)
}
```
## Invite
@@ -235,13 +240,12 @@ func InviteAuser() {
}
```
## Send
## Leave
Connect to a chat to receive a stream of messages
Send a message to a chat
Leave a chat room
[https://m3o.com/chat/api#Send](https://m3o.com/chat/api#Send)
[https://m3o.com/chat/api#Leave](https://m3o.com/chat/api#Leave)
```go
package example
@@ -253,15 +257,11 @@ import(
"go.m3o.com/chat"
)
// Connect to a chat to receive a stream of messages
// Send a message to a chat
func SendAmessage() {
// Leave a chat room
func LeaveAroom() {
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
rsp, err := chatService.Send(&chat.SendRequest{
Client: "web",
Subject: "Random",
Text: "Hey whats up?",
rsp, err := chatService.Leave(&chat.LeaveRequest{
})
fmt.Println(rsp, err)

View File

@@ -4,75 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/comments/api](
Endpoints:
## 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
Subscribe to comments events
[https://m3o.com/comments/api#Events](https://m3o.com/comments/api#Events)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/comments"
)
// Subscribe to comments events
func SubscribeToEvents() {
commentsService := comments.NewCommentsService(os.Getenv("M3O_API_TOKEN"))
stream, err := commentsService.Events(&comments.EventsRequest{
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
})
if err != nil {
fmt.Println(err)
return
}
for {
rsp, err := stream.Recv()
if err != nil {
fmt.Println(err)
return
}
fmt.Println(rsp)
}
}
```
## Create
Create a new comment
@@ -188,3 +119,72 @@ func UpdateAcomment() {
}
```
## 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
Subscribe to comments events
[https://m3o.com/comments/api#Events](https://m3o.com/comments/api#Events)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/comments"
)
// Subscribe to comments events
func SubscribeToEvents() {
commentsService := comments.NewCommentsService(os.Getenv("M3O_API_TOKEN"))
stream, err := commentsService.Events(&comments.EventsRequest{
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
})
if err != nil {
fmt.Println(err)
return
}
for {
rsp, err := stream.Recv()
if err != nil {
fmt.Println(err)
return
}
fmt.Println(rsp)
}
}
```

View File

@@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/crypto/api](ht
Endpoints:
## History
Returns the history for the previous close
[https://m3o.com/crypto/api#History](https://m3o.com/crypto/api#History)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/crypto"
)
// Returns the history for the previous close
func GetPreviousClose() {
cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN"))
rsp, err := cryptoService.History(&crypto.HistoryRequest{
Symbol: "BTCUSD",
})
fmt.Println(rsp, err)
}
```
## News
Get news related to a currency
@@ -116,3 +88,31 @@ func GetAcryptocurrencyQuote() {
}
```
## History
Returns the history for the previous close
[https://m3o.com/crypto/api#History](https://m3o.com/crypto/api#History)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/crypto"
)
// Returns the history for the previous close
func GetPreviousClose() {
cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN"))
rsp, err := cryptoService.History(&crypto.HistoryRequest{
Symbol: "BTCUSD",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/db/api](https:
Endpoints:
## Truncate
Truncate the records in a table
[https://m3o.com/db/api#Truncate](https://m3o.com/db/api#Truncate)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/db"
)
// Truncate the records in a table
func TruncateTable() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Truncate(&db.TruncateRequest{
Table: "example",
})
fmt.Println(rsp, err)
}
```
## Count
Count records in a table
@@ -32,12 +60,12 @@ func CountEntriesInAtable() {
}
```
## ListTables
## Create
List tables in the DB
Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
[https://m3o.com/db/api#ListTables](https://m3o.com/db/api#ListTables)
[https://m3o.com/db/api#Create](https://m3o.com/db/api#Create)
```go
package example
@@ -49,39 +77,17 @@ import(
"go.m3o.com/db"
)
// List tables in the DB
func ListTables() {
// 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.ListTables(&db.ListTablesRequest{
})
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",
rsp, err := dbService.Create(&db.CreateRequest{
Record: map[string]interface{}{
"id": "1",
"name": "Jane",
"age": 42,
"isActive": true,
},
Table: "example",
})
fmt.Println(rsp, err)
@@ -110,8 +116,8 @@ func UpdateArecord() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Update(&db.UpdateRequest{
Record: map[string]interface{}{
"age": 43,
"id": "1",
"age": 43,
},
Table: "example",
@@ -206,12 +212,12 @@ func DropTable() {
}
```
## Create
## ListTables
Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
List tables in the DB
[https://m3o.com/db/api#Create](https://m3o.com/db/api#Create)
[https://m3o.com/db/api#ListTables](https://m3o.com/db/api#ListTables)
```go
package example
@@ -223,29 +229,22 @@ import(
"go.m3o.com/db"
)
// Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
func CreateArecord() {
// List tables in the DB
func ListTables() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Create(&db.CreateRequest{
Record: map[string]interface{}{
"id": "1",
"name": "Jane",
"age": 42,
"isActive": true,
},
Table: "example",
rsp, err := dbService.ListTables(&db.ListTablesRequest{
})
fmt.Println(rsp, err)
}
```
## Truncate
## RenameTable
Truncate the records in a table
Rename a table
[https://m3o.com/db/api#Truncate](https://m3o.com/db/api#Truncate)
[https://m3o.com/db/api#RenameTable](https://m3o.com/db/api#RenameTable)
```go
package example
@@ -257,11 +256,12 @@ import(
"go.m3o.com/db"
)
// Truncate the records in a table
func TruncateTable() {
// Rename a table
func RenameTable() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Truncate(&db.TruncateRequest{
Table: "example",
rsp, err := dbService.RenameTable(&db.RenameTableRequest{
From: "examples2",
To: "examples3",
})
fmt.Println(rsp, err)

View File

@@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/email/api](htt
Endpoints:
## Parse
Parse an RFC5322 address e.g "Joe Blogs <joe@example.com>"
[https://m3o.com/email/api#Parse](https://m3o.com/email/api#Parse)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/email"
)
// Parse an RFC5322 address e.g "Joe Blogs <joe@example.com>"
func ParseEmail() {
emailService := email.NewEmailService(os.Getenv("M3O_API_TOKEN"))
rsp, err := emailService.Parse(&email.ParseRequest{
Address: "Joe Blogs <joe@example.com>",
})
fmt.Println(rsp, err)
}
```
## Validate
Validate an email address format
@@ -64,31 +92,3 @@ Please verify your email by clicking this link: $micro_verification_link`,
}
```
## Parse
Parse an RFC5322 address e.g "Joe Blogs <joe@example.com>"
[https://m3o.com/email/api#Parse](https://m3o.com/email/api#Parse)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/email"
)
// Parse an RFC5322 address e.g "Joe Blogs <joe@example.com>"
func ParseEmail() {
emailService := email.NewEmailService(os.Getenv("M3O_API_TOKEN"))
rsp, err := emailService.Parse(&email.ParseRequest{
Address: "Joe Blogs <joe@example.com>",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,6 +4,36 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/emoji/api](htt
Endpoints:
## Print
Print text and renders the emojis with aliases e.g
let's grab a :beer: becomes let's grab a 🍺
[https://m3o.com/emoji/api#Print](https://m3o.com/emoji/api#Print)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/emoji"
)
// Print text and renders the emojis with aliases e.g
// let's grab a :beer: becomes let's grab a 🍺
func PrintTextIncludingEmoji() {
emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN"))
rsp, err := emojiService.Print(&emoji.PrintRequest{
Text: "let's grab a :beer:",
})
fmt.Println(rsp, err)
}
```
## Find
Find an emoji by its alias e.g :beer:
@@ -59,33 +89,3 @@ func GetFlagByCountryCode() {
}
```
## Print
Print text and renders the emojis with aliases e.g
let's grab a :beer: becomes let's grab a 🍺
[https://m3o.com/emoji/api#Print](https://m3o.com/emoji/api#Print)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/emoji"
)
// Print text and renders the emojis with aliases e.g
// let's grab a :beer: becomes let's grab a 🍺
func PrintTextIncludingEmoji() {
emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN"))
rsp, err := emojiService.Print(&emoji.PrintRequest{
Text: "let's grab a :beer:",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/event/api](htt
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 a event to the event stream.
@@ -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)
}
```

View File

@@ -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",
})

View File

@@ -4,38 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/file/api](http
Endpoints:
## Save
Save a file
[https://m3o.com/file/api#Save](https://m3o.com/file/api#Save)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/file"
)
// Save a file
func SaveFile() {
fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN"))
rsp, err := fileService.Save(&file.SaveRequest{
File: &file.Record{
Content: "file content example",
Path: "/document/text-files/file.txt",
Project: "examples",
},
})
fmt.Println(rsp, err)
}
```
## List
List files by their project and optionally a path.
@@ -122,3 +90,35 @@ Project: "examples",
}
```
## Save
Save a file
[https://m3o.com/file/api#Save](https://m3o.com/file/api#Save)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/file"
)
// Save a file
func SaveFile() {
fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN"))
rsp, err := fileService.Save(&file.SaveRequest{
File: &file.Record{
Content: "file content example",
Path: "/document/text-files/file.txt",
Project: "examples",
},
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,12 +4,12 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/function/api](
Endpoints:
## Deploy
## Regions
Deploy a group of functions
Return a list of supported regions
[https://m3o.com/function/api#Deploy](https://m3o.com/function/api#Deploy)
[https://m3o.com/function/api#Regions](https://m3o.com/function/api#Regions)
```go
package example
@@ -21,17 +21,38 @@ import(
"go.m3o.com/function"
)
// Deploy a group of functions
func DeployAfunction() {
// Return a list of supported regions
func ListRegions() {
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",
rsp, err := functionService.Regions(&function.RegionsRequest{
})
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)
@@ -64,88 +85,6 @@ func UpdateAfunction() {
})
fmt.Println(rsp, err)
}
```
## List
List all the deployed functions
[https://m3o.com/function/api#List](https://m3o.com/function/api#List)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/function"
)
// List all the deployed functions
func ListFunctions() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.List(&function.ListRequest{
})
fmt.Println(rsp, err)
}
```
## Describe
Get the info for a deployed function
[https://m3o.com/function/api#Describe](https://m3o.com/function/api#Describe)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/function"
)
// Get the info for a deployed function
func DescribeFunctionStatus() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.Describe(&function.DescribeRequest{
Name: "helloworld",
})
fmt.Println(rsp, err)
}
```
## Regions
Return a list of supported regions
[https://m3o.com/function/api#Regions](https://m3o.com/function/api#Regions)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/function"
)
// Return a list of supported regions
func ListRegions() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.Regions(&function.RegionsRequest{
})
fmt.Println(rsp, err)
}
```
## Call
@@ -177,6 +116,33 @@ Request: map[string]interface{}{
})
fmt.Println(rsp, err)
}
```
## List
List all the deployed functions
[https://m3o.com/function/api#List](https://m3o.com/function/api#List)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/function"
)
// List all the deployed functions
func ListFunctions() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.List(&function.ListRequest{
})
fmt.Println(rsp, err)
}
```
## Delete
@@ -205,6 +171,68 @@ func DeleteAfunction() {
})
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)
}
```
## Describe
Get the info for a deployed function
[https://m3o.com/function/api#Describe](https://m3o.com/function/api#Describe)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/function"
)
// Get the info for a deployed function
func DescribeFunctionStatus() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.Describe(&function.DescribeRequest{
Name: "helloworld",
})
fmt.Println(rsp, err)
}
```
## Reserve
@@ -235,31 +263,3 @@ func ReserveAfunction() {
}
```
## 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)
}
```

View File

@@ -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)
}
```

View File

@@ -4,6 +4,47 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/notes/api](htt
Endpoints:
## Events
Subscribe to notes events
[https://m3o.com/notes/api#Events](https://m3o.com/notes/api#Events)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/notes"
)
// Subscribe to notes events
func SubscribeToEvents() {
notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN"))
stream, err := notesService.Events(&notes.EventsRequest{
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
})
if err != nil {
fmt.Println(err)
return
}
for {
rsp, err := stream.Recv()
if err != nil {
fmt.Println(err)
return
}
fmt.Println(rsp)
}
}
```
## Create
Create a new note
@@ -148,44 +189,3 @@ func DeleteAnote() {
}
```
## Events
Subscribe to notes events
[https://m3o.com/notes/api#Events](https://m3o.com/notes/api#Events)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/notes"
)
// Subscribe to notes events
func SubscribeToEvents() {
notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN"))
stream, err := notesService.Events(&notes.EventsRequest{
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
})
if err != nil {
fmt.Println(err)
return
}
for {
rsp, err := stream.Recv()
if err != nil {
fmt.Println(err)
return
}
fmt.Println(rsp)
}
}
```

View File

@@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/postcode/api](
Endpoints:
## Lookup
Lookup a postcode to retrieve the related region, county, etc
[https://m3o.com/postcode/api#Lookup](https://m3o.com/postcode/api#Lookup)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/postcode"
)
// Lookup a postcode to retrieve the related region, county, etc
func LookupPostcode() {
postcodeService := postcode.NewPostcodeService(os.Getenv("M3O_API_TOKEN"))
rsp, err := postcodeService.Lookup(&postcode.LookupRequest{
Postcode: "SW1A 2AA",
})
fmt.Println(rsp, err)
}
```
## Random
Return a random postcode and its related info
@@ -59,31 +87,3 @@ func ReturnArandomPostcodeAndItsInformation() {
}
```
## Lookup
Lookup a postcode to retrieve the related region, county, etc
[https://m3o.com/postcode/api#Lookup](https://m3o.com/postcode/api#Lookup)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/postcode"
)
// Lookup a postcode to retrieve the related region, county, etc
func LookupPostcode() {
postcodeService := postcode.NewPostcodeService(os.Getenv("M3O_API_TOKEN"))
rsp, err := postcodeService.Lookup(&postcode.LookupRequest{
Postcode: "SW1A 2AA",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/search/api](ht
Endpoints:
## DeleteIndex
Delete an index by name
[https://m3o.com/search/api#DeleteIndex](https://m3o.com/search/api#DeleteIndex)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/search"
)
// Delete an index by name
func DeleteAnIndex() {
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
rsp, err := searchService.DeleteIndex(&search.DeleteIndexRequest{
Index: "customers",
})
fmt.Println(rsp, err)
}
```
## Index
Index a record i.e. insert a document to search for.
@@ -209,3 +181,31 @@ func CreateAnIndex() {
}
```
## DeleteIndex
Delete an index by name
[https://m3o.com/search/api#DeleteIndex](https://m3o.com/search/api#DeleteIndex)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/search"
)
// Delete an index by name
func DeleteAnIndex() {
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
rsp, err := searchService.DeleteIndex(&search.DeleteIndexRequest{
Index: "customers",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,6 +4,94 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/space/api](htt
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 an object. If an object with this name does not exist, creates a new one.
[https://m3o.com/space/api#Update](https://m3o.com/space/api#Update)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/space"
)
// Update an object. If an object with this name does not exist, creates a new one.
func UpdateAnObject() {
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
rsp, err := spaceService.Update(&space.UpdateRequest{
Name: "images/file.jpg",
Object: "<file bytes>",
Visibility: "public",
})
fmt.Println(rsp, err)
}
```
## Delete
Delete an object from space
[https://m3o.com/space/api#Delete](https://m3o.com/space/api#Delete)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/space"
)
// Delete an object from space
func DeleteAnObject() {
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
rsp, err := spaceService.Delete(&space.DeleteRequest{
Name: "images/file.jpg",
})
fmt.Println(rsp, err)
}
```
## List
List the objects in space
@@ -144,91 +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)
}
```
## Update
Update an object. If an object with this name does not exist, creates a new one.
[https://m3o.com/space/api#Update](https://m3o.com/space/api#Update)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/space"
)
// Update an object. If an object with this name does not exist, creates a new one.
func UpdateAnObject() {
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
rsp, err := spaceService.Update(&space.UpdateRequest{
Name: "images/file.jpg",
Object: "<file bytes>",
Visibility: "public",
})
fmt.Println(rsp, err)
}
```
## Delete
Delete an object from space
[https://m3o.com/space/api#Delete](https://m3o.com/space/api#Delete)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/space"
)
// Delete an object from space
func DeleteAnObject() {
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
rsp, err := spaceService.Delete(&space.DeleteRequest{
Name: "images/file.jpg",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,6 +4,62 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/stock/api](htt
Endpoints:
## Price
Get the last price for a given stock ticker
[https://m3o.com/stock/api#Price](https://m3o.com/stock/api#Price)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/stock"
)
// Get the last price for a given stock ticker
func GetAstockPrice() {
stockService := stock.NewStockService(os.Getenv("M3O_API_TOKEN"))
rsp, err := stockService.Price(&stock.PriceRequest{
Symbol: "AAPL",
})
fmt.Println(rsp, err)
}
```
## Quote
Get the last quote for the stock
[https://m3o.com/stock/api#Quote](https://m3o.com/stock/api#Quote)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/stock"
)
// Get the last quote for the stock
func GetAstockQuote() {
stockService := stock.NewStockService(os.Getenv("M3O_API_TOKEN"))
rsp, err := stockService.Quote(&stock.QuoteRequest{
Symbol: "AAPL",
})
fmt.Println(rsp, err)
}
```
## History
Get the historic open-close for a given day
@@ -65,59 +121,3 @@ Stock: "AAPL",
}
```
## Price
Get the last price for a given stock ticker
[https://m3o.com/stock/api#Price](https://m3o.com/stock/api#Price)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/stock"
)
// Get the last price for a given stock ticker
func GetAstockPrice() {
stockService := stock.NewStockService(os.Getenv("M3O_API_TOKEN"))
rsp, err := stockService.Price(&stock.PriceRequest{
Symbol: "AAPL",
})
fmt.Println(rsp, err)
}
```
## Quote
Get the last quote for the stock
[https://m3o.com/stock/api#Quote](https://m3o.com/stock/api#Quote)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/stock"
)
// Get the last quote for the stock
func GetAstockQuote() {
stockService := stock.NewStockService(os.Getenv("M3O_API_TOKEN"))
rsp, err := stockService.Quote(&stock.QuoteRequest{
Symbol: "AAPL",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,35 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/sunnah/api](ht
Endpoints:
## Collections
Get a list of available collections. A collection is
a compilation of hadiths collected and written by an author.
[https://m3o.com/sunnah/api#Collections](https://m3o.com/sunnah/api#Collections)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/sunnah"
)
// Get a list of available collections. A collection is
// a compilation of hadiths collected and written by an author.
func ListAvailableCollections() {
sunnahService := sunnah.NewSunnahService(os.Getenv("M3O_API_TOKEN"))
rsp, err := sunnahService.Collections(&sunnah.CollectionsRequest{
})
fmt.Println(rsp, err)
}
```
## Books
Get a list of books from within a collection. A book can contain many chapters
@@ -123,3 +94,32 @@ Collection: "bukhari",
}
```
## Collections
Get a list of available collections. A collection is
a compilation of hadiths collected and written by an author.
[https://m3o.com/sunnah/api#Collections](https://m3o.com/sunnah/api#Collections)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/sunnah"
)
// Get a list of available collections. A collection is
// a compilation of hadiths collected and written by an author.
func ListAvailableCollections() {
sunnahService := sunnah.NewSunnahService(os.Getenv("M3O_API_TOKEN"))
rsp, err := sunnahService.Collections(&sunnah.CollectionsRequest{
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/twitter/api](h
Endpoints:
## User
Get a user's twitter profile
[https://m3o.com/twitter/api#User](https://m3o.com/twitter/api#User)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/twitter"
)
// Get a user's twitter profile
func GetAusersTwitterProfile() {
twitterService := twitter.NewTwitterService(os.Getenv("M3O_API_TOKEN"))
rsp, err := twitterService.User(&twitter.UserRequest{
Username: "crufter",
})
fmt.Println(rsp, err)
}
```
## Timeline
Get the timeline for a given user
@@ -116,3 +88,31 @@ func GetTheCurrentGlobalTrendingTopics() {
}
```
## User
Get a user's twitter profile
[https://m3o.com/twitter/api#User](https://m3o.com/twitter/api#User)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/twitter"
)
// Get a user's twitter profile
func GetAusersTwitterProfile() {
twitterService := twitter.NewTwitterService(os.Getenv("M3O_API_TOKEN"))
rsp, err := twitterService.User(&twitter.UserRequest{
Username: "crufter",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,33 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/url/api](https
Endpoints:
## Shorten
Shorten a long URL
[https://m3o.com/url/api#Shorten](https://m3o.com/url/api#Shorten)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/url"
)
// Shorten a long URL
func ShortenAlongUrl() {
urlService := url.NewUrlService(os.Getenv("M3O_API_TOKEN"))
rsp, err := urlService.Shorten(&url.ShortenRequest{
})
fmt.Println(rsp, err)
}
```
## Proxy
Proxy returns the destination URL of a short URL.
@@ -85,3 +58,30 @@ func ListYourShortenedUrls() {
}
```
## Shorten
Shorten a long URL
[https://m3o.com/url/api#Shorten](https://m3o.com/url/api#Shorten)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/url"
)
// Shorten a long URL
func ShortenAlongUrl() {
urlService := url.NewUrlService(os.Getenv("M3O_API_TOKEN"))
rsp, err := urlService.Shorten(&url.ShortenRequest{
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,12 +4,13 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/user/api](http
Endpoints:
## Delete
## Login
Delete an account by id
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#Delete](https://m3o.com/user/api#Delete)
[https://m3o.com/user/api#Login](https://m3o.com/user/api#Login)
```go
package example
@@ -21,11 +22,13 @@ import(
"go.m3o.com/user"
)
// Delete an account by id
func DeleteUserAccount() {
// 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.Delete(&user.DeleteRequest{
Id: "8b98acbe-0b6a-4d66-a414-5ffbf666786f",
rsp, err := userService.Login(&user.LoginRequest{
Email: "joe@example.com",
Password: "Password1",
})
fmt.Println(rsp, err)
@@ -117,6 +120,299 @@ Username: "joe",
})
fmt.Println(rsp, err)
}
```
## Update
Update the account username or email
[https://m3o.com/user/api#Update](https://m3o.com/user/api#Update)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Update the account username or email
func UpdateAnAccount() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.Update(&user.UpdateRequest{
Email: "joe+2@example.com",
Id: "user-1",
Username: "joe",
})
fmt.Println(rsp, err)
}
```
## 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)
}
```
## 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)
}
```
## 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)
}
```
## 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)
}
```
## 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)
}
```
## 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)
}
```
## Read
@@ -201,53 +497,6 @@ func ReadAccountByEmail() {
})
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
@@ -284,252 +533,3 @@ TextContent: `Hi there,
}
```
## 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)
}
```
## Update
Update the account username or email
[https://m3o.com/user/api#Update](https://m3o.com/user/api#Update)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Update the account username or email
func UpdateAnAccount() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.Update(&user.UpdateRequest{
Email: "joe+2@example.com",
Id: "user-1",
Username: "joe",
})
fmt.Println(rsp, err)
}
```
## SendMagicLink
Login using email only - Passwordless
[https://m3o.com/user/api#SendMagicLink](https://m3o.com/user/api#SendMagicLink)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Login using email only - Passwordless
func SendAmagicLink() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.SendMagicLink(&user.SendMagicLinkRequest{
Address: "www.example.com",
Email: "joe@example.com",
Endpoint: "verifytoken",
FromName: "Awesome Dot Com",
Subject: "MagicLink to access your account",
TextContent: `Hi there,
Click here to access your account $micro_verification_link`,
})
fmt.Println(rsp, err)
}
```
## UpdatePassword
Update the account password
[https://m3o.com/user/api#UpdatePassword](https://m3o.com/user/api#UpdatePassword)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Update the account password
func UpdateTheAccountPassword() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.UpdatePassword(&user.UpdatePasswordRequest{
ConfirmPassword: "Password2",
NewPassword: "Password2",
OldPassword: "Password1",
UserId: "user-1",
})
fmt.Println(rsp, err)
}
```
## Login
Login using username or email. The response will return a new session for successful login,
401 in the case of login failure and 500 for any other error
[https://m3o.com/user/api#Login](https://m3o.com/user/api#Login)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Login using username or email. The response will return a new session for successful login,
// 401 in the case of login failure and 500 for any other error
func LogAuserIn() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.Login(&user.LoginRequest{
Email: "joe@example.com",
Password: "Password1",
})
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)
}
```

View File

@@ -162,7 +162,17 @@ type ListResponse struct {
Objects []ListObject `json:"objects"`
}
type Object struct {
type ReadRequest struct {
// name of the object
Name string `json:"name"`
}
type ReadResponse struct {
// The object itself
Object *SpaceObject `json:"object"`
}
type SpaceObject struct {
// when was this created
Created string `json:"created"`
// the data within the object
@@ -177,16 +187,6 @@ type Object struct {
Visibility string `json:"visibility"`
}
type ReadRequest struct {
// name of the object
Name string `json:"name"`
}
type ReadResponse struct {
// The object itself
Object *Object `json:"object"`
}
type UpdateRequest struct {
// The name of the object. Use forward slash delimiter to implement a nested directory-like structure e.g. images/foo.jpg
Name string `json:"name"`