From eeced0f4bc06f73eae92a907a8fd3aee2274981c Mon Sep 17 00:00:00 2001 From: m3o-actions <> Date: Wed, 9 Mar 2022 07:43:59 +0000 Subject: [PATCH] Commit from m3o/m3o action --- examples/app/README.md | 224 ++++---- examples/cache/README.md | 56 +- examples/chat/README.md | 292 +++++----- examples/comments/README.md | 56 +- examples/crypto/README.md | 56 +- examples/currency/README.md | 54 +- examples/db/README.md | 290 +++++----- examples/email/README.md | 56 +- examples/event/publish/publishAnEvent/main.go | 2 +- examples/file/README.md | 56 +- examples/function/README.md | 246 ++++---- examples/mq/README.md | 66 +-- examples/notes/README.md | 120 ++-- examples/ping/README.md | 56 +- examples/search/README.md | 66 +-- examples/space/README.md | 176 +++--- examples/stream/README.md | 110 ++-- examples/sunnah/README.md | 58 +- examples/twitter/README.md | 110 ++-- examples/user/README.md | 542 +++++++++--------- 20 files changed, 1346 insertions(+), 1346 deletions(-) diff --git a/examples/app/README.md b/examples/app/README.md index adff04f..99d6b0c 100755 --- a/examples/app/README.md +++ b/examples/app/README.md @@ -4,118 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/app/api](https Endpoints: -## 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 - - -[https://m3o.com/app/api#Delete](https://m3o.com/app/api#Delete) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/app" -) - -// Delete an app -func DeleteAnApp() { - appService := app.NewAppService(os.Getenv("M3O_API_TOKEN")) - rsp, err := appService.Delete(&app.DeleteRequest{ - Name: "helloworld", - - }) - fmt.Println(rsp, err) - -} -``` -## Reserve - -Reserve apps beyond the free quota. Call Run after. - - -[https://m3o.com/app/api#Reserve](https://m3o.com/app/api#Reserve) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/app" -) - -// Reserve apps beyond the free quota. Call Run after. -func ReserveAppName() { - appService := app.NewAppService(os.Getenv("M3O_API_TOKEN")) - rsp, err := appService.Reserve(&app.ReserveRequest{ - Name: "helloworld", - - }) - fmt.Println(rsp, err) - -} -``` ## List List all the apps @@ -230,3 +118,115 @@ func GetTheStatusOfAnApp() { } ``` +## 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 + + +[https://m3o.com/app/api#Delete](https://m3o.com/app/api#Delete) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/app" +) + +// Delete an app +func DeleteAnApp() { + appService := app.NewAppService(os.Getenv("M3O_API_TOKEN")) + rsp, err := appService.Delete(&app.DeleteRequest{ + Name: "helloworld", + + }) + fmt.Println(rsp, err) + +} +``` +## Reserve + +Reserve apps beyond the free quota. Call Run after. + + +[https://m3o.com/app/api#Reserve](https://m3o.com/app/api#Reserve) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/app" +) + +// Reserve apps beyond the free quota. Call Run after. +func ReserveAppName() { + appService := app.NewAppService(os.Getenv("M3O_API_TOKEN")) + rsp, err := appService.Reserve(&app.ReserveRequest{ + Name: "helloworld", + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/cache/README.md b/examples/cache/README.md index 575e286..82e340c 100755 --- a/examples/cache/README.md +++ b/examples/cache/README.md @@ -4,6 +4,34 @@ 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. @@ -146,31 +174,3 @@ 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) - -} -``` diff --git a/examples/chat/README.md b/examples/chat/README.md index f06a4e1..1137eed 100755 --- a/examples/chat/README.md +++ b/examples/chat/README.md @@ -4,6 +4,146 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/chat/api](http Endpoints: +## Invite + +Invite a user to a chat room + + +[https://m3o.com/chat/api#Invite](https://m3o.com/chat/api#Invite) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/chat" +) + +// Invite a user to a chat room +func InviteAuser() { + chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN")) + rsp, err := chatService.Invite(&chat.InviteRequest{ + + }) + fmt.Println(rsp, err) + +} +``` +## Send + +Connect to a chat to receive a stream of messages +Send a message to a chat + + +[https://m3o.com/chat/api#Send](https://m3o.com/chat/api#Send) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/chat" +) + +// Connect to a chat to receive a stream of messages +// Send a message to a chat +func SendAmessage() { + chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN")) + rsp, err := chatService.Send(&chat.SendRequest{ + Client: "web", +Subject: "Random", +Text: "Hey whats up?", + + }) + fmt.Println(rsp, err) + +} +``` +## History + +List the messages in a chat + + +[https://m3o.com/chat/api#History](https://m3o.com/chat/api#History) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/chat" +) + +// List the messages in a chat +func GetChatHistory() { + chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN")) + rsp, err := chatService.History(&chat.HistoryRequest{ + + }) + fmt.Println(rsp, err) + +} +``` +## Kick + +Kick a user from a chat room + + +[https://m3o.com/chat/api#Kick](https://m3o.com/chat/api#Kick) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/chat" +) + +// Kick a user from a chat room +func KickAuserFromAroom() { + chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN")) + rsp, err := chatService.Kick(&chat.KickRequest{ + + }) + fmt.Println(rsp, err) + +} +``` +## Leave + +Leave a chat room + + +[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 @@ -31,12 +171,12 @@ func ListChatRooms() { } ``` -## History +## Delete -List the messages in a chat +Delete a chat room -[https://m3o.com/chat/api#History](https://m3o.com/chat/api#History) +[https://m3o.com/chat/api#Delete](https://m3o.com/chat/api#Delete) ```go package example @@ -48,10 +188,10 @@ import( "go.m3o.com/chat" ) -// List the messages in a chat -func GetChatHistory() { +// Delete a chat room +func DeleteAchat() { chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN")) - rsp, err := chatService.History(&chat.HistoryRequest{ + rsp, err := chatService.Delete(&chat.DeleteRequest{ }) fmt.Println(rsp, err) @@ -127,143 +267,3 @@ Name: "general", } ``` -## Invite - -Invite a user to a chat room - - -[https://m3o.com/chat/api#Invite](https://m3o.com/chat/api#Invite) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/chat" -) - -// Invite a user to a chat room -func InviteAuser() { - chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN")) - rsp, err := chatService.Invite(&chat.InviteRequest{ - - }) - fmt.Println(rsp, err) - -} -``` -## Send - -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) - -} -``` -## 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) - -} -``` -## 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) - -} -``` diff --git a/examples/comments/README.md b/examples/comments/README.md index 6e8311b..847f891 100755 --- a/examples/comments/README.md +++ b/examples/comments/README.md @@ -4,34 +4,6 @@ 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 @@ -188,3 +160,31 @@ 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) + +} +``` diff --git a/examples/crypto/README.md b/examples/crypto/README.md index d9bae9e..1d69dc6 100755 --- a/examples/crypto/README.md +++ b/examples/crypto/README.md @@ -4,34 +4,6 @@ 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 @@ -143,3 +115,31 @@ func GetListOfAllSupportedSymbols() { } ``` +## 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) + +} +``` diff --git a/examples/currency/README.md b/examples/currency/README.md index f788d89..333170f 100755 --- a/examples/currency/README.md +++ b/examples/currency/README.md @@ -4,6 +4,33 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/currency/api]( Endpoints: +## Codes + +Codes returns the supported currency codes for the API + + +[https://m3o.com/currency/api#Codes](https://m3o.com/currency/api#Codes) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/currency" +) + +// Codes returns the supported currency codes for the API +func GetSupportedCodes() { + currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN")) + rsp, err := currencyService.Codes(¤cy.CodesRequest{ + + }) + fmt.Println(rsp, err) + +} +``` ## Rates Rates returns the currency rates for a given code e.g USD @@ -120,30 +147,3 @@ Date: "2021-05-30", } ``` -## Codes - -Codes returns the supported currency codes for the API - - -[https://m3o.com/currency/api#Codes](https://m3o.com/currency/api#Codes) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/currency" -) - -// Codes returns the supported currency codes for the API -func GetSupportedCodes() { - currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN")) - rsp, err := currencyService.Codes(¤cy.CodesRequest{ - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/db/README.md b/examples/db/README.md index 0959e8e..1b380a3 100755 --- a/examples/db/README.md +++ b/examples/db/README.md @@ -4,6 +4,61 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/db/api](https: Endpoints: +## 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) + +} +``` +## ListTables + +List tables in the DB + + +[https://m3o.com/db/api#ListTables](https://m3o.com/db/api#ListTables) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/db" +) + +// List tables in the DB +func ListTables() { + dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) + rsp, err := dbService.ListTables(&db.ListTablesRequest{ + + }) + fmt.Println(rsp, err) + +} +``` ## RenameTable Rename a table @@ -55,16 +110,105 @@ func CreateArecord() { dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) rsp, err := dbService.Create(&db.CreateRequest{ Record: map[string]interface{}{ - "name": "Jane", "age": 42, "isActive": true, "id": "1", + "name": "Jane", }, Table: "example", }) 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) + +} +``` +## DropTable + +Drop a table in the DB + + +[https://m3o.com/db/api#DropTable](https://m3o.com/db/api#DropTable) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/db" +) + +// Drop a table in the DB +func DropTable() { + dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) + rsp, err := dbService.DropTable(&db.DropTableRequest{ + Table: "example", + + }) + fmt.Println(rsp, err) + +} +``` +## 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) + } ``` ## Delete @@ -124,147 +268,3 @@ func TruncateTable() { } ``` -## 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) - -} -``` -## ListTables - -List tables in the DB - - -[https://m3o.com/db/api#ListTables](https://m3o.com/db/api#ListTables) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/db" -) - -// List tables in the DB -func ListTables() { - dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) - rsp, err := dbService.ListTables(&db.ListTablesRequest{ - - }) - 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) - -} -``` -## DropTable - -Drop a table in the DB - - -[https://m3o.com/db/api#DropTable](https://m3o.com/db/api#DropTable) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/db" -) - -// Drop a table in the DB -func DropTable() { - dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) - rsp, err := dbService.DropTable(&db.DropTableRequest{ - Table: "example", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/email/README.md b/examples/email/README.md index b04ca45..8e6afcf 100755 --- a/examples/email/README.md +++ b/examples/email/README.md @@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/email/api](htt Endpoints: -## Validate - -Validate an email address format - - -[https://m3o.com/email/api#Validate](https://m3o.com/email/api#Validate) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/email" -) - -// Validate an email address format -func ValidateEmail() { - emailService := email.NewEmailService(os.Getenv("M3O_API_TOKEN")) - rsp, err := emailService.Validate(&email.ValidateRequest{ - Address: "joe@example.com", - - }) - fmt.Println(rsp, err) - -} -``` ## Send Send an email by passing in from, to, subject, and a text or html body @@ -92,3 +64,31 @@ func ParseEmail() { } ``` +## Validate + +Validate an email address format + + +[https://m3o.com/email/api#Validate](https://m3o.com/email/api#Validate) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/email" +) + +// Validate an email address format +func ValidateEmail() { + emailService := email.NewEmailService(os.Getenv("M3O_API_TOKEN")) + rsp, err := emailService.Validate(&email.ValidateRequest{ + Address: "joe@example.com", + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/event/publish/publishAnEvent/main.go b/examples/event/publish/publishAnEvent/main.go index 287af64..5c63360 100755 --- a/examples/event/publish/publishAnEvent/main.go +++ b/examples/event/publish/publishAnEvent/main.go @@ -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", }) diff --git a/examples/file/README.md b/examples/file/README.md index 40962ee..7435de8 100755 --- a/examples/file/README.md +++ b/examples/file/README.md @@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/file/api](http Endpoints: +## List + +List files by their project and optionally a path. + + +[https://m3o.com/file/api#List](https://m3o.com/file/api#List) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/file" +) + +// List files by their project and optionally a path. +func ListFiles() { + fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN")) + rsp, err := fileService.List(&file.ListRequest{ + Project: "examples", + + }) + fmt.Println(rsp, err) + +} +``` ## Read Read a file by path @@ -94,31 +122,3 @@ func SaveFile() { } ``` -## List - -List files by their project and optionally a path. - - -[https://m3o.com/file/api#List](https://m3o.com/file/api#List) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/file" -) - -// List files by their project and optionally a path. -func ListFiles() { - fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN")) - rsp, err := fileService.List(&file.ListRequest{ - Project: "examples", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/function/README.md b/examples/function/README.md index ca58d12..b1ca498 100755 --- a/examples/function/README.md +++ b/examples/function/README.md @@ -4,12 +4,12 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/function/api]( Endpoints: -## Regions +## Update -Return a list of supported regions +Update a function. Downloads the source, builds and redeploys -[https://m3o.com/function/api#Regions](https://m3o.com/function/api#Regions) +[https://m3o.com/function/api#Update](https://m3o.com/function/api#Update) ```go package example @@ -21,93 +21,12 @@ import( "go.m3o.com/function" ) -// Return a list of supported regions -func ListRegions() { +// Update a function. Downloads the source, builds and redeploys +func UpdateAfunction() { functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) - rsp, err := functionService.Regions(&function.RegionsRequest{ - - }) - fmt.Println(rsp, err) - -} -``` -## Runtimes + rsp, err := functionService.Update(&function.UpdateRequest{ + Name: "helloworld", -Return a list of supported runtimes - - -[https://m3o.com/function/api#Runtimes](https://m3o.com/function/api#Runtimes) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/function" -) - -// Return a list of supported runtimes -func ListRuntimes() { - functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) - rsp, err := functionService.Runtimes(&function.RuntimesRequest{ - - }) - fmt.Println(rsp, err) - -} -``` -## Proxy - -Return the backend url for proxying - - -[https://m3o.com/function/api#Proxy](https://m3o.com/function/api#Proxy) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/function" -) - -// Return the backend url for proxying -func ProxyUrl() { - functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) - rsp, err := functionService.Proxy(&function.ProxyRequest{ - Id: "helloworld", - - }) - fmt.Println(rsp, err) - -} -``` -## 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) @@ -141,12 +60,12 @@ func DeleteAfunction() { } ``` -## Describe +## Proxy -Get the info for a deployed function +Return the backend url for proxying -[https://m3o.com/function/api#Describe](https://m3o.com/function/api#Describe) +[https://m3o.com/function/api#Proxy](https://m3o.com/function/api#Proxy) ```go package example @@ -158,15 +77,42 @@ import( "go.m3o.com/function" ) -// Get the info for a deployed function -func DescribeFunctionStatus() { +// Return the backend url for proxying +func ProxyUrl() { functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) - rsp, err := functionService.Describe(&function.DescribeRequest{ - Name: "helloworld", + rsp, err := functionService.Proxy(&function.ProxyRequest{ + Id: "helloworld", }) fmt.Println(rsp, err) +} +``` +## Regions + +Return a list of supported regions + + +[https://m3o.com/function/api#Regions](https://m3o.com/function/api#Regions) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/function" +) + +// Return a list of supported regions +func ListRegions() { + functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) + rsp, err := functionService.Regions(&function.RegionsRequest{ + + }) + fmt.Println(rsp, err) + } ``` ## Reserve @@ -195,6 +141,33 @@ func ReserveAfunction() { }) fmt.Println(rsp, err) +} +``` +## Runtimes + +Return a list of supported runtimes + + +[https://m3o.com/function/api#Runtimes](https://m3o.com/function/api#Runtimes) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/function" +) + +// Return a list of supported runtimes +func ListRuntimes() { + functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) + rsp, err := functionService.Runtimes(&function.RuntimesRequest{ + + }) + fmt.Println(rsp, err) + } ``` ## Deploy @@ -229,34 +202,6 @@ Subfolder: "examples/go-function", }) 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 @@ -290,3 +235,58 @@ Request: map[string]interface{}{ } ``` +## 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) + +} +``` diff --git a/examples/mq/README.md b/examples/mq/README.md index 2bde790..1582975 100755 --- a/examples/mq/README.md +++ b/examples/mq/README.md @@ -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{}{ - "user": "john", - "id": "1", - "type": "signup", -}, -Topic: "events", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/notes/README.md b/examples/notes/README.md index 3bc665d..6997879 100755 --- a/examples/notes/README.md +++ b/examples/notes/README.md @@ -4,66 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/notes/api](htt Endpoints: -## Update - -Update a note - - -[https://m3o.com/notes/api#Update](https://m3o.com/notes/api#Update) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/notes" -) - -// Update a note -func UpdateAnote() { - notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN")) - rsp, err := notesService.Update(¬es.UpdateRequest{ - Note: ¬es.Note{ - Id: "63c0cdf8-2121-11ec-a881-0242e36f037a", - Text: "Updated note text", - Title: "Update Note", - }, - - }) - fmt.Println(rsp, err) - -} -``` -## Delete - -Delete a note - - -[https://m3o.com/notes/api#Delete](https://m3o.com/notes/api#Delete) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/notes" -) - -// Delete a note -func DeleteAnote() { - notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN")) - rsp, err := notesService.Delete(¬es.DeleteRequest{ - Id: "63c0cdf8-2121-11ec-a881-0242e36f037a", - - }) - fmt.Println(rsp, err) - -} -``` ## Events Subscribe to notes events @@ -189,3 +129,63 @@ func ListAllNotes() { } ``` +## Update + +Update a note + + +[https://m3o.com/notes/api#Update](https://m3o.com/notes/api#Update) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/notes" +) + +// Update a note +func UpdateAnote() { + notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN")) + rsp, err := notesService.Update(¬es.UpdateRequest{ + Note: ¬es.Note{ + Id: "63c0cdf8-2121-11ec-a881-0242e36f037a", + Text: "Updated note text", + Title: "Update Note", + }, + + }) + fmt.Println(rsp, err) + +} +``` +## Delete + +Delete a note + + +[https://m3o.com/notes/api#Delete](https://m3o.com/notes/api#Delete) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/notes" +) + +// Delete a note +func DeleteAnote() { + notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN")) + rsp, err := notesService.Delete(¬es.DeleteRequest{ + Id: "63c0cdf8-2121-11ec-a881-0242e36f037a", + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/ping/README.md b/examples/ping/README.md index 54dea8b..f7db414 100755 --- a/examples/ping/README.md +++ b/examples/ping/README.md @@ -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) + +} +``` diff --git a/examples/search/README.md b/examples/search/README.md index 3fc5086..c731a03 100755 --- a/examples/search/README.md +++ b/examples/search/README.md @@ -4,39 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/search/api](ht Endpoints: -## Index - -Index a record i.e. insert a document to search for. - - -[https://m3o.com/search/api#Index](https://m3o.com/search/api#Index) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/search" -) - -// Index a record i.e. insert a document to search for. -func IndexArecord() { - searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN")) - rsp, err := searchService.Index(&search.IndexRequest{ - Data: map[string]interface{}{ - "age": 37, - "starsign": "Leo", - "name": "John Doe", -}, -Index: "customers", - - }) - fmt.Println(rsp, err) - -} -``` ## Search Search for records in a given in index @@ -209,3 +176,36 @@ func DeleteAnIndex() { } ``` +## Index + +Index a record i.e. insert a document to search for. + + +[https://m3o.com/search/api#Index](https://m3o.com/search/api#Index) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/search" +) + +// Index a record i.e. insert a document to search for. +func IndexArecord() { + searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN")) + rsp, err := searchService.Index(&search.IndexRequest{ + Data: map[string]interface{}{ + "name": "John Doe", + "age": 37, + "starsign": "Leo", +}, +Index: "customers", + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/space/README.md b/examples/space/README.md index d61c3c6..caa0bf5 100755 --- a/examples/space/README.md +++ b/examples/space/README.md @@ -4,6 +4,94 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/space/api](htt Endpoints: +## Upload + +Upload a large object (> 10MB). Returns a time limited presigned URL to be used for uploading the object + + +[https://m3o.com/space/api#Upload](https://m3o.com/space/api#Upload) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/space" +) + +// Upload a large object (> 10MB). Returns a time limited presigned URL to be used for uploading the object +func UploadAnObject() { + spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN")) + rsp, err := spaceService.Upload(&space.UploadRequest{ + Name: "images/file.jpg", + + }) + fmt.Println(rsp, err) + +} +``` +## Create + +Create an object. Returns error if object with this name already exists. Max object size of 10MB, see Upload endpoint for larger objects. If you want to update an existing object use the `Update` endpoint + + +[https://m3o.com/space/api#Create](https://m3o.com/space/api#Create) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/space" +) + +// Create an object. Returns error if object with this name already exists. Max object size of 10MB, see Upload endpoint for larger objects. If you want to update an existing object use the `Update` endpoint +func CreateAnObject() { + spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN")) + rsp, err := spaceService.Create(&space.CreateRequest{ + Name: "images/file.jpg", +Object: "", +Visibility: "public", + + }) + fmt.Println(rsp, err) + +} +``` +## Update + +Update an object. If an object with this name does not exist, creates a new one. + + +[https://m3o.com/space/api#Update](https://m3o.com/space/api#Update) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/space" +) + +// Update an object. If an object with this name does not exist, creates a new one. +func UpdateAnObject() { + spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN")) + rsp, err := spaceService.Update(&space.UpdateRequest{ + Name: "images/file.jpg", +Object: "", +Visibility: "public", + + }) + fmt.Println(rsp, err) + +} +``` ## Delete Delete an object from space @@ -144,91 +232,3 @@ func DownloadAnObject() { } ``` -## Upload - -Upload a large object (> 10MB). Returns a time limited presigned URL to be used for uploading the object - - -[https://m3o.com/space/api#Upload](https://m3o.com/space/api#Upload) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/space" -) - -// Upload a large object (> 10MB). Returns a time limited presigned URL to be used for uploading the object -func UploadAnObject() { - spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN")) - rsp, err := spaceService.Upload(&space.UploadRequest{ - Name: "images/file.jpg", - - }) - fmt.Println(rsp, err) - -} -``` -## Create - -Create an object. Returns error if object with this name already exists. Max object size of 10MB, see Upload endpoint for larger objects. If you want to update an existing object use the `Update` endpoint - - -[https://m3o.com/space/api#Create](https://m3o.com/space/api#Create) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/space" -) - -// Create an object. Returns error if object with this name already exists. Max object size of 10MB, see Upload endpoint for larger objects. If you want to update an existing object use the `Update` endpoint -func CreateAnObject() { - spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN")) - rsp, err := spaceService.Create(&space.CreateRequest{ - Name: "images/file.jpg", -Object: "", -Visibility: "public", - - }) - fmt.Println(rsp, err) - -} -``` -## Update - -Update an object. If an object with this name does not exist, creates a new one. - - -[https://m3o.com/space/api#Update](https://m3o.com/space/api#Update) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/space" -) - -// Update an object. If an object with this name does not exist, creates a new one. -func UpdateAnObject() { - spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN")) - rsp, err := spaceService.Update(&space.UpdateRequest{ - Name: "images/file.jpg", -Object: "", -Visibility: "public", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/stream/README.md b/examples/stream/README.md index 232026e..248440b 100755 --- a/examples/stream/README.md +++ b/examples/stream/README.md @@ -4,6 +4,61 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/stream/api](ht Endpoints: +## ListMessages + +List messages for a given channel + + +[https://m3o.com/stream/api#ListMessages](https://m3o.com/stream/api#ListMessages) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/stream" +) + +// List messages for a given channel +func ListMessages() { + streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN")) + rsp, err := streamService.ListMessages(&stream.ListMessagesRequest{ + Channel: "general", + + }) + fmt.Println(rsp, err) + +} +``` +## 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 @@ -64,58 +119,3 @@ Text: "Hey checkout this tweet https://twitter.com/m3oservices/status/1455291054 } ``` -## ListMessages - -List messages for a given channel - - -[https://m3o.com/stream/api#ListMessages](https://m3o.com/stream/api#ListMessages) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/stream" -) - -// List messages for a given channel -func ListMessages() { - streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN")) - rsp, err := streamService.ListMessages(&stream.ListMessagesRequest{ - Channel: "general", - - }) - fmt.Println(rsp, err) - -} -``` -## 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) - -} -``` diff --git a/examples/sunnah/README.md b/examples/sunnah/README.md index 68ccae1..d2d603b 100755 --- a/examples/sunnah/README.md +++ b/examples/sunnah/README.md @@ -4,6 +4,35 @@ 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 @@ -94,32 +123,3 @@ 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) - -} -``` diff --git a/examples/twitter/README.md b/examples/twitter/README.md index ec1dada..19128ad 100755 --- a/examples/twitter/README.md +++ b/examples/twitter/README.md @@ -4,6 +4,61 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/twitter/api](h Endpoints: +## Search + +Search for tweets with a simple query + + +[https://m3o.com/twitter/api#Search](https://m3o.com/twitter/api#Search) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/twitter" +) + +// Search for tweets with a simple query +func SearchForTweets() { + twitterService := twitter.NewTwitterService(os.Getenv("M3O_API_TOKEN")) + rsp, err := twitterService.Search(&twitter.SearchRequest{ + Query: "cats", + + }) + fmt.Println(rsp, err) + +} +``` +## 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 @@ -61,58 +116,3 @@ Username: "m3oservices", } ``` -## Search - -Search for tweets with a simple query - - -[https://m3o.com/twitter/api#Search](https://m3o.com/twitter/api#Search) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/twitter" -) - -// Search for tweets with a simple query -func SearchForTweets() { - twitterService := twitter.NewTwitterService(os.Getenv("M3O_API_TOKEN")) - rsp, err := twitterService.Search(&twitter.SearchRequest{ - Query: "cats", - - }) - fmt.Println(rsp, err) - -} -``` -## 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) - -} -``` diff --git a/examples/user/README.md b/examples/user/README.md index 99c1a84..870e410 100755 --- a/examples/user/README.md +++ b/examples/user/README.md @@ -4,239 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/user/api](http Endpoints: -## Logout - -Logout a user account - - -[https://m3o.com/user/api#Logout](https://m3o.com/user/api#Logout) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/user" -) - -// Logout a user account -func LogAuserOut() { - userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.Logout(&user.LogoutRequest{ - SessionId: "df91a612-5b24-4634-99ff-240220ab8f55", - - }) - fmt.Println(rsp, err) - -} -``` -## VerifyToken - -Check whether the token attached to MagicLink is valid or not. -Ideally, you need to call this endpoint from your http request -handler that handles the endpoint which is specified in the -SendMagicLink request. - - -[https://m3o.com/user/api#VerifyToken](https://m3o.com/user/api#VerifyToken) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/user" -) - -// Check whether the token attached to MagicLink is valid or not. -// Ideally, you need to call this endpoint from your http request -// handler that handles the endpoint which is specified in the -// SendMagicLink request. -func VerifyAtoken() { - userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.VerifyToken(&user.VerifyTokenRequest{ - Token: "EdsUiidouJJJLldjlloofUiorkojflsWWdld", - - }) - fmt.Println(rsp, err) - -} -``` -## Create - -Create a new user account. The email address and username for the account must be unique. - - -[https://m3o.com/user/api#Create](https://m3o.com/user/api#Create) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/user" -) - -// Create a new user account. The email address and username for the account must be unique. -func CreateAnAccount() { - userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.Create(&user.CreateRequest{ - Email: "joe@example.com", -Id: "user-1", -Password: "Password1", -Username: "joe", - - }) - fmt.Println(rsp, err) - -} -``` -## UpdatePassword - -Update the account password - - -[https://m3o.com/user/api#UpdatePassword](https://m3o.com/user/api#UpdatePassword) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/user" -) - -// Update the account password -func UpdateTheAccountPassword() { - userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.UpdatePassword(&user.UpdatePasswordRequest{ - ConfirmPassword: "Password2", -NewPassword: "Password2", -OldPassword: "Password1", -UserId: "user-1", - - }) - fmt.Println(rsp, err) - -} -``` -## 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) - -} -``` -## 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) - -} -``` -## 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) - -} -``` ## ResetPassword Reset password with the code sent by the "SendPasswordResetEmail" endpoint. @@ -294,35 +61,6 @@ func VerifyEmail() { }) 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 @@ -360,12 +98,15 @@ Click here to access your account $micro_verification_link`, } ``` -## Update +## VerifyToken -Update the account username or email +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#Update](https://m3o.com/user/api#Update) +[https://m3o.com/user/api#VerifyToken](https://m3o.com/user/api#VerifyToken) ```go package example @@ -377,13 +118,14 @@ import( "go.m3o.com/user" ) -// Update the account username or email -func UpdateAnAccount() { +// 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.Update(&user.UpdateRequest{ - Email: "joe+2@example.com", -Id: "user-1", -Username: "joe", + rsp, err := userService.VerifyToken(&user.VerifyTokenRequest{ + Token: "EdsUiidouJJJLldjlloofUiorkojflsWWdld", }) fmt.Println(rsp, err) @@ -472,6 +214,71 @@ func ReadAccountByEmail() { }) 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) + +} +``` +## UpdatePassword + +Update the account password + + +[https://m3o.com/user/api#UpdatePassword](https://m3o.com/user/api#UpdatePassword) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Update the account password +func UpdateTheAccountPassword() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.UpdatePassword(&user.UpdatePasswordRequest{ + ConfirmPassword: "Password2", +NewPassword: "Password2", +OldPassword: "Password1", +UserId: "user-1", + + }) + fmt.Println(rsp, err) + } ``` ## Login @@ -533,3 +340,196 @@ func ReadAsessionByTheSessionId() { } ``` +## 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) + +} +``` +## SendVerificationEmail + +Send a verification email to a user. +Email "from" will be 'noreply@email.m3ocontent.com'. +The verification link will be injected in the email +as a template variable, $micro_verification_link e.g +'Welcome to M3O! Use the link below to verify your email: $micro_verification_link' +The variable will be replaced with a url similar to: +'https://user.m3o.com/user/verify?token=a-verification-token&redirectUrl=your-redir-url' + + +[https://m3o.com/user/api#SendVerificationEmail](https://m3o.com/user/api#SendVerificationEmail) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Send a verification email to a user. +// Email "from" will be 'noreply@email.m3ocontent.com'. +// The verification link will be injected in the email +// as a template variable, $micro_verification_link e.g +// 'Welcome to M3O! Use the link below to verify your email: $micro_verification_link' +// The variable will be replaced with a url similar to: +// 'https://user.m3o.com/user/verify?token=a-verification-token&redirectUrl=your-redir-url' +func SendVerificationEmail() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.SendVerificationEmail(&user.SendVerificationEmailRequest{ + Email: "joe@example.com", +FailureRedirectUrl: "https://m3o.com/verification-failed", +FromName: "Awesome Dot Com", +RedirectUrl: "https://m3o.com", +Subject: "Email verification", +TextContent: `Hi there, + +Please verify your email by clicking this link: $micro_verification_link`, + + }) + fmt.Println(rsp, err) + +} +``` +## Logout + +Logout a user account + + +[https://m3o.com/user/api#Logout](https://m3o.com/user/api#Logout) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Logout a user account +func LogAuserOut() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.Logout(&user.LogoutRequest{ + SessionId: "df91a612-5b24-4634-99ff-240220ab8f55", + + }) + fmt.Println(rsp, err) + +} +``` +## 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) + +} +``` +## 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) + +} +``` +## 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) + +} +```