Commit from m3o/m3o action

This commit is contained in:
m3o-actions
2022-02-21 13:22:08 +00:00
parent 0638da0d21
commit 86d710f81e
30 changed files with 1274 additions and 1216 deletions

View File

@@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/cache/api](htt
Endpoints:
## Get
Get an item from the cache by key. If key is not found, an empty response is returned.
[https://m3o.com/cache/api#Get](https://m3o.com/cache/api#Get)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/cache"
)
// Get an item from the cache by key. If key is not found, an empty response is returned.
func GetAvalue() {
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
rsp, err := cacheService.Get(&cache.GetRequest{
Key: "foo",
})
fmt.Println(rsp, err)
}
```
## Delete
Delete a value from the cache. If key not found a success response is returned.
@@ -174,3 +146,31 @@ Value: "bar",
}
```
## Get
Get an item from the cache by key. If key is not found, an empty response is returned.
[https://m3o.com/cache/api#Get](https://m3o.com/cache/api#Get)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/cache"
)
// Get an item from the cache by key. If key is not found, an empty response is returned.
func GetAvalue() {
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
rsp, err := cacheService.Get(&cache.GetRequest{
Key: "foo",
})
fmt.Println(rsp, err)
}
```

View File

@@ -31,65 +31,6 @@ Name: "general",
})
fmt.Println(rsp, err)
}
```
## Send
Connect to a chat to receive a stream of messages
Send a message to a chat
[https://m3o.com/chat/api#Send](https://m3o.com/chat/api#Send)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/chat"
)
// Connect to a chat to receive a stream of messages
// Send a message to a chat
func SendAmessage() {
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
rsp, err := chatService.Send(&chat.SendRequest{
Client: "web",
Subject: "Random",
Text: "Hey whats up?",
})
fmt.Println(rsp, err)
}
```
## 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
@@ -132,6 +73,60 @@ func JoinAroom() {
}
}
```
## 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)
}
```
## 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)
}
```
## Leave
Leave a chat room
@@ -240,12 +235,13 @@ func InviteAuser() {
}
```
## Kick
## Send
Kick a user from a chat room
Connect to a chat to receive a stream of messages
Send a message to a chat
[https://m3o.com/chat/api#Kick](https://m3o.com/chat/api#Kick)
[https://m3o.com/chat/api#Send](https://m3o.com/chat/api#Send)
```go
package example
@@ -257,10 +253,14 @@ import(
"go.m3o.com/chat"
)
// Kick a user from a chat room
func KickAuserFromAroom() {
// 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.Kick(&chat.KickRequest{
rsp, err := chatService.Send(&chat.SendRequest{
Client: "web",
Subject: "Random",
Text: "Hey whats up?",
})
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,107 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/contact/api](h
Endpoints:
## Create
[https://m3o.com/contact/api#Create](https://m3o.com/contact/api#Create)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/contact"
)
//
func CreateAcontact() {
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
rsp, err := contactService.Create(&contact.CreateRequest{
Addresses: []contact.Address{
contact.Address{
Label: "company address",
Location: "123 street address",
}},
Birthday: "1995-01-01",
Emails: []contact.Email{
contact.Email{
Address: "home@example.com",
Label: "home",
}},
Links: []contact.Link{
contact.Link{
Label: "blog",
Url: "https://blog.joe.me",
}},
Name: "joe",
Note: "this person is very important",
Phones: []contact.Phone{
contact.Phone{
Label: "home",
Number: "010-12345678",
}},
})
fmt.Println(rsp, err)
}
```
## Update
[https://m3o.com/contact/api#Update](https://m3o.com/contact/api#Update)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/contact"
)
//
func UpdateAcontact() {
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
rsp, err := contactService.Update(&contact.UpdateRequest{
Addresses: []contact.Address{
contact.Address{
Label: "company address",
Location: "123 street address",
}},
Birthday: "1995-01-01",
Emails: []contact.Email{
contact.Email{
Address: "home@example.com",
Label: "home",
}},
Id: "42e48a3c-6221-11ec-96d2-acde48001122",
Links: []contact.Link{
contact.Link{
Label: "blog",
Url: "https://blog.joe.me",
}},
Name: "joe",
Note: "this person is very important",
Phones: []contact.Phone{
contact.Phone{
Label: "home",
Number: "010-12345678",
}},
})
fmt.Println(rsp, err)
}
```
## Read
@@ -217,3 +116,104 @@ Offset: 1,
}
```
## Create
[https://m3o.com/contact/api#Create](https://m3o.com/contact/api#Create)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/contact"
)
//
func CreateAcontact() {
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
rsp, err := contactService.Create(&contact.CreateRequest{
Addresses: []contact.Address{
contact.Address{
Label: "company address",
Location: "123 street address",
}},
Birthday: "1995-01-01",
Emails: []contact.Email{
contact.Email{
Address: "home@example.com",
Label: "home",
}},
Links: []contact.Link{
contact.Link{
Label: "blog",
Url: "https://blog.joe.me",
}},
Name: "joe",
Note: "this person is very important",
Phones: []contact.Phone{
contact.Phone{
Label: "home",
Number: "010-12345678",
}},
})
fmt.Println(rsp, err)
}
```
## Update
[https://m3o.com/contact/api#Update](https://m3o.com/contact/api#Update)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/contact"
)
//
func UpdateAcontact() {
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
rsp, err := contactService.Update(&contact.UpdateRequest{
Addresses: []contact.Address{
contact.Address{
Label: "company address",
Location: "123 street address",
}},
Birthday: "1995-01-01",
Emails: []contact.Email{
contact.Email{
Address: "home@example.com",
Label: "home",
}},
Id: "42e48a3c-6221-11ec-96d2-acde48001122",
Links: []contact.Link{
contact.Link{
Label: "blog",
Url: "https://blog.joe.me",
}},
Name: "joe",
Note: "this person is very important",
Phones: []contact.Phone{
contact.Phone{
Label: "home",
Number: "010-12345678",
}},
})
fmt.Println(rsp, err)
}
```

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,61 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/currency/api](
Endpoints:
## Codes
Codes returns the supported currency codes for the API
[https://m3o.com/currency/api#Codes](https://m3o.com/currency/api#Codes)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/currency"
)
// Codes returns the supported currency codes for the API
func GetSupportedCodes() {
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
rsp, err := currencyService.Codes(&currency.CodesRequest{
})
fmt.Println(rsp, err)
}
```
## Rates
Rates returns the currency rates for a given code e.g USD
[https://m3o.com/currency/api#Rates](https://m3o.com/currency/api#Rates)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/currency"
)
// Rates returns the currency rates for a given code e.g USD
func GetRatesForUsd() {
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
rsp, err := currencyService.Rates(&currency.RatesRequest{
Code: "USD",
})
fmt.Println(rsp, err)
}
```
## Convert
Convert returns the currency conversion rate between two pairs e.g USD/GBP
@@ -147,3 +92,58 @@ Date: "2021-05-30",
}
```
## Codes
Codes returns the supported currency codes for the API
[https://m3o.com/currency/api#Codes](https://m3o.com/currency/api#Codes)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/currency"
)
// Codes returns the supported currency codes for the API
func GetSupportedCodes() {
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
rsp, err := currencyService.Codes(&currency.CodesRequest{
})
fmt.Println(rsp, err)
}
```
## Rates
Rates returns the currency rates for a given code e.g USD
[https://m3o.com/currency/api#Rates](https://m3o.com/currency/api#Rates)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/currency"
)
// Rates returns the currency rates for a given code e.g USD
func GetRatesForUsd() {
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
rsp, err := currencyService.Rates(&currency.RatesRequest{
Code: "USD",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,6 +4,67 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/db/api](https:
Endpoints:
## Update
Update a record in the database. Include an "id" in the record to update.
[https://m3o.com/db/api#Update](https://m3o.com/db/api#Update)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/db"
)
// Update a record in the database. Include an "id" in the record to update.
func UpdateArecord() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Update(&db.UpdateRequest{
Record: map[string]interface{}{
"id": "1",
"age": 43,
},
Table: "example",
})
fmt.Println(rsp, err)
}
```
## Delete
Delete a record in the database by id.
[https://m3o.com/db/api#Delete](https://m3o.com/db/api#Delete)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/db"
)
// Delete a record in the database by id.
func DeleteArecord() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Delete(&db.DeleteRequest{
Id: "1",
Table: "example",
})
fmt.Println(rsp, err)
}
```
## ListTables
List tables in the DB
@@ -29,6 +90,35 @@ func ListTables() {
})
fmt.Println(rsp, err)
}
```
## RenameTable
Rename a table
[https://m3o.com/db/api#RenameTable](https://m3o.com/db/api#RenameTable)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/db"
)
// Rename a table
func RenameTable() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.RenameTable(&db.RenameTableRequest{
From: "examples2",
To: "examples3",
})
fmt.Println(rsp, err)
}
```
## Create
@@ -92,35 +182,6 @@ Table: "example",
})
fmt.Println(rsp, err)
}
```
## Delete
Delete a record in the database by id.
[https://m3o.com/db/api#Delete](https://m3o.com/db/api#Delete)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/db"
)
// Delete a record in the database by id.
func DeleteArecord() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Delete(&db.DeleteRequest{
Id: "1",
Table: "example",
})
fmt.Println(rsp, err)
}
```
## Truncate
@@ -177,38 +238,6 @@ func DropTable() {
})
fmt.Println(rsp, err)
}
```
## Update
Update a record in the database. Include an "id" in the record to update.
[https://m3o.com/db/api#Update](https://m3o.com/db/api#Update)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/db"
)
// Update a record in the database. Include an "id" in the record to update.
func UpdateArecord() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Update(&db.UpdateRequest{
Record: map[string]interface{}{
"id": "1",
"age": 43,
},
Table: "example",
})
fmt.Println(rsp, err)
}
```
## Count
@@ -239,32 +268,3 @@ func CountEntriesInAtable() {
}
```
## 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)
}
```

View File

@@ -12,10 +12,10 @@ func main() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Create(&db.CreateRequest{
Record: map[string]interface{}{
"id": "1",
"name": "Jane",
"age": 42,
"isActive": true,
"id": "1",
},
Table: "example",
})

View File

@@ -12,8 +12,8 @@ func main() {
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",
})

View File

@@ -26,9 +26,9 @@ 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",
"user": "john",
},
Topic: "user",

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,6 +4,38 @@ 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.
@@ -90,35 +122,3 @@ 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,6 +4,65 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/function/api](
Endpoints:
## Call
Call a function by name
[https://m3o.com/function/api#Call](https://m3o.com/function/api#Call)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/function"
)
// Call a function by name
func CallAfunction() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.Call(&function.CallRequest{
Name: "helloworld",
Request: map[string]interface{}{
"name": "Alice",
},
})
fmt.Println(rsp, err)
}
```
## 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)
}
```
## List
List all the deployed functions
@@ -29,6 +88,34 @@ func ListFunctions() {
})
fmt.Println(rsp, err)
}
```
## Delete
Delete a function by name
[https://m3o.com/function/api#Delete](https://m3o.com/function/api#Delete)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/function"
)
// Delete a function by name
func DeleteAfunction() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.Delete(&function.DeleteRequest{
Name: "helloworld",
})
fmt.Println(rsp, err)
}
```
## Regions
@@ -176,90 +263,3 @@ func UpdateAfunction() {
}
```
## Call
Call a function by name
[https://m3o.com/function/api#Call](https://m3o.com/function/api#Call)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/function"
)
// Call a function by name
func CallAfunction() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.Call(&function.CallRequest{
Name: "helloworld",
Request: map[string]interface{}{
"name": "Alice",
},
})
fmt.Println(rsp, err)
}
```
## Delete
Delete a function by name
[https://m3o.com/function/api#Delete](https://m3o.com/function/api#Delete)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/function"
)
// Delete a function by name
func DeleteAfunction() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.Delete(&function.DeleteRequest{
Name: "helloworld",
})
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)
}
```

View File

@@ -4,91 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/lists/api](htt
Endpoints:
## List
List all the lists
[https://m3o.com/lists/api#List](https://m3o.com/lists/api#List)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/lists"
)
// List all the lists
func ListAllLists() {
listsService := lists.NewListsService(os.Getenv("M3O_API_TOKEN"))
rsp, err := listsService.List(&lists.ListRequest{
})
fmt.Println(rsp, err)
}
```
## Update
Update a list
[https://m3o.com/lists/api#Update](https://m3o.com/lists/api#Update)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/lists"
)
// Update a list
func UpdateAlist() {
listsService := lists.NewListsService(os.Getenv("M3O_API_TOKEN"))
rsp, err := listsService.Update(&lists.UpdateRequest{
List: &lists.List{
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
},
})
fmt.Println(rsp, err)
}
```
## Delete
Delete a list
[https://m3o.com/lists/api#Delete](https://m3o.com/lists/api#Delete)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/lists"
)
// Delete a list
func DeleteAlist() {
listsService := lists.NewListsService(os.Getenv("M3O_API_TOKEN"))
rsp, err := listsService.Delete(&lists.DeleteRequest{
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
})
fmt.Println(rsp, err)
}
```
## Events
Subscribe to lists events
@@ -185,3 +100,88 @@ func ReadAlist() {
}
```
## List
List all the lists
[https://m3o.com/lists/api#List](https://m3o.com/lists/api#List)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/lists"
)
// List all the lists
func ListAllLists() {
listsService := lists.NewListsService(os.Getenv("M3O_API_TOKEN"))
rsp, err := listsService.List(&lists.ListRequest{
})
fmt.Println(rsp, err)
}
```
## Update
Update a list
[https://m3o.com/lists/api#Update](https://m3o.com/lists/api#Update)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/lists"
)
// Update a list
func UpdateAlist() {
listsService := lists.NewListsService(os.Getenv("M3O_API_TOKEN"))
rsp, err := listsService.Update(&lists.UpdateRequest{
List: &lists.List{
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
},
})
fmt.Println(rsp, err)
}
```
## Delete
Delete a list
[https://m3o.com/lists/api#Delete](https://m3o.com/lists/api#Delete)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/lists"
)
// Delete a list
func DeleteAlist() {
listsService := lists.NewListsService(os.Getenv("M3O_API_TOKEN"))
rsp, err := listsService.Delete(&lists.DeleteRequest{
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
})
fmt.Println(rsp, err)
}
```

View File

@@ -12,9 +12,9 @@ func main() {
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",
})

View File

@@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/nft/api](https
Endpoints:
## Collections
Get a list of collections
[https://m3o.com/nft/api#Collections](https://m3o.com/nft/api#Collections)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/nft"
)
// Get a list of collections
func ListCollections() {
nftService := nft.NewNftService(os.Getenv("M3O_API_TOKEN"))
rsp, err := nftService.Collections(&nft.CollectionsRequest{
Limit: 1,
})
fmt.Println(rsp, err)
}
```
## Assets
Return a list of assets
@@ -61,31 +89,3 @@ Name: "Guybrush Threepwood",
}
```
## Collections
Get a list of collections
[https://m3o.com/nft/api#Collections](https://m3o.com/nft/api#Collections)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/nft"
)
// Get a list of collections
func ListCollections() {
nftService := nft.NewNftService(os.Getenv("M3O_API_TOKEN"))
rsp, err := nftService.Collections(&nft.CollectionsRequest{
Limit: 1,
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,35 +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(&notes.CreateRequest{
Text: "This is my note",
Title: "New Note",
})
fmt.Println(rsp, err)
}
```
## Read
Read a note
@@ -189,3 +160,32 @@ 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(&notes.CreateRequest{
Text: "This is my note",
Title: "New Note",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/quran/api](htt
Endpoints:
## Search
Search the Quran for any form of query or questions
[https://m3o.com/quran/api#Search](https://m3o.com/quran/api#Search)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/quran"
)
// Search the Quran for any form of query or questions
func SearchTheQuran() {
quranService := quran.NewQuranService(os.Getenv("M3O_API_TOKEN"))
rsp, err := quranService.Search(&quran.SearchRequest{
Query: "messenger",
})
fmt.Println(rsp, err)
}
```
## Chapters
List the Chapters (surahs) of the Quran
@@ -120,3 +92,31 @@ func GetVersesOfAchapter() {
}
```
## Search
Search the Quran for any form of query or questions
[https://m3o.com/quran/api#Search](https://m3o.com/quran/api#Search)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/quran"
)
// Search the Quran for any form of query or questions
func SearchTheQuran() {
quranService := quran.NewQuranService(os.Getenv("M3O_API_TOKEN"))
rsp, err := quranService.Search(&quran.SearchRequest{
Query: "messenger",
})
fmt.Println(rsp, err)
}
```

View File

@@ -6,7 +6,7 @@ Endpoints:
## Index
Index a document i.e. insert a document to search for.
Index a record i.e. insert a document to search for.
[https://m3o.com/search/api#Index](https://m3o.com/search/api#Index)
@@ -21,17 +21,14 @@ import(
"go.m3o.com/search"
)
// Index a document i.e. insert a document to search for.
func IndexAdocument() {
// Index a record i.e. insert a document to search for.
func IndexArecord() {
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
rsp, err := searchService.Index(&search.IndexRequest{
Document: &search.Document{
Contents: map[string]interface{}{
"name": "John Doe",
"age": 37,
"starsign": "Leo",
},
Id: "1234",
Data: map[string]interface{}{
"name": "John Doe",
"age": 37,
"starsign": "Leo",
},
Index: "customers",
@@ -42,7 +39,7 @@ Index: "customers",
```
## Search
Search for documents in a given in index
Search for records in a given in index
[https://m3o.com/search/api#Search](https://m3o.com/search/api#Search)
@@ -57,8 +54,8 @@ import(
"go.m3o.com/search"
)
// Search for documents in a given in index
func SearchForAdocument() {
// Search for records in a given in index
func SearchForArecord() {
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
rsp, err := searchService.Search(&search.SearchRequest{
Index: "customers",
@@ -71,7 +68,7 @@ Query: "name == 'John'",
```
## Search
Search for documents in a given in index
Search for records in a given in index
[https://m3o.com/search/api#Search](https://m3o.com/search/api#Search)
@@ -86,7 +83,7 @@ import(
"go.m3o.com/search"
)
// Search for documents in a given in index
// Search for records in a given in index
func SearchOnMultipleFieldsand() {
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
rsp, err := searchService.Search(&search.SearchRequest{
@@ -100,7 +97,7 @@ Query: "name == 'John' AND starsign == 'Leo'",
```
## Search
Search for documents in a given in index
Search for records in a given in index
[https://m3o.com/search/api#Search](https://m3o.com/search/api#Search)
@@ -115,7 +112,7 @@ import(
"go.m3o.com/search"
)
// Search for documents in a given in index
// Search for records in a given in index
func SearchOnMultipleFieldsor() {
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
rsp, err := searchService.Search(&search.SearchRequest{
@@ -129,7 +126,7 @@ Query: "name == 'John' OR name == 'Jane'",
```
## Delete
Delete a document given its ID
Delete a record given its ID
[https://m3o.com/search/api#Delete](https://m3o.com/search/api#Delete)
@@ -144,8 +141,8 @@ import(
"go.m3o.com/search"
)
// Delete a document given its ID
func DeleteAdocument() {
// Delete a record given its ID
func DeleteArecord() {
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
rsp, err := searchService.Delete(&search.DeleteRequest{
Id: "1234",

View File

@@ -0,0 +1,18 @@
package main
import (
"fmt"
"os"
"go.m3o.com/search"
)
// Delete a record given its ID
func main() {
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
rsp, err := searchService.Delete(&search.DeleteRequest{
Id: "1234",
Index: "customers",
})
fmt.Println(rsp, err)
}

View File

@@ -0,0 +1,22 @@
package main
import (
"fmt"
"os"
"go.m3o.com/search"
)
// Index a record i.e. insert a document to search for.
func main() {
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
rsp, err := searchService.Index(&search.IndexRequest{
Data: map[string]interface{}{
"starsign": "Leo",
"name": "John Doe",
"age": 37,
},
Index: "customers",
})
fmt.Println(rsp, err)
}

View File

@@ -0,0 +1,18 @@
package main
import (
"fmt"
"os"
"go.m3o.com/search"
)
// Search for records in a given in index
func main() {
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
rsp, err := searchService.Search(&search.SearchRequest{
Index: "customers",
Query: "name == 'John'",
})
fmt.Println(rsp, err)
}

View File

@@ -7,7 +7,7 @@ import (
"go.m3o.com/search"
)
// Search for documents in a given in index
// Search for records in a given in index
func main() {
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
rsp, err := searchService.Search(&search.SearchRequest{

View File

@@ -7,7 +7,7 @@ import (
"go.m3o.com/search"
)
// Search for documents in a given in index
// Search for records in a given in index
func main() {
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
rsp, err := searchService.Search(&search.SearchRequest{

View File

@@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/space/api](htt
Endpoints:
## 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
@@ -204,31 +232,3 @@ func DownloadAnObject() {
}
```
## 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)
}
```

View File

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

View File

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

View File

@@ -4,6 +4,35 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/sunnah/api](ht
Endpoints:
## Chapters
Get all the chapters of a given book within a collection.
[https://m3o.com/sunnah/api#Chapters](https://m3o.com/sunnah/api#Chapters)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/sunnah"
)
// Get all the chapters of a given book within a collection.
func ListTheChaptersInAbook() {
sunnahService := sunnah.NewSunnahService(os.Getenv("M3O_API_TOKEN"))
rsp, err := sunnahService.Chapters(&sunnah.ChaptersRequest{
Book: 1,
Collection: "bukhari",
})
fmt.Println(rsp, err)
}
```
## Hadiths
Hadiths returns a list of hadiths and their corresponding text for a
@@ -94,32 +123,3 @@ func GetTheBooksWithinAcollection() {
}
```
## Chapters
Get all the chapters of a given book within a collection.
[https://m3o.com/sunnah/api#Chapters](https://m3o.com/sunnah/api#Chapters)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/sunnah"
)
// Get all the chapters of a given book within a collection.
func ListTheChaptersInAbook() {
sunnahService := sunnah.NewSunnahService(os.Getenv("M3O_API_TOKEN"))
rsp, err := sunnahService.Chapters(&sunnah.ChaptersRequest{
Book: 1,
Collection: "bukhari",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,12 +4,12 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/user/api](http
Endpoints:
## Update
## Logout
Update the account username or email
Logout a user account
[https://m3o.com/user/api#Update](https://m3o.com/user/api#Update)
[https://m3o.com/user/api#Logout](https://m3o.com/user/api#Logout)
```go
package example
@@ -21,13 +21,261 @@ import(
"go.m3o.com/user"
)
// Update the account username or email
func UpdateAnAccount() {
// Logout a user account
func LogAuserOut() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.Update(&user.UpdateRequest{
Email: "joe+2@example.com",
Id: "user-1",
Username: "joe",
rsp, err := userService.Logout(&user.LogoutRequest{
SessionId: "df91a612-5b24-4634-99ff-240220ab8f55",
})
fmt.Println(rsp, err)
}
```
## ReadSession
Read a session by the session id. In the event it has expired or is not found and error is returned.
[https://m3o.com/user/api#ReadSession](https://m3o.com/user/api#ReadSession)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Read a session by the session id. In the event it has expired or is not found and error is returned.
func ReadAsessionByTheSessionId() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.ReadSession(&user.ReadSessionRequest{
SessionId: "df91a612-5b24-4634-99ff-240220ab8f55",
})
fmt.Println(rsp, err)
}
```
## List
List all users. Returns a paged list of results
[https://m3o.com/user/api#List](https://m3o.com/user/api#List)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// List all users. Returns a paged list of results
func ListAllUsers() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.List(&user.ListRequest{
Limit: 100,
Offset: 0,
})
fmt.Println(rsp, err)
}
```
## SendMagicLink
Login using email only - Passwordless
[https://m3o.com/user/api#SendMagicLink](https://m3o.com/user/api#SendMagicLink)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Login using email only - Passwordless
func SendAmagicLink() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.SendMagicLink(&user.SendMagicLinkRequest{
Address: "www.example.com",
Email: "joe@example.com",
Endpoint: "verifytoken",
FromName: "Awesome Dot Com",
Subject: "MagicLink to access your account",
TextContent: `Hi there,
Click here to access your account $micro_verification_link`,
})
fmt.Println(rsp, err)
}
```
## VerifyToken
Check whether the token attached to MagicLink is valid or not.
Ideally, you need to call this endpoint from your http request
handler that handles the endpoint which is specified in the
SendMagicLink request.
[https://m3o.com/user/api#VerifyToken](https://m3o.com/user/api#VerifyToken)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Check whether the token attached to MagicLink is valid or not.
// Ideally, you need to call this endpoint from your http request
// handler that handles the endpoint which is specified in the
// SendMagicLink request.
func VerifyAtoken() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.VerifyToken(&user.VerifyTokenRequest{
Token: "EdsUiidouJJJLldjlloofUiorkojflsWWdld",
})
fmt.Println(rsp, err)
}
```
## 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)
}
```
## 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)
}
```
## 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)
}
```
## SendPasswordResetEmail
Send an email with a verification code to reset password.
Call "ResetPassword" endpoint once user provides the code.
[https://m3o.com/user/api#SendPasswordResetEmail](https://m3o.com/user/api#SendPasswordResetEmail)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Send an email with a verification code to reset password.
// Call "ResetPassword" endpoint once user provides the code.
func SendPasswordResetEmail() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.SendPasswordResetEmail(&user.SendPasswordResetEmailRequest{
Email: "joe@example.com",
FromName: "Awesome Dot Com",
Subject: "Password reset",
TextContent: `Hi there,
click here to reset your password: myapp.com/reset/code?=$code`,
})
fmt.Println(rsp, err)
@@ -116,315 +364,6 @@ func ReadAccountByEmail() {
})
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)
}
```
## SendPasswordResetEmail
Send an email with a verification code to reset password.
Call "ResetPassword" endpoint once user provides the code.
[https://m3o.com/user/api#SendPasswordResetEmail](https://m3o.com/user/api#SendPasswordResetEmail)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Send an email with a verification code to reset password.
// Call "ResetPassword" endpoint once user provides the code.
func SendPasswordResetEmail() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.SendPasswordResetEmail(&user.SendPasswordResetEmailRequest{
Email: "joe@example.com",
FromName: "Awesome Dot Com",
Subject: "Password reset",
TextContent: `Hi there,
click here to reset your password: myapp.com/reset/code?=$code`,
})
fmt.Println(rsp, err)
}
```
## 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)
}
```
## SendMagicLink
Login using email only - Passwordless
[https://m3o.com/user/api#SendMagicLink](https://m3o.com/user/api#SendMagicLink)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Login using email only - Passwordless
func SendAmagicLink() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.SendMagicLink(&user.SendMagicLinkRequest{
Address: "www.example.com",
Email: "joe@example.com",
Endpoint: "verifytoken",
FromName: "Awesome Dot Com",
Subject: "MagicLink to access your account",
TextContent: `Hi there,
Click here to access your account $micro_verification_link`,
})
fmt.Println(rsp, err)
}
```
## VerifyToken
Check whether the token attached to MagicLink is valid or not.
Ideally, you need to call this endpoint from your http request
handler that handles the endpoint which is specified in the
SendMagicLink request.
[https://m3o.com/user/api#VerifyToken](https://m3o.com/user/api#VerifyToken)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Check whether the token attached to MagicLink is valid or not.
// Ideally, you need to call this endpoint from your http request
// handler that handles the endpoint which is specified in the
// SendMagicLink request.
func VerifyAtoken() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.VerifyToken(&user.VerifyTokenRequest{
Token: "EdsUiidouJJJLldjlloofUiorkojflsWWdld",
})
fmt.Println(rsp, err)
}
```
## Create
Create a new user account. The email address and username for the account must be unique.
[https://m3o.com/user/api#Create](https://m3o.com/user/api#Create)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Create a new user account. The email address and username for the account must be unique.
func CreateAnAccount() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.Create(&user.CreateRequest{
Email: "joe@example.com",
Id: "user-1",
Password: "Password1",
Username: "joe",
})
fmt.Println(rsp, err)
}
```
## 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)
}
```
## VerifyEmail
Verify the email address of an account from a token sent in an email to the user.
[https://m3o.com/user/api#VerifyEmail](https://m3o.com/user/api#VerifyEmail)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Verify the email address of an account from a token sent in an email to the user.
func VerifyEmail() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.VerifyEmail(&user.VerifyEmailRequest{
Token: "012345",
})
fmt.Println(rsp, err)
}
```
## ReadSession
Read a session by the session id. In the event it has expired or is not found and error is returned.
[https://m3o.com/user/api#ReadSession](https://m3o.com/user/api#ReadSession)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Read a session by the session id. In the event it has expired or is not found and error is returned.
func ReadAsessionByTheSessionId() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.ReadSession(&user.ReadSessionRequest{
SessionId: "df91a612-5b24-4634-99ff-240220ab8f55",
})
fmt.Println(rsp, err)
}
```
## 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)
}
```
## SendVerificationEmail
@@ -505,12 +444,12 @@ NewPassword: "NewPassword1",
}
```
## Delete
## VerifyEmail
Delete an account by id
Verify the email address of an account from a token sent in an email to the user.
[https://m3o.com/user/api#Delete](https://m3o.com/user/api#Delete)
[https://m3o.com/user/api#VerifyEmail](https://m3o.com/user/api#VerifyEmail)
```go
package example
@@ -522,11 +461,72 @@ import(
"go.m3o.com/user"
)
// Delete an account by id
func DeleteUserAccount() {
// 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.Delete(&user.DeleteRequest{
Id: "8b98acbe-0b6a-4d66-a414-5ffbf666786f",
rsp, err := userService.VerifyEmail(&user.VerifyEmailRequest{
Token: "012345",
})
fmt.Println(rsp, err)
}
```
## Create
Create a new user account. The email address and username for the account must be unique.
[https://m3o.com/user/api#Create](https://m3o.com/user/api#Create)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Create a new user account. The email address and username for the account must be unique.
func CreateAnAccount() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.Create(&user.CreateRequest{
Email: "joe@example.com",
Id: "user-1",
Password: "Password1",
Username: "joe",
})
fmt.Println(rsp, err)
}
```
## 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)

View File

@@ -40,7 +40,7 @@ func (t *SearchService) DeleteIndex(request *DeleteIndexRequest) (*DeleteIndexRe
}
// Delete a document given its ID
// Delete a record given its ID
func (t *SearchService) Delete(request *DeleteRequest) (*DeleteResponse, error) {
rsp := &DeleteResponse{}
@@ -48,7 +48,7 @@ func (t *SearchService) Delete(request *DeleteRequest) (*DeleteResponse, error)
}
// Index a document i.e. insert a document to search for.
// Index a record i.e. insert a document to search for.
func (t *SearchService) Index(request *IndexRequest) (*IndexResponse, error) {
rsp := &IndexResponse{}
@@ -56,7 +56,7 @@ func (t *SearchService) Index(request *IndexRequest) (*IndexResponse, error) {
}
// Search for documents in a given in index
// Search for records in a given in index
func (t *SearchService) Search(request *SearchRequest) (*SearchResponse, error) {
rsp := &SearchResponse{}
@@ -81,22 +81,15 @@ type DeleteIndexResponse struct {
}
type DeleteRequest struct {
// The ID of the document to delete
// The ID of the record to delete
Id string `json:"id"`
// The index the document belongs to
// The index the record belongs to
Index string `json:"index"`
}
type DeleteResponse struct {
}
type Document struct {
// The JSON contents of the document
Contents map[string]interface{} `json:"contents"`
// The ID for this document. If blank, one will be generated
Id string `json:"id"`
}
type Field struct {
// The name of the field. Use a `.` separator to define nested fields e.g. foo.bar
Name string `json:"name"`
@@ -105,24 +98,34 @@ type Field struct {
}
type IndexRequest struct {
// The document to index
Document *Document `json:"document"`
// The index this document belongs to
// The data to index
Data map[string]interface{} `json:"data"`
// Optional ID for the record
Id string `json:"id"`
// The index this record belongs to
Index string `json:"index"`
}
type IndexResponse struct {
// the indexed record
Record *Record `json:"record"`
}
type Record struct {
// The JSON contents of the record
Data map[string]interface{} `json:"data"`
// The ID for this record. If blank, one will be generated
Id string `json:"id"`
}
type SearchRequest struct {
// The index the document belongs to
// The index the record belongs to
Index string `json:"index"`
// The query. See docs for query language examples
Query string `json:"query"`
}
type SearchResponse struct {
// The matching documents
Documents []Document `json:"documents"`
// The matching records
Records []Record `json:"records"`
}