From e9229571ad1e0669e806647b108c200a77432449 Mon Sep 17 00:00:00 2001 From: m3o-actions <> Date: Tue, 15 Feb 2022 17:32:16 +0000 Subject: [PATCH] Commit from m3o/m3o action --- examples/app/README.md | 172 ++++---- examples/contact/README.md | 112 ++--- examples/crypto/README.md | 56 +-- examples/currency/README.md | 58 +-- examples/db/README.md | 154 +++---- examples/db/create/createARecord/main.go | 4 +- examples/emoji/README.md | 110 ++--- examples/evchargers/README.md | 54 +-- examples/function/README.md | 240 +++++----- examples/image/README.md | 140 +++--- examples/location/README.md | 72 +-- examples/mq/README.md | 2 +- examples/mq/publish/publishAMessage/main.go | 2 +- examples/notes/README.md | 54 +-- examples/ping/README.md | 56 +-- examples/place/README.md | 27 -- examples/quran/README.md | 56 +-- examples/routing/README.md | 70 +-- examples/rss/README.md | 60 +-- examples/search/README.md | 114 ++--- examples/space/README.md | 56 +-- examples/stock/README.md | 64 +-- examples/stream/README.md | 62 +-- examples/sunnah/README.md | 58 +-- examples/url/README.md | 54 +-- examples/user/README.md | 460 ++++++++++---------- examples/youtube/README.md | 56 +-- place/place.go | 9 - 28 files changed, 1198 insertions(+), 1234 deletions(-) diff --git a/examples/app/README.md b/examples/app/README.md index 3c53fd6..99d6b0c 100755 --- a/examples/app/README.md +++ b/examples/app/README.md @@ -4,6 +4,92 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/app/api](https Endpoints: +## 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 + + +[https://m3o.com/app/api#Run](https://m3o.com/app/api#Run) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/app" +) + +// Run an app from source +func RunAnApp() { + appService := app.NewAppService(os.Getenv("M3O_API_TOKEN")) + rsp, err := appService.Run(&app.RunRequest{ + Branch: "master", +Name: "helloworld", +Port: 8080, +Region: "europe-west1", +Repo: "github.com/asim/helloworld", + + }) + fmt.Println(rsp, err) + +} +``` +## Regions + +Return the support regions + + +[https://m3o.com/app/api#Regions](https://m3o.com/app/api#Regions) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/app" +) + +// Return the support regions +func ListRegions() { + appService := app.NewAppService(os.Getenv("M3O_API_TOKEN")) + rsp, err := appService.Regions(&app.RegionsRequest{ + + }) + fmt.Println(rsp, err) + +} +``` ## Status Get the status of an app @@ -144,89 +230,3 @@ func ReserveAppName() { } ``` -## 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 - - -[https://m3o.com/app/api#Run](https://m3o.com/app/api#Run) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/app" -) - -// Run an app from source -func RunAnApp() { - appService := app.NewAppService(os.Getenv("M3O_API_TOKEN")) - rsp, err := appService.Run(&app.RunRequest{ - Branch: "master", -Name: "helloworld", -Port: 8080, -Region: "europe-west1", -Repo: "github.com/asim/helloworld", - - }) - fmt.Println(rsp, err) - -} -``` -## Regions - -Return the support regions - - -[https://m3o.com/app/api#Regions](https://m3o.com/app/api#Regions) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/app" -) - -// Return the support regions -func ListRegions() { - appService := app.NewAppService(os.Getenv("M3O_API_TOKEN")) - rsp, err := appService.Regions(&app.RegionsRequest{ - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/contact/README.md b/examples/contact/README.md index 07c19b2..9a0ba7e 100755 --- a/examples/contact/README.md +++ b/examples/contact/README.md @@ -4,62 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/contact/api](h Endpoints: -## List - - - - -[https://m3o.com/contact/api#List](https://m3o.com/contact/api#List) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/contact" -) - -// -func ListContactsWithDefaultOffsetAndLimitDefaultLimitIs20() { - contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN")) - rsp, err := contactService.List(&contact.ListRequest{ - - }) - fmt.Println(rsp, err) - -} -``` -## List - - - - -[https://m3o.com/contact/api#List](https://m3o.com/contact/api#List) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/contact" -) - -// -func ListContactsWithSpecificOffsetAndLimit() { - contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN")) - rsp, err := contactService.List(&contact.ListRequest{ - Limit: 1, -Offset: 1, - - }) - fmt.Println(rsp, err) - -} -``` ## Create @@ -217,3 +161,59 @@ func DeleteAcontact() { } ``` +## List + + + + +[https://m3o.com/contact/api#List](https://m3o.com/contact/api#List) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/contact" +) + +// +func ListContactsWithDefaultOffsetAndLimitDefaultLimitIs20() { + contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN")) + rsp, err := contactService.List(&contact.ListRequest{ + + }) + fmt.Println(rsp, err) + +} +``` +## List + + + + +[https://m3o.com/contact/api#List](https://m3o.com/contact/api#List) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/contact" +) + +// +func ListContactsWithSpecificOffsetAndLimit() { + contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN")) + rsp, err := contactService.List(&contact.ListRequest{ + Limit: 1, +Offset: 1, + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/crypto/README.md b/examples/crypto/README.md index f80084c..4f0aca0 100755 --- a/examples/crypto/README.md +++ b/examples/crypto/README.md @@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/crypto/api](ht Endpoints: +## News + +Get news related to a currency + + +[https://m3o.com/crypto/api#News](https://m3o.com/crypto/api#News) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/crypto" +) + +// Get news related to a currency +func GetCryptocurrencyNews() { + cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN")) + rsp, err := cryptoService.News(&crypto.NewsRequest{ + Symbol: "BTCUSD", + + }) + fmt.Println(rsp, err) + +} +``` ## Price Get the last price for a given crypto ticker @@ -88,31 +116,3 @@ func GetPreviousClose() { } ``` -## News - -Get news related to a currency - - -[https://m3o.com/crypto/api#News](https://m3o.com/crypto/api#News) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/crypto" -) - -// Get news related to a currency -func GetCryptocurrencyNews() { - cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN")) - rsp, err := cryptoService.News(&crypto.NewsRequest{ - Symbol: "BTCUSD", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/currency/README.md b/examples/currency/README.md index e112f11..333170f 100755 --- a/examples/currency/README.md +++ b/examples/currency/README.md @@ -4,35 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/currency/api]( Endpoints: -## History - -Returns the historic rates for a currency on a given date - - -[https://m3o.com/currency/api#History](https://m3o.com/currency/api#History) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/currency" -) - -// Returns the historic rates for a currency on a given date -func HistoricRatesForAcurrency() { - currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN")) - rsp, err := currencyService.History(¤cy.HistoryRequest{ - Code: "USD", -Date: "2021-05-30", - - }) - fmt.Println(rsp, err) - -} -``` ## Codes Codes returns the supported currency codes for the API @@ -147,3 +118,32 @@ To: "GBP", } ``` +## History + +Returns the historic rates for a currency on a given date + + +[https://m3o.com/currency/api#History](https://m3o.com/currency/api#History) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/currency" +) + +// Returns the historic rates for a currency on a given date +func HistoricRatesForAcurrency() { + currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN")) + rsp, err := currencyService.History(¤cy.HistoryRequest{ + Code: "USD", +Date: "2021-05-30", + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/db/README.md b/examples/db/README.md index baf53ea..e08efcc 100755 --- a/examples/db/README.md +++ b/examples/db/README.md @@ -4,6 +4,40 @@ 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{}{ + "name": "Jane", + "age": 42, + "isActive": true, + "id": "1", +}, +Table: "example", + + }) + fmt.Println(rsp, err) + +} +``` ## Delete Delete a record in the database by id. @@ -33,12 +67,12 @@ Table: "example", } ``` -## Count +## Truncate -Count records in a table +Truncate the records in a table -[https://m3o.com/db/api#Count](https://m3o.com/db/api#Count) +[https://m3o.com/db/api#Truncate](https://m3o.com/db/api#Truncate) ```go package example @@ -50,10 +84,10 @@ import( "go.m3o.com/db" ) -// Count records in a table -func CountEntriesInAtable() { +// Truncate the records in a table +func TruncateTable() { dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) - rsp, err := dbService.Count(&db.CountRequest{ + rsp, err := dbService.Truncate(&db.TruncateRequest{ Table: "example", }) @@ -61,12 +95,12 @@ func CountEntriesInAtable() { } ``` -## Create +## RenameTable -Create a record in the database. Optionally include an "id" field otherwise it's set automatically. +Rename a table -[https://m3o.com/db/api#Create](https://m3o.com/db/api#Create) +[https://m3o.com/db/api#RenameTable](https://m3o.com/db/api#RenameTable) ```go package example @@ -78,17 +112,12 @@ import( "go.m3o.com/db" ) -// Create a record in the database. Optionally include an "id" field otherwise it's set automatically. -func CreateArecord() { +// Rename a table +func RenameTable() { 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", + rsp, err := dbService.RenameTable(&db.RenameTableRequest{ + From: "examples2", +To: "examples3", }) fmt.Println(rsp, err) @@ -117,8 +146,8 @@ func UpdateArecord() { dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) rsp, err := dbService.Update(&db.UpdateRequest{ Record: map[string]interface{}{ - "id": "1", "age": 43, + "id": "1", }, Table: "example", @@ -154,34 +183,6 @@ Table: "example", }) fmt.Println(rsp, err) -} -``` -## Truncate - -Truncate the records in a table - - -[https://m3o.com/db/api#Truncate](https://m3o.com/db/api#Truncate) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/db" -) - -// Truncate the records in a table -func TruncateTable() { - dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) - rsp, err := dbService.Truncate(&db.TruncateRequest{ - Table: "example", - - }) - fmt.Println(rsp, err) - } ``` ## DropTable @@ -210,6 +211,34 @@ func DropTable() { }) fmt.Println(rsp, err) +} +``` +## Count + +Count records in a table + + +[https://m3o.com/db/api#Count](https://m3o.com/db/api#Count) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/db" +) + +// Count records in a table +func CountEntriesInAtable() { + dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) + rsp, err := dbService.Count(&db.CountRequest{ + Table: "example", + + }) + fmt.Println(rsp, err) + } ``` ## ListTables @@ -239,32 +268,3 @@ func ListTables() { } ``` -## 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 f094c0c..f258334 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{}{ - "age": 42, - "isActive": true, "id": "1", "name": "Jane", + "age": 42, + "isActive": true, }, Table: "example", }) diff --git a/examples/emoji/README.md b/examples/emoji/README.md index 75291ff..ea3a4ee 100755 --- a/examples/emoji/README.md +++ b/examples/emoji/README.md @@ -4,6 +4,61 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/emoji/api](htt Endpoints: +## Find + +Find an emoji by its alias e.g :beer: + + +[https://m3o.com/emoji/api#Find](https://m3o.com/emoji/api#Find) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/emoji" +) + +// Find an emoji by its alias e.g :beer: +func FindEmoji() { + emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN")) + rsp, err := emojiService.Find(&emoji.FindRequest{ + Alias: ":beer:", + + }) + fmt.Println(rsp, err) + +} +``` +## Flag + +Get the flag for a country. Requires country code e.g GB for great britain + + +[https://m3o.com/emoji/api#Flag](https://m3o.com/emoji/api#Flag) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/emoji" +) + +// Get the flag for a country. Requires country code e.g GB for great britain +func GetFlagByCountryCode() { + emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN")) + rsp, err := emojiService.Flag(&emoji.FlagRequest{ + + }) + fmt.Println(rsp, err) + +} +``` ## Print Print text and renders the emojis with aliases e.g @@ -64,58 +119,3 @@ To: "+44782669123", } ``` -## Find - -Find an emoji by its alias e.g :beer: - - -[https://m3o.com/emoji/api#Find](https://m3o.com/emoji/api#Find) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/emoji" -) - -// Find an emoji by its alias e.g :beer: -func FindEmoji() { - emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN")) - rsp, err := emojiService.Find(&emoji.FindRequest{ - Alias: ":beer:", - - }) - fmt.Println(rsp, err) - -} -``` -## Flag - -Get the flag for a country. Requires country code e.g GB for great britain - - -[https://m3o.com/emoji/api#Flag](https://m3o.com/emoji/api#Flag) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/emoji" -) - -// Get the flag for a country. Requires country code e.g GB for great britain -func GetFlagByCountryCode() { - emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN")) - rsp, err := emojiService.Flag(&emoji.FlagRequest{ - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/evchargers/README.md b/examples/evchargers/README.md index 176565e..7e1c9b6 100755 --- a/examples/evchargers/README.md +++ b/examples/evchargers/README.md @@ -4,33 +4,6 @@ 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 @@ -125,3 +98,30 @@ 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/function/README.md b/examples/function/README.md index cb3d580..7be1ec6 100755 --- a/examples/function/README.md +++ b/examples/function/README.md @@ -4,12 +4,12 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/function/api]( Endpoints: -## Describe +## Call -Get the info for a deployed function +Call a function by name -[https://m3o.com/function/api#Describe](https://m3o.com/function/api#Describe) +[https://m3o.com/function/api#Call](https://m3o.com/function/api#Call) ```go package example @@ -21,11 +21,70 @@ import( "go.m3o.com/function" ) -// Get the info for a deployed function -func DescribeFunctionStatus() { +// Call a function by name +func CallAfunction() { functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) - rsp, err := functionService.Describe(&function.DescribeRequest{ + rsp, err := functionService.Call(&function.CallRequest{ Name: "helloworld", +Request: map[string]interface{}{ + "name": "Alice", +}, + + }) + fmt.Println(rsp, err) + +} +``` +## Reserve + +Reserve function names and resources beyond free quota + + +[https://m3o.com/function/api#Reserve](https://m3o.com/function/api#Reserve) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/function" +) + +// Reserve function names and resources beyond free quota +func ReserveAfunction() { + functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) + rsp, err := functionService.Reserve(&function.ReserveRequest{ + Name: "helloworld", + + }) + 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) @@ -92,6 +151,61 @@ func UpdateAfunction() { }) 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) + +} +``` +## 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) + } ``` ## List @@ -149,117 +263,3 @@ func DeleteAfunction() { } ``` -## Call - -Call a function by name - - -[https://m3o.com/function/api#Call](https://m3o.com/function/api#Call) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/function" -) - -// Call a function by name -func CallAfunction() { - functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) - rsp, err := functionService.Call(&function.CallRequest{ - Name: "helloworld", -Request: map[string]interface{}{ - "name": "Alice", -}, - - }) - fmt.Println(rsp, err) - -} -``` -## 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 - -Reserve function names and resources beyond free quota - - -[https://m3o.com/function/api#Reserve](https://m3o.com/function/api#Reserve) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/function" -) - -// Reserve function names and resources beyond free quota -func ReserveAfunction() { - functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) - rsp, err := functionService.Reserve(&function.ReserveRequest{ - Name: "helloworld", - - }) - fmt.Println(rsp, err) - -} -``` -## Proxy - -Return the backend url for proxying - - -[https://m3o.com/function/api#Proxy](https://m3o.com/function/api#Proxy) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/function" -) - -// Return the backend url for proxying -func ProxyUrl() { - functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) - rsp, err := functionService.Proxy(&function.ProxyRequest{ - Id: "helloworld", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/image/README.md b/examples/image/README.md index f0985e4..a05edab 100755 --- a/examples/image/README.md +++ b/examples/image/README.md @@ -4,76 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/image/api](htt Endpoints: -## Upload - -Upload an image by either sending a base64 encoded image to this endpoint or a URL. -To resize an image before uploading, see the Resize endpoint. -To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json -with each parameter as a form field. - - -[https://m3o.com/image/api#Upload](https://m3o.com/image/api#Upload) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/image" -) - -// Upload an image by either sending a base64 encoded image to this endpoint or a URL. -// To resize an image before uploading, see the Resize endpoint. -// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json -// with each parameter as a form field. -func UploadAbase64imageToMicrosCdn() { - imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN")) - rsp, err := imageService.Upload(&image.UploadRequest{ - Base64: "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAx0lEQVR4nOzaMaoDMQyE4ZHj+x82vVdhwQoTkzKQEcwP5r0ihT7sbjUTeAJ4HCegXQJYfOYefOyjDuBiz3yjwJBoCIl6QZOeUjTC1Ix1IxEJXF9+0KWsf2bD4bn37OO/c/wuQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9Sa/NG94Tf3j4WBdaxudMEkn4IM2rZBA0wBrvo7aOcpj2emXvLeVt0IGm0GVXUj91mvAAAA//+V2CZl+4AKXwAAAABJRU5ErkJggg==", -Name: "cat.jpeg", - - }) - fmt.Println(rsp, err) - -} -``` -## Upload - -Upload an image by either sending a base64 encoded image to this endpoint or a URL. -To resize an image before uploading, see the Resize endpoint. -To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json -with each parameter as a form field. - - -[https://m3o.com/image/api#Upload](https://m3o.com/image/api#Upload) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/image" -) - -// Upload an image by either sending a base64 encoded image to this endpoint or a URL. -// To resize an image before uploading, see the Resize endpoint. -// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json -// with each parameter as a form field. -func UploadAnImageFromAurlToMicrosCdn() { - imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN")) - rsp, err := imageService.Upload(&image.UploadRequest{ - Name: "cat.jpeg", -Url: "somewebsite.com/cat.png", - - }) - fmt.Println(rsp, err) - -} -``` ## Delete Delete an image previously uploaded. @@ -256,3 +186,73 @@ Url: "somewebsite.com/cat.png", } ``` +## Upload + +Upload an image by either sending a base64 encoded image to this endpoint or a URL. +To resize an image before uploading, see the Resize endpoint. +To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json +with each parameter as a form field. + + +[https://m3o.com/image/api#Upload](https://m3o.com/image/api#Upload) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/image" +) + +// Upload an image by either sending a base64 encoded image to this endpoint or a URL. +// To resize an image before uploading, see the Resize endpoint. +// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json +// with each parameter as a form field. +func UploadAbase64imageToMicrosCdn() { + imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN")) + rsp, err := imageService.Upload(&image.UploadRequest{ + Base64: "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAx0lEQVR4nOzaMaoDMQyE4ZHj+x82vVdhwQoTkzKQEcwP5r0ihT7sbjUTeAJ4HCegXQJYfOYefOyjDuBiz3yjwJBoCIl6QZOeUjTC1Ix1IxEJXF9+0KWsf2bD4bn37OO/c/wuQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9Sa/NG94Tf3j4WBdaxudMEkn4IM2rZBA0wBrvo7aOcpj2emXvLeVt0IGm0GVXUj91mvAAAA//+V2CZl+4AKXwAAAABJRU5ErkJggg==", +Name: "cat.jpeg", + + }) + fmt.Println(rsp, err) + +} +``` +## Upload + +Upload an image by either sending a base64 encoded image to this endpoint or a URL. +To resize an image before uploading, see the Resize endpoint. +To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json +with each parameter as a form field. + + +[https://m3o.com/image/api#Upload](https://m3o.com/image/api#Upload) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/image" +) + +// Upload an image by either sending a base64 encoded image to this endpoint or a URL. +// To resize an image before uploading, see the Resize endpoint. +// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json +// with each parameter as a form field. +func UploadAnImageFromAurlToMicrosCdn() { + imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN")) + rsp, err := imageService.Upload(&image.UploadRequest{ + Name: "cat.jpeg", +Url: "somewebsite.com/cat.png", + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/location/README.md b/examples/location/README.md index a7e58ad..78700e1 100755 --- a/examples/location/README.md +++ b/examples/location/README.md @@ -4,6 +4,42 @@ 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 @@ -66,39 +102,3 @@ 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 1582975..1fc9922 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 ad993e2..e6a7451 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{}{ - "id": "1", "type": "signup", "user": "john", + "id": "1", }, Topic: "events", }) diff --git a/examples/notes/README.md b/examples/notes/README.md index 3bc665d..6d6064b 100755 --- a/examples/notes/README.md +++ b/examples/notes/README.md @@ -4,6 +4,33 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/notes/api](htt Endpoints: +## List + +List all the notes + + +[https://m3o.com/notes/api#List](https://m3o.com/notes/api#List) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/notes" +) + +// List all the notes +func ListAllNotes() { + notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN")) + rsp, err := notesService.List(¬es.ListRequest{ + + }) + fmt.Println(rsp, err) + +} +``` ## Update Update a note @@ -162,30 +189,3 @@ func ReadAnote() { } ``` -## List - -List all the notes - - -[https://m3o.com/notes/api#List](https://m3o.com/notes/api#List) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/notes" -) - -// List all the notes -func ListAllNotes() { - notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN")) - rsp, err := notesService.List(¬es.ListRequest{ - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/ping/README.md b/examples/ping/README.md index c07dd30..54dea8b 100755 --- a/examples/ping/README.md +++ b/examples/ping/README.md @@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/ping/api](http Endpoints: -## Url - -Ping a HTTP URL - - -[https://m3o.com/ping/api#Url](https://m3o.com/ping/api#Url) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/ping" -) - -// Ping a HTTP URL -func CheckAurl() { - pingService := ping.NewPingService(os.Getenv("M3O_API_TOKEN")) - rsp, err := pingService.Url(&ping.UrlRequest{ - Address: "google.com", - - }) - fmt.Println(rsp, err) - -} -``` ## Ip Ping an IP address @@ -88,3 +60,31 @@ func DialAtcpAddress() { } ``` +## Url + +Ping a HTTP URL + + +[https://m3o.com/ping/api#Url](https://m3o.com/ping/api#Url) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/ping" +) + +// Ping a HTTP URL +func CheckAurl() { + pingService := ping.NewPingService(os.Getenv("M3O_API_TOKEN")) + rsp, err := pingService.Url(&ping.UrlRequest{ + Address: "google.com", + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/place/README.md b/examples/place/README.md index 2c7199c..4a83a0a 100755 --- a/examples/place/README.md +++ b/examples/place/README.md @@ -4,33 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/place/api](htt Endpoints: -## Autocomplete - -Autocomplete queries (coming soon) - - -[https://m3o.com/place/api#Autocomplete](https://m3o.com/place/api#Autocomplete) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/place" -) - -// Autocomplete queries (coming soon) -func AutocompleteQueries() { - placeService := place.NewPlaceService(os.Getenv("M3O_API_TOKEN")) - rsp, err := placeService.Autocomplete(&place.AutocompleteRequest{ - - }) - fmt.Println(rsp, err) - -} -``` ## Nearby Find places nearby using a location diff --git a/examples/quran/README.md b/examples/quran/README.md index 5ce6584..7381cb5 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: +## 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) @@ -92,31 +120,3 @@ func SearchTheQuran() { } ``` -## 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/routing/README.md b/examples/routing/README.md index f133a39..513ed01 100755 --- a/examples/routing/README.md +++ b/examples/routing/README.md @@ -4,6 +4,41 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/routing/api](h Endpoints: +## Route + +Retrieve a route as a simple list of gps points along with total distance and estimated duration + + +[https://m3o.com/routing/api#Route](https://m3o.com/routing/api#Route) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/routing" +) + +// Retrieve a route as a simple list of gps points along with total distance and estimated duration +func GpsPointsForAroute() { + routingService := routing.NewRoutingService(os.Getenv("M3O_API_TOKEN")) + rsp, err := routingService.Route(&routing.RouteRequest{ + Destination: &routing.Point{ + Latitude: 52.529407, + Longitude: 13.397634, +}, +Origin: &routing.Point{ + Latitude: 52.517037, + Longitude: 13.38886, +}, + + }) + fmt.Println(rsp, err) + +} +``` ## Eta Get the eta for a route from origin to destination. The eta is an estimated time based on car routes @@ -74,38 +109,3 @@ Origin: &routing.Point{ } ``` -## Route - -Retrieve a route as a simple list of gps points along with total distance and estimated duration - - -[https://m3o.com/routing/api#Route](https://m3o.com/routing/api#Route) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/routing" -) - -// Retrieve a route as a simple list of gps points along with total distance and estimated duration -func GpsPointsForAroute() { - routingService := routing.NewRoutingService(os.Getenv("M3O_API_TOKEN")) - rsp, err := routingService.Route(&routing.RouteRequest{ - Destination: &routing.Point{ - Latitude: 52.529407, - Longitude: 13.397634, -}, -Origin: &routing.Point{ - Latitude: 52.517037, - Longitude: 13.38886, -}, - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/rss/README.md b/examples/rss/README.md index 5cda3e4..528df60 100755 --- a/examples/rss/README.md +++ b/examples/rss/README.md @@ -4,36 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/rss/api](https Endpoints: -## Add - -Add a new RSS feed with a name, url, and category - - -[https://m3o.com/rss/api#Add](https://m3o.com/rss/api#Add) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/rss" -) - -// Add a new RSS feed with a name, url, and category -func AddAnewFeed() { - rssService := rss.NewRssService(os.Getenv("M3O_API_TOKEN")) - rsp, err := rssService.Add(&rss.AddRequest{ - Category: "news", -Name: "bbc", -Url: "http://feeds.bbci.co.uk/news/rss.xml", - - }) - fmt.Println(rsp, err) - -} -``` ## Feed Get an RSS feed by name. If no name is given, all feeds are returned. Default limit is 25 entries. @@ -117,3 +87,33 @@ func RemoveAfeed() { } ``` +## Add + +Add a new RSS feed with a name, url, and category + + +[https://m3o.com/rss/api#Add](https://m3o.com/rss/api#Add) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/rss" +) + +// Add a new RSS feed with a name, url, and category +func AddAnewFeed() { + rssService := rss.NewRssService(os.Getenv("M3O_API_TOKEN")) + rsp, err := rssService.Add(&rss.AddRequest{ + Category: "news", +Name: "bbc", +Url: "http://feeds.bbci.co.uk/news/rss.xml", + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/search/README.md b/examples/search/README.md index 6290fbc..d16563c 100755 --- a/examples/search/README.md +++ b/examples/search/README.md @@ -4,6 +4,62 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/search/api](ht Endpoints: +## CreateIndex + +Create an index by name + + +[https://m3o.com/search/api#CreateIndex](https://m3o.com/search/api#CreateIndex) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/search" +) + +// Create an index by name +func CreateAnIndex() { + searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN")) + rsp, err := searchService.CreateIndex(&search.CreateIndexRequest{ + Index: "customers", + + }) + fmt.Println(rsp, err) + +} +``` +## 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. @@ -27,9 +83,9 @@ func IndexAdocument() { rsp, err := searchService.Index(&search.IndexRequest{ Document: &search.Document{ Contents: map[string]interface{}{ - "name": "John Doe", "age": 37, "starsign": "Leo", + "name": "John Doe", }, Id: "1234", }, @@ -156,59 +212,3 @@ Index: "customers", } ``` -## CreateIndex - -Create an index by name - - -[https://m3o.com/search/api#CreateIndex](https://m3o.com/search/api#CreateIndex) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/search" -) - -// Create an index by name -func CreateAnIndex() { - searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN")) - rsp, err := searchService.CreateIndex(&search.CreateIndexRequest{ - Index: "customers", - - }) - fmt.Println(rsp, err) - -} -``` -## 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/space/README.md b/examples/space/README.md index 5aecb93..e0dac00 100755 --- a/examples/space/README.md +++ b/examples/space/README.md @@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/space/api](htt Endpoints: +## Read + +Read an object in space + + +[https://m3o.com/space/api#Read](https://m3o.com/space/api#Read) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/space" +) + +// Read an object in space +func ReadAnObject() { + spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN")) + rsp, err := spaceService.Read(&space.ReadRequest{ + Name: "images/file.jpg", + + }) + fmt.Println(rsp, err) + +} +``` ## Download Download an object via a presigned url @@ -204,31 +232,3 @@ func HeadAnObject() { } ``` -## Read - -Read an object in space - - -[https://m3o.com/space/api#Read](https://m3o.com/space/api#Read) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/space" -) - -// Read an object in space -func ReadAnObject() { - spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN")) - rsp, err := spaceService.Read(&space.ReadRequest{ - Name: "images/file.jpg", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/stock/README.md b/examples/stock/README.md index 0d497b8..2018b54 100755 --- a/examples/stock/README.md +++ b/examples/stock/README.md @@ -4,6 +4,38 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/stock/api](htt Endpoints: +## OrderBook + +Get the historic order book and each trade by timestamp + + +[https://m3o.com/stock/api#OrderBook](https://m3o.com/stock/api#OrderBook) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/stock" +) + +// Get the historic order book and each trade by timestamp +func OrderBookHistory() { + stockService := stock.NewStockService(os.Getenv("M3O_API_TOKEN")) + rsp, err := stockService.OrderBook(&stock.OrderBookRequest{ + Date: "2020-10-01", +End: "2020-10-01T11:00:00Z", +Limit: 3, +Start: "2020-10-01T10:00:00Z", +Stock: "AAPL", + + }) + fmt.Println(rsp, err) + +} +``` ## Price Get the last price for a given stock ticker @@ -89,35 +121,3 @@ Stock: "AAPL", } ``` -## OrderBook - -Get the historic order book and each trade by timestamp - - -[https://m3o.com/stock/api#OrderBook](https://m3o.com/stock/api#OrderBook) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/stock" -) - -// Get the historic order book and each trade by timestamp -func OrderBookHistory() { - stockService := stock.NewStockService(os.Getenv("M3O_API_TOKEN")) - rsp, err := stockService.OrderBook(&stock.OrderBookRequest{ - Date: "2020-10-01", -End: "2020-10-01T11:00:00Z", -Limit: 3, -Start: "2020-10-01T10:00:00Z", -Stock: "AAPL", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/stream/README.md b/examples/stream/README.md index 232026e..11fa9f3 100755 --- a/examples/stream/README.md +++ b/examples/stream/README.md @@ -4,37 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/stream/api](ht Endpoints: -## CreateChannel - -Create a channel with a given name and description. Channels are created automatically but -this allows you to specify a description that's persisted for the lifetime of the channel. - - -[https://m3o.com/stream/api#CreateChannel](https://m3o.com/stream/api#CreateChannel) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/stream" -) - -// Create a channel with a given name and description. Channels are created automatically but -// this allows you to specify a description that's persisted for the lifetime of the channel. -func CreateChannel() { - streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN")) - rsp, err := streamService.CreateChannel(&stream.CreateChannelRequest{ - Description: "The channel for all things", -Name: "general", - - }) - fmt.Println(rsp, err) - -} -``` ## SendMessage Send a message to the stream. @@ -119,3 +88,34 @@ func ListChannels() { } ``` +## CreateChannel + +Create a channel with a given name and description. Channels are created automatically but +this allows you to specify a description that's persisted for the lifetime of the channel. + + +[https://m3o.com/stream/api#CreateChannel](https://m3o.com/stream/api#CreateChannel) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/stream" +) + +// Create a channel with a given name and description. Channels are created automatically but +// this allows you to specify a description that's persisted for the lifetime of the channel. +func CreateChannel() { + streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN")) + rsp, err := streamService.CreateChannel(&stream.CreateChannelRequest{ + Description: "The channel for all things", +Name: "general", + + }) + 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/url/README.md b/examples/url/README.md index ec670c0..551bd38 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: +## Proxy + +Proxy returns the destination URL of a short URL. + + +[https://m3o.com/url/api#Proxy](https://m3o.com/url/api#Proxy) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/url" +) + +// Proxy returns the destination URL of a short URL. +func ResolveAshortUrlToAlongDestinationUrl() { + urlService := url.NewUrlService(os.Getenv("M3O_API_TOKEN")) + rsp, err := urlService.Proxy(&url.ProxyRequest{ + + }) + fmt.Println(rsp, err) + +} +``` ## List List all the shortened URLs @@ -58,30 +85,3 @@ func ShortenAlongUrl() { } ``` -## Proxy - -Proxy returns the destination URL of a short URL. - - -[https://m3o.com/url/api#Proxy](https://m3o.com/url/api#Proxy) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/url" -) - -// Proxy returns the destination URL of a short URL. -func ResolveAshortUrlToAlongDestinationUrl() { - urlService := url.NewUrlService(os.Getenv("M3O_API_TOKEN")) - rsp, err := urlService.Proxy(&url.ProxyRequest{ - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/user/README.md b/examples/user/README.md index 576e80d..0a71b01 100755 --- a/examples/user/README.md +++ b/examples/user/README.md @@ -4,6 +4,65 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/user/api](http Endpoints: +## 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) + +} +``` ## VerifyToken Check whether the token attached to MagicLink is valid or not. @@ -38,12 +97,12 @@ func VerifyAtoken() { } ``` -## ReadSession +## Update -Read a session by the session id. In the event it has expired or is not found and error is returned. +Update the account username or email -[https://m3o.com/user/api#ReadSession](https://m3o.com/user/api#ReadSession) +[https://m3o.com/user/api#Update](https://m3o.com/user/api#Update) ```go package example @@ -55,99 +114,12 @@ import( "go.m3o.com/user" ) -// Read a session by the session id. In the event it has expired or is not found and error is returned. -func ReadAsessionByTheSessionId() { +// Update the account username or email +func UpdateAnAccount() { userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.ReadSession(&user.ReadSessionRequest{ - SessionId: "df91a612-5b24-4634-99ff-240220ab8f55", - - }) - 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) - -} -``` -## VerifyEmail - -Verify the email address of an account from a token sent in an email to the user. - - -[https://m3o.com/user/api#VerifyEmail](https://m3o.com/user/api#VerifyEmail) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/user" -) - -// Verify the email address of an account from a token sent in an email to the user. -func VerifyEmail() { - userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.VerifyEmail(&user.VerifyEmailRequest{ - Token: "012345", - - }) - 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, + rsp, err := userService.Update(&user.UpdateRequest{ + Email: "joe+2@example.com", +Id: "user-1", }) fmt.Println(rsp, err) @@ -189,12 +161,13 @@ Click here to access your account $micro_verification_link`, } ``` -## Create +## Login -Create a new user account. The email address and username for the account must be unique. +Login using username or email. The response will return a new session for successful login, +401 in the case of login failure and 500 for any other error -[https://m3o.com/user/api#Create](https://m3o.com/user/api#Create) +[https://m3o.com/user/api#Login](https://m3o.com/user/api#Login) ```go package example @@ -206,14 +179,41 @@ import( "go.m3o.com/user" ) -// Create a new user account. The email address and username for the account must be unique. -func CreateAnAccount() { +// Login using username or email. The response will return a new session for successful login, +// 401 in the case of login failure and 500 for any other error +func LogAuserIn() { userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.Create(&user.CreateRequest{ + rsp, err := userService.Login(&user.LoginRequest{ Email: "joe@example.com", -Id: "user-1", Password: "Password1", -Username: "joe", + + }) + 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) @@ -304,13 +304,13 @@ func ReadAccountByEmail() { } ``` -## Login +## SendPasswordResetEmail -Login using username or email. The response will return a new session for successful login, -401 in the case of login failure and 500 for any other error +Send an email with a verification code to reset password. +Call "ResetPassword" endpoint once user provides the code. -[https://m3o.com/user/api#Login](https://m3o.com/user/api#Login) +[https://m3o.com/user/api#SendPasswordResetEmail](https://m3o.com/user/api#SendPasswordResetEmail) ```go package example @@ -322,13 +322,132 @@ import( "go.m3o.com/user" ) -// Login using username or email. The response will return a new session for successful login, -// 401 in the case of login failure and 500 for any other error -func LogAuserIn() { +// 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.Login(&user.LoginRequest{ + 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) + +} +``` +## VerifyEmail + +Verify the email address of an account from a token sent in an email to the user. + + +[https://m3o.com/user/api#VerifyEmail](https://m3o.com/user/api#VerifyEmail) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Verify the email address of an account from a token sent in an email to the user. +func VerifyEmail() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.VerifyEmail(&user.VerifyEmailRequest{ + Token: "012345", + + }) + fmt.Println(rsp, err) + +} +``` +## ReadSession + +Read a session by the session id. In the event it has expired or is not found and error is returned. + + +[https://m3o.com/user/api#ReadSession](https://m3o.com/user/api#ReadSession) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Read a session by the session id. In the event it has expired or is not found and error is returned. +func ReadAsessionByTheSessionId() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.ReadSession(&user.ReadSessionRequest{ + SessionId: "df91a612-5b24-4634-99ff-240220ab8f55", + + }) + fmt.Println(rsp, err) + +} +``` +## List + +List all users. Returns a paged list of results + + +[https://m3o.com/user/api#List](https://m3o.com/user/api#List) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/user" +) + +// List all users. Returns a paged list of results +func ListAllUsers() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.List(&user.ListRequest{ + Limit: 100, +Offset: 0, + + }) + fmt.Println(rsp, err) + +} +``` +## Create + +Create a new user account. The email address and username for the account must be unique. + + +[https://m3o.com/user/api#Create](https://m3o.com/user/api#Create) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Create a new user account. The email address and username for the account must be unique. +func CreateAnAccount() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.Create(&user.CreateRequest{ + Email: "joe@example.com", +Id: "user-1", Password: "Password1", +Username: "joe", }) fmt.Println(rsp, err) @@ -413,122 +532,3 @@ Please verify your email by clicking this link: $micro_verification_link`, } ``` -## SendPasswordResetEmail - -Send an email with a verification code to reset password. -Call "ResetPassword" endpoint once user provides the code. - - -[https://m3o.com/user/api#SendPasswordResetEmail](https://m3o.com/user/api#SendPasswordResetEmail) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/user" -) - -// Send an email with a verification code to reset password. -// Call "ResetPassword" endpoint once user provides the code. -func SendPasswordResetEmail() { - userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.SendPasswordResetEmail(&user.SendPasswordResetEmailRequest{ - Email: "joe@example.com", -FromName: "Awesome Dot Com", -Subject: "Password reset", -TextContent: `Hi there, - click here to reset your password: myapp.com/reset/code?=$code`, - - }) - fmt.Println(rsp, err) - -} -``` -## Delete - -Delete an account by id - - -[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) - -} -``` -## 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) - -} -``` diff --git a/examples/youtube/README.md b/examples/youtube/README.md index fc27a59..a866acf 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/place/place.go b/place/place.go index deff5fc..f3c6819 100755 --- a/place/place.go +++ b/place/place.go @@ -5,7 +5,6 @@ import ( ) type Place interface { - Autocomplete(*AutocompleteRequest) (*AutocompleteResponse, error) Nearby(*NearbyRequest) (*NearbyResponse, error) Search(*SearchRequest) (*SearchResponse, error) } @@ -22,14 +21,6 @@ type PlaceService struct { client *client.Client } -// Autocomplete queries (coming soon) -func (t *PlaceService) Autocomplete(request *AutocompleteRequest) (*AutocompleteResponse, error) { - - rsp := &AutocompleteResponse{} - return rsp, t.client.Call("place", "Autocomplete", request, rsp) - -} - // Find places nearby using a location func (t *PlaceService) Nearby(request *NearbyRequest) (*NearbyResponse, error) {