diff --git a/examples/app/README.md b/examples/app/README.md index 67740e7..47d0f0f 100755 --- a/examples/app/README.md +++ b/examples/app/README.md @@ -4,6 +4,61 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/app/api](https Endpoints: +## 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 source @@ -175,58 +230,3 @@ func DeleteAnApp() { } ``` -## 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 be90aff..359c982 100755 --- a/examples/cache/README.md +++ b/examples/cache/README.md @@ -4,91 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/cache/api](htt Endpoints: -## Increment - -Increment a value (if it's a number). If key not found it is equivalent to set. - - -[https://m3o.com/cache/api#Increment](https://m3o.com/cache/api#Increment) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/cache" -) - -// Increment a value (if it's a number). If key not found it is equivalent to set. -func IncrementAvalue() { - cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN")) - rsp, err := cacheService.Increment(&cache.IncrementRequest{ - Key: "counter", -Value: 2, - - }) - fmt.Println(rsp, err) - -} -``` -## Decrement - -Decrement a value (if it's a number). If key not found it is equivalent to set. - - -[https://m3o.com/cache/api#Decrement](https://m3o.com/cache/api#Decrement) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/cache" -) - -// Decrement a value (if it's a number). If key not found it is equivalent to set. -func DecrementAvalue() { - cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN")) - rsp, err := cacheService.Decrement(&cache.DecrementRequest{ - Key: "counter", -Value: 2, - - }) - fmt.Println(rsp, err) - -} -``` -## ListKeys - -List all the available keys - - -[https://m3o.com/cache/api#ListKeys](https://m3o.com/cache/api#ListKeys) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/cache" -) - -// List all the available keys -func ListTheKeys() { - cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN")) - rsp, err := cacheService.ListKeys(&cache.ListKeysRequest{ - - }) - fmt.Println(rsp, err) - -} -``` ## Set Set an item in the cache. Overwrites any existing value already set. @@ -174,3 +89,88 @@ func DeleteAvalue() { } ``` +## Increment + +Increment a value (if it's a number). If key not found it is equivalent to set. + + +[https://m3o.com/cache/api#Increment](https://m3o.com/cache/api#Increment) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/cache" +) + +// Increment a value (if it's a number). If key not found it is equivalent to set. +func IncrementAvalue() { + cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN")) + rsp, err := cacheService.Increment(&cache.IncrementRequest{ + Key: "counter", +Value: 2, + + }) + fmt.Println(rsp, err) + +} +``` +## Decrement + +Decrement a value (if it's a number). If key not found it is equivalent to set. + + +[https://m3o.com/cache/api#Decrement](https://m3o.com/cache/api#Decrement) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/cache" +) + +// Decrement a value (if it's a number). If key not found it is equivalent to set. +func DecrementAvalue() { + cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN")) + rsp, err := cacheService.Decrement(&cache.DecrementRequest{ + Key: "counter", +Value: 2, + + }) + fmt.Println(rsp, err) + +} +``` +## ListKeys + +List all the available keys + + +[https://m3o.com/cache/api#ListKeys](https://m3o.com/cache/api#ListKeys) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/cache" +) + +// List all the available keys +func ListTheKeys() { + cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN")) + rsp, err := cacheService.ListKeys(&cache.ListKeysRequest{ + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/contact/README.md b/examples/contact/README.md index 07c19b2..e52974c 100755 --- a/examples/contact/README.md +++ b/examples/contact/README.md @@ -4,6 +4,62 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/contact/api](h Endpoints: +## Read + + + + +[https://m3o.com/contact/api#Read](https://m3o.com/contact/api#Read) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/contact" +) + +// +func GetAcontact() { + contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN")) + rsp, err := contactService.Read(&contact.ReadRequest{ + Id: "42e48a3c-6221-11ec-96d2-acde48001122", + + }) + fmt.Println(rsp, err) + +} +``` +## Delete + + + + +[https://m3o.com/contact/api#Delete](https://m3o.com/contact/api#Delete) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/contact" +) + +// +func DeleteAcontact() { + contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN")) + rsp, err := contactService.Delete(&contact.DeleteRequest{ + Id: "42e48a3c-6221-11ec-96d2-acde48001122", + + }) + fmt.Println(rsp, err) + +} +``` ## List @@ -161,59 +217,3 @@ contact.Phone{ } ``` -## Read - - - - -[https://m3o.com/contact/api#Read](https://m3o.com/contact/api#Read) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/contact" -) - -// -func GetAcontact() { - contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN")) - rsp, err := contactService.Read(&contact.ReadRequest{ - Id: "42e48a3c-6221-11ec-96d2-acde48001122", - - }) - fmt.Println(rsp, err) - -} -``` -## Delete - - - - -[https://m3o.com/contact/api#Delete](https://m3o.com/contact/api#Delete) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/contact" -) - -// -func DeleteAcontact() { - contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN")) - rsp, err := contactService.Delete(&contact.DeleteRequest{ - Id: "42e48a3c-6221-11ec-96d2-acde48001122", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/crypto/README.md b/examples/crypto/README.md index 6434fc3..4f0aca0 100755 --- a/examples/crypto/README.md +++ b/examples/crypto/README.md @@ -4,62 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/crypto/api](ht Endpoints: -## Quote - -Get the last quote for a given crypto ticker - - -[https://m3o.com/crypto/api#Quote](https://m3o.com/crypto/api#Quote) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/crypto" -) - -// Get the last quote for a given crypto ticker -func GetAcryptocurrencyQuote() { - cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN")) - rsp, err := cryptoService.Quote(&crypto.QuoteRequest{ - Symbol: "BTCUSD", - - }) - fmt.Println(rsp, err) - -} -``` -## History - -Returns the history for the previous close - - -[https://m3o.com/crypto/api#History](https://m3o.com/crypto/api#History) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/crypto" -) - -// Returns the history for the previous close -func GetPreviousClose() { - cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN")) - rsp, err := cryptoService.History(&crypto.HistoryRequest{ - Symbol: "BTCUSD", - - }) - fmt.Println(rsp, err) - -} -``` ## News Get news related to a currency @@ -116,3 +60,59 @@ func GetCryptocurrencyPrice() { } ``` +## Quote + +Get the last quote for a given crypto ticker + + +[https://m3o.com/crypto/api#Quote](https://m3o.com/crypto/api#Quote) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/crypto" +) + +// Get the last quote for a given crypto ticker +func GetAcryptocurrencyQuote() { + cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN")) + rsp, err := cryptoService.Quote(&crypto.QuoteRequest{ + Symbol: "BTCUSD", + + }) + fmt.Println(rsp, err) + +} +``` +## History + +Returns the history for the previous close + + +[https://m3o.com/crypto/api#History](https://m3o.com/crypto/api#History) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/crypto" +) + +// Returns the history for the previous close +func GetPreviousClose() { + cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN")) + rsp, err := cryptoService.History(&crypto.HistoryRequest{ + Symbol: "BTCUSD", + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/db/README.md b/examples/db/README.md index 4256f44..5ed2bb1 100755 --- a/examples/db/README.md +++ b/examples/db/README.md @@ -4,6 +4,129 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/db/api](https: Endpoints: +## Create + +Create a record in the database. Optionally include an "id" field otherwise it's set automatically. + + +[https://m3o.com/db/api#Create](https://m3o.com/db/api#Create) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/db" +) + +// Create a record in the database. Optionally include an "id" field otherwise it's set automatically. +func CreateArecord() { + dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) + rsp, err := dbService.Create(&db.CreateRequest{ + Record: map[string]interface{}{ + "isActive": true, + "id": "1", + "name": "Jane", + "age": 42, +}, +Table: "example", + + }) + fmt.Println(rsp, err) + +} +``` +## Update + +Update a record in the database. Include an "id" in the record to update. + + +[https://m3o.com/db/api#Update](https://m3o.com/db/api#Update) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/db" +) + +// Update a record in the database. Include an "id" in the record to update. +func UpdateArecord() { + dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) + rsp, err := dbService.Update(&db.UpdateRequest{ + Record: map[string]interface{}{ + "id": "1", + "age": 43, +}, +Table: "example", + + }) + fmt.Println(rsp, err) + +} +``` +## Truncate + +Truncate the records in a table + + +[https://m3o.com/db/api#Truncate](https://m3o.com/db/api#Truncate) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/db" +) + +// Truncate the records in a table +func TruncateTable() { + dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) + rsp, err := dbService.Truncate(&db.TruncateRequest{ + Table: "example", + + }) + fmt.Println(rsp, err) + +} +``` +## 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 Delete a record in the database by id. @@ -33,12 +156,12 @@ Table: "example", } ``` -## Truncate +## DropTable -Truncate the records in a table +Drop a table in the DB -[https://m3o.com/db/api#Truncate](https://m3o.com/db/api#Truncate) +[https://m3o.com/db/api#DropTable](https://m3o.com/db/api#DropTable) ```go package example @@ -50,10 +173,10 @@ import( "go.m3o.com/db" ) -// Truncate the records in a table -func TruncateTable() { +// Drop a table in the DB +func DropTable() { dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) - rsp, err := dbService.Truncate(&db.TruncateRequest{ + rsp, err := dbService.DropTable(&db.DropTableRequest{ Table: "example", }) @@ -114,129 +237,6 @@ func ListTables() { }) fmt.Println(rsp, err) -} -``` -## Create - -Create a record in the database. Optionally include an "id" field otherwise it's set automatically. - - -[https://m3o.com/db/api#Create](https://m3o.com/db/api#Create) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/db" -) - -// Create a record in the database. Optionally include an "id" field otherwise it's set automatically. -func CreateArecord() { - dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) - rsp, err := dbService.Create(&db.CreateRequest{ - Record: map[string]interface{}{ - "id": "1", - "name": "Jane", - "age": 42, - "isActive": true, -}, -Table: "example", - - }) - fmt.Println(rsp, err) - -} -``` -## Update - -Update a record in the database. Include an "id" in the record to update. - - -[https://m3o.com/db/api#Update](https://m3o.com/db/api#Update) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/db" -) - -// Update a record in the database. Include an "id" in the record to update. -func UpdateArecord() { - dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) - rsp, err := dbService.Update(&db.UpdateRequest{ - Record: map[string]interface{}{ - "id": "1", - "age": 43, -}, -Table: "example", - - }) - fmt.Println(rsp, err) - -} -``` -## Read - -Read data from a table. Lookup can be by ID or via querying any field in the record. - - -[https://m3o.com/db/api#Read](https://m3o.com/db/api#Read) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/db" -) - -// Read data from a table. Lookup can be by ID or via querying any field in the record. -func ReadRecords() { - dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) - rsp, err := dbService.Read(&db.ReadRequest{ - Query: "age == 43", -Table: "example", - - }) - fmt.Println(rsp, err) - -} -``` -## DropTable - -Drop a table in the DB - - -[https://m3o.com/db/api#DropTable](https://m3o.com/db/api#DropTable) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/db" -) - -// Drop a table in the DB -func DropTable() { - dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) - rsp, err := dbService.DropTable(&db.DropTableRequest{ - Table: "example", - - }) - fmt.Println(rsp, err) - } ``` ## RenameTable diff --git a/examples/evchargers/README.md b/examples/evchargers/README.md index 7e1c9b6..176565e 100755 --- a/examples/evchargers/README.md +++ b/examples/evchargers/README.md @@ -4,6 +4,33 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/evchargers/api Endpoints: +## ReferenceData + +Retrieve reference data as used by this API and in conjunction with the Search endpoint + + +[https://m3o.com/evchargers/api#ReferenceData](https://m3o.com/evchargers/api#ReferenceData) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/evchargers" +) + +// Retrieve reference data as used by this API and in conjunction with the Search endpoint +func GetReferenceData() { + evchargersService := evchargers.NewEvchargersService(os.Getenv("M3O_API_TOKEN")) + rsp, err := evchargersService.ReferenceData(&evchargers.ReferenceDataRequest{ + + }) + fmt.Println(rsp, err) + +} +``` ## Search Search by giving a coordinate and a max distance, or bounding box and optional filters @@ -98,30 +125,3 @@ Location: &evchargers.Coordinates{ } ``` -## ReferenceData - -Retrieve reference data as used by this API and in conjunction with the Search endpoint - - -[https://m3o.com/evchargers/api#ReferenceData](https://m3o.com/evchargers/api#ReferenceData) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/evchargers" -) - -// Retrieve reference data as used by this API and in conjunction with the Search endpoint -func GetReferenceData() { - evchargersService := evchargers.NewEvchargersService(os.Getenv("M3O_API_TOKEN")) - rsp, err := evchargersService.ReferenceData(&evchargers.ReferenceDataRequest{ - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/event/README.md b/examples/event/README.md index c8f6f43..a478169 100755 --- a/examples/event/README.md +++ b/examples/event/README.md @@ -26,9 +26,9 @@ func PublishAnEvent() { 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/forex/README.md b/examples/forex/README.md index 358f510..a91003f 100755 --- a/examples/forex/README.md +++ b/examples/forex/README.md @@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/forex/api](htt Endpoints: -## History - -Returns the data for the previous close - - -[https://m3o.com/forex/api#History](https://m3o.com/forex/api#History) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/forex" -) - -// Returns the data for the previous close -func GetPreviousClose() { - forexService := forex.NewForexService(os.Getenv("M3O_API_TOKEN")) - rsp, err := forexService.History(&forex.HistoryRequest{ - Symbol: "GBPUSD", - - }) - fmt.Println(rsp, err) - -} -``` ## Price Get the latest price for a given forex ticker @@ -88,3 +60,31 @@ func GetAfxQuote() { } ``` +## History + +Returns the data for the previous close + + +[https://m3o.com/forex/api#History](https://m3o.com/forex/api#History) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/forex" +) + +// Returns the data for the previous close +func GetPreviousClose() { + forexService := forex.NewForexService(os.Getenv("M3O_API_TOKEN")) + rsp, err := forexService.History(&forex.HistoryRequest{ + Symbol: "GBPUSD", + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/function/README.md b/examples/function/README.md index e288163..b31f293 100755 --- a/examples/function/README.md +++ b/examples/function/README.md @@ -38,12 +38,12 @@ Subfolder: "examples/go-function", } ``` -## Delete +## Describe -Delete a function by name +Get the info for a deployed function -[https://m3o.com/function/api#Delete](https://m3o.com/function/api#Delete) +[https://m3o.com/function/api#Describe](https://m3o.com/function/api#Describe) ```go package example @@ -55,42 +55,15 @@ import( "go.m3o.com/function" ) -// Delete a function by name -func DeleteAfunction() { +// Get the info for a deployed function +func DescribeFunctionStatus() { functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) - rsp, err := functionService.Delete(&function.DeleteRequest{ + rsp, err := functionService.Describe(&function.DescribeRequest{ Name: "helloworld", }) fmt.Println(rsp, err) -} -``` -## Regions - -Return a list of supported regions - - -[https://m3o.com/function/api#Regions](https://m3o.com/function/api#Regions) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/function" -) - -// Return a list of supported regions -func ListRegions() { - functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) - rsp, err := functionService.Regions(&function.RegionsRequest{ - - }) - fmt.Println(rsp, err) - } ``` ## Reserve @@ -119,6 +92,34 @@ func ReserveAfunction() { }) 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 @@ -207,12 +208,12 @@ func ListFunctions() { } ``` -## Describe +## Delete -Get the info for a deployed function +Delete a function by name -[https://m3o.com/function/api#Describe](https://m3o.com/function/api#Describe) +[https://m3o.com/function/api#Delete](https://m3o.com/function/api#Delete) ```go package example @@ -224,10 +225,10 @@ import( "go.m3o.com/function" ) -// Get the info for a deployed function -func DescribeFunctionStatus() { +// Delete a function by name +func DeleteAfunction() { functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) - rsp, err := functionService.Describe(&function.DescribeRequest{ + rsp, err := functionService.Delete(&function.DeleteRequest{ Name: "helloworld", }) @@ -235,12 +236,12 @@ func DescribeFunctionStatus() { } ``` -## Proxy +## Regions -Return the backend url for proxying +Return a list of supported regions -[https://m3o.com/function/api#Proxy](https://m3o.com/function/api#Proxy) +[https://m3o.com/function/api#Regions](https://m3o.com/function/api#Regions) ```go package example @@ -252,12 +253,11 @@ import( "go.m3o.com/function" ) -// Return the backend url for proxying -func ProxyUrl() { +// Return a list of supported regions +func ListRegions() { functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) - rsp, err := functionService.Proxy(&function.ProxyRequest{ - Id: "helloworld", - + rsp, err := functionService.Regions(&function.RegionsRequest{ + }) fmt.Println(rsp, err) diff --git a/examples/geocoding/README.md b/examples/geocoding/README.md index ffc18bb..b29fb43 100755 --- a/examples/geocoding/README.md +++ b/examples/geocoding/README.md @@ -4,6 +4,35 @@ 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 @@ -35,32 +64,3 @@ 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/location/README.md b/examples/location/README.md index 78700e1..a7e58ad 100755 --- a/examples/location/README.md +++ b/examples/location/README.md @@ -4,42 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/location/api]( Endpoints: -## Save - -Save an entity's current position - - -[https://m3o.com/location/api#Save](https://m3o.com/location/api#Save) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/location" -) - -// Save an entity's current position -func SaveAnEntity() { - locationService := location.NewLocationService(os.Getenv("M3O_API_TOKEN")) - rsp, err := locationService.Save(&location.SaveRequest{ - Entity: &location.Entity{ - Id: "1", - Location: &location.Point{ - Latitude: 51.511061, - Longitude: -0.120022, - Timestamp: 1622802761, -}, - Type: "bike", -}, - - }) - fmt.Println(rsp, err) - -} -``` ## Read Read an entity by its ID @@ -102,3 +66,39 @@ Type: "bike", } ``` +## Save + +Save an entity's current position + + +[https://m3o.com/location/api#Save](https://m3o.com/location/api#Save) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/location" +) + +// Save an entity's current position +func SaveAnEntity() { + locationService := location.NewLocationService(os.Getenv("M3O_API_TOKEN")) + rsp, err := locationService.Save(&location.SaveRequest{ + Entity: &location.Entity{ + Id: "1", + Location: &location.Point{ + Latitude: 51.511061, + Longitude: -0.120022, + Timestamp: 1622802761, +}, + Type: "bike", +}, + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/mq/README.md b/examples/mq/README.md index 16eaf27..1582975 100755 --- a/examples/mq/README.md +++ b/examples/mq/README.md @@ -4,6 +4,39 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/mq/api](https: Endpoints: +## Publish + +Publish a message. Specify a topic to group messages for a specific topic. + + +[https://m3o.com/mq/api#Publish](https://m3o.com/mq/api#Publish) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/mq" +) + +// Publish a message. Specify a topic to group messages for a specific topic. +func PublishAmessage() { + mqService := mq.NewMqService(os.Getenv("M3O_API_TOKEN")) + rsp, err := mqService.Publish(&mq.PublishRequest{ + Message: map[string]interface{}{ + "id": "1", + "type": "signup", + "user": "john", +}, +Topic: "events", + + }) + fmt.Println(rsp, err) + +} +``` ## Subscribe Subscribe to messages for a given topic. @@ -45,36 +78,3 @@ func SubscribeToAtopic() { } } ``` -## Publish - -Publish a message. Specify a topic to group messages for a specific topic. - - -[https://m3o.com/mq/api#Publish](https://m3o.com/mq/api#Publish) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/mq" -) - -// Publish a message. Specify a topic to group messages for a specific topic. -func PublishAmessage() { - mqService := mq.NewMqService(os.Getenv("M3O_API_TOKEN")) - rsp, err := mqService.Publish(&mq.PublishRequest{ - Message: map[string]interface{}{ - "type": "signup", - "user": "john", - "id": "1", -}, -Topic: "events", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/nft/README.md b/examples/nft/README.md index 9ae06b4..d3bafa7 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 6997879..9e98ae9 100755 --- a/examples/notes/README.md +++ b/examples/notes/README.md @@ -4,47 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/notes/api](htt Endpoints: -## Events - -Subscribe to notes events - - -[https://m3o.com/notes/api#Events](https://m3o.com/notes/api#Events) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/notes" -) - -// Subscribe to notes events -func SubscribeToEvents() { - notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN")) - - stream, err := notesService.Events(¬es.EventsRequest{ - Id: "63c0cdf8-2121-11ec-a881-0242e36f037a", - - }) - if err != nil { - fmt.Println(err) - return - } - - for { - rsp, err := stream.Recv() - if err != nil { - fmt.Println(err) - return - } - - fmt.Println(rsp) - } -} -``` ## Create Create a new note @@ -189,3 +148,44 @@ func DeleteAnote() { } ``` +## Events + +Subscribe to notes events + + +[https://m3o.com/notes/api#Events](https://m3o.com/notes/api#Events) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/notes" +) + +// Subscribe to notes events +func SubscribeToEvents() { + notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN")) + + stream, err := notesService.Events(¬es.EventsRequest{ + Id: "63c0cdf8-2121-11ec-a881-0242e36f037a", + + }) + if err != nil { + fmt.Println(err) + return + } + + for { + rsp, err := stream.Recv() + if err != nil { + fmt.Println(err) + return + } + + fmt.Println(rsp) + } +} +``` diff --git a/examples/quran/README.md b/examples/quran/README.md index 7381cb5..e007ded 100755 --- a/examples/quran/README.md +++ b/examples/quran/README.md @@ -4,6 +4,34 @@ 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 @@ -92,31 +120,3 @@ 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) - -} -``` diff --git a/examples/rss/README.md b/examples/rss/README.md index 81d4c6b..5cda3e4 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/README.md b/examples/search/README.md index 6290fbc..be3999d 100755 --- a/examples/search/README.md +++ b/examples/search/README.md @@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/search/api](ht Endpoints: +## DeleteIndex + +Delete an index by name + + +[https://m3o.com/search/api#DeleteIndex](https://m3o.com/search/api#DeleteIndex) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/search" +) + +// Delete an index by name +func DeleteAnIndex() { + searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN")) + rsp, err := searchService.DeleteIndex(&search.DeleteIndexRequest{ + Index: "customers", + + }) + fmt.Println(rsp, err) + +} +``` ## Index Index a document i.e. insert a document to search for. @@ -184,31 +212,3 @@ func CreateAnIndex() { } ``` -## DeleteIndex - -Delete an index by name - - -[https://m3o.com/search/api#DeleteIndex](https://m3o.com/search/api#DeleteIndex) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/search" -) - -// Delete an index by name -func DeleteAnIndex() { - searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN")) - rsp, err := searchService.DeleteIndex(&search.DeleteIndexRequest{ - Index: "customers", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/search/index/indexADocument/main.go b/examples/search/index/indexADocument/main.go index 81df17a..d35c325 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{}{ + "starsign": "Leo", "name": "John Doe", "age": 37, - "starsign": "Leo", }, Id: "1234", }, diff --git a/examples/stock/README.md b/examples/stock/README.md index 0d497b8..83cd80a 100755 --- a/examples/stock/README.md +++ b/examples/stock/README.md @@ -4,62 +4,6 @@ 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 - - -[https://m3o.com/stock/api#Quote](https://m3o.com/stock/api#Quote) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/stock" -) - -// Get the last quote for the stock -func GetAstockQuote() { - stockService := stock.NewStockService(os.Getenv("M3O_API_TOKEN")) - rsp, err := stockService.Quote(&stock.QuoteRequest{ - Symbol: "AAPL", - - }) - fmt.Println(rsp, err) - -} -``` ## History Get the historic open-close for a given day @@ -121,3 +65,59 @@ 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) + +} +``` +## Quote + +Get the last quote for the stock + + +[https://m3o.com/stock/api#Quote](https://m3o.com/stock/api#Quote) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/stock" +) + +// Get the last quote for the stock +func GetAstockQuote() { + stockService := stock.NewStockService(os.Getenv("M3O_API_TOKEN")) + rsp, err := stockService.Quote(&stock.QuoteRequest{ + Symbol: "AAPL", + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/sunnah/README.md b/examples/sunnah/README.md index 68ccae1..d2d603b 100755 --- a/examples/sunnah/README.md +++ b/examples/sunnah/README.md @@ -4,6 +4,35 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/sunnah/api](ht Endpoints: +## Collections + +Get a list of available collections. A collection is +a compilation of hadiths collected and written by an author. + + +[https://m3o.com/sunnah/api#Collections](https://m3o.com/sunnah/api#Collections) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/sunnah" +) + +// Get a list of available collections. A collection is +// a compilation of hadiths collected and written by an author. +func ListAvailableCollections() { + sunnahService := sunnah.NewSunnahService(os.Getenv("M3O_API_TOKEN")) + rsp, err := sunnahService.Collections(&sunnah.CollectionsRequest{ + + }) + fmt.Println(rsp, err) + +} +``` ## Books Get a list of books from within a collection. A book can contain many chapters @@ -94,32 +123,3 @@ Collection: "bukhari", } ``` -## Collections - -Get a list of available collections. A collection is -a compilation of hadiths collected and written by an author. - - -[https://m3o.com/sunnah/api#Collections](https://m3o.com/sunnah/api#Collections) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/sunnah" -) - -// Get a list of available collections. A collection is -// a compilation of hadiths collected and written by an author. -func ListAvailableCollections() { - sunnahService := sunnah.NewSunnahService(os.Getenv("M3O_API_TOKEN")) - rsp, err := sunnahService.Collections(&sunnah.CollectionsRequest{ - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/twitter/README.md b/examples/twitter/README.md index b65c6ac..19128ad 100755 --- a/examples/twitter/README.md +++ b/examples/twitter/README.md @@ -4,35 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/twitter/api](h Endpoints: -## Timeline - -Get the timeline for a given user - - -[https://m3o.com/twitter/api#Timeline](https://m3o.com/twitter/api#Timeline) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/twitter" -) - -// Get the timeline for a given user -func GetAtwitterTimeline() { - twitterService := twitter.NewTwitterService(os.Getenv("M3O_API_TOKEN")) - rsp, err := twitterService.Timeline(&twitter.TimelineRequest{ - Limit: 1, -Username: "m3oservices", - - }) - fmt.Println(rsp, err) - -} -``` ## Search Search for tweets with a simple query @@ -116,3 +87,32 @@ func GetAusersTwitterProfile() { } ``` +## Timeline + +Get the timeline for a given user + + +[https://m3o.com/twitter/api#Timeline](https://m3o.com/twitter/api#Timeline) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/twitter" +) + +// Get the timeline for a given user +func GetAtwitterTimeline() { + twitterService := twitter.NewTwitterService(os.Getenv("M3O_API_TOKEN")) + rsp, err := twitterService.Timeline(&twitter.TimelineRequest{ + Limit: 1, +Username: "m3oservices", + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/url/README.md b/examples/url/README.md index 24bd71a..ec670c0 100755 --- a/examples/url/README.md +++ b/examples/url/README.md @@ -4,6 +4,33 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/url/api](https Endpoints: +## List + +List all the shortened URLs + + +[https://m3o.com/url/api#List](https://m3o.com/url/api#List) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/url" +) + +// List all the shortened URLs +func ListYourShortenedUrls() { + urlService := url.NewUrlService(os.Getenv("M3O_API_TOKEN")) + rsp, err := urlService.List(&url.ListRequest{ + + }) + fmt.Println(rsp, err) + +} +``` ## Shorten Shorten a long URL @@ -58,30 +85,3 @@ func ResolveAshortUrlToAlongDestinationUrl() { } ``` -## List - -List all the shortened URLs - - -[https://m3o.com/url/api#List](https://m3o.com/url/api#List) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/url" -) - -// List all the shortened URLs -func ListYourShortenedUrls() { - urlService := url.NewUrlService(os.Getenv("M3O_API_TOKEN")) - rsp, err := urlService.List(&url.ListRequest{ - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/user/README.md b/examples/user/README.md index 72bc0b8..3e4dc4e 100755 --- a/examples/user/README.md +++ b/examples/user/README.md @@ -4,116 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/user/api](http Endpoints: -## List - -List all users. Returns a paged list of results - - -[https://m3o.com/user/api#List](https://m3o.com/user/api#List) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/user" -) - -// List all users. Returns a paged list of results -func ListAllUsers() { - userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.List(&user.ListRequest{ - Limit: 100, -Offset: 0, - - }) - fmt.Println(rsp, err) - -} -``` -## VerifyToken - -Check whether the token attached to MagicLink is valid or not. -Ideally, you need to call this endpoint from your http request -handler that handles the endpoint which is specified in the -SendMagicLink request. - - -[https://m3o.com/user/api#VerifyToken](https://m3o.com/user/api#VerifyToken) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/user" -) - -// Check whether the token attached to MagicLink is valid or not. -// Ideally, you need to call this endpoint from your http request -// handler that handles the endpoint which is specified in the -// SendMagicLink request. -func VerifyAtoken() { - userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.VerifyToken(&user.VerifyTokenRequest{ - Token: "EdsUiidouJJJLldjlloofUiorkojflsWWdld", - - }) - fmt.Println(rsp, err) - -} -``` -## SendVerificationEmail - -Send a verification email to a user. -Email "from" will be 'noreply@email.m3ocontent.com'. -The verification link will be injected in the email -as a template variable, $micro_verification_link e.g -'Welcome to M3O! Use the link below to verify your email: $micro_verification_link' -The variable will be replaced with a url similar to: -'https://user.m3o.com/user/verify?token=a-verification-token&redirectUrl=your-redir-url' - - -[https://m3o.com/user/api#SendVerificationEmail](https://m3o.com/user/api#SendVerificationEmail) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/user" -) - -// Send a verification email to a user. -// Email "from" will be 'noreply@email.m3ocontent.com'. -// The verification link will be injected in the email -// as a template variable, $micro_verification_link e.g -// 'Welcome to M3O! Use the link below to verify your email: $micro_verification_link' -// The variable will be replaced with a url similar to: -// 'https://user.m3o.com/user/verify?token=a-verification-token&redirectUrl=your-redir-url' -func SendVerificationEmail() { - userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.SendVerificationEmail(&user.SendVerificationEmailRequest{ - Email: "joe@example.com", -FailureRedirectUrl: "https://m3o.com/verification-failed", -FromName: "Awesome Dot Com", -RedirectUrl: "https://m3o.com", -Subject: "Email verification", -TextContent: `Hi there, - -Please verify your email by clicking this link: $micro_verification_link`, - - }) - fmt.Println(rsp, err) - -} -``` ## UpdatePassword Update the account password @@ -174,34 +64,6 @@ NewPassword: "NewPassword1", }) 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) - } ``` ## ReadSession @@ -230,41 +92,6 @@ func ReadAsessionByTheSessionId() { }) 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 @@ -296,6 +123,40 @@ Username: "joe", }) 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 @@ -382,13 +243,18 @@ func ReadAccountByEmail() { } ``` -## 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 a user. +Email "from" will be 'noreply@email.m3ocontent.com'. +The verification link will be injected in the email +as a template variable, $micro_verification_link e.g +'Welcome to M3O! Use the link below to verify your email: $micro_verification_link' +The variable will be replaced with a url similar to: +'https://user.m3o.com/user/verify?token=a-verification-token&redirectUrl=your-redir-url' -[https://m3o.com/user/api#SendPasswordResetEmail](https://m3o.com/user/api#SendPasswordResetEmail) +[https://m3o.com/user/api#SendVerificationEmail](https://m3o.com/user/api#SendVerificationEmail) ```go package example @@ -400,16 +266,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 a user. +// Email "from" will be 'noreply@email.m3ocontent.com'. +// The verification link will be injected in the email +// as a template variable, $micro_verification_link e.g +// 'Welcome to M3O! Use the link below to verify your email: $micro_verification_link' +// The variable will be replaced with a url similar to: +// 'https://user.m3o.com/user/verify?token=a-verification-token&redirectUrl=your-redir-url' +func SendVerificationEmail() { userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.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`, + +Please verify your email by clicking this link: $micro_verification_link`, }) fmt.Println(rsp, err) @@ -473,6 +347,41 @@ Password: "Password1", }) fmt.Println(rsp, err) +} +``` +## SendMagicLink + +Login using email only - Passwordless + + +[https://m3o.com/user/api#SendMagicLink](https://m3o.com/user/api#SendMagicLink) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Login using email only - Passwordless +func SendAmagicLink() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.SendMagicLink(&user.SendMagicLinkRequest{ + Address: "www.example.com", +Email: "joe@example.com", +Endpoint: "verifytoken", +FromName: "Awesome Dot Com", +Subject: "MagicLink to access your account", +TextContent: `Hi there, + +Click here to access your account $micro_verification_link`, + + }) + fmt.Println(rsp, err) + } ``` ## Update @@ -532,3 +441,94 @@ func DeleteUserAccount() { } ``` +## 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) + +} +``` +## 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/weather/README.md b/examples/weather/README.md index 43c5660..4fa715b 100755 --- a/examples/weather/README.md +++ b/examples/weather/README.md @@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/weather/api](h Endpoints: +## Now + +Get the current weather report for a location by postcode, city, zip code, ip address + + +[https://m3o.com/weather/api#Now](https://m3o.com/weather/api#Now) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/weather" +) + +// Get the current weather report for a location by postcode, city, zip code, ip address +func GetCurrentWeather() { + weatherService := weather.NewWeatherService(os.Getenv("M3O_API_TOKEN")) + rsp, err := weatherService.Now(&weather.NowRequest{ + Location: "london", + + }) + fmt.Println(rsp, err) + +} +``` ## Forecast Get the weather forecast for the next 1-10 days @@ -33,31 +61,3 @@ Location: "London", } ``` -## Now - -Get the current weather report for a location by postcode, city, zip code, ip address - - -[https://m3o.com/weather/api#Now](https://m3o.com/weather/api#Now) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/weather" -) - -// Get the current weather report for a location by postcode, city, zip code, ip address -func GetCurrentWeather() { - weatherService := weather.NewWeatherService(os.Getenv("M3O_API_TOKEN")) - rsp, err := weatherService.Now(&weather.NowRequest{ - Location: "london", - - }) - fmt.Println(rsp, err) - -} -```