Commit from m3o/m3o action

This commit is contained in:
m3o-actions
2022-02-20 12:02:04 +00:00
parent c5749cbf5c
commit c41627014b
31 changed files with 1937 additions and 1472 deletions

View File

@@ -4,6 +4,93 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/app/api](https
Endpoints:
## Run
Run an app from source
[https://m3o.com/app/api#Run](https://m3o.com/app/api#Run)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/app"
)
// Run an app from source
func RunAnApp() {
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
rsp, err := appService.Run(&app.RunRequest{
Branch: "master",
Name: "helloworld",
Port: 8080,
Region: "europe-west1",
Repo: "github.com/asim/helloworld",
})
fmt.Println(rsp, err)
}
```
## Regions
Return the support regions
[https://m3o.com/app/api#Regions](https://m3o.com/app/api#Regions)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/app"
)
// Return the support regions
func ListRegions() {
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
rsp, err := appService.Regions(&app.RegionsRequest{
})
fmt.Println(rsp, err)
}
```
## Status
Get the status of an app
[https://m3o.com/app/api#Status](https://m3o.com/app/api#Status)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/app"
)
// Get the status of an app
func GetTheStatusOfAnApp() {
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
rsp, err := appService.Status(&app.StatusRequest{
Name: "helloworld",
})
fmt.Println(rsp, err)
}
```
## Resolve
Resolve an app by id to its raw backend endpoint
@@ -143,90 +230,3 @@ func ListTheApps() {
}
```
## Run
Run an app from source
[https://m3o.com/app/api#Run](https://m3o.com/app/api#Run)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/app"
)
// Run an app from source
func RunAnApp() {
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
rsp, err := appService.Run(&app.RunRequest{
Branch: "master",
Name: "helloworld",
Port: 8080,
Region: "europe-west1",
Repo: "github.com/asim/helloworld",
})
fmt.Println(rsp, err)
}
```
## Regions
Return the support regions
[https://m3o.com/app/api#Regions](https://m3o.com/app/api#Regions)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/app"
)
// Return the support regions
func ListRegions() {
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
rsp, err := appService.Regions(&app.RegionsRequest{
})
fmt.Println(rsp, err)
}
```
## Status
Get the status of an app
[https://m3o.com/app/api#Status](https://m3o.com/app/api#Status)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/app"
)
// Get the status of an app
func GetTheStatusOfAnApp() {
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
rsp, err := appService.Status(&app.StatusRequest{
Name: "helloworld",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,91 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/cache/api](htt
Endpoints:
## Decrement
Decrement a value (if it's a number). If key not found it is equivalent to set.
[https://m3o.com/cache/api#Decrement](https://m3o.com/cache/api#Decrement)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/cache"
)
// Decrement a value (if it's a number). If key not found it is equivalent to set.
func DecrementAvalue() {
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
rsp, err := cacheService.Decrement(&cache.DecrementRequest{
Key: "counter",
Value: 2,
})
fmt.Println(rsp, err)
}
```
## ListKeys
List all the available keys
[https://m3o.com/cache/api#ListKeys](https://m3o.com/cache/api#ListKeys)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/cache"
)
// List all the available keys
func ListTheKeys() {
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
rsp, err := cacheService.ListKeys(&cache.ListKeysRequest{
})
fmt.Println(rsp, err)
}
```
## Set
Set 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.
@@ -174,3 +89,88 @@ Value: 2,
}
```
## Decrement
Decrement a value (if it's a number). If key not found it is equivalent to set.
[https://m3o.com/cache/api#Decrement](https://m3o.com/cache/api#Decrement)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/cache"
)
// Decrement a value (if it's a number). If key not found it is equivalent to set.
func DecrementAvalue() {
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
rsp, err := cacheService.Decrement(&cache.DecrementRequest{
Key: "counter",
Value: 2,
})
fmt.Println(rsp, err)
}
```
## ListKeys
List all the available keys
[https://m3o.com/cache/api#ListKeys](https://m3o.com/cache/api#ListKeys)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/cache"
)
// List all the available keys
func ListTheKeys() {
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
rsp, err := cacheService.ListKeys(&cache.ListKeysRequest{
})
fmt.Println(rsp, err)
}
```
## 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)
}
```

View File

@@ -4,12 +4,12 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/chat/api](http
Endpoints:
## Delete
## New
Delete a chat room
Create a new chat room
[https://m3o.com/chat/api#Delete](https://m3o.com/chat/api#Delete)
[https://m3o.com/chat/api#New](https://m3o.com/chat/api#New)
```go
package example
@@ -21,11 +21,13 @@ import(
"go.m3o.com/chat"
)
// Delete a chat room
func DeleteAchat() {
// Create a new chat room
func CreateAnewChat() {
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
rsp, err := chatService.Delete(&chat.DeleteRequest{
rsp, err := chatService.New(&chat.NewRequest{
Description: "The general chat room",
Name: "general",
})
fmt.Println(rsp, err)
@@ -83,148 +85,6 @@ func GetChatHistory() {
})
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)
}
```
## Kick
Kick a user from a chat room
[https://m3o.com/chat/api#Kick](https://m3o.com/chat/api#Kick)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/chat"
)
// Kick a user from a chat room
func KickAuserFromAroom() {
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
rsp, err := chatService.Kick(&chat.KickRequest{
})
fmt.Println(rsp, err)
}
```
## New
Create a new chat room
[https://m3o.com/chat/api#New](https://m3o.com/chat/api#New)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/chat"
)
// Create a new chat room
func CreateAnewChat() {
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
rsp, err := chatService.New(&chat.NewRequest{
Description: "The general chat room",
Name: "general",
})
fmt.Println(rsp, err)
}
```
## List
List available chats
[https://m3o.com/chat/api#List](https://m3o.com/chat/api#List)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/chat"
)
// List available chats
func ListChatRooms() {
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
rsp, err := chatService.List(&chat.ListRequest{
})
fmt.Println(rsp, err)
}
```
## 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)
}
```
## Join
@@ -267,3 +127,143 @@ func JoinAroom() {
}
}
```
## 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)
}
```
## 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)
}
```
## 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)
}
```

View File

@@ -4,6 +4,62 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/contact/api](h
Endpoints:
## List
[https://m3o.com/contact/api#List](https://m3o.com/contact/api#List)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/contact"
)
//
func ListContactsWithDefaultOffsetAndLimitDefaultLimitIs20() {
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
rsp, err := contactService.List(&contact.ListRequest{
})
fmt.Println(rsp, err)
}
```
## List
[https://m3o.com/contact/api#List](https://m3o.com/contact/api#List)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/contact"
)
//
func ListContactsWithSpecificOffsetAndLimit() {
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
rsp, err := contactService.List(&contact.ListRequest{
Limit: 1,
Offset: 1,
})
fmt.Println(rsp, err)
}
```
## Create
@@ -161,59 +217,3 @@ func DeleteAcontact() {
}
```
## List
[https://m3o.com/contact/api#List](https://m3o.com/contact/api#List)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/contact"
)
//
func ListContactsWithDefaultOffsetAndLimitDefaultLimitIs20() {
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
rsp, err := contactService.List(&contact.ListRequest{
})
fmt.Println(rsp, err)
}
```
## List
[https://m3o.com/contact/api#List](https://m3o.com/contact/api#List)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/contact"
)
//
func ListContactsWithSpecificOffsetAndLimit() {
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
rsp, err := contactService.List(&contact.ListRequest{
Limit: 1,
Offset: 1,
})
fmt.Println(rsp, err)
}
```

View File

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

View File

@@ -4,6 +4,35 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/currency/api](
Endpoints:
## History
Returns the historic rates for a currency on a given date
[https://m3o.com/currency/api#History](https://m3o.com/currency/api#History)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/currency"
)
// Returns the historic rates for a currency on a given date
func HistoricRatesForAcurrency() {
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
rsp, err := currencyService.History(&currency.HistoryRequest{
Code: "USD",
Date: "2021-05-30",
})
fmt.Println(rsp, err)
}
```
## Codes
Codes returns the supported currency codes for the API
@@ -118,32 +147,3 @@ To: "GBP",
}
```
## History
Returns the historic rates for a currency on a given date
[https://m3o.com/currency/api#History](https://m3o.com/currency/api#History)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/currency"
)
// Returns the historic rates for a currency on a given date
func HistoricRatesForAcurrency() {
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
rsp, err := currencyService.History(&currency.HistoryRequest{
Code: "USD",
Date: "2021-05-30",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,38 +4,6 @@ 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.
@@ -63,154 +31,6 @@ Table: "example",
})
fmt.Println(rsp, err)
}
```
## Count
Count records in a table
[https://m3o.com/db/api#Count](https://m3o.com/db/api#Count)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/db"
)
// Count records in a table
func CountEntriesInAtable() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Count(&db.CountRequest{
Table: "example",
})
fmt.Println(rsp, err)
}
```
## RenameTable
Rename a table
[https://m3o.com/db/api#RenameTable](https://m3o.com/db/api#RenameTable)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/db"
)
// Rename a table
func RenameTable() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.RenameTable(&db.RenameTableRequest{
From: "examples2",
To: "examples3",
})
fmt.Println(rsp, err)
}
```
## Create
Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
[https://m3o.com/db/api#Create](https://m3o.com/db/api#Create)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/db"
)
// Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
func CreateArecord() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Create(&db.CreateRequest{
Record: map[string]interface{}{
"id": "1",
"name": "Jane",
"age": 42,
"isActive": true,
},
Table: "example",
})
fmt.Println(rsp, err)
}
```
## Read
Read data from a table. Lookup can be by ID or via querying any field in the record.
[https://m3o.com/db/api#Read](https://m3o.com/db/api#Read)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/db"
)
// Read data from a table. Lookup can be by ID or via querying any field in the record.
func ReadRecords() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Read(&db.ReadRequest{
Query: "age == 43",
Table: "example",
})
fmt.Println(rsp, err)
}
```
## Truncate
Truncate the records in a table
[https://m3o.com/db/api#Truncate](https://m3o.com/db/api#Truncate)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/db"
)
// Truncate the records in a table
func TruncateTable() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Truncate(&db.TruncateRequest{
Table: "example",
})
fmt.Println(rsp, err)
}
```
## DropTable
@@ -268,3 +88,183 @@ func ListTables() {
}
```
## 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)
}
```
## 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)
}
```
## Read
Read data from a table. Lookup can be by ID or via querying any field in the record.
[https://m3o.com/db/api#Read](https://m3o.com/db/api#Read)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/db"
)
// Read data from a table. Lookup can be by ID or via querying any field in the record.
func ReadRecords() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Read(&db.ReadRequest{
Query: "age == 43",
Table: "example",
})
fmt.Println(rsp, err)
}
```
## Count
Count records in a table
[https://m3o.com/db/api#Count](https://m3o.com/db/api#Count)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/db"
)
// Count records in a table
func CountEntriesInAtable() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Count(&db.CountRequest{
Table: "example",
})
fmt.Println(rsp, err)
}
```
## Create
Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
[https://m3o.com/db/api#Create](https://m3o.com/db/api#Create)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/db"
)
// Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
func CreateArecord() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Create(&db.CreateRequest{
Record: map[string]interface{}{
"id": "1",
"name": "Jane",
"age": 42,
"isActive": true,
},
Table: "example",
})
fmt.Println(rsp, err)
}
```
## Truncate
Truncate the records in a table
[https://m3o.com/db/api#Truncate](https://m3o.com/db/api#Truncate)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/db"
)
// Truncate the records in a table
func TruncateTable() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Truncate(&db.TruncateRequest{
Table: "example",
})
fmt.Println(rsp, err)
}
```

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{}{
"isActive": true,
"id": "1",
"name": "Jane",
"age": 42,
"isActive": true,
},
Table: "example",
})

View File

@@ -4,36 +4,6 @@ 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:
@@ -89,3 +59,33 @@ 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

@@ -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,61 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/function/api](
Endpoints:
## 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
@@ -84,6 +29,34 @@ func ListRegions() {
})
fmt.Println(rsp, err)
}
```
## Reserve
Reserve function names and resources beyond free quota
[https://m3o.com/function/api#Reserve](https://m3o.com/function/api#Reserve)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/function"
)
// Reserve function names and resources beyond free quota
func ReserveAfunction() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.Reserve(&function.ReserveRequest{
Name: "helloworld",
})
fmt.Println(rsp, err)
}
```
## Proxy
@@ -112,34 +85,6 @@ func ProxyUrl() {
})
fmt.Println(rsp, err)
}
```
## Update
Update a function. Downloads the source, builds and redeploys
[https://m3o.com/function/api#Update](https://m3o.com/function/api#Update)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/function"
)
// Update a function. Downloads the source, builds and redeploys
func UpdateAfunction() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.Update(&function.UpdateRequest{
Name: "helloworld",
})
fmt.Println(rsp, err)
}
```
## Call
@@ -171,6 +116,61 @@ Request: map[string]interface{}{
})
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
[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
@@ -199,34 +199,6 @@ func DeleteAfunction() {
})
fmt.Println(rsp, err)
}
```
## Reserve
Reserve function names and resources beyond free quota
[https://m3o.com/function/api#Reserve](https://m3o.com/function/api#Reserve)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/function"
)
// Reserve function names and resources beyond free quota
func ReserveAfunction() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.Reserve(&function.ReserveRequest{
Name: "helloworld",
})
fmt.Println(rsp, err)
}
```
## Deploy
@@ -263,3 +235,31 @@ Subfolder: "examples/go-function",
}
```
## Update
Update a function. Downloads the source, builds and redeploys
[https://m3o.com/function/api#Update](https://m3o.com/function/api#Update)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/function"
)
// Update a function. Downloads the source, builds and redeploys
func UpdateAfunction() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.Update(&function.UpdateRequest{
Name: "helloworld",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,6 +4,104 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/image/api](htt
Endpoints:
## Upload
Upload an image by either sending a base64 encoded image to this endpoint or a URL.
To resize an image before uploading, see the Resize endpoint.
To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
with each parameter as a form field.
[https://m3o.com/image/api#Upload](https://m3o.com/image/api#Upload)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/image"
)
// Upload an image by either sending a base64 encoded image to this endpoint or a URL.
// To resize an image before uploading, see the Resize endpoint.
// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
// with each parameter as a form field.
func UploadAbase64imageToMicrosCdn() {
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
rsp, err := imageService.Upload(&image.UploadRequest{
Base64: "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAx0lEQVR4nOzaMaoDMQyE4ZHj+x82vVdhwQoTkzKQEcwP5r0ihT7sbjUTeAJ4HCegXQJYfOYefOyjDuBiz3yjwJBoCIl6QZOeUjTC1Ix1IxEJXF9+0KWsf2bD4bn37OO/c/wuQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9Sa/NG94Tf3j4WBdaxudMEkn4IM2rZBA0wBrvo7aOcpj2emXvLeVt0IGm0GVXUj91mvAAAA//+V2CZl+4AKXwAAAABJRU5ErkJggg==",
Name: "cat.jpeg",
})
fmt.Println(rsp, err)
}
```
## Upload
Upload an image by either sending a base64 encoded image to this endpoint or a URL.
To resize an image before uploading, see the Resize endpoint.
To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
with each parameter as a form field.
[https://m3o.com/image/api#Upload](https://m3o.com/image/api#Upload)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/image"
)
// Upload an image by either sending a base64 encoded image to this endpoint or a URL.
// To resize an image before uploading, see the Resize endpoint.
// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
// with each parameter as a form field.
func UploadAnImageFromAurlToMicrosCdn() {
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
rsp, err := imageService.Upload(&image.UploadRequest{
Name: "cat.jpeg",
Url: "somewebsite.com/cat.png",
})
fmt.Println(rsp, err)
}
```
## Delete
Delete an image previously uploaded.
[https://m3o.com/image/api#Delete](https://m3o.com/image/api#Delete)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/image"
)
// Delete an image previously uploaded.
func DeleteAnUploadedImage() {
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
rsp, err := imageService.Delete(&image.DeleteRequest{
Url: "https://cdn.m3ocontent.com/micro/images/micro/41e23b39-48dd-42b6-9738-79a313414bb8/cat.png",
})
fmt.Println(rsp, err)
}
```
## Resize
Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters.
@@ -158,101 +256,3 @@ Url: "somewebsite.com/cat.png",
}
```
## Upload
Upload an image by either sending a base64 encoded image to this endpoint or a URL.
To resize an image before uploading, see the Resize endpoint.
To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
with each parameter as a form field.
[https://m3o.com/image/api#Upload](https://m3o.com/image/api#Upload)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/image"
)
// Upload an image by either sending a base64 encoded image to this endpoint or a URL.
// To resize an image before uploading, see the Resize endpoint.
// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
// with each parameter as a form field.
func UploadAbase64imageToMicrosCdn() {
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
rsp, err := imageService.Upload(&image.UploadRequest{
Base64: "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAx0lEQVR4nOzaMaoDMQyE4ZHj+x82vVdhwQoTkzKQEcwP5r0ihT7sbjUTeAJ4HCegXQJYfOYefOyjDuBiz3yjwJBoCIl6QZOeUjTC1Ix1IxEJXF9+0KWsf2bD4bn37OO/c/wuQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9Sa/NG94Tf3j4WBdaxudMEkn4IM2rZBA0wBrvo7aOcpj2emXvLeVt0IGm0GVXUj91mvAAAA//+V2CZl+4AKXwAAAABJRU5ErkJggg==",
Name: "cat.jpeg",
})
fmt.Println(rsp, err)
}
```
## Upload
Upload an image by either sending a base64 encoded image to this endpoint or a URL.
To resize an image before uploading, see the Resize endpoint.
To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
with each parameter as a form field.
[https://m3o.com/image/api#Upload](https://m3o.com/image/api#Upload)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/image"
)
// Upload an image by either sending a base64 encoded image to this endpoint or a URL.
// To resize an image before uploading, see the Resize endpoint.
// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
// with each parameter as a form field.
func UploadAnImageFromAurlToMicrosCdn() {
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
rsp, err := imageService.Upload(&image.UploadRequest{
Name: "cat.jpeg",
Url: "somewebsite.com/cat.png",
})
fmt.Println(rsp, err)
}
```
## Delete
Delete an image previously uploaded.
[https://m3o.com/image/api#Delete](https://m3o.com/image/api#Delete)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/image"
)
// Delete an image previously uploaded.
func DeleteAnUploadedImage() {
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
rsp, err := imageService.Delete(&image.DeleteRequest{
Url: "https://cdn.m3ocontent.com/micro/images/micro/41e23b39-48dd-42b6-9738-79a313414bb8/cat.png",
})
fmt.Println(rsp, err)
}
```

187
examples/lists/README.md Executable file
View File

@@ -0,0 +1,187 @@
# Lists
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/lists/api](https://m3o.com/lists/api).
Endpoints:
## Create
Create a new list
[https://m3o.com/lists/api#Create](https://m3o.com/lists/api#Create)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/lists"
)
// Create a new list
func CreateAlist() {
listsService := lists.NewListsService(os.Getenv("M3O_API_TOKEN"))
rsp, err := listsService.Create(&lists.CreateRequest{
})
fmt.Println(rsp, err)
}
```
## Read
Read a list
[https://m3o.com/lists/api#Read](https://m3o.com/lists/api#Read)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/lists"
)
// Read a list
func ReadAlist() {
listsService := lists.NewListsService(os.Getenv("M3O_API_TOKEN"))
rsp, err := listsService.Read(&lists.ReadRequest{
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
})
fmt.Println(rsp, err)
}
```
## 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
[https://m3o.com/lists/api#Events](https://m3o.com/lists/api#Events)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/lists"
)
// Subscribe to lists events
func SubscribeToEvents() {
listsService := lists.NewListsService(os.Getenv("M3O_API_TOKEN"))
stream, err := listsService.Events(&lists.EventsRequest{
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
})
if err != nil {
fmt.Println(err)
return
}
for {
rsp, err := stream.Recv()
if err != nil {
fmt.Println(err)
return
}
fmt.Println(rsp)
}
}
```

View File

@@ -0,0 +1,15 @@
package main
import (
"fmt"
"os"
"go.m3o.com/lists"
)
// Create a new list
func main() {
listsService := lists.NewListsService(os.Getenv("M3O_API_TOKEN"))
rsp, err := listsService.Create(&lists.CreateRequest{})
fmt.Println(rsp, err)
}

View File

@@ -0,0 +1,17 @@
package main
import (
"fmt"
"os"
"go.m3o.com/lists"
)
// Delete a list
func main() {
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

@@ -0,0 +1,30 @@
package main
import (
"fmt"
"os"
"go.m3o.com/lists"
)
// Subscribe to lists events
func main() {
listsService := lists.NewListsService(os.Getenv("M3O_API_TOKEN"))
stream, err := listsService.Events(&lists.EventsRequest{
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
})
if err != nil {
fmt.Println(err)
return
}
for {
rsp, err := stream.Recv()
if err != nil {
fmt.Println(err)
return
}
fmt.Println(rsp)
}
}

View File

@@ -0,0 +1,15 @@
package main
import (
"fmt"
"os"
"go.m3o.com/lists"
)
// List all the lists
func main() {
listsService := lists.NewListsService(os.Getenv("M3O_API_TOKEN"))
rsp, err := listsService.List(&lists.ListRequest{})
fmt.Println(rsp, err)
}

View File

@@ -0,0 +1,17 @@
package main
import (
"fmt"
"os"
"go.m3o.com/lists"
)
// Read a list
func main() {
listsService := lists.NewListsService(os.Getenv("M3O_API_TOKEN"))
rsp, err := listsService.Read(&lists.ReadRequest{
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
})
fmt.Println(rsp, err)
}

View File

@@ -0,0 +1,19 @@
package main
import (
"fmt"
"os"
"go.m3o.com/lists"
)
// Update a list
func main() {
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)
}

View File

@@ -4,6 +4,39 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/mq/api](https:
Endpoints:
## Publish
Publish a message. Specify a topic to group messages for a specific topic.
[https://m3o.com/mq/api#Publish](https://m3o.com/mq/api#Publish)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/mq"
)
// Publish a message. Specify a topic to group messages for a specific topic.
func PublishAmessage() {
mqService := mq.NewMqService(os.Getenv("M3O_API_TOKEN"))
rsp, err := mqService.Publish(&mq.PublishRequest{
Message: map[string]interface{}{
"id": "1",
"type": "signup",
"user": "john",
},
Topic: "events",
})
fmt.Println(rsp, err)
}
```
## Subscribe
Subscribe to messages for a given topic.
@@ -45,36 +78,3 @@ func SubscribeToAtopic() {
}
}
```
## Publish
Publish a message. Specify a topic to group messages for a specific topic.
[https://m3o.com/mq/api#Publish](https://m3o.com/mq/api#Publish)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/mq"
)
// Publish a message. Specify a topic to group messages for a specific topic.
func PublishAmessage() {
mqService := mq.NewMqService(os.Getenv("M3O_API_TOKEN"))
rsp, err := mqService.Publish(&mq.PublishRequest{
Message: map[string]interface{}{
"id": "1",
"type": "signup",
"user": "john",
},
Topic: "events",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,6 +4,90 @@ 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
[https://m3o.com/notes/api#Read](https://m3o.com/notes/api#Read)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/notes"
)
// Read a note
func ReadAnote() {
notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN"))
rsp, err := notesService.Read(&notes.ReadRequest{
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
})
fmt.Println(rsp, err)
}
```
## List
List all the notes
[https://m3o.com/notes/api#List](https://m3o.com/notes/api#List)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/notes"
)
// List all the notes
func ListAllNotes() {
notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN"))
rsp, err := notesService.List(&notes.ListRequest{
})
fmt.Println(rsp, err)
}
```
## Update
Update a note
@@ -105,87 +189,3 @@ 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)
}
```
## Read
Read a note
[https://m3o.com/notes/api#Read](https://m3o.com/notes/api#Read)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/notes"
)
// Read a note
func ReadAnote() {
notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN"))
rsp, err := notesService.Read(&notes.ReadRequest{
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
})
fmt.Println(rsp, err)
}
```
## List
List all the notes
[https://m3o.com/notes/api#List](https://m3o.com/notes/api#List)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/notes"
)
// List all the notes
func ListAllNotes() {
notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN"))
rsp, err := notesService.List(&notes.ListRequest{
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,6 +4,38 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/quran/api](htt
Endpoints:
## Verses
Lookup the verses (ayahs) for a chapter including
translation, interpretation and breakdown by individual
words.
[https://m3o.com/quran/api#Verses](https://m3o.com/quran/api#Verses)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/quran"
)
// Lookup the verses (ayahs) for a chapter including
// translation, interpretation and breakdown by individual
// words.
func GetVersesOfAchapter() {
quranService := quran.NewQuranService(os.Getenv("M3O_API_TOKEN"))
rsp, err := quranService.Verses(&quran.VersesRequest{
Chapter: 1,
})
fmt.Println(rsp, err)
}
```
## Search
Search the Quran for any form of query or questions
@@ -88,35 +120,3 @@ func GetChapterSummary() {
}
```
## Verses
Lookup the verses (ayahs) for a chapter including
translation, interpretation and breakdown by individual
words.
[https://m3o.com/quran/api#Verses](https://m3o.com/quran/api#Verses)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/quran"
)
// Lookup the verses (ayahs) for a chapter including
// translation, interpretation and breakdown by individual
// words.
func GetVersesOfAchapter() {
quranService := quran.NewQuranService(os.Getenv("M3O_API_TOKEN"))
rsp, err := quranService.Verses(&quran.VersesRequest{
Chapter: 1,
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,6 +4,61 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/rss/api](https
Endpoints:
## Feed
Get an RSS feed by name. If no name is given, all feeds are returned. Default limit is 25 entries.
[https://m3o.com/rss/api#Feed](https://m3o.com/rss/api#Feed)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/rss"
)
// Get an RSS feed by name. If no name is given, all feeds are returned. Default limit is 25 entries.
func ReadAfeed() {
rssService := rss.NewRssService(os.Getenv("M3O_API_TOKEN"))
rsp, err := rssService.Feed(&rss.FeedRequest{
Name: "bbc",
})
fmt.Println(rsp, err)
}
```
## List
List the saved RSS fields
[https://m3o.com/rss/api#List](https://m3o.com/rss/api#List)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/rss"
)
// List the saved RSS fields
func ListRssFeeds() {
rssService := rss.NewRssService(os.Getenv("M3O_API_TOKEN"))
rsp, err := rssService.List(&rss.ListRequest{
})
fmt.Println(rsp, err)
}
```
## Remove
Remove an RSS feed by name
@@ -62,58 +117,3 @@ Url: "http://feeds.bbci.co.uk/news/rss.xml",
}
```
## Feed
Get an RSS feed by name. If no name is given, all feeds are returned. Default limit is 25 entries.
[https://m3o.com/rss/api#Feed](https://m3o.com/rss/api#Feed)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/rss"
)
// Get an RSS feed by name. If no name is given, all feeds are returned. Default limit is 25 entries.
func ReadAfeed() {
rssService := rss.NewRssService(os.Getenv("M3O_API_TOKEN"))
rsp, err := rssService.Feed(&rss.FeedRequest{
Name: "bbc",
})
fmt.Println(rsp, err)
}
```
## List
List the saved RSS fields
[https://m3o.com/rss/api#List](https://m3o.com/rss/api#List)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/rss"
)
// List the saved RSS fields
func ListRssFeeds() {
rssService := rss.NewRssService(os.Getenv("M3O_API_TOKEN"))
rsp, err := rssService.List(&rss.ListRequest{
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,6 +4,62 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/search/api](ht
Endpoints:
## CreateIndex
Create an index by name
[https://m3o.com/search/api#CreateIndex](https://m3o.com/search/api#CreateIndex)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/search"
)
// Create an index by name
func CreateAnIndex() {
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
rsp, err := searchService.CreateIndex(&search.CreateIndexRequest{
Index: "customers",
})
fmt.Println(rsp, err)
}
```
## DeleteIndex
Delete an index by name
[https://m3o.com/search/api#DeleteIndex](https://m3o.com/search/api#DeleteIndex)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/search"
)
// Delete an index by name
func DeleteAnIndex() {
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
rsp, err := searchService.DeleteIndex(&search.DeleteIndexRequest{
Index: "customers",
})
fmt.Println(rsp, err)
}
```
## Index
Index a document i.e. insert a document to search for.
@@ -156,59 +212,3 @@ Index: "customers",
}
```
## CreateIndex
Create an index by name
[https://m3o.com/search/api#CreateIndex](https://m3o.com/search/api#CreateIndex)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/search"
)
// Create an index by name
func CreateAnIndex() {
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
rsp, err := searchService.CreateIndex(&search.CreateIndexRequest{
Index: "customers",
})
fmt.Println(rsp, err)
}
```
## 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,35 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/stream/api](ht
Endpoints:
## SendMessage
Send a message to the stream.
[https://m3o.com/stream/api#SendMessage](https://m3o.com/stream/api#SendMessage)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/stream"
)
// Send a message to the stream.
func SendMessage() {
streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN"))
rsp, err := streamService.SendMessage(&stream.SendMessageRequest{
Channel: "general",
Text: "Hey checkout this tweet https://twitter.com/m3oservices/status/1455291054295498752",
})
fmt.Println(rsp, err)
}
```
## ListMessages
List messages for a given channel
@@ -119,3 +90,32 @@ Name: "general",
}
```
## SendMessage
Send a message to the stream.
[https://m3o.com/stream/api#SendMessage](https://m3o.com/stream/api#SendMessage)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/stream"
)
// Send a message to the stream.
func SendMessage() {
streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN"))
rsp, err := streamService.SendMessage(&stream.SendMessageRequest{
Channel: "general",
Text: "Hey checkout this tweet https://twitter.com/m3oservices/status/1455291054295498752",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,6 +4,61 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/twitter/api](h
Endpoints:
## Trends
Get the current global trending topics
[https://m3o.com/twitter/api#Trends](https://m3o.com/twitter/api#Trends)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/twitter"
)
// Get the current global trending topics
func GetTheCurrentGlobalTrendingTopics() {
twitterService := twitter.NewTwitterService(os.Getenv("M3O_API_TOKEN"))
rsp, err := twitterService.Trends(&twitter.TrendsRequest{
})
fmt.Println(rsp, err)
}
```
## 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
@@ -61,58 +116,3 @@ func SearchForTweets() {
}
```
## Trends
Get the current global trending topics
[https://m3o.com/twitter/api#Trends](https://m3o.com/twitter/api#Trends)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/twitter"
)
// Get the current global trending topics
func GetTheCurrentGlobalTrendingTopics() {
twitterService := twitter.NewTwitterService(os.Getenv("M3O_API_TOKEN"))
rsp, err := twitterService.Trends(&twitter.TrendsRequest{
})
fmt.Println(rsp, err)
}
```
## 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,6 +4,33 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/url/api](https
Endpoints:
## List
List all the shortened URLs
[https://m3o.com/url/api#List](https://m3o.com/url/api#List)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/url"
)
// List all the shortened URLs
func ListYourShortenedUrls() {
urlService := url.NewUrlService(os.Getenv("M3O_API_TOKEN"))
rsp, err := urlService.List(&url.ListRequest{
})
fmt.Println(rsp, err)
}
```
## Shorten
Shorten a long URL
@@ -58,30 +85,3 @@ func ResolveAshortUrlToAlongDestinationUrl() {
}
```
## List
List all the shortened URLs
[https://m3o.com/url/api#List](https://m3o.com/url/api#List)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/url"
)
// List all the shortened URLs
func ListYourShortenedUrls() {
urlService := url.NewUrlService(os.Getenv("M3O_API_TOKEN"))
rsp, err := urlService.List(&url.ListRequest{
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,13 +4,12 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/user/api](http
Endpoints:
## SendPasswordResetEmail
## Create
Send an email with a verification code to reset password.
Call "ResetPassword" endpoint once user provides the code.
Create a new user account. The email address and username for the account must be unique.
[https://m3o.com/user/api#SendPasswordResetEmail](https://m3o.com/user/api#SendPasswordResetEmail)
[https://m3o.com/user/api#Create](https://m3o.com/user/api#Create)
```go
package example
@@ -22,59 +21,26 @@ import(
"go.m3o.com/user"
)
// Send an email with a verification code to reset password.
// Call "ResetPassword" endpoint once user provides the code.
func SendPasswordResetEmail() {
// 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.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{
rsp, err := userService.Create(&user.CreateRequest{
Email: "joe@example.com",
Id: "user-1",
Password: "Password1",
Username: "joe",
})
fmt.Println(rsp, err)
}
```
## Logout
## Update
Logout a user account
Update the account username or email
[https://m3o.com/user/api#Logout](https://m3o.com/user/api#Logout)
[https://m3o.com/user/api#Update](https://m3o.com/user/api#Update)
```go
package example
@@ -86,74 +52,13 @@ import(
"go.m3o.com/user"
)
// Logout a user account
func LogAuserOut() {
// Update the account username or email
func UpdateAnAccount() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.Logout(&user.LogoutRequest{
SessionId: "df91a612-5b24-4634-99ff-240220ab8f55",
})
fmt.Println(rsp, err)
}
```
## List
List all users. Returns a paged list of results
[https://m3o.com/user/api#List](https://m3o.com/user/api#List)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// List all users. Returns a paged list of results
func ListAllUsers() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.List(&user.ListRequest{
Limit: 100,
Offset: 0,
})
fmt.Println(rsp, err)
}
```
## VerifyToken
Check whether the token attached to MagicLink is valid or not.
Ideally, you need to call this endpoint from your http request
handler that handles the endpoint which is specified in the
SendMagicLink request.
[https://m3o.com/user/api#VerifyToken](https://m3o.com/user/api#VerifyToken)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Check whether the token attached to MagicLink is valid or not.
// Ideally, you need to call this endpoint from your http request
// handler that handles the endpoint which is specified in the
// SendMagicLink request.
func VerifyAtoken() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.VerifyToken(&user.VerifyTokenRequest{
Token: "EdsUiidouJJJLldjlloofUiorkojflsWWdld",
rsp, err := userService.Update(&user.UpdateRequest{
Email: "joe+2@example.com",
Id: "user-1",
Username: "joe",
})
fmt.Println(rsp, err)
@@ -205,96 +110,6 @@ Please verify your email by clicking this link: $micro_verification_link`,
})
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)
}
```
## 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)
}
```
## ResetPassword
@@ -328,12 +143,12 @@ NewPassword: "NewPassword1",
}
```
## 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
@@ -345,13 +160,104 @@ 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)
}
```
## SendPasswordResetEmail
Send an email with a verification code to reset password.
Call "ResetPassword" endpoint once user provides the code.
[https://m3o.com/user/api#SendPasswordResetEmail](https://m3o.com/user/api#SendPasswordResetEmail)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Send an email with a verification code to reset password.
// Call "ResetPassword" endpoint once user provides the code.
func SendPasswordResetEmail() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.SendPasswordResetEmail(&user.SendPasswordResetEmailRequest{
Email: "joe@example.com",
FromName: "Awesome Dot Com",
Subject: "Password reset",
TextContent: `Hi there,
click here to reset your password: myapp.com/reset/code?=$code`,
})
fmt.Println(rsp, err)
}
```
## Delete
Delete 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)
}
```
## 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)
@@ -442,12 +348,13 @@ func ReadAccountByEmail() {
}
```
## VerifyEmail
## Login
Verify the email address of an account from a token sent in an email to the 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
[https://m3o.com/user/api#VerifyEmail](https://m3o.com/user/api#VerifyEmail)
[https://m3o.com/user/api#Login](https://m3o.com/user/api#Login)
```go
package example
@@ -459,11 +366,13 @@ import(
"go.m3o.com/user"
)
// Verify the email address of an account from a token sent in an email to the user.
func VerifyEmail() {
// 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.VerifyEmail(&user.VerifyEmailRequest{
Token: "012345",
rsp, err := userService.Login(&user.LoginRequest{
Email: "joe@example.com",
Password: "Password1",
})
fmt.Println(rsp, err)
@@ -496,6 +405,63 @@ func ReadAsessionByTheSessionId() {
})
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)
}
```
## 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
@@ -533,3 +499,37 @@ Click here to access your account $micro_verification_link`,
}
```
## 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)
}
```

View File

@@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/weather/api](h
Endpoints:
## Now
Get the current weather report for a location by postcode, city, zip code, ip address
[https://m3o.com/weather/api#Now](https://m3o.com/weather/api#Now)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/weather"
)
// Get the current weather report for a location by postcode, city, zip code, ip address
func GetCurrentWeather() {
weatherService := weather.NewWeatherService(os.Getenv("M3O_API_TOKEN"))
rsp, err := weatherService.Now(&weather.NowRequest{
Location: "london",
})
fmt.Println(rsp, err)
}
```
## Forecast
Get the weather forecast for the next 1-10 days
@@ -61,3 +33,31 @@ Location: "London",
}
```
## Now
Get the current weather report for a location by postcode, city, zip code, ip address
[https://m3o.com/weather/api#Now](https://m3o.com/weather/api#Now)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/weather"
)
// Get the current weather report for a location by postcode, city, zip code, ip address
func GetCurrentWeather() {
weatherService := weather.NewWeatherService(os.Getenv("M3O_API_TOKEN"))
rsp, err := weatherService.Now(&weather.NowRequest{
Location: "london",
})
fmt.Println(rsp, err)
}
```

162
lists/lists.go Executable file
View File

@@ -0,0 +1,162 @@
package lists
import (
"go.m3o.com/client"
)
type Lists interface {
Create(*CreateRequest) (*CreateResponse, error)
Delete(*DeleteRequest) (*DeleteResponse, error)
Events(*EventsRequest) (*EventsResponseStream, error)
List(*ListRequest) (*ListResponse, error)
Read(*ReadRequest) (*ReadResponse, error)
Update(*UpdateRequest) (*UpdateResponse, error)
}
func NewListsService(token string) *ListsService {
return &ListsService{
client: client.NewClient(&client.Options{
Token: token,
}),
}
}
type ListsService struct {
client *client.Client
}
// Create a new list
func (t *ListsService) Create(request *CreateRequest) (*CreateResponse, error) {
rsp := &CreateResponse{}
return rsp, t.client.Call("lists", "Create", request, rsp)
}
// Delete a list
func (t *ListsService) Delete(request *DeleteRequest) (*DeleteResponse, error) {
rsp := &DeleteResponse{}
return rsp, t.client.Call("lists", "Delete", request, rsp)
}
// Subscribe to lists events
func (t *ListsService) Events(request *EventsRequest) (*EventsResponseStream, error) {
stream, err := t.client.Stream("lists", "Events", request)
if err != nil {
return nil, err
}
return &EventsResponseStream{
stream: stream,
}, nil
}
type EventsResponseStream struct {
stream *client.Stream
}
func (t *EventsResponseStream) Recv() (*EventsResponse, error) {
var rsp EventsResponse
if err := t.stream.Recv(&rsp); err != nil {
return nil, err
}
return &rsp, nil
}
// List all the lists
func (t *ListsService) List(request *ListRequest) (*ListResponse, error) {
rsp := &ListResponse{}
return rsp, t.client.Call("lists", "List", request, rsp)
}
// Read a list
func (t *ListsService) Read(request *ReadRequest) (*ReadResponse, error) {
rsp := &ReadResponse{}
return rsp, t.client.Call("lists", "Read", request, rsp)
}
// Update a list
func (t *ListsService) Update(request *UpdateRequest) (*UpdateResponse, error) {
rsp := &UpdateResponse{}
return rsp, t.client.Call("lists", "Update", request, rsp)
}
type CreateRequest struct {
// list items
Items []string `json:"items"`
// list name
Name string `json:"name"`
}
type CreateResponse struct {
// The created list
List *List `json:"list"`
}
type DeleteRequest struct {
// specify the id of the list
Id string `json:"id"`
}
type DeleteResponse struct {
List *List `json:"list"`
}
type EventsRequest struct {
// optionally specify a list id
Id string `json:"id"`
}
type EventsResponse struct {
// the event which occured; create, delete, update
Event string `json:"event"`
// the list which the operation occured on
List *List `json:"list"`
}
type List struct {
// time at which the list was created
Created string `json:"created"`
// unique id for the list, generated if not specified
Id string `json:"id"`
// items within the list
Items []string `json:"items"`
// name of the list
Name string `json:"name"`
// time at which the list was updated
Updated string `json:"updated"`
}
type ListRequest struct {
}
type ListResponse struct {
// the list of lists
Lists []List `json:"lists"`
}
type ReadRequest struct {
// the list id
Id string `json:"id"`
}
type ReadResponse struct {
// The list
List *List `json:"list"`
}
type UpdateRequest struct {
List *List `json:"list"`
}
type UpdateResponse struct {
List *List `json:"list"`
}

3
m3o.go
View File

@@ -28,6 +28,7 @@ import (
"go.m3o.com/image"
"go.m3o.com/ip"
"go.m3o.com/joke"
"go.m3o.com/lists"
"go.m3o.com/location"
"go.m3o.com/minecraft"
"go.m3o.com/movie"
@@ -94,6 +95,7 @@ func NewClient(token string) *Client {
ImageService: image.NewImageService(token),
IpService: ip.NewIpService(token),
JokeService: joke.NewJokeService(token),
ListsService: lists.NewListsService(token),
LocationService: location.NewLocationService(token),
MinecraftService: minecraft.NewMinecraftService(token),
MovieService: movie.NewMovieService(token),
@@ -160,6 +162,7 @@ type Client struct {
ImageService *image.ImageService
IpService *ip.IpService
JokeService *joke.JokeService
ListsService *lists.ListsService
LocationService *location.LocationService
MinecraftService *minecraft.MinecraftService
MovieService *movie.MovieService