From 05bd1cc0194f9280ae44cd3bd87b4b8b4d1351d5 Mon Sep 17 00:00:00 2001 From: m3o-actions <> Date: Fri, 10 Dec 2021 16:48:02 +0000 Subject: [PATCH] Commit from m3o/m3o action --- examples/app/README.md | 56 +- examples/cache/README.md | 114 ++-- examples/currency/README.md | 110 ++-- examples/db/README.md | 228 +++---- examples/db/create/createARecord/main.go | 4 +- examples/event/README.md | 56 +- examples/event/publish/publishAnEvent/main.go | 2 +- examples/file/README.md | 116 ++-- examples/function/README.md | 112 ++-- examples/helloworld/README.md | 56 +- examples/holidays/README.md | 54 +- examples/id/README.md | 54 +- examples/mq/README.md | 2 +- examples/mq/publish/publishAMessage/main.go | 2 +- examples/nft/README.md | 56 +- examples/notes/README.md | 120 ++-- examples/quran/README.md | 112 ++-- examples/space/README.md | 132 ++-- examples/space/create/createAnObject/main.go | 2 +- examples/space/upload/uploadAnObject/main.go | 2 +- examples/stream/README.md | 54 +- examples/twitter/README.md | 56 +- examples/url/README.md | 54 +- examples/user/README.md | 566 +++++++++--------- examples/youtube/README.md | 56 +- space/space.go | 4 +- 26 files changed, 1090 insertions(+), 1090 deletions(-) diff --git a/examples/app/README.md b/examples/app/README.md index a220779..9af92ba 100755 --- a/examples/app/README.md +++ b/examples/app/README.md @@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/App/api](https Endpoints: -## Reserve - -Reserve your app name - - -[https://m3o.com/app/api#Reserve](https://m3o.com/app/api#Reserve) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/app" -) - -// Reserve your app name -func ReserveAppName() { - appService := app.NewAppService(os.Getenv("M3O_API_TOKEN")) - rsp, err := appService.Reserve(&app.ReserveRequest{ - Name: "helloworld", - - }) - fmt.Println(rsp, err) - -} -``` ## Vote Vote to have the App api launched faster! @@ -60,3 +32,31 @@ func VoteForTheApi() { } ``` +## Reserve + +Reserve your app name + + +[https://m3o.com/app/api#Reserve](https://m3o.com/app/api#Reserve) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/app" +) + +// Reserve your app name +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 03c0009..44097c1 100755 --- a/examples/cache/README.md +++ b/examples/cache/README.md @@ -4,6 +4,63 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Cache/api](htt Endpoints: +## Set + +Set an item in the cache. Overwrites any existing value already set. + + +[https://m3o.com/cache/api#Set](https://m3o.com/cache/api#Set) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/cache" +) + +// Set an item in the cache. Overwrites any existing value already set. +func SetAvalue() { + cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN")) + rsp, err := cacheService.Set(&cache.SetRequest{ + Key: "foo", +Value: "bar", + + }) + fmt.Println(rsp, err) + +} +``` +## Get + +Get an item from the cache by key. If key is not found, an empty response is returned. + + +[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. @@ -90,60 +147,3 @@ Value: 2, } ``` -## Set - -Set an item in the cache. Overwrites any existing value already set. - - -[https://m3o.com/cache/api#Set](https://m3o.com/cache/api#Set) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/cache" -) - -// Set an item in the cache. Overwrites any existing value already set. -func SetAvalue() { - cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN")) - rsp, err := cacheService.Set(&cache.SetRequest{ - Key: "foo", -Value: "bar", - - }) - fmt.Println(rsp, err) - -} -``` -## Get - -Get an item from the cache by key. If key is not found, an empty response is returned. - - -[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/currency/README.md b/examples/currency/README.md index 65a799d..bf674d6 100755 --- a/examples/currency/README.md +++ b/examples/currency/README.md @@ -4,61 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Currency/api]( Endpoints: -## Codes - -Codes returns the supported currency codes for the API - - -[https://m3o.com/currency/api#Codes](https://m3o.com/currency/api#Codes) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/currency" -) - -// Codes returns the supported currency codes for the API -func GetSupportedCodes() { - currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN")) - rsp, err := currencyService.Codes(¤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 @@ -147,3 +92,58 @@ Date: "2021-05-30", } ``` +## Codes + +Codes returns the supported currency codes for the API + + +[https://m3o.com/currency/api#Codes](https://m3o.com/currency/api#Codes) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/currency" +) + +// Codes returns the supported currency codes for the API +func GetSupportedCodes() { + currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN")) + rsp, err := currencyService.Codes(¤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 db30383..6611722 100755 --- a/examples/db/README.md +++ b/examples/db/README.md @@ -26,16 +26,129 @@ func CreateArecord() { dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) rsp, err := dbService.Create(&db.CreateRequest{ Record: map[string]interface{}{ + "id": "1", "name": "Jane", "age": 42, "isActive": true, - "id": "1", }, 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) + +} +``` +## 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 @@ -68,35 +181,6 @@ 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 @@ -126,33 +210,6 @@ 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) - } ``` ## Truncate @@ -181,34 +238,6 @@ func TruncateTable() { }) 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) - } ``` ## Count @@ -239,32 +268,3 @@ func CountEntriesInAtable() { } ``` -## RenameTable - -Rename a table - - -[https://m3o.com/db/api#RenameTable](https://m3o.com/db/api#RenameTable) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/db" -) - -// Rename a table -func RenameTable() { - dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) - rsp, err := dbService.RenameTable(&db.RenameTableRequest{ - From: "examples2", -To: "examples3", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/db/create/createARecord/main.go b/examples/db/create/createARecord/main.go index f258334..f094c0c 100755 --- a/examples/db/create/createARecord/main.go +++ b/examples/db/create/createARecord/main.go @@ -12,10 +12,10 @@ func main() { dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) rsp, err := dbService.Create(&db.CreateRequest{ Record: map[string]interface{}{ - "id": "1", - "name": "Jane", "age": 42, "isActive": true, + "id": "1", + "name": "Jane", }, Table: "example", }) diff --git a/examples/event/README.md b/examples/event/README.md index a01a4f0..bfdbd1a 100755 --- a/examples/event/README.md +++ b/examples/event/README.md @@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Event/api](htt Endpoints: -## Read - -Read stored events - - -[https://m3o.com/event/api#Read](https://m3o.com/event/api#Read) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/event" -) - -// Read stored events -func ReadEventsOnAtopic() { - eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN")) - rsp, err := eventService.Read(&event.ReadRequest{ - Topic: "user", - - }) - fmt.Println(rsp, err) - -} -``` ## Publish Publish a event to the event stream. @@ -106,3 +78,31 @@ func ConsumeFromAtopic() { } } ``` +## Read + +Read stored events + + +[https://m3o.com/event/api#Read](https://m3o.com/event/api#Read) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/event" +) + +// Read stored events +func ReadEventsOnAtopic() { + eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN")) + rsp, err := eventService.Read(&event.ReadRequest{ + Topic: "user", + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/event/publish/publishAnEvent/main.go b/examples/event/publish/publishAnEvent/main.go index eb4cfd3..287af64 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{}{ - "user": "john", "id": "1", "type": "signup", + "user": "john", }, Topic: "user", }) diff --git a/examples/file/README.md b/examples/file/README.md index f07c5f3..6b3ff5e 100755 --- a/examples/file/README.md +++ b/examples/file/README.md @@ -4,64 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/File/api](http Endpoints: -## Delete - -Delete a file by project name/path - - -[https://m3o.com/file/api#Delete](https://m3o.com/file/api#Delete) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/file" -) - -// Delete a file by project name/path -func DeleteFile() { - fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN")) - rsp, err := fileService.Delete(&file.DeleteRequest{ - Path: "/document/text-files/file.txt", -Project: "examples", - - }) - fmt.Println(rsp, err) - -} -``` -## Read - -Read a file by path - - -[https://m3o.com/file/api#Read](https://m3o.com/file/api#Read) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/file" -) - -// Read a file by path -func ReadFile() { - fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN")) - rsp, err := fileService.Read(&file.ReadRequest{ - Path: "/document/text-files/file.txt", -Project: "examples", - - }) - fmt.Println(rsp, err) - -} -``` ## Save Save a file @@ -122,3 +64,61 @@ func ListFiles() { } ``` +## Delete + +Delete a file by project name/path + + +[https://m3o.com/file/api#Delete](https://m3o.com/file/api#Delete) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/file" +) + +// Delete a file by project name/path +func DeleteFile() { + fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN")) + rsp, err := fileService.Delete(&file.DeleteRequest{ + Path: "/document/text-files/file.txt", +Project: "examples", + + }) + fmt.Println(rsp, err) + +} +``` +## Read + +Read a file by path + + +[https://m3o.com/file/api#Read](https://m3o.com/file/api#Read) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/file" +) + +// Read a file by path +func ReadFile() { + fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN")) + rsp, err := fileService.Read(&file.ReadRequest{ + Path: "/document/text-files/file.txt", +Project: "examples", + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/function/README.md b/examples/function/README.md index c2c5bf5..0cf9bd4 100755 --- a/examples/function/README.md +++ b/examples/function/README.md @@ -4,6 +4,62 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Function/api]( Endpoints: +## Delete + +Delete a function by name + + +[https://m3o.com/function/api#Delete](https://m3o.com/function/api#Delete) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/function" +) + +// Delete a function by name +func DeleteAfunction() { + functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) + rsp, err := functionService.Delete(&function.DeleteRequest{ + Name: "helloworld", + + }) + fmt.Println(rsp, err) + +} +``` +## Describe + +Get the info for a deployed function + + +[https://m3o.com/function/api#Describe](https://m3o.com/function/api#Describe) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/function" +) + +// Get the info for a deployed function +func DescribeFunctionStatus() { + functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) + rsp, err := functionService.Describe(&function.DescribeRequest{ + Name: "helloworld", + + }) + fmt.Println(rsp, err) + +} +``` ## Deploy Deploy a group of functions @@ -92,59 +148,3 @@ func ListFunctions() { } ``` -## Delete - -Delete a function by name - - -[https://m3o.com/function/api#Delete](https://m3o.com/function/api#Delete) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/function" -) - -// Delete a function by name -func DeleteAfunction() { - functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) - rsp, err := functionService.Delete(&function.DeleteRequest{ - Name: "helloworld", - - }) - fmt.Println(rsp, err) - -} -``` -## Describe - -Get the info for a deployed function - - -[https://m3o.com/function/api#Describe](https://m3o.com/function/api#Describe) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/function" -) - -// Get the info for a deployed function -func DescribeFunctionStatus() { - functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) - rsp, err := functionService.Describe(&function.DescribeRequest{ - Name: "helloworld", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/helloworld/README.md b/examples/helloworld/README.md index 8f0aa43..3593fb7 100755 --- a/examples/helloworld/README.md +++ b/examples/helloworld/README.md @@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Helloworld/api Endpoints: -## Call - -Call returns a personalised "Hello $name" response - - -[https://m3o.com/helloworld/api#Call](https://m3o.com/helloworld/api#Call) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/helloworld" -) - -// Call returns a personalised "Hello $name" response -func CallTheHelloworldService() { - helloworldService := helloworld.NewHelloworldService(os.Getenv("M3O_API_TOKEN")) - rsp, err := helloworldService.Call(&helloworld.CallRequest{ - Name: "John", - - }) - fmt.Println(rsp, err) - -} -``` ## Stream Stream returns a stream of "Hello $name" responses @@ -74,3 +46,31 @@ Name: "John", } } ``` +## Call + +Call returns a personalised "Hello $name" response + + +[https://m3o.com/helloworld/api#Call](https://m3o.com/helloworld/api#Call) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/helloworld" +) + +// Call returns a personalised "Hello $name" response +func CallTheHelloworldService() { + helloworldService := helloworld.NewHelloworldService(os.Getenv("M3O_API_TOKEN")) + rsp, err := helloworldService.Call(&helloworld.CallRequest{ + Name: "John", + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/holidays/README.md b/examples/holidays/README.md index c0b9f00..22e8fcd 100755 --- a/examples/holidays/README.md +++ b/examples/holidays/README.md @@ -4,33 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Holidays/api]( Endpoints: -## Countries - -Get the list of countries that are supported by this API - - -[https://m3o.com/holidays/api#Countries](https://m3o.com/holidays/api#Countries) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/holidays" -) - -// Get the list of countries that are supported by this API -func ListCountries() { - holidaysService := holidays.NewHolidaysService(os.Getenv("M3O_API_TOKEN")) - rsp, err := holidaysService.Countries(&holidays.CountriesRequest{ - - }) - fmt.Println(rsp, err) - -} -``` ## List List the holiday dates for a given country and year @@ -59,3 +32,30 @@ func GetHolidays() { } ``` +## Countries + +Get the list of countries that are supported by this API + + +[https://m3o.com/holidays/api#Countries](https://m3o.com/holidays/api#Countries) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/holidays" +) + +// Get the list of countries that are supported by this API +func ListCountries() { + holidaysService := holidays.NewHolidaysService(os.Getenv("M3O_API_TOKEN")) + rsp, err := holidaysService.Countries(&holidays.CountriesRequest{ + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/id/README.md b/examples/id/README.md index e42c554..6d0391b 100755 --- a/examples/id/README.md +++ b/examples/id/README.md @@ -4,33 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Id/api](https: Endpoints: -## Types - -List the types of IDs available. No query params needed. - - -[https://m3o.com/id/api#Types](https://m3o.com/id/api#Types) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/id" -) - -// List the types of IDs available. No query params needed. -func ListTheTypesOfIdsAvailable() { - idService := id.NewIdService(os.Getenv("M3O_API_TOKEN")) - rsp, err := idService.Types(&id.TypesRequest{ - - }) - fmt.Println(rsp, err) - -} -``` ## Generate Generate a unique ID. Defaults to uuid. @@ -143,3 +116,30 @@ func GenerateAbigflakeId() { } ``` +## Types + +List the types of IDs available. No query params needed. + + +[https://m3o.com/id/api#Types](https://m3o.com/id/api#Types) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/id" +) + +// List the types of IDs available. No query params needed. +func ListTheTypesOfIdsAvailable() { + idService := id.NewIdService(os.Getenv("M3O_API_TOKEN")) + rsp, err := idService.Types(&id.TypesRequest{ + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/mq/README.md b/examples/mq/README.md index 10f108b..8153f1c 100755 --- a/examples/mq/README.md +++ b/examples/mq/README.md @@ -26,9 +26,9 @@ 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", + "id": "1", }, Topic: "events", diff --git a/examples/mq/publish/publishAMessage/main.go b/examples/mq/publish/publishAMessage/main.go index fe21c56..ad993e2 100755 --- a/examples/mq/publish/publishAMessage/main.go +++ b/examples/mq/publish/publishAMessage/main.go @@ -12,9 +12,9 @@ func main() { mqService := mq.NewMqService(os.Getenv("M3O_API_TOKEN")) rsp, err := mqService.Publish(&mq.PublishRequest{ Message: map[string]interface{}{ - "user": "john", "id": "1", "type": "signup", + "user": "john", }, Topic: "events", }) diff --git a/examples/nft/README.md b/examples/nft/README.md index 0075be9..4450c3a 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: +## Assets + +Return a list of assets + + +[https://m3o.com/nft/api#Assets](https://m3o.com/nft/api#Assets) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/nft" +) + +// Return a list of assets +func GetAlistOfAssets() { + nftService := nft.NewNftService(os.Getenv("M3O_API_TOKEN")) + rsp, err := nftService.Assets(&nft.AssetsRequest{ + Limit: 1, + + }) + fmt.Println(rsp, err) + +} +``` ## Create Create your own NFT (coming soon) @@ -61,31 +89,3 @@ func ListCollections() { } ``` -## Assets - -Return a list of assets - - -[https://m3o.com/nft/api#Assets](https://m3o.com/nft/api#Assets) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/nft" -) - -// Return a list of assets -func GetAlistOfAssets() { - nftService := nft.NewNftService(os.Getenv("M3O_API_TOKEN")) - rsp, err := nftService.Assets(&nft.AssetsRequest{ - Limit: 1, - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/notes/README.md b/examples/notes/README.md index ccace0c..d3734ad 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/quran/README.md b/examples/quran/README.md index 5f43d60..927b4b4 100755 --- a/examples/quran/README.md +++ b/examples/quran/README.md @@ -4,62 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Quran/api](htt Endpoints: -## Search - -Search the Quran for any form of query or questions - - -[https://m3o.com/quran/api#Search](https://m3o.com/quran/api#Search) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/quran" -) - -// Search the Quran for any form of query or questions -func SearchTheQuran() { - quranService := quran.NewQuranService(os.Getenv("M3O_API_TOKEN")) - rsp, err := quranService.Search(&quran.SearchRequest{ - Query: "messenger", - - }) - fmt.Println(rsp, err) - -} -``` -## Chapters - -List the Chapters (surahs) of the Quran - - -[https://m3o.com/quran/api#Chapters](https://m3o.com/quran/api#Chapters) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/quran" -) - -// List the Chapters (surahs) of the Quran -func ListChapters() { - quranService := quran.NewQuranService(os.Getenv("M3O_API_TOKEN")) - rsp, err := quranService.Chapters(&quran.ChaptersRequest{ - Language: "en", - - }) - fmt.Println(rsp, err) - -} -``` ## Summary Get a summary for a given chapter (surah) @@ -120,3 +64,59 @@ func GetVersesOfAchapter() { } ``` +## Search + +Search the Quran for any form of query or questions + + +[https://m3o.com/quran/api#Search](https://m3o.com/quran/api#Search) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/quran" +) + +// Search the Quran for any form of query or questions +func SearchTheQuran() { + quranService := quran.NewQuranService(os.Getenv("M3O_API_TOKEN")) + rsp, err := quranService.Search(&quran.SearchRequest{ + Query: "messenger", + + }) + fmt.Println(rsp, err) + +} +``` +## Chapters + +List the Chapters (surahs) of the Quran + + +[https://m3o.com/quran/api#Chapters](https://m3o.com/quran/api#Chapters) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/quran" +) + +// List the Chapters (surahs) of the Quran +func ListChapters() { + quranService := quran.NewQuranService(os.Getenv("M3O_API_TOKEN")) + rsp, err := quranService.Chapters(&quran.ChaptersRequest{ + Language: "en", + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/space/README.md b/examples/space/README.md index 2178d05..e432074 100755 --- a/examples/space/README.md +++ b/examples/space/README.md @@ -4,68 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Space/api](htt Endpoints: -## Update - -Update an object. If an object with this name does not exist, creates a new one. -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/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. -// 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 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 - - -[https://m3o.com/space/api#Delete](https://m3o.com/space/api#Delete) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/space" -) - -// Delete an object from space -func DeleteAnObject() { - spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN")) - rsp, err := spaceService.Delete(&space.DeleteRequest{ - Name: "images/file.jpg", - - }) - fmt.Println(rsp, err) - -} -``` ## List List the objects in space @@ -180,7 +118,7 @@ func DownloadAnObject() { ``` ## Upload -Upload a large object. Returns a time limited presigned URL to be used for uploading the object +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) @@ -195,7 +133,7 @@ import( "go.m3o.com/space" ) -// Upload a large object. Returns a time limited presigned URL to be used for uploading the object +// 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{ @@ -208,7 +146,7 @@ func UploadAnObject() { ``` ## Create -Create an object. Returns error if object with this name already exists. If you want to update an existing object use the `Update` endpoint +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 You need to send the request as a multipart/form-data rather than the usual application/json with each parameter as a form field. @@ -225,7 +163,7 @@ import( "go.m3o.com/space" ) -// Create an object. Returns error if object with this name already exists. If you want to update an existing object use the `Update` endpoint +// 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 // 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 CreateAnObject() { @@ -240,3 +178,65 @@ Visibility: "public", } ``` +## Update + +Update an object. If an object with this name does not exist, creates a new one. +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/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. +// 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 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 + + +[https://m3o.com/space/api#Delete](https://m3o.com/space/api#Delete) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/space" +) + +// Delete an object from space +func DeleteAnObject() { + spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN")) + rsp, err := spaceService.Delete(&space.DeleteRequest{ + Name: "images/file.jpg", + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/space/create/createAnObject/main.go b/examples/space/create/createAnObject/main.go index 8c202d5..cc4378d 100755 --- a/examples/space/create/createAnObject/main.go +++ b/examples/space/create/createAnObject/main.go @@ -7,7 +7,7 @@ import ( "go.m3o.com/space" ) -// Create an object. Returns error if object with this name already exists. If you want to update an existing object use the `Update` endpoint +// 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 // 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 main() { diff --git a/examples/space/upload/uploadAnObject/main.go b/examples/space/upload/uploadAnObject/main.go index 09dfabf..60907ea 100755 --- a/examples/space/upload/uploadAnObject/main.go +++ b/examples/space/upload/uploadAnObject/main.go @@ -7,7 +7,7 @@ import ( "go.m3o.com/space" ) -// Upload a large object. Returns a time limited presigned URL to be used for uploading the object +// Upload a large object (> 10MB). Returns a time limited presigned URL to be used for uploading the object func main() { spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN")) rsp, err := spaceService.Upload(&space.UploadRequest{ diff --git a/examples/stream/README.md b/examples/stream/README.md index 6d83f90..08f1f1a 100755 --- a/examples/stream/README.md +++ b/examples/stream/README.md @@ -4,33 +4,6 @@ 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 @@ -119,3 +92,30 @@ 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/twitter/README.md b/examples/twitter/README.md index e099911..fd92920 100755 --- a/examples/twitter/README.md +++ b/examples/twitter/README.md @@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Twitter/api](h Endpoints: +## User + +Get a user's twitter profile + + +[https://m3o.com/twitter/api#User](https://m3o.com/twitter/api#User) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/twitter" +) + +// Get a user's twitter profile +func GetAusersTwitterProfile() { + twitterService := twitter.NewTwitterService(os.Getenv("M3O_API_TOKEN")) + rsp, err := twitterService.User(&twitter.UserRequest{ + Username: "crufter", + + }) + fmt.Println(rsp, err) + +} +``` ## Timeline Get the timeline for a given user @@ -88,31 +116,3 @@ func GetTheCurrentGlobalTrendingTopics() { } ``` -## User - -Get a user's twitter profile - - -[https://m3o.com/twitter/api#User](https://m3o.com/twitter/api#User) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/twitter" -) - -// Get a user's twitter profile -func GetAusersTwitterProfile() { - twitterService := twitter.NewTwitterService(os.Getenv("M3O_API_TOKEN")) - rsp, err := twitterService.User(&twitter.UserRequest{ - Username: "crufter", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/url/README.md b/examples/url/README.md index 9cb9280..8093f12 100755 --- a/examples/url/README.md +++ b/examples/url/README.md @@ -4,33 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Url/api](https Endpoints: -## List - -List information on all the shortened URLs that you have created - - -[https://m3o.com/url/api#List](https://m3o.com/url/api#List) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/url" -) - -// List information on all the shortened URLs that you have created -func ListYourShortenedUrls() { - urlService := url.NewUrlService(os.Getenv("M3O_API_TOKEN")) - rsp, err := urlService.List(&url.ListRequest{ - - }) - fmt.Println(rsp, err) - -} -``` ## Shorten Shortens a destination URL and returns a full short URL. @@ -85,3 +58,30 @@ func ResolveAshortUrlToAlongDestinationUrl() { } ``` +## List + +List information on all the shortened URLs that you have created + + +[https://m3o.com/url/api#List](https://m3o.com/url/api#List) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/url" +) + +// List information on all the shortened URLs that you have created +func ListYourShortenedUrls() { + urlService := url.NewUrlService(os.Getenv("M3O_API_TOKEN")) + rsp, err := urlService.List(&url.ListRequest{ + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/user/README.md b/examples/user/README.md index 1805a80..598ef68 100755 --- a/examples/user/README.md +++ b/examples/user/README.md @@ -4,13 +4,18 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/User/api](http Endpoints: -## SendPasswordResetEmail +## SendVerificationEmail -Send an email with a verification code to reset password. -Call "ResetPassword" endpoint once user provides the code. +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#SendPasswordResetEmail](https://m3o.com/user/api#SendPasswordResetEmail) +[https://m3o.com/user/api#SendVerificationEmail](https://m3o.com/user/api#SendVerificationEmail) ```go package example @@ -22,75 +27,24 @@ import( "go.m3o.com/user" ) -// Send an email with a verification code to reset password. -// Call "ResetPassword" endpoint once user provides the code. -func SendPasswordResetEmail() { +// 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.SendPasswordResetEmail(&user.SendPasswordResetEmailRequest{ + rsp, err := userService.SendVerificationEmail(&user.SendVerificationEmailRequest{ Email: "joe@example.com", +FailureRedirectUrl: "https://m3o.com/verification-failed", FromName: "Awesome Dot Com", -Subject: "Password reset", +RedirectUrl: "https://m3o.com", +Subject: "Email verification", 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" endoint. - - -[https://m3o.com/user/api#ResetPassword](https://m3o.com/user/api#ResetPassword) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/user" -) - -// Reset password with the code sent by the "SendPasswordResetEmail" endoint. -func ResetPassword() { - userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.ResetPassword(&user.ResetPasswordRequest{ - Code: "012345", -ConfirmPassword: "NewPassword1", -Email: "joe@example.com", -NewPassword: "NewPassword1", - - }) - fmt.Println(rsp, err) - -} -``` -## Delete - -Delete an account by id - - -[https://m3o.com/user/api#Delete](https://m3o.com/user/api#Delete) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/user" -) - -// Delete an account by id -func DeleteUserAccount() { - userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.Delete(&user.DeleteRequest{ - Id: "8b98acbe-0b6a-4d66-a414-5ffbf666786f", +Please verify your email by clicking this link: $micro_verification_link`, }) fmt.Println(rsp, err) @@ -156,6 +110,117 @@ func ReadAsessionByTheSessionId() { } ``` +## 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) + +} +``` +## 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")) + + stream, 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`, + + }) + if err != nil { + fmt.Println(err) + return + } + + for { + rsp, err := stream.Recv() + if err != nil { + fmt.Println(err) + return + } + + fmt.Println(rsp) + } +} +``` ## Create Create a new user account. The email address and username for the account must be unique. @@ -185,6 +250,35 @@ 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) + } ``` ## UpdatePassword @@ -215,6 +309,127 @@ OldPassword: "Password1", }) fmt.Println(rsp, err) +} +``` +## ResetPassword + +Reset password with the code sent by the "SendPasswordResetEmail" endoint. + + +[https://m3o.com/user/api#ResetPassword](https://m3o.com/user/api#ResetPassword) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Reset password with the code sent by the "SendPasswordResetEmail" endoint. +func ResetPassword() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.ResetPassword(&user.ResetPasswordRequest{ + Code: "012345", +ConfirmPassword: "NewPassword1", +Email: "joe@example.com", +NewPassword: "NewPassword1", + + }) + fmt.Println(rsp, err) + +} +``` +## Delete + +Delete an account by id + + +[https://m3o.com/user/api#Delete](https://m3o.com/user/api#Delete) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Delete an account by id +func DeleteUserAccount() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.Delete(&user.DeleteRequest{ + Id: "8b98acbe-0b6a-4d66-a414-5ffbf666786f", + + }) + fmt.Println(rsp, err) + +} +``` +## Logout + +Logout a user account + + +[https://m3o.com/user/api#Logout](https://m3o.com/user/api#Logout) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Logout a user account +func LogAuserOut() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.Logout(&user.LogoutRequest{ + SessionId: "df91a612-5b24-4634-99ff-240220ab8f55", + + }) + fmt.Println(rsp, err) + +} +``` +## SendPasswordResetEmail + +Send an email with a verification code to reset password. +Call "ResetPassword" endpoint once user provides the code. + + +[https://m3o.com/user/api#SendPasswordResetEmail](https://m3o.com/user/api#SendPasswordResetEmail) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Send an email with a verification code to reset password. +// Call "ResetPassword" endpoint once user provides the code. +func SendPasswordResetEmail() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.SendPasswordResetEmail(&user.SendPasswordResetEmailRequest{ + Email: "joe@example.com", +FromName: "Awesome Dot Com", +Subject: "Password reset", +TextContent: `Hi there, + click here to reset your password: myapp.com/reset/code?=$code`, + + }) + fmt.Println(rsp, err) + } ``` ## Read @@ -299,82 +514,6 @@ func ReadAccountByEmail() { }) 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) - -} -``` -## 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) - } ``` ## VerifyEmail @@ -406,142 +545,3 @@ Token: "012345", } ``` -## 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) - -} -``` -## 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")) - - stream, 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`, - - }) - if err != nil { - fmt.Println(err) - return - } - - for { - rsp, err := stream.Recv() - if err != nil { - fmt.Println(err) - return - } - - fmt.Println(rsp) - } -} -``` -## 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) - -} -``` diff --git a/examples/youtube/README.md b/examples/youtube/README.md index 6dbb4f4..908ecd5 100755 --- a/examples/youtube/README.md +++ b/examples/youtube/README.md @@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Youtube/api](h Endpoints: -## Search - -Search for videos on YouTube - - -[https://m3o.com/youtube/api#Search](https://m3o.com/youtube/api#Search) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/youtube" -) - -// Search for videos on YouTube -func SearchForVideos() { - youtubeService := youtube.NewYoutubeService(os.Getenv("M3O_API_TOKEN")) - rsp, err := youtubeService.Search(&youtube.SearchRequest{ - Query: "donuts", - - }) - fmt.Println(rsp, err) - -} -``` ## Embed Embed a YouTube video @@ -60,3 +32,31 @@ func EmbedAyoutubeVideo() { } ``` +## Search + +Search for videos on YouTube + + +[https://m3o.com/youtube/api#Search](https://m3o.com/youtube/api#Search) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/youtube" +) + +// Search for videos on YouTube +func SearchForVideos() { + youtubeService := youtube.NewYoutubeService(os.Getenv("M3O_API_TOKEN")) + rsp, err := youtubeService.Search(&youtube.SearchRequest{ + Query: "donuts", + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/space/space.go b/space/space.go index 865542c..6c4e935 100755 --- a/space/space.go +++ b/space/space.go @@ -16,7 +16,7 @@ type SpaceService struct { client *client.Client } -// Create an object. Returns error if object with this name already exists. If you want to update an existing object use the `Update` endpoint +// 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 // 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 (t *SpaceService) Create(request *CreateRequest) (*CreateResponse, error) { @@ -76,7 +76,7 @@ func (t *SpaceService) Update(request *UpdateRequest) (*UpdateResponse, error) { } -// Upload a large object. Returns a time limited presigned URL to be used for uploading the object +// Upload a large object (> 10MB). Returns a time limited presigned URL to be used for uploading the object func (t *SpaceService) Upload(request *UploadRequest) (*UploadResponse, error) { rsp := &UploadResponse{}