From 9fb8b7249a13b3694e1bcbf20a927efb68aa6edd Mon Sep 17 00:00:00 2001 From: m3o-actions <> Date: Wed, 12 Jan 2022 09:46:51 +0000 Subject: [PATCH] Commit from m3o/m3o action --- examples/app/README.md | 166 +++--- examples/cache/README.md | 56 +- examples/contact/README.md | 112 ++-- examples/crypto/README.md | 56 +- examples/currency/README.md | 110 ++-- examples/db/README.md | 194 +++--- examples/emoji/README.md | 60 +- examples/function/README.md | 244 ++++---- examples/geocoding/README.md | 58 +- examples/image/README.md | 238 ++++---- examples/nft/README.md | 56 +- examples/rss/README.md | 110 ++-- examples/search/index/indexADocument/main.go | 2 +- examples/space/README.md | 112 ++-- examples/stock/README.md | 56 +- examples/stream/README.md | 54 +- examples/sunnah/README.md | 118 ++-- examples/user/README.md | 590 +++++++++---------- 18 files changed, 1196 insertions(+), 1196 deletions(-) diff --git a/examples/app/README.md b/examples/app/README.md index ead5e7b..bb051f7 100755 --- a/examples/app/README.md +++ b/examples/app/README.md @@ -4,89 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/App/api](https Endpoints: -## 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 - - -[https://m3o.com/app/api#List](https://m3o.com/app/api#List) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/app" -) - -// List all the apps -func ListTheApps() { - appService := app.NewAppService(os.Getenv("M3O_API_TOKEN")) - rsp, err := appService.List(&app.ListRequest{ - - }) - fmt.Println(rsp, err) - -} -``` ## Run Run an app from a source repo. Specify region etc. @@ -230,3 +147,86 @@ func UpdateAnApp() { } ``` +## 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 + + +[https://m3o.com/app/api#List](https://m3o.com/app/api#List) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/app" +) + +// List all the apps +func ListTheApps() { + appService := app.NewAppService(os.Getenv("M3O_API_TOKEN")) + rsp, err := appService.List(&app.ListRequest{ + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/cache/README.md b/examples/cache/README.md index 5229fee..03c0009 100755 --- a/examples/cache/README.md +++ b/examples/cache/README.md @@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Cache/api](htt Endpoints: -## Get - -Get an item from the cache by key. If key is not found, an empty response is returned. - - -[https://m3o.com/cache/api#Get](https://m3o.com/cache/api#Get) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/cache" -) - -// Get an item from the cache by key. If key is not found, an empty response is returned. -func GetAvalue() { - cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN")) - rsp, err := cacheService.Get(&cache.GetRequest{ - Key: "foo", - - }) - fmt.Println(rsp, err) - -} -``` ## Delete Delete a value from the cache. If key not found a success response is returned. @@ -147,3 +119,31 @@ Value: "bar", } ``` +## Get + +Get an item from the cache by key. If key is not found, an empty response is returned. + + +[https://m3o.com/cache/api#Get](https://m3o.com/cache/api#Get) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/cache" +) + +// Get an item from the cache by key. If key is not found, an empty response is returned. +func GetAvalue() { + cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN")) + rsp, err := cacheService.Get(&cache.GetRequest{ + Key: "foo", + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/contact/README.md b/examples/contact/README.md index efaddd5..13df2eb 100755 --- a/examples/contact/README.md +++ b/examples/contact/README.md @@ -4,62 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Contact/api](h Endpoints: -## List - - - - -[https://m3o.com/contact/api#List](https://m3o.com/contact/api#List) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/contact" -) - -// -func ListContactsWithDefaultOffsetAndLimitDefaultLimitIs20() { - contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN")) - rsp, err := contactService.List(&contact.ListRequest{ - - }) - fmt.Println(rsp, err) - -} -``` -## List - - - - -[https://m3o.com/contact/api#List](https://m3o.com/contact/api#List) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/contact" -) - -// -func ListContactsWithSpecificOffsetAndLimit() { - contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN")) - rsp, err := contactService.List(&contact.ListRequest{ - Limit: 1, -Offset: 1, - - }) - fmt.Println(rsp, err) - -} -``` ## Create @@ -217,3 +161,59 @@ func DeleteAcontact() { } ``` +## List + + + + +[https://m3o.com/contact/api#List](https://m3o.com/contact/api#List) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/contact" +) + +// +func ListContactsWithDefaultOffsetAndLimitDefaultLimitIs20() { + contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN")) + rsp, err := contactService.List(&contact.ListRequest{ + + }) + fmt.Println(rsp, err) + +} +``` +## List + + + + +[https://m3o.com/contact/api#List](https://m3o.com/contact/api#List) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/contact" +) + +// +func ListContactsWithSpecificOffsetAndLimit() { + contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN")) + rsp, err := contactService.List(&contact.ListRequest{ + Limit: 1, +Offset: 1, + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/crypto/README.md b/examples/crypto/README.md index b836e92..40c1322 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 @@ -116,3 +88,31 @@ func GetPreviousClose() { } ``` +## News + +Get news related to a currency + + +[https://m3o.com/crypto/api#News](https://m3o.com/crypto/api#News) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/crypto" +) + +// Get news related to a currency +func GetCryptocurrencyNews() { + cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN")) + rsp, err := cryptoService.News(&crypto.NewsRequest{ + Symbol: "BTCUSD", + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/currency/README.md b/examples/currency/README.md index bf674d6..65a799d 100755 --- a/examples/currency/README.md +++ b/examples/currency/README.md @@ -4,6 +4,61 @@ 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 + + +[https://m3o.com/currency/api#Rates](https://m3o.com/currency/api#Rates) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/currency" +) + +// Rates returns the currency rates for a given code e.g USD +func GetRatesForUsd() { + currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN")) + rsp, err := currencyService.Rates(¤cy.RatesRequest{ + Code: "USD", + + }) + fmt.Println(rsp, err) + +} +``` ## Convert Convert returns the currency conversion rate between two pairs e.g USD/GBP @@ -92,58 +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) - -} -``` -## Rates - -Rates returns the currency rates for a given code e.g USD - - -[https://m3o.com/currency/api#Rates](https://m3o.com/currency/api#Rates) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/currency" -) - -// Rates returns the currency rates for a given code e.g USD -func GetRatesForUsd() { - currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN")) - rsp, err := currencyService.Rates(¤cy.RatesRequest{ - Code: "USD", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/db/README.md b/examples/db/README.md index fe2c800..d3b6b52 100755 --- a/examples/db/README.md +++ b/examples/db/README.md @@ -4,6 +4,94 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Db/api](https: Endpoints: +## 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 + + +[https://m3o.com/db/api#RenameTable](https://m3o.com/db/api#RenameTable) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/db" +) + +// Rename a table +func RenameTable() { + dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) + rsp, err := dbService.RenameTable(&db.RenameTableRequest{ + From: "examples2", +To: "examples3", + + }) + fmt.Println(rsp, err) + +} +``` +## Update + +Update a record in the database. Include an "id" in the record to update. + + +[https://m3o.com/db/api#Update](https://m3o.com/db/api#Update) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/db" +) + +// Update a record in the database. Include an "id" in the record to update. +func UpdateArecord() { + dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) + rsp, err := dbService.Update(&db.UpdateRequest{ + Record: map[string]interface{}{ + "id": "1", + "age": 43, +}, +Table: "example", + + }) + fmt.Println(rsp, err) + +} +``` ## Read Read data from a table. Lookup can be by ID or via querying any field in the record. @@ -31,35 +119,6 @@ Table: "example", }) fmt.Println(rsp, err) -} -``` -## Delete - -Delete a record in the database by id. - - -[https://m3o.com/db/api#Delete](https://m3o.com/db/api#Delete) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/db" -) - -// Delete a record in the database by id. -func DeleteArecord() { - dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) - rsp, err := dbService.Delete(&db.DeleteRequest{ - Id: "1", -Table: "example", - - }) - fmt.Println(rsp, err) - } ``` ## Truncate @@ -116,35 +175,6 @@ func DropTable() { }) fmt.Println(rsp, err) -} -``` -## RenameTable - -Rename a table - - -[https://m3o.com/db/api#RenameTable](https://m3o.com/db/api#RenameTable) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/db" -) - -// Rename a table -func RenameTable() { - dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) - rsp, err := dbService.RenameTable(&db.RenameTableRequest{ - From: "examples2", -To: "examples3", - - }) - fmt.Println(rsp, err) - } ``` ## Create @@ -169,10 +199,10 @@ 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", + "age": 42, }, Table: "example", @@ -181,12 +211,12 @@ Table: "example", } ``` -## Update +## Delete -Update a record in the database. Include an "id" in the record to update. +Delete a record in the database by id. -[https://m3o.com/db/api#Update](https://m3o.com/db/api#Update) +[https://m3o.com/db/api#Delete](https://m3o.com/db/api#Delete) ```go package example @@ -198,14 +228,11 @@ import( "go.m3o.com/db" ) -// Update a record in the database. Include an "id" in the record to update. -func UpdateArecord() { +// Delete a record in the database by id. +func DeleteArecord() { dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) - rsp, err := dbService.Update(&db.UpdateRequest{ - Record: map[string]interface{}{ - "id": "1", - "age": 43, -}, + rsp, err := dbService.Delete(&db.DeleteRequest{ + Id: "1", Table: "example", }) @@ -241,30 +268,3 @@ func CountEntriesInAtable() { } ``` -## 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) - -} -``` diff --git a/examples/emoji/README.md b/examples/emoji/README.md index f4b291f..d2a4c7f 100755 --- a/examples/emoji/README.md +++ b/examples/emoji/README.md @@ -4,36 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Emoji/api](htt Endpoints: -## Send - -Send an emoji to anyone via SMS. Messages are sent in the form ' Sent from ' - - -[https://m3o.com/emoji/api#Send](https://m3o.com/emoji/api#Send) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/emoji" -) - -// Send an emoji to anyone via SMS. Messages are sent in the form ' Sent from ' -func SendAtextContainingAnEmojiToAnyoneViaSms() { - emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN")) - rsp, err := emojiService.Send(&emoji.SendRequest{ - From: "Alice", -Message: "let's grab a :beer:", -To: "+44782669123", - - }) - fmt.Println(rsp, err) - -} -``` ## Find Find an emoji by its alias e.g :beer: @@ -119,3 +89,33 @@ func PrintTextIncludingEmoji() { } ``` +## Send + +Send an emoji to anyone via SMS. Messages are sent in the form ' Sent from ' + + +[https://m3o.com/emoji/api#Send](https://m3o.com/emoji/api#Send) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/emoji" +) + +// Send an emoji to anyone via SMS. Messages are sent in the form ' Sent from ' +func SendAtextContainingAnEmojiToAnyoneViaSms() { + emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN")) + rsp, err := emojiService.Send(&emoji.SendRequest{ + From: "Alice", +Message: "let's grab a :beer:", +To: "+44782669123", + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/function/README.md b/examples/function/README.md index c27c411..3966d19 100755 --- a/examples/function/README.md +++ b/examples/function/README.md @@ -4,121 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Function/api]( Endpoints: -## 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) - -} -``` -## 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) - -} -``` -## 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 - -Call a function by name - - -[https://m3o.com/function/api#Call](https://m3o.com/function/api#Call) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/function" -) - -// Call a function by name -func CallAfunction() { - functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) - rsp, err := functionService.Call(&function.CallRequest{ - Name: "helloworld", -Request: map[string]interface{}{ - "name": "Alice", -}, - - }) - fmt.Println(rsp, err) - -} -``` ## List List all the deployed functions @@ -144,6 +29,33 @@ func ListFunctions() { }) 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 @@ -206,6 +118,65 @@ 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 + +Call a function by name + + +[https://m3o.com/function/api#Call](https://m3o.com/function/api#Call) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/function" +) + +// Call a function by name +func CallAfunction() { + functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) + rsp, err := functionService.Call(&function.CallRequest{ + Name: "helloworld", +Request: map[string]interface{}{ + "name": "Alice", +}, + + }) + fmt.Println(rsp, err) + } ``` ## Delete @@ -236,12 +207,12 @@ func DeleteAfunction() { } ``` -## Regions +## Describe -Return a list of supported regions +Get the info for a deployed function -[https://m3o.com/function/api#Regions](https://m3o.com/function/api#Regions) +[https://m3o.com/function/api#Describe](https://m3o.com/function/api#Describe) ```go package example @@ -253,11 +224,40 @@ import( "go.m3o.com/function" ) -// Return a list of supported regions -func ListRegions() { +// Get the info for a deployed function +func DescribeFunctionStatus() { functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) - rsp, err := functionService.Regions(&function.RegionsRequest{ - + rsp, err := functionService.Describe(&function.DescribeRequest{ + Name: "helloworld", + + }) + 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) diff --git a/examples/geocoding/README.md b/examples/geocoding/README.md index 3ee6de8..ad1daf9 100755 --- a/examples/geocoding/README.md +++ b/examples/geocoding/README.md @@ -4,35 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Geocoding/api] Endpoints: -## Reverse - -Reverse lookup an address from gps coordinates - - -[https://m3o.com/geocoding/api#Reverse](https://m3o.com/geocoding/api#Reverse) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/geocoding" -) - -// Reverse lookup an address from gps coordinates -func ReverseGeocodeLocation() { - geocodingService := geocoding.NewGeocodingService(os.Getenv("M3O_API_TOKEN")) - rsp, err := geocodingService.Reverse(&geocoding.ReverseRequest{ - Latitude: 51.5123064, -Longitude: -0.1216235, - - }) - fmt.Println(rsp, err) - -} -``` ## Lookup Lookup returns a geocoded address including normalized address and gps coordinates. All fields are optional, provide more to get more accurate results @@ -64,3 +35,32 @@ Postcode: "wc2b", } ``` +## Reverse + +Reverse lookup an address from gps coordinates + + +[https://m3o.com/geocoding/api#Reverse](https://m3o.com/geocoding/api#Reverse) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/geocoding" +) + +// Reverse lookup an address from gps coordinates +func ReverseGeocodeLocation() { + geocodingService := geocoding.NewGeocodingService(os.Getenv("M3O_API_TOKEN")) + rsp, err := geocodingService.Reverse(&geocoding.ReverseRequest{ + Latitude: 51.5123064, +Longitude: -0.1216235, + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/image/README.md b/examples/image/README.md index ae229e6..017aa39 100755 --- a/examples/image/README.md +++ b/examples/image/README.md @@ -4,125 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Image/api](htt Endpoints: -## Resize - -Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters. -If one of width or height is 0, the image aspect ratio is preserved. -Optional cropping. -To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json -with each parameter as a form field. - - -[https://m3o.com/image/api#Resize](https://m3o.com/image/api#Resize) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/image" -) - -// Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters. -// If one of width or height is 0, the image aspect ratio is preserved. -// Optional cropping. -// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json -// with each parameter as a form field. -func Base64toHostedImage() { - imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN")) - rsp, err := imageService.Resize(&image.ResizeRequest{ - Base64: "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==", -Height: 100, -Name: "cat.png", -Width: 100, - - }) - fmt.Println(rsp, err) - -} -``` -## Resize - -Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters. -If one of width or height is 0, the image aspect ratio is preserved. -Optional cropping. -To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json -with each parameter as a form field. - - -[https://m3o.com/image/api#Resize](https://m3o.com/image/api#Resize) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/image" -) - -// Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters. -// If one of width or height is 0, the image aspect ratio is preserved. -// Optional cropping. -// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json -// with each parameter as a form field. -func Base64toBase64image() { - imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN")) - rsp, err := imageService.Resize(&image.ResizeRequest{ - Base64: "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==", -Height: 100, -Width: 100, - - }) - fmt.Println(rsp, err) - -} -``` -## Resize - -Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters. -If one of width or height is 0, the image aspect ratio is preserved. -Optional cropping. -To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json -with each parameter as a form field. - - -[https://m3o.com/image/api#Resize](https://m3o.com/image/api#Resize) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/image" -) - -// Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters. -// If one of width or height is 0, the image aspect ratio is preserved. -// Optional cropping. -// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json -// with each parameter as a form field. -func Base64toBase64imageWithCropping() { - imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN")) - rsp, err := imageService.Resize(&image.ResizeRequest{ - Base64: "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==", -CropOptions: &image.CropOptions{ - Height: 50, - Width: 50, -}, -Height: 100, -Width: 100, - - }) - fmt.Println(rsp, err) - -} -``` ## Convert Convert an image from one format (jpeg, png etc.) to an other either on the fly (from base64 to base64), @@ -256,3 +137,122 @@ func DeleteAnUploadedImage() { } ``` +## Resize + +Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters. +If one of width or height is 0, the image aspect ratio is preserved. +Optional cropping. +To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json +with each parameter as a form field. + + +[https://m3o.com/image/api#Resize](https://m3o.com/image/api#Resize) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/image" +) + +// Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters. +// If one of width or height is 0, the image aspect ratio is preserved. +// Optional cropping. +// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json +// with each parameter as a form field. +func Base64toHostedImage() { + imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN")) + rsp, err := imageService.Resize(&image.ResizeRequest{ + Base64: "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==", +Height: 100, +Name: "cat.png", +Width: 100, + + }) + fmt.Println(rsp, err) + +} +``` +## Resize + +Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters. +If one of width or height is 0, the image aspect ratio is preserved. +Optional cropping. +To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json +with each parameter as a form field. + + +[https://m3o.com/image/api#Resize](https://m3o.com/image/api#Resize) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/image" +) + +// Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters. +// If one of width or height is 0, the image aspect ratio is preserved. +// Optional cropping. +// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json +// with each parameter as a form field. +func Base64toBase64image() { + imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN")) + rsp, err := imageService.Resize(&image.ResizeRequest{ + Base64: "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==", +Height: 100, +Width: 100, + + }) + fmt.Println(rsp, err) + +} +``` +## Resize + +Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters. +If one of width or height is 0, the image aspect ratio is preserved. +Optional cropping. +To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json +with each parameter as a form field. + + +[https://m3o.com/image/api#Resize](https://m3o.com/image/api#Resize) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/image" +) + +// Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters. +// If one of width or height is 0, the image aspect ratio is preserved. +// Optional cropping. +// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json +// with each parameter as a form field. +func Base64toBase64imageWithCropping() { + imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN")) + rsp, err := imageService.Resize(&image.ResizeRequest{ + Base64: "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==", +CropOptions: &image.CropOptions{ + Height: 50, + Width: 50, +}, +Height: 100, +Width: 100, + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/nft/README.md b/examples/nft/README.md index 4450c3a..dfd79cb 100755 --- a/examples/nft/README.md +++ b/examples/nft/README.md @@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Nft/api](https Endpoints: +## Collections + +Get a list of collections + + +[https://m3o.com/nft/api#Collections](https://m3o.com/nft/api#Collections) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/nft" +) + +// Get a list of collections +func ListCollections() { + nftService := nft.NewNftService(os.Getenv("M3O_API_TOKEN")) + rsp, err := nftService.Collections(&nft.CollectionsRequest{ + Limit: 1, + + }) + fmt.Println(rsp, err) + +} +``` ## Assets Return a list of assets @@ -61,31 +89,3 @@ Name: "Guybrush Threepwood", } ``` -## Collections - -Get a list of collections - - -[https://m3o.com/nft/api#Collections](https://m3o.com/nft/api#Collections) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/nft" -) - -// Get a list of collections -func ListCollections() { - nftService := nft.NewNftService(os.Getenv("M3O_API_TOKEN")) - rsp, err := nftService.Collections(&nft.CollectionsRequest{ - Limit: 1, - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/rss/README.md b/examples/rss/README.md index bde5033..62d0224 100755 --- a/examples/rss/README.md +++ b/examples/rss/README.md @@ -4,61 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Rss/api](https Endpoints: -## List - -List the saved RSS fields - - -[https://m3o.com/rss/api#List](https://m3o.com/rss/api#List) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/rss" -) - -// List the saved RSS fields -func ListRssFeeds() { - rssService := rss.NewRssService(os.Getenv("M3O_API_TOKEN")) - rsp, err := rssService.List(&rss.ListRequest{ - - }) - fmt.Println(rsp, err) - -} -``` -## Remove - -Remove an RSS feed by name - - -[https://m3o.com/rss/api#Remove](https://m3o.com/rss/api#Remove) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/rss" -) - -// Remove an RSS feed by name -func RemoveAfeed() { - rssService := rss.NewRssService(os.Getenv("M3O_API_TOKEN")) - rsp, err := rssService.Remove(&rss.RemoveRequest{ - Name: "bbc", - - }) - fmt.Println(rsp, err) - -} -``` ## Add Add a new RSS feed with a name, url, and category @@ -117,3 +62,58 @@ func ReadAfeed() { } ``` +## List + +List the saved RSS fields + + +[https://m3o.com/rss/api#List](https://m3o.com/rss/api#List) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/rss" +) + +// List the saved RSS fields +func ListRssFeeds() { + rssService := rss.NewRssService(os.Getenv("M3O_API_TOKEN")) + rsp, err := rssService.List(&rss.ListRequest{ + + }) + fmt.Println(rsp, err) + +} +``` +## Remove + +Remove an RSS feed by name + + +[https://m3o.com/rss/api#Remove](https://m3o.com/rss/api#Remove) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/rss" +) + +// Remove an RSS feed by name +func RemoveAfeed() { + rssService := rss.NewRssService(os.Getenv("M3O_API_TOKEN")) + rsp, err := rssService.Remove(&rss.RemoveRequest{ + Name: "bbc", + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/search/index/indexADocument/main.go b/examples/search/index/indexADocument/main.go index b81496d..81df17a 100755 --- a/examples/search/index/indexADocument/main.go +++ b/examples/search/index/indexADocument/main.go @@ -13,9 +13,9 @@ func main() { rsp, err := searchService.Index(&search.IndexRequest{ Document: &search.Document{ Contents: map[string]interface{}{ + "name": "John Doe", "age": 37, "starsign": "Leo", - "name": "John Doe", }, Id: "1234", }, diff --git a/examples/space/README.md b/examples/space/README.md index c9a9a13..a72858f 100755 --- a/examples/space/README.md +++ b/examples/space/README.md @@ -4,6 +4,62 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Space/api](htt Endpoints: +## Read + +Read an object in space + + +[https://m3o.com/space/api#Read](https://m3o.com/space/api#Read) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/space" +) + +// Read an object in space +func ReadAnObject() { + spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN")) + rsp, err := spaceService.Read(&space.ReadRequest{ + Name: "images/file.jpg", + + }) + fmt.Println(rsp, err) + +} +``` +## Download + +Download an object via a presigned url + + +[https://m3o.com/space/api#Download](https://m3o.com/space/api#Download) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/space" +) + +// Download an object via a presigned url +func DownloadAnObject() { + spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN")) + rsp, err := spaceService.Download(&space.DownloadRequest{ + Name: "images/file.jpg", + + }) + fmt.Println(rsp, err) + +} +``` ## Upload Upload a large object (> 10MB). Returns a time limited presigned URL to be used for uploading the object @@ -176,59 +232,3 @@ func HeadAnObject() { } ``` -## Read - -Read an object in space - - -[https://m3o.com/space/api#Read](https://m3o.com/space/api#Read) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/space" -) - -// Read an object in space -func ReadAnObject() { - spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN")) - rsp, err := spaceService.Read(&space.ReadRequest{ - Name: "images/file.jpg", - - }) - fmt.Println(rsp, err) - -} -``` -## Download - -Download an object via a presigned url - - -[https://m3o.com/space/api#Download](https://m3o.com/space/api#Download) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/space" -) - -// Download an object via a presigned url -func DownloadAnObject() { - spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN")) - rsp, err := spaceService.Download(&space.DownloadRequest{ - Name: "images/file.jpg", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/stock/README.md b/examples/stock/README.md index 3090684..b627a34 100755 --- a/examples/stock/README.md +++ b/examples/stock/README.md @@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Stock/api](htt Endpoints: +## Price + +Get the last price for a given stock ticker + + +[https://m3o.com/stock/api#Price](https://m3o.com/stock/api#Price) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/stock" +) + +// Get the last price for a given stock ticker +func GetAstockPrice() { + stockService := stock.NewStockService(os.Getenv("M3O_API_TOKEN")) + rsp, err := stockService.Price(&stock.PriceRequest{ + Symbol: "AAPL", + + }) + fmt.Println(rsp, err) + +} +``` ## Quote Get the last quote for the stock @@ -93,31 +121,3 @@ Stock: "AAPL", } ``` -## Price - -Get the last price for a given stock ticker - - -[https://m3o.com/stock/api#Price](https://m3o.com/stock/api#Price) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/stock" -) - -// Get the last price for a given stock ticker -func GetAstockPrice() { - stockService := stock.NewStockService(os.Getenv("M3O_API_TOKEN")) - rsp, err := stockService.Price(&stock.PriceRequest{ - Symbol: "AAPL", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/stream/README.md b/examples/stream/README.md index 08f1f1a..6d83f90 100755 --- a/examples/stream/README.md +++ b/examples/stream/README.md @@ -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) - -} -``` diff --git a/examples/sunnah/README.md b/examples/sunnah/README.md index 2b42fdf..0b5cf6e 100755 --- a/examples/sunnah/README.md +++ b/examples/sunnah/README.md @@ -4,6 +4,65 @@ 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. @@ -64,62 +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) - -} -``` -## 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) - -} -``` diff --git a/examples/user/README.md b/examples/user/README.md index 9e0d6d7..b94644f 100755 --- a/examples/user/README.md +++ b/examples/user/README.md @@ -4,6 +4,87 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/User/api](http Endpoints: +## SendVerificationEmail + +Send a verification email +to the user being signed up. Email from will be from 'noreply@email.m3ocontent.com', +but you can provide the title and contents. +The verification link will be injected in to the email as a template variable, $micro_verification_link. +Example: 'Hi there, welcome onboard! Use the link below to verify your email: $micro_verification_link' +The variable will be replaced with an actual url that will look similar to this: +'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 the user being signed up. Email from will be from 'noreply@email.m3ocontent.com', +// but you can provide the title and contents. +// The verification link will be injected in to the email as a template variable, $micro_verification_link. +// Example: 'Hi there, welcome onboard! Use the link below to verify your email: $micro_verification_link' +// The variable will be replaced with an actual url that will look similar to this: +// 'https://user.m3o.com/user/verify?token=a-verification-token&redirectUrl=your-redir-url' +func SendVerificationEmail() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.SendVerificationEmail(&user.SendVerificationEmailRequest{ + Email: "joe@example.com", +FailureRedirectUrl: "https://m3o.com/verification-failed", +FromName: "Awesome Dot Com", +RedirectUrl: "https://m3o.com", +Subject: "Email verification", +TextContent: `Hi there, + +Please verify your email by clicking this link: $micro_verification_link`, + + }) + fmt.Println(rsp, err) + +} +``` +## SendPasswordResetEmail + +Send an email with a verification code to reset password. +Call "ResetPassword" endpoint once user provides the code. + + +[https://m3o.com/user/api#SendPasswordResetEmail](https://m3o.com/user/api#SendPasswordResetEmail) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Send an email with a verification code to reset password. +// Call "ResetPassword" endpoint once user provides the code. +func SendPasswordResetEmail() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.SendPasswordResetEmail(&user.SendPasswordResetEmailRequest{ + Email: "joe@example.com", +FromName: "Awesome Dot Com", +Subject: "Password reset", +TextContent: `Hi there, + click here to reset your password: myapp.com/reset/code?=$code`, + + }) + fmt.Println(rsp, err) + +} +``` ## Delete Delete an account by id @@ -30,6 +111,65 @@ func DeleteUserAccount() { }) 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) + +} +``` +## 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) + } ``` ## ResetPassword @@ -90,6 +230,161 @@ Token: "012345", }) fmt.Println(rsp, err) +} +``` +## ReadSession + +Read a session by the session id. In the event it has expired or is not found and error is returned. + + +[https://m3o.com/user/api#ReadSession](https://m3o.com/user/api#ReadSession) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Read a session by the session id. In the event it has expired or is not found and error is returned. +func ReadAsessionByTheSessionId() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.ReadSession(&user.ReadSessionRequest{ + SessionId: "df91a612-5b24-4634-99ff-240220ab8f55", + + }) + fmt.Println(rsp, err) + +} +``` +## List + +List all users. Returns a paged list of results + + +[https://m3o.com/user/api#List](https://m3o.com/user/api#List) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/user" +) + +// List all users. Returns a paged list of results +func ListAllUsers() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.List(&user.ListRequest{ + Limit: 100, +Offset: 0, + + }) + fmt.Println(rsp, err) + +} +``` +## SendMagicLink + +Login using email only - Passwordless + + +[https://m3o.com/user/api#SendMagicLink](https://m3o.com/user/api#SendMagicLink) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Login using email only - Passwordless +func SendAmagicLink() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.SendMagicLink(&user.SendMagicLinkRequest{ + Address: "www.example.com", +Email: "joe@example.com", +Endpoint: "verifytoken", +FromName: "Awesome Dot Com", +Subject: "MagicLink to access your account", +TextContent: `Hi there, + +Click here to access your account $micro_verification_link`, + + }) + fmt.Println(rsp, err) + +} +``` +## VerifyToken + +Check whether the token attached to MagicLink is valid or not. +Ideally, you need to call this endpoint from your http request +handler that handles the endpoint which is specified in the +SendMagicLink request. + + +[https://m3o.com/user/api#VerifyToken](https://m3o.com/user/api#VerifyToken) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Check whether the token attached to MagicLink is valid or not. +// Ideally, you need to call this endpoint from your http request +// handler that handles the endpoint which is specified in the +// SendMagicLink request. +func VerifyAtoken() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.VerifyToken(&user.VerifyTokenRequest{ + Token: "EdsUiidouJJJLldjlloofUiorkojflsWWdld", + + }) + fmt.Println(rsp, err) + +} +``` +## 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", + + }) + fmt.Println(rsp, err) + } ``` ## UpdatePassword @@ -204,272 +499,6 @@ func ReadAccountByEmail() { }) fmt.Println(rsp, err) -} -``` -## SendVerificationEmail - -Send a verification email -to the user being signed up. Email from will be from 'noreply@email.m3ocontent.com', -but you can provide the title and contents. -The verification link will be injected in to the email as a template variable, $micro_verification_link. -Example: 'Hi there, welcome onboard! Use the link below to verify your email: $micro_verification_link' -The variable will be replaced with an actual url that will look similar to this: -'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 the user being signed up. Email from will be from 'noreply@email.m3ocontent.com', -// but you can provide the title and contents. -// The verification link will be injected in to the email as a template variable, $micro_verification_link. -// Example: 'Hi there, welcome onboard! Use the link below to verify your email: $micro_verification_link' -// The variable will be replaced with an actual url that will look similar to this: -// '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) - -} -``` -## 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) - -} -``` -## Create - -Create a new user account. The email address and username for the account must be unique. - - -[https://m3o.com/user/api#Create](https://m3o.com/user/api#Create) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/user" -) - -// Create a new user account. The email address and username for the account must be unique. -func CreateAnAccount() { - userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.Create(&user.CreateRequest{ - Email: "joe@example.com", -Id: "user-1", -Password: "Password1", -Username: "joe", - - }) - fmt.Println(rsp, err) - -} -``` -## Update - -Update the account username or email - - -[https://m3o.com/user/api#Update](https://m3o.com/user/api#Update) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/user" -) - -// Update the account username or email -func UpdateAnAccount() { - userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.Update(&user.UpdateRequest{ - Email: "joe+2@example.com", -Id: "user-1", - - }) - 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) - -} -``` -## 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) - -} -``` -## 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) - } ``` ## Login @@ -503,32 +532,3 @@ Password: "Password1", } ``` -## 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) - -} -```