Commit from m3o/m3o action

This commit is contained in:
m3o-actions
2022-03-07 20:20:04 +00:00
parent 6464c39046
commit aab69f0713
28 changed files with 1549 additions and 1549 deletions

View File

@@ -4,90 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/app/api](https
Endpoints:
## Status
Get the status of an app
[https://m3o.com/app/api#Status](https://m3o.com/app/api#Status)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/app"
)
// Get the status of an app
func GetTheStatusOfAnApp() {
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
rsp, err := appService.Status(&app.StatusRequest{
Name: "helloworld",
})
fmt.Println(rsp, err)
}
```
## Resolve
Resolve an app by id to its raw backend endpoint
[https://m3o.com/app/api#Resolve](https://m3o.com/app/api#Resolve)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/app"
)
// Resolve an app by id to its raw backend endpoint
func ResolveAppById() {
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
rsp, err := appService.Resolve(&app.ResolveRequest{
Id: "helloworld",
})
fmt.Println(rsp, err)
}
```
## Update
Update the app. The latest source code will be downloaded, built and deployed.
[https://m3o.com/app/api#Update](https://m3o.com/app/api#Update)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/app"
)
// Update the app. The latest source code will be downloaded, built and deployed.
func UpdateAnApp() {
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
rsp, err := appService.Update(&app.UpdateRequest{
Name: "helloworld",
})
fmt.Println(rsp, err)
}
```
## Delete
Delete an app
@@ -230,3 +146,87 @@ func ListRegions() {
}
```
## Status
Get the status of an app
[https://m3o.com/app/api#Status](https://m3o.com/app/api#Status)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/app"
)
// Get the status of an app
func GetTheStatusOfAnApp() {
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
rsp, err := appService.Status(&app.StatusRequest{
Name: "helloworld",
})
fmt.Println(rsp, err)
}
```
## Resolve
Resolve an app by id to its raw backend endpoint
[https://m3o.com/app/api#Resolve](https://m3o.com/app/api#Resolve)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/app"
)
// Resolve an app by id to its raw backend endpoint
func ResolveAppById() {
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
rsp, err := appService.Resolve(&app.ResolveRequest{
Id: "helloworld",
})
fmt.Println(rsp, err)
}
```
## Update
Update the app. The latest source code will be downloaded, built and deployed.
[https://m3o.com/app/api#Update](https://m3o.com/app/api#Update)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/app"
)
// Update the app. The latest source code will be downloaded, built and deployed.
func UpdateAnApp() {
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
rsp, err := appService.Update(&app.UpdateRequest{
Name: "helloworld",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,62 +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.
[https://m3o.com/cache/api#Delete](https://m3o.com/cache/api#Delete)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/cache"
)
// Delete a value from the cache. If key not found a success response is returned.
func DeleteAvalue() {
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
rsp, err := cacheService.Delete(&cache.DeleteRequest{
Key: "foo",
})
fmt.Println(rsp, err)
}
```
## Increment
Increment a value (if it's a number). If key not found it is equivalent to set.
@@ -174,3 +118,59 @@ Value: "bar",
}
```
## Get
Get an item from the cache by key. If key is not found, an empty response is returned.
[https://m3o.com/cache/api#Get](https://m3o.com/cache/api#Get)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/cache"
)
// Get an item from the cache by key. If key is not found, an empty response is returned.
func GetAvalue() {
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
rsp, err := cacheService.Get(&cache.GetRequest{
Key: "foo",
})
fmt.Println(rsp, err)
}
```
## Delete
Delete a value from the cache. If key not found a success response is returned.
[https://m3o.com/cache/api#Delete](https://m3o.com/cache/api#Delete)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/cache"
)
// Delete a value from the cache. If key not found a success response is returned.
func DeleteAvalue() {
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
rsp, err := cacheService.Delete(&cache.DeleteRequest{
Key: "foo",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,6 +4,46 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/chat/api](http
Endpoints:
## Join
Join a chat room
[https://m3o.com/chat/api#Join](https://m3o.com/chat/api#Join)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/chat"
)
// Join a chat room
func JoinAroom() {
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
stream, err := chatService.Join(&chat.JoinRequest{
})
if err != nil {
fmt.Println(err)
return
}
for {
rsp, err := stream.Recv()
if err != nil {
fmt.Println(err)
return
}
fmt.Println(rsp)
}
}
```
## List
List available chats
@@ -88,6 +128,60 @@ 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)
}
```
## Kick
Kick a user from a chat room
[https://m3o.com/chat/api#Kick](https://m3o.com/chat/api#Kick)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/chat"
)
// Kick a user from a chat room
func KickAuserFromAroom() {
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
rsp, err := chatService.Kick(&chat.KickRequest{
})
fmt.Println(rsp, err)
}
```
## Leave
@@ -173,97 +267,3 @@ func DeleteAchat() {
}
```
## History
List the messages in a chat
[https://m3o.com/chat/api#History](https://m3o.com/chat/api#History)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/chat"
)
// List the messages in a chat
func GetChatHistory() {
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
rsp, err := chatService.History(&chat.HistoryRequest{
})
fmt.Println(rsp, err)
}
```
## Join
Join a chat room
[https://m3o.com/chat/api#Join](https://m3o.com/chat/api#Join)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/chat"
)
// Join a chat room
func JoinAroom() {
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
stream, err := chatService.Join(&chat.JoinRequest{
})
if err != nil {
fmt.Println(err)
return
}
for {
rsp, err := stream.Recv()
if err != nil {
fmt.Println(err)
return
}
fmt.Println(rsp)
}
}
```
## 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,89 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/comments/api](
Endpoints:
## Create
Create a new comment
[https://m3o.com/comments/api#Create](https://m3o.com/comments/api#Create)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/comments"
)
// Create a new comment
func CreateAcomment() {
commentsService := comments.NewCommentsService(os.Getenv("M3O_API_TOKEN"))
rsp, err := commentsService.Create(&comments.CreateRequest{
Text: "This is my comment",
})
fmt.Println(rsp, err)
}
```
## Read
Read a comment
[https://m3o.com/comments/api#Read](https://m3o.com/comments/api#Read)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/comments"
)
// Read a comment
func ReadAcomment() {
commentsService := comments.NewCommentsService(os.Getenv("M3O_API_TOKEN"))
rsp, err := commentsService.Read(&comments.ReadRequest{
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
})
fmt.Println(rsp, err)
}
```
## List
List all the comments
[https://m3o.com/comments/api#List](https://m3o.com/comments/api#List)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/comments"
)
// List all the comments
func ListAllComments() {
commentsService := comments.NewCommentsService(os.Getenv("M3O_API_TOKEN"))
rsp, err := commentsService.List(&comments.ListRequest{
})
fmt.Println(rsp, err)
}
```
## Update
Update a comment
@@ -105,86 +188,3 @@ func SubscribeToEvents() {
}
}
```
## Create
Create a new comment
[https://m3o.com/comments/api#Create](https://m3o.com/comments/api#Create)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/comments"
)
// Create a new comment
func CreateAcomment() {
commentsService := comments.NewCommentsService(os.Getenv("M3O_API_TOKEN"))
rsp, err := commentsService.Create(&comments.CreateRequest{
Text: "This is my comment",
})
fmt.Println(rsp, err)
}
```
## Read
Read a comment
[https://m3o.com/comments/api#Read](https://m3o.com/comments/api#Read)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/comments"
)
// Read a comment
func ReadAcomment() {
commentsService := comments.NewCommentsService(os.Getenv("M3O_API_TOKEN"))
rsp, err := commentsService.Read(&comments.ReadRequest{
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
})
fmt.Println(rsp, err)
}
```
## List
List all the comments
[https://m3o.com/comments/api#List](https://m3o.com/comments/api#List)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/comments"
)
// List all the comments
func ListAllComments() {
commentsService := comments.NewCommentsService(os.Getenv("M3O_API_TOKEN"))
rsp, err := commentsService.List(&comments.ListRequest{
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,61 +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)
}
```
## Symbols
Returns the full list of supported symbols
[https://m3o.com/crypto/api#Symbols](https://m3o.com/crypto/api#Symbols)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/crypto"
)
// Returns the full list of supported symbols
func GetListOfAllSupportedSymbols() {
cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN"))
rsp, err := cryptoService.Symbols(&crypto.SymbolsRequest{
})
fmt.Println(rsp, err)
}
```
## News
Get news related to a currency
@@ -143,3 +88,58 @@ 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)
}
```
## Symbols
Returns the full list of supported symbols
[https://m3o.com/crypto/api#Symbols](https://m3o.com/crypto/api#Symbols)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/crypto"
)
// Returns the full list of supported symbols
func GetListOfAllSupportedSymbols() {
cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN"))
rsp, err := cryptoService.Symbols(&crypto.SymbolsRequest{
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,6 +4,186 @@ 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)
}
```
## 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{}{
"age": 42,
"isActive": true,
"id": "1",
"name": "Jane",
},
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
Drop a table in the DB
@@ -88,183 +268,3 @@ To: "examples3",
}
```
## 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)
}
```
## Truncate
Truncate the records in a table
[https://m3o.com/db/api#Truncate](https://m3o.com/db/api#Truncate)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/db"
)
// Truncate the records in a table
func TruncateTable() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Truncate(&db.TruncateRequest{
Table: "example",
})
fmt.Println(rsp, err)
}
```
## Count
Count records in a table
[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)
}
```
## 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)
}
```

View File

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

View File

@@ -4,39 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/event/api](htt
Endpoints:
## Publish
Publish a event to the event stream.
[https://m3o.com/event/api#Publish](https://m3o.com/event/api#Publish)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/event"
)
// Publish a event to the event stream.
func PublishAnEvent() {
eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN"))
rsp, err := eventService.Publish(&event.PublishRequest{
Message: map[string]interface{}{
"id": "1",
"type": "signup",
"user": "john",
},
Topic: "user",
})
fmt.Println(rsp, err)
}
```
## Consume
Consume events from a given topic.
@@ -106,3 +73,36 @@ func ReadEventsOnAtopic() {
}
```
## Publish
Publish a event to the event stream.
[https://m3o.com/event/api#Publish](https://m3o.com/event/api#Publish)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/event"
)
// Publish a event to the event stream.
func PublishAnEvent() {
eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN"))
rsp, err := eventService.Publish(&event.PublishRequest{
Message: map[string]interface{}{
"id": "1",
"type": "signup",
"user": "john",
},
Topic: "user",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,35 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/file/api](http
Endpoints:
## Delete
Delete a file by project name/path
[https://m3o.com/file/api#Delete](https://m3o.com/file/api#Delete)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/file"
)
// Delete a file by project name/path
func DeleteFile() {
fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN"))
rsp, err := fileService.Delete(&file.DeleteRequest{
Path: "/document/text-files/file.txt",
Project: "examples",
})
fmt.Println(rsp, err)
}
```
## Save
Save a file
@@ -122,3 +93,32 @@ Project: "examples",
}
```
## Delete
Delete a file by project name/path
[https://m3o.com/file/api#Delete](https://m3o.com/file/api#Delete)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/file"
)
// Delete a file by project name/path
func DeleteFile() {
fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN"))
rsp, err := fileService.Delete(&file.DeleteRequest{
Path: "/document/text-files/file.txt",
Project: "examples",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/forex/api](htt
Endpoints:
## History
Returns the data for the previous close
[https://m3o.com/forex/api#History](https://m3o.com/forex/api#History)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/forex"
)
// Returns the data for the previous close
func GetPreviousClose() {
forexService := forex.NewForexService(os.Getenv("M3O_API_TOKEN"))
rsp, err := forexService.History(&forex.HistoryRequest{
Symbol: "GBPUSD",
})
fmt.Println(rsp, err)
}
```
## Price
Get the latest price for a given forex ticker
@@ -88,3 +60,31 @@ func GetAfxQuote() {
}
```
## History
Returns the data for the previous close
[https://m3o.com/forex/api#History](https://m3o.com/forex/api#History)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/forex"
)
// Returns the data for the previous close
func GetPreviousClose() {
forexService := forex.NewForexService(os.Getenv("M3O_API_TOKEN"))
rsp, err := forexService.History(&forex.HistoryRequest{
Symbol: "GBPUSD",
})
fmt.Println(rsp, err)
}
```

View File

@@ -38,12 +38,12 @@ Subfolder: "examples/go-function",
}
```
## Delete
## List
Delete a function by name
List all the deployed functions
[https://m3o.com/function/api#Delete](https://m3o.com/function/api#Delete)
[https://m3o.com/function/api#List](https://m3o.com/function/api#List)
```go
package example
@@ -55,23 +55,22 @@ import(
"go.m3o.com/function"
)
// Delete a function by name
func DeleteAfunction() {
// List all the deployed functions
func ListFunctions() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.Delete(&function.DeleteRequest{
Name: "helloworld",
rsp, err := functionService.List(&function.ListRequest{
})
fmt.Println(rsp, err)
}
```
## Reserve
## Describe
Reserve function names and resources beyond free quota
Get the info for a deployed function
[https://m3o.com/function/api#Reserve](https://m3o.com/function/api#Reserve)
[https://m3o.com/function/api#Describe](https://m3o.com/function/api#Describe)
```go
package example
@@ -83,10 +82,10 @@ import(
"go.m3o.com/function"
)
// Reserve function names and resources beyond free quota
func ReserveAfunction() {
// Get the info for a deployed function
func DescribeFunctionStatus() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.Reserve(&function.ReserveRequest{
rsp, err := functionService.Describe(&function.DescribeRequest{
Name: "helloworld",
})
@@ -235,12 +234,12 @@ Request: map[string]interface{}{
}
```
## List
## Delete
List all the deployed functions
Delete a function by name
[https://m3o.com/function/api#List](https://m3o.com/function/api#List)
[https://m3o.com/function/api#Delete](https://m3o.com/function/api#Delete)
```go
package example
@@ -252,37 +251,38 @@ import(
"go.m3o.com/function"
)
// List all the deployed functions
func ListFunctions() {
// Delete a function by name
func DeleteAfunction() {
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{
rsp, err := functionService.Delete(&function.DeleteRequest{
Name: "helloworld",
})
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",
})

View File

@@ -4,6 +4,91 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/lists/api](htt
Endpoints:
## 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
@@ -100,88 +185,3 @@ func CreateAlist() {
}
```
## 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)
}
```

View File

@@ -4,33 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/memegen/api](h
Endpoints:
## Templates
List the available templates
[https://m3o.com/memegen/api#Templates](https://m3o.com/memegen/api#Templates)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/memegen"
)
// List the available templates
func MemeTemplates() {
memegenService := memegen.NewMemegenService(os.Getenv("M3O_API_TOKEN"))
rsp, err := memegenService.Templates(&memegen.TemplatesRequest{
})
fmt.Println(rsp, err)
}
```
## Generate
Generate a meme using a template
@@ -59,3 +32,30 @@ func GenerateAmeme() {
}
```
## Templates
List the available templates
[https://m3o.com/memegen/api#Templates](https://m3o.com/memegen/api#Templates)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/memegen"
)
// List the available templates
func MemeTemplates() {
memegenService := memegen.NewMemegenService(os.Getenv("M3O_API_TOKEN"))
rsp, err := memegenService.Templates(&memegen.TemplatesRequest{
})
fmt.Println(rsp, err)
}
```

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{}{
"id": "1",
"type": "signup",
"user": "john",
"id": "1",
},
Topic: "events",
})

View File

@@ -4,63 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/nft/api](https
Endpoints:
## Assets
Return a list of assets
[https://m3o.com/nft/api#Assets](https://m3o.com/nft/api#Assets)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/nft"
)
// Return a list of assets
func GetAlistOfAssets() {
nftService := nft.NewNftService(os.Getenv("M3O_API_TOKEN"))
rsp, err := nftService.Assets(&nft.AssetsRequest{
Limit: 1,
})
fmt.Println(rsp, err)
}
```
## Create
Create your own NFT (coming soon)
[https://m3o.com/nft/api#Create](https://m3o.com/nft/api#Create)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/nft"
)
// Create your own NFT (coming soon)
func CreateAnNft() {
nftService := nft.NewNftService(os.Getenv("M3O_API_TOKEN"))
rsp, err := nftService.Create(&nft.CreateRequest{
Description: "The epic monkey island character",
Name: "Guybrush Threepwood",
})
fmt.Println(rsp, err)
}
```
## Collections
Get a list of collections
@@ -144,3 +87,60 @@ func GetAsingleCollection() {
}
```
## Assets
Return a list of assets
[https://m3o.com/nft/api#Assets](https://m3o.com/nft/api#Assets)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/nft"
)
// Return a list of assets
func GetAlistOfAssets() {
nftService := nft.NewNftService(os.Getenv("M3O_API_TOKEN"))
rsp, err := nftService.Assets(&nft.AssetsRequest{
Limit: 1,
})
fmt.Println(rsp, err)
}
```
## Create
Create your own NFT (coming soon)
[https://m3o.com/nft/api#Create](https://m3o.com/nft/api#Create)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/nft"
)
// Create your own NFT (coming soon)
func CreateAnNft() {
nftService := nft.NewNftService(os.Getenv("M3O_API_TOKEN"))
rsp, err := nftService.Create(&nft.CreateRequest{
Description: "The epic monkey island character",
Name: "Guybrush Threepwood",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/ping/api](http
Endpoints:
## Ip
Ping an IP address
[https://m3o.com/ping/api#Ip](https://m3o.com/ping/api#Ip)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/ping"
)
// Ping an IP address
func PingAnIp() {
pingService := ping.NewPingService(os.Getenv("M3O_API_TOKEN"))
rsp, err := pingService.Ip(&ping.IpRequest{
Address: "google.com",
})
fmt.Println(rsp, err)
}
```
## Tcp
Ping a TCP port is open
@@ -88,3 +60,31 @@ func CheckAurl() {
}
```
## Ip
Ping an IP address
[https://m3o.com/ping/api#Ip](https://m3o.com/ping/api#Ip)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/ping"
)
// Ping an IP address
func PingAnIp() {
pingService := ping.NewPingService(os.Getenv("M3O_API_TOKEN"))
rsp, err := pingService.Ip(&ping.IpRequest{
Address: "google.com",
})
fmt.Println(rsp, err)
}
```

View File

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

View File

@@ -4,6 +4,41 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/routing/api](h
Endpoints:
## Route
Retrieve a route as a simple list of gps points along with total distance and estimated duration
[https://m3o.com/routing/api#Route](https://m3o.com/routing/api#Route)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/routing"
)
// Retrieve a route as a simple list of gps points along with total distance and estimated duration
func GpsPointsForAroute() {
routingService := routing.NewRoutingService(os.Getenv("M3O_API_TOKEN"))
rsp, err := routingService.Route(&routing.RouteRequest{
Destination: &routing.Point{
Latitude: 52.529407,
Longitude: 13.397634,
},
Origin: &routing.Point{
Latitude: 52.517037,
Longitude: 13.38886,
},
})
fmt.Println(rsp, err)
}
```
## Eta
Get the eta for a route from origin to destination. The eta is an estimated time based on car routes
@@ -74,38 +109,3 @@ Origin: &routing.Point{
}
```
## Route
Retrieve a route as a simple list of gps points along with total distance and estimated duration
[https://m3o.com/routing/api#Route](https://m3o.com/routing/api#Route)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/routing"
)
// Retrieve a route as a simple list of gps points along with total distance and estimated duration
func GpsPointsForAroute() {
routingService := routing.NewRoutingService(os.Getenv("M3O_API_TOKEN"))
rsp, err := routingService.Route(&routing.RouteRequest{
Destination: &routing.Point{
Latitude: 52.529407,
Longitude: 13.397634,
},
Origin: &routing.Point{
Latitude: 52.517037,
Longitude: 13.38886,
},
})
fmt.Println(rsp, err)
}
```

View File

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

View File

@@ -12,9 +12,9 @@ func main() {
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
rsp, err := searchService.Index(&search.IndexRequest{
Data: map[string]interface{}{
"name": "John Doe",
"age": 37,
"starsign": "Leo",
"name": "John Doe",
},
Index: "customers",
})

View File

@@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/space/api](htt
Endpoints:
## Head
Retrieve meta information about an object
[https://m3o.com/space/api#Head](https://m3o.com/space/api#Head)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/space"
)
// Retrieve meta information about an object
func HeadAnObject() {
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
rsp, err := spaceService.Head(&space.HeadRequest{
Name: "images/file.jpg",
})
fmt.Println(rsp, err)
}
```
## Read
Read an object in space
@@ -204,31 +232,3 @@ func ListObjectsWithPrefix() {
}
```
## Head
Retrieve meta information about an object
[https://m3o.com/space/api#Head](https://m3o.com/space/api#Head)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/space"
)
// Retrieve meta information about an object
func HeadAnObject() {
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
rsp, err := spaceService.Head(&space.HeadRequest{
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,33 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/stream/api](ht
Endpoints:
## ListChannels
List all the active channels
[https://m3o.com/stream/api#ListChannels](https://m3o.com/stream/api#ListChannels)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/stream"
)
// List all the active channels
func ListChannels() {
streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN"))
rsp, err := streamService.ListChannels(&stream.ListChannelsRequest{
})
fmt.Println(rsp, err)
}
```
## CreateChannel
Create a channel with a given name and description. Channels are created automatically but
@@ -92,30 +119,3 @@ func ListMessages() {
}
```
## ListChannels
List all the active channels
[https://m3o.com/stream/api#ListChannels](https://m3o.com/stream/api#ListChannels)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/stream"
)
// List all the active channels
func ListChannels() {
streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN"))
rsp, err := streamService.ListChannels(&stream.ListChannelsRequest{
})
fmt.Println(rsp, err)
}
```

View File

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

View File

@@ -4,6 +4,35 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/twitter/api](h
Endpoints:
## Timeline
Get the timeline for a given user
[https://m3o.com/twitter/api#Timeline](https://m3o.com/twitter/api#Timeline)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/twitter"
)
// Get the timeline for a given user
func GetAtwitterTimeline() {
twitterService := twitter.NewTwitterService(os.Getenv("M3O_API_TOKEN"))
rsp, err := twitterService.Timeline(&twitter.TimelineRequest{
Limit: 1,
Username: "m3oservices",
})
fmt.Println(rsp, err)
}
```
## Search
Search for tweets with a simple query
@@ -87,32 +116,3 @@ func GetAusersTwitterProfile() {
}
```
## Timeline
Get the timeline for a given user
[https://m3o.com/twitter/api#Timeline](https://m3o.com/twitter/api#Timeline)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/twitter"
)
// Get the timeline for a given user
func GetAtwitterTimeline() {
twitterService := twitter.NewTwitterService(os.Getenv("M3O_API_TOKEN"))
rsp, err := twitterService.Timeline(&twitter.TimelineRequest{
Limit: 1,
Username: "m3oservices",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,33 +4,6 @@ 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
@@ -85,3 +58,30 @@ 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

@@ -33,299 +33,6 @@ 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)
}
```
## 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)
}
```
## SendMagicLink
Login using email only - Passwordless
[https://m3o.com/user/api#SendMagicLink](https://m3o.com/user/api#SendMagicLink)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Login using email only - Passwordless
func SendAmagicLink() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.SendMagicLink(&user.SendMagicLinkRequest{
Address: "www.example.com",
Email: "joe@example.com",
Endpoint: "verifytoken",
FromName: "Awesome Dot Com",
Subject: "MagicLink to access your account",
TextContent: `Hi there,
Click here to access your account $micro_verification_link`,
})
fmt.Println(rsp, err)
}
```
## Update
Update the account username or email
[https://m3o.com/user/api#Update](https://m3o.com/user/api#Update)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Update the account username or email
func UpdateAnAccount() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.Update(&user.UpdateRequest{
Email: "joe+2@example.com",
Id: "user-1",
Username: "joe",
})
fmt.Println(rsp, err)
}
```
## SendVerificationEmail
Send a verification email to a user.
Email "from" will be 'noreply@email.m3ocontent.com'.
The verification link will be injected in the email
as a template variable, $micro_verification_link e.g
'Welcome to M3O! Use the link below to verify your email: $micro_verification_link'
The variable will be replaced with a url similar to:
'https://user.m3o.com/user/verify?token=a-verification-token&redirectUrl=your-redir-url'
[https://m3o.com/user/api#SendVerificationEmail](https://m3o.com/user/api#SendVerificationEmail)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Send a verification email to a user.
// Email "from" will be 'noreply@email.m3ocontent.com'.
// The verification link will be injected in the email
// as a template variable, $micro_verification_link e.g
// 'Welcome to M3O! Use the link below to verify your email: $micro_verification_link'
// The variable will be replaced with a url similar to:
// 'https://user.m3o.com/user/verify?token=a-verification-token&redirectUrl=your-redir-url'
func SendVerificationEmail() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.SendVerificationEmail(&user.SendVerificationEmailRequest{
Email: "joe@example.com",
FailureRedirectUrl: "https://m3o.com/verification-failed",
FromName: "Awesome Dot Com",
RedirectUrl: "https://m3o.com",
Subject: "Email verification",
TextContent: `Hi there,
Please verify your email by clicking this link: $micro_verification_link`,
})
fmt.Println(rsp, err)
}
```
## ReadSession
Read a session by the session id. In the event it has expired or is not found and error is returned.
[https://m3o.com/user/api#ReadSession](https://m3o.com/user/api#ReadSession)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Read a session by the session id. In the event it has expired or is not found and error is returned.
func ReadAsessionByTheSessionId() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.ReadSession(&user.ReadSessionRequest{
SessionId: "df91a612-5b24-4634-99ff-240220ab8f55",
})
fmt.Println(rsp, err)
}
```
## List
List all users. Returns a paged list of results
[https://m3o.com/user/api#List](https://m3o.com/user/api#List)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// List all users. Returns a paged list of results
func ListAllUsers() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.List(&user.ListRequest{
Limit: 100,
Offset: 0,
})
fmt.Println(rsp, err)
}
```
## VerifyToken
Check whether the token attached to MagicLink is valid or not.
Ideally, you need to call this endpoint from your http request
handler that handles the endpoint which is specified in the
SendMagicLink request.
[https://m3o.com/user/api#VerifyToken](https://m3o.com/user/api#VerifyToken)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Check whether the token attached to MagicLink is valid or not.
// Ideally, you need to call this endpoint from your http request
// handler that handles the endpoint which is specified in the
// SendMagicLink request.
func VerifyAtoken() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.VerifyToken(&user.VerifyTokenRequest{
Token: "EdsUiidouJJJLldjlloofUiorkojflsWWdld",
})
fmt.Println(rsp, err)
}
```
## Read
@@ -412,12 +119,12 @@ func ReadAccountByEmail() {
}
```
## ResetPassword
## Logout
Reset password with the code sent by the "SendPasswordResetEmail" endpoint.
Logout a user account
[https://m3o.com/user/api#ResetPassword](https://m3o.com/user/api#ResetPassword)
[https://m3o.com/user/api#Logout](https://m3o.com/user/api#Logout)
```go
package example
@@ -429,14 +136,120 @@ import(
"go.m3o.com/user"
)
// Reset password with the code sent by the "SendPasswordResetEmail" endpoint.
func ResetPassword() {
// Logout a user account
func LogAuserOut() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.ResetPassword(&user.ResetPasswordRequest{
Code: "012345",
ConfirmPassword: "NewPassword1",
Email: "joe@example.com",
NewPassword: "NewPassword1",
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)
}
```
## VerifyToken
Check whether the token attached to MagicLink is valid or not.
Ideally, you need to call this endpoint from your http request
handler that handles the endpoint which is specified in the
SendMagicLink request.
[https://m3o.com/user/api#VerifyToken](https://m3o.com/user/api#VerifyToken)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Check whether the token attached to MagicLink is valid or not.
// Ideally, you need to call this endpoint from your http request
// handler that handles the endpoint which is specified in the
// SendMagicLink request.
func VerifyAtoken() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.VerifyToken(&user.VerifyTokenRequest{
Token: "EdsUiidouJJJLldjlloofUiorkojflsWWdld",
})
fmt.Println(rsp, err)
}
```
## SendVerificationEmail
Send a verification email to a user.
Email "from" will be 'noreply@email.m3ocontent.com'.
The verification link will be injected in the email
as a template variable, $micro_verification_link e.g
'Welcome to M3O! Use the link below to verify your email: $micro_verification_link'
The variable will be replaced with a url similar to:
'https://user.m3o.com/user/verify?token=a-verification-token&redirectUrl=your-redir-url'
[https://m3o.com/user/api#SendVerificationEmail](https://m3o.com/user/api#SendVerificationEmail)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Send a verification email to a user.
// Email "from" will be 'noreply@email.m3ocontent.com'.
// The verification link will be injected in the email
// as a template variable, $micro_verification_link e.g
// 'Welcome to M3O! Use the link below to verify your email: $micro_verification_link'
// The variable will be replaced with a url similar to:
// 'https://user.m3o.com/user/verify?token=a-verification-token&redirectUrl=your-redir-url'
func SendVerificationEmail() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.SendVerificationEmail(&user.SendVerificationEmailRequest{
Email: "joe@example.com",
FailureRedirectUrl: "https://m3o.com/verification-failed",
FromName: "Awesome Dot Com",
RedirectUrl: "https://m3o.com",
Subject: "Email verification",
TextContent: `Hi there,
Please verify your email by clicking this link: $micro_verification_link`,
})
fmt.Println(rsp, err)
@@ -471,12 +284,12 @@ func VerifyEmail() {
}
```
## Logout
## SendMagicLink
Logout a user account
Login using email only - Passwordless
[https://m3o.com/user/api#Logout](https://m3o.com/user/api#Logout)
[https://m3o.com/user/api#SendMagicLink](https://m3o.com/user/api#SendMagicLink)
```go
package example
@@ -488,11 +301,110 @@ import(
"go.m3o.com/user"
)
// Logout a user account
func LogAuserOut() {
// Login using email only - Passwordless
func SendAmagicLink() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.Logout(&user.LogoutRequest{
SessionId: "df91a612-5b24-4634-99ff-240220ab8f55",
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)
}
```
## 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)
}
```
## 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)
}
```
## 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)
@@ -533,3 +445,91 @@ TextContent: `Hi there,
}
```
## ResetPassword
Reset password with the code sent by the "SendPasswordResetEmail" endpoint.
[https://m3o.com/user/api#ResetPassword](https://m3o.com/user/api#ResetPassword)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Reset password with the code sent by the "SendPasswordResetEmail" endpoint.
func ResetPassword() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.ResetPassword(&user.ResetPasswordRequest{
Code: "012345",
ConfirmPassword: "NewPassword1",
Email: "joe@example.com",
NewPassword: "NewPassword1",
})
fmt.Println(rsp, err)
}
```
## Delete
Delete an account by id
[https://m3o.com/user/api#Delete](https://m3o.com/user/api#Delete)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Delete an account by id
func DeleteUserAccount() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.Delete(&user.DeleteRequest{
Id: "8b98acbe-0b6a-4d66-a414-5ffbf666786f",
})
fmt.Println(rsp, err)
}
```
## List
List all users. Returns a paged list of results
[https://m3o.com/user/api#List](https://m3o.com/user/api#List)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// List all users. Returns a paged list of results
func ListAllUsers() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.List(&user.ListRequest{
Limit: 100,
Offset: 0,
})
fmt.Println(rsp, err)
}
```

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