diff --git a/examples/address/README.md b/examples/address/README.md index 7b38a9a..866a674 100755 --- a/examples/address/README.md +++ b/examples/address/README.md @@ -29,5 +29,6 @@ func LookupPostcode() { }) fmt.Println(rsp, err) + } ``` diff --git a/examples/answer/README.md b/examples/answer/README.md index ef2dc2a..9fcaa7b 100755 --- a/examples/answer/README.md +++ b/examples/answer/README.md @@ -29,5 +29,6 @@ func AskAquestion() { }) fmt.Println(rsp, err) + } ``` diff --git a/examples/cache/README.md b/examples/cache/README.md index a506148..4cdb349 100755 --- a/examples/cache/README.md +++ b/examples/cache/README.md @@ -4,88 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Cache/api](htt Endpoints: -## Get - -Get an item from the cache by key. If key is not found, an empty response is returned. - - -[https://m3o.com/cache/api#Get](https://m3o.com/cache/api#Get) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/cache" -) - -// Get an item from the cache by key. If key is not found, an empty response is returned. -func GetAvalue() { - cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN")) - rsp, err := cacheService.Get(&cache.GetRequest{ - Key: "foo", - - }) - fmt.Println(rsp, err) -} -``` -## Delete - -Delete a value from the cache. If key not found a success response is returned. - - -[https://m3o.com/cache/api#Delete](https://m3o.com/cache/api#Delete) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/cache" -) - -// Delete a value from the cache. If key not found a success response is returned. -func DeleteAvalue() { - cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN")) - rsp, err := cacheService.Delete(&cache.DeleteRequest{ - Key: "foo", - - }) - fmt.Println(rsp, err) -} -``` -## 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. @@ -112,6 +30,7 @@ Value: 2, }) fmt.Println(rsp, err) + } ``` ## Set @@ -140,5 +59,91 @@ Value: "bar", }) fmt.Println(rsp, err) + +} +``` +## Get + +Get an item from the cache by key. If key is not found, an empty response is returned. + + +[https://m3o.com/cache/api#Get](https://m3o.com/cache/api#Get) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/cache" +) + +// Get an item from the cache by key. If key is not found, an empty response is returned. +func GetAvalue() { + cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN")) + rsp, err := cacheService.Get(&cache.GetRequest{ + Key: "foo", + + }) + fmt.Println(rsp, err) + +} +``` +## Delete + +Delete a value from the cache. If key not found a success response is returned. + + +[https://m3o.com/cache/api#Delete](https://m3o.com/cache/api#Delete) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/cache" +) + +// Delete a value from the cache. If key not found a success response is returned. +func DeleteAvalue() { + cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN")) + rsp, err := cacheService.Delete(&cache.DeleteRequest{ + Key: "foo", + + }) + fmt.Println(rsp, err) + +} +``` +## 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) + } ``` diff --git a/examples/crypto/README.md b/examples/crypto/README.md index a74272f..b836e92 100755 --- a/examples/crypto/README.md +++ b/examples/crypto/README.md @@ -29,6 +29,7 @@ func GetCryptocurrencyNews() { }) fmt.Println(rsp, err) + } ``` ## Price @@ -56,6 +57,7 @@ func GetCryptocurrencyPrice() { }) fmt.Println(rsp, err) + } ``` ## Quote @@ -83,6 +85,7 @@ func GetAcryptocurrencyQuote() { }) fmt.Println(rsp, err) + } ``` ## History @@ -110,5 +113,6 @@ func GetPreviousClose() { }) fmt.Println(rsp, err) + } ``` diff --git a/examples/currency/README.md b/examples/currency/README.md index 1e32012..773caf3 100755 --- a/examples/currency/README.md +++ b/examples/currency/README.md @@ -4,6 +4,35 @@ 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 @@ -28,6 +57,7 @@ func GetSupportedCodes() { }) fmt.Println(rsp, err) + } ``` ## Rates @@ -55,6 +85,7 @@ func GetRatesForUsd() { }) fmt.Println(rsp, err) + } ``` ## Convert @@ -83,6 +114,7 @@ To: "GBP", }) fmt.Println(rsp, err) + } ``` ## Convert @@ -112,33 +144,6 @@ To: "GBP", }) fmt.Println(rsp, err) -} -``` -## 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 1f4eb65..e390a54 100755 --- a/examples/db/README.md +++ b/examples/db/README.md @@ -4,33 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Db/api](https: Endpoints: -## Count - -Count records in a table - - -[https://m3o.com/db/api#Count](https://m3o.com/db/api#Count) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/db" -) - -// Count records in a table -func CountEntriesInAtable() { - dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) - rsp, err := dbService.Count(&db.CountRequest{ - Table: "users", - - }) - fmt.Println(rsp, err) -} -``` ## Create Create a record in the database. Optionally include an "id" field otherwise it's set automatically. @@ -53,15 +26,16 @@ func CreateArecord() { dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) rsp, err := dbService.Create(&db.CreateRequest{ Record: map[string]interface{}{ + "id": "1", "name": "Jane", "age": 42, "isActive": true, - "id": "1", }, Table: "users", }) fmt.Println(rsp, err) + } ``` ## Update @@ -93,6 +67,7 @@ Table: "users", }) fmt.Println(rsp, err) + } ``` ## Read @@ -121,6 +96,7 @@ Table: "users", }) fmt.Println(rsp, err) + } ``` ## Delete @@ -149,6 +125,7 @@ Table: "users", }) fmt.Println(rsp, err) + } ``` ## Truncate @@ -176,5 +153,34 @@ func TruncateTable() { }) 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: "users", + + }) + fmt.Println(rsp, err) + } ``` diff --git a/examples/db/create/createARecord/main.go b/examples/db/create/createARecord/main.go index 886de82..bb15dac 100755 --- a/examples/db/create/createARecord/main.go +++ b/examples/db/create/createARecord/main.go @@ -12,10 +12,10 @@ func main() { dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) rsp, err := dbService.Create(&db.CreateRequest{ Record: map[string]interface{}{ - "id": "1", "name": "Jane", "age": 42, "isActive": true, + "id": "1", }, Table: "users", }) diff --git a/examples/email/README.md b/examples/email/README.md index 7c2e1f4..18d5c93 100755 --- a/examples/email/README.md +++ b/examples/email/README.md @@ -33,5 +33,6 @@ Please verify your email by clicking this link: $micro_verification_link`, }) fmt.Println(rsp, err) + } ``` diff --git a/examples/emoji/README.md b/examples/emoji/README.md index af78e78..d2a4c7f 100755 --- a/examples/emoji/README.md +++ b/examples/emoji/README.md @@ -29,6 +29,7 @@ func FindEmoji() { }) fmt.Println(rsp, err) + } ``` ## Flag @@ -55,6 +56,7 @@ func GetFlagByCountryCode() { }) fmt.Println(rsp, err) + } ``` ## Print @@ -84,6 +86,7 @@ func PrintTextIncludingEmoji() { }) fmt.Println(rsp, err) + } ``` ## Send @@ -113,5 +116,6 @@ To: "+44782669123", }) fmt.Println(rsp, err) + } ``` diff --git a/examples/evchargers/README.md b/examples/evchargers/README.md index 81daae4..335b9e3 100755 --- a/examples/evchargers/README.md +++ b/examples/evchargers/README.md @@ -33,6 +33,7 @@ Location: &evchargers.Coordinates{ }) fmt.Println(rsp, err) + } ``` ## Search @@ -61,6 +62,7 @@ func SearchByBoundingBox() { }) fmt.Println(rsp, err) + } ``` ## Search @@ -93,6 +95,7 @@ Location: &evchargers.Coordinates{ }) fmt.Println(rsp, err) + } ``` ## ReferenceData @@ -119,5 +122,6 @@ func GetReferenceData() { }) fmt.Println(rsp, err) + } ``` diff --git a/examples/event/README.md b/examples/event/README.md index 38d6199..bfdbd1a 100755 --- a/examples/event/README.md +++ b/examples/event/README.md @@ -34,6 +34,7 @@ Topic: "user", }) fmt.Println(rsp, err) + } ``` ## Consume @@ -56,11 +57,25 @@ import( // Consume events from a given topic. func ConsumeFromAtopic() { eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN")) - rsp, err := eventService.Consume(&event.ConsumeRequest{ + + stream, err := eventService.Consume(&event.ConsumeRequest{ Topic: "user", }) - fmt.Println(rsp, err) + if err != nil { + fmt.Println(err) + return + } + + for { + rsp, err := stream.Recv() + if err != nil { + fmt.Println(err) + return + } + + fmt.Println(rsp) + } } ``` ## Read @@ -88,5 +103,6 @@ func ReadEventsOnAtopic() { }) fmt.Println(rsp, err) + } ``` diff --git a/examples/event/publish/publishAnEvent/main.go b/examples/event/publish/publishAnEvent/main.go index 49e4e18..c60c214 100755 --- a/examples/event/publish/publishAnEvent/main.go +++ b/examples/event/publish/publishAnEvent/main.go @@ -12,9 +12,9 @@ func main() { eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN")) rsp, err := eventService.Publish(&event.PublishRequest{ Message: map[string]interface{}{ + "user": "john", "id": "1", "type": "signup", - "user": "john", }, Topic: "user", }) diff --git a/examples/file/README.md b/examples/file/README.md index 68a6a0a..600798e 100755 --- a/examples/file/README.md +++ b/examples/file/README.md @@ -4,6 +4,92 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/File/api](http Endpoints: +## List + +List files by their project and optionally a path. + + +[https://m3o.com/file/api#List](https://m3o.com/file/api#List) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/file" +) + +// List files by their project and optionally a path. +func ListFiles() { + fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN")) + rsp, err := fileService.List(&file.ListRequest{ + Project: "examples", + + }) + fmt.Println(rsp, err) + +} +``` +## Delete + +Delete a file by project name/path + + +[https://m3o.com/file/api#Delete](https://m3o.com/file/api#Delete) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/file" +) + +// Delete a file by project name/path +func DeleteFile() { + fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN")) + rsp, err := fileService.Delete(&file.DeleteRequest{ + Path: "/document/text-files/file.txt", +Project: "examples", + + }) + fmt.Println(rsp, err) + +} +``` +## Read + +Read a file by path + + +[https://m3o.com/file/api#Read](https://m3o.com/file/api#Read) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/file" +) + +// Read a file by path +func ReadFile() { + fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN")) + rsp, err := fileService.Read(&file.ReadRequest{ + Path: "/document/text-files/file.txt", +Project: "examples", + + }) + fmt.Println(rsp, err) + +} +``` ## Save Save a file @@ -33,88 +119,6 @@ func SaveFile() { }) fmt.Println(rsp, err) -} -``` -## List - -List files by their project and optionally a path. - - -[https://m3o.com/file/api#List](https://m3o.com/file/api#List) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/file" -) - -// List files by their project and optionally a path. -func ListFiles() { - fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN")) - rsp, err := fileService.List(&file.ListRequest{ - Project: "examples", - - }) - fmt.Println(rsp, err) -} -``` -## Delete - -Delete a file by project name/path - - -[https://m3o.com/file/api#Delete](https://m3o.com/file/api#Delete) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/file" -) - -// Delete a file by project name/path -func DeleteFile() { - fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN")) - rsp, err := fileService.Delete(&file.DeleteRequest{ - Path: "/document/text-files/file.txt", -Project: "examples", - - }) - fmt.Println(rsp, err) -} -``` -## Read - -Read a file by path - - -[https://m3o.com/file/api#Read](https://m3o.com/file/api#Read) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/file" -) - -// Read a file by path -func ReadFile() { - fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN")) - rsp, err := fileService.Read(&file.ReadRequest{ - Path: "/document/text-files/file.txt", -Project: "examples", - - }) - fmt.Println(rsp, err) + } ``` diff --git a/examples/forex/README.md b/examples/forex/README.md index 8fe80a6..076f73a 100755 --- a/examples/forex/README.md +++ b/examples/forex/README.md @@ -29,6 +29,7 @@ func GetAnFxPrice() { }) fmt.Println(rsp, err) + } ``` ## Quote @@ -56,6 +57,7 @@ func GetAfxQuote() { }) fmt.Println(rsp, err) + } ``` ## History @@ -83,5 +85,6 @@ func GetPreviousClose() { }) fmt.Println(rsp, err) + } ``` diff --git a/examples/function/README.md b/examples/function/README.md index 13108b1..0889d21 100755 --- a/examples/function/README.md +++ b/examples/function/README.md @@ -4,117 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Function/api]( Endpoints: -## 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: "my-first-func", -Request: map[string]interface{}{ -}, - - }) - fmt.Println(rsp, err) -} -``` -## List - -List all the deployed functions - - -[https://m3o.com/function/api#List](https://m3o.com/function/api#List) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/function" -) - -// List all the deployed functions -func ListFunctions() { - functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) - rsp, err := functionService.List(&function.ListRequest{ - - }) - fmt.Println(rsp, err) -} -``` -## Delete - -Delete a function by name - - -[https://m3o.com/function/api#Delete](https://m3o.com/function/api#Delete) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/function" -) - -// Delete a function by name -func DeleteAfunction() { - functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) - rsp, err := functionService.Delete(&function.DeleteRequest{ - Name: "my-first-func", -Project: "tests", - - }) - 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: "my-first-func", -Project: "tests", - - }) - fmt.Println(rsp, err) -} -``` ## Deploy Deploy a group of functions @@ -144,5 +33,121 @@ Runtime: "nodejs14", }) fmt.Println(rsp, err) + +} +``` +## Call + +Call a function by name + + +[https://m3o.com/function/api#Call](https://m3o.com/function/api#Call) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/function" +) + +// Call a function by name +func CallAfunction() { + functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) + rsp, err := functionService.Call(&function.CallRequest{ + Name: "my-first-func", +Request: map[string]interface{}{ +}, + + }) + fmt.Println(rsp, err) + +} +``` +## List + +List all the deployed functions + + +[https://m3o.com/function/api#List](https://m3o.com/function/api#List) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/function" +) + +// List all the deployed functions +func ListFunctions() { + functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) + rsp, err := functionService.List(&function.ListRequest{ + + }) + fmt.Println(rsp, err) + +} +``` +## Delete + +Delete a function by name + + +[https://m3o.com/function/api#Delete](https://m3o.com/function/api#Delete) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/function" +) + +// Delete a function by name +func DeleteAfunction() { + functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) + rsp, err := functionService.Delete(&function.DeleteRequest{ + Name: "my-first-func", +Project: "tests", + + }) + 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: "my-first-func", +Project: "tests", + + }) + fmt.Println(rsp, err) + } ``` diff --git a/examples/geocoding/README.md b/examples/geocoding/README.md index 448d333..ad1daf9 100755 --- a/examples/geocoding/README.md +++ b/examples/geocoding/README.md @@ -32,6 +32,7 @@ Postcode: "wc2b", }) fmt.Println(rsp, err) + } ``` ## Reverse @@ -60,5 +61,6 @@ Longitude: -0.1216235, }) fmt.Println(rsp, err) + } ``` diff --git a/examples/gifs/README.md b/examples/gifs/README.md index 3e7b371..e207e8b 100755 --- a/examples/gifs/README.md +++ b/examples/gifs/README.md @@ -30,5 +30,6 @@ Query: "dogs", }) fmt.Println(rsp, err) + } ``` diff --git a/examples/google/README.md b/examples/google/README.md index 80278a9..3a21caf 100755 --- a/examples/google/README.md +++ b/examples/google/README.md @@ -29,5 +29,6 @@ func SearchForVideos() { }) fmt.Println(rsp, err) + } ``` diff --git a/examples/helloworld/README.md b/examples/helloworld/README.md index a5bd4db..f20bfb9 100755 --- a/examples/helloworld/README.md +++ b/examples/helloworld/README.md @@ -4,6 +4,47 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Helloworld/api Endpoints: +## Stream + +Stream returns a stream of "Hello $name" responses + + +[https://m3o.com/helloworld/api#Stream](https://m3o.com/helloworld/api#Stream) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/helloworld" +) + +// Stream returns a stream of "Hello $name" responses +func StreamsResponsesFromTheServerUsingWebsockets() { + helloworldService := helloworld.NewHelloworldService(os.Getenv("M3O_API_TOKEN")) + + stream, err := helloworldService.Stream(&helloworld.StreamRequest{ + Name: "John", + + }) + if err != nil { + fmt.Println(err) + return + } + + for { + rsp, err := stream.Recv() + if err != nil { + fmt.Println(err) + return + } + + fmt.Println(rsp) + } +} +``` ## Call Call returns a personalised "Hello $name" response @@ -29,32 +70,6 @@ func CallTheHelloworldService() { }) fmt.Println(rsp, err) -} -``` -## Stream - -Stream returns a stream of "Hello $name" responses - - -[https://m3o.com/helloworld/api#Stream](https://m3o.com/helloworld/api#Stream) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/helloworld" -) - -// Stream returns a stream of "Hello $name" responses -func StreamsResponsesFromTheServerUsingWebsockets() { - helloworldService := helloworld.NewHelloworldService(os.Getenv("M3O_API_TOKEN")) - rsp, err := helloworldService.Stream(&helloworld.StreamRequest{ - Name: "John", - - }) - fmt.Println(rsp, err) + } ``` diff --git a/examples/holidays/README.md b/examples/holidays/README.md index 1e49dab..22e8fcd 100755 --- a/examples/holidays/README.md +++ b/examples/holidays/README.md @@ -4,32 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Holidays/api]( Endpoints: -## Countries - -Get the list of countries that are supported by this API - - -[https://m3o.com/holidays/api#Countries](https://m3o.com/holidays/api#Countries) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/holidays" -) - -// Get the list of countries that are supported by this API -func ListCountries() { - holidaysService := holidays.NewHolidaysService(os.Getenv("M3O_API_TOKEN")) - rsp, err := holidaysService.Countries(&holidays.CountriesRequest{ - - }) - fmt.Println(rsp, err) -} -``` ## List List the holiday dates for a given country and year @@ -55,5 +29,33 @@ func GetHolidays() { }) fmt.Println(rsp, err) + +} +``` +## Countries + +Get the list of countries that are supported by this API + + +[https://m3o.com/holidays/api#Countries](https://m3o.com/holidays/api#Countries) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/holidays" +) + +// Get the list of countries that are supported by this API +func ListCountries() { + holidaysService := holidays.NewHolidaysService(os.Getenv("M3O_API_TOKEN")) + rsp, err := holidaysService.Countries(&holidays.CountriesRequest{ + + }) + fmt.Println(rsp, err) + } ``` diff --git a/examples/id/README.md b/examples/id/README.md index a3713d1..6d0391b 100755 --- a/examples/id/README.md +++ b/examples/id/README.md @@ -29,6 +29,7 @@ func GenerateAuniqueId() { }) fmt.Println(rsp, err) + } ``` ## Generate @@ -56,6 +57,7 @@ func GenerateAshortId() { }) fmt.Println(rsp, err) + } ``` ## Generate @@ -83,6 +85,7 @@ func GenerateAsnowflakeId() { }) fmt.Println(rsp, err) + } ``` ## Generate @@ -110,6 +113,7 @@ func GenerateAbigflakeId() { }) fmt.Println(rsp, err) + } ``` ## Types @@ -136,5 +140,6 @@ func ListTheTypesOfIdsAvailable() { }) fmt.Println(rsp, err) + } ``` diff --git a/examples/image/README.md b/examples/image/README.md index 3dfb2e6..8515906 100755 --- a/examples/image/README.md +++ b/examples/image/README.md @@ -36,6 +36,7 @@ Width: 100, }) fmt.Println(rsp, err) + } ``` ## Resize @@ -69,6 +70,7 @@ Width: 100, }) fmt.Println(rsp, err) + } ``` ## Resize @@ -106,6 +108,7 @@ Width: 100, }) fmt.Println(rsp, err) + } ``` ## Convert @@ -136,6 +139,7 @@ Url: "somewebsite.com/cat.png", }) fmt.Println(rsp, err) + } ``` ## Upload @@ -166,6 +170,7 @@ Name: "cat.jpeg", }) fmt.Println(rsp, err) + } ``` ## Upload @@ -196,6 +201,7 @@ Url: "somewebsite.com/cat.png", }) fmt.Println(rsp, err) + } ``` ## Delete @@ -223,5 +229,6 @@ func DeleteAnUploadedImage() { }) fmt.Println(rsp, err) + } ``` diff --git a/examples/ip/README.md b/examples/ip/README.md index ab99d55..bc0377b 100755 --- a/examples/ip/README.md +++ b/examples/ip/README.md @@ -29,5 +29,6 @@ func LookupIpInfo() { }) fmt.Println(rsp, err) + } ``` diff --git a/examples/location/README.md b/examples/location/README.md index 4db841c..83046bb 100755 --- a/examples/location/README.md +++ b/examples/location/README.md @@ -4,66 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Location/api]( Endpoints: -## Read - -Read an entity by its ID - - -[https://m3o.com/location/api#Read](https://m3o.com/location/api#Read) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/location" -) - -// Read an entity by its ID -func GetLocationById() { - locationService := location.NewLocationService(os.Getenv("M3O_API_TOKEN")) - rsp, err := locationService.Read(&location.ReadRequest{ - Id: "1", - - }) - fmt.Println(rsp, err) -} -``` -## Search - -Search for entities in a given radius - - -[https://m3o.com/location/api#Search](https://m3o.com/location/api#Search) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/location" -) - -// Search for entities in a given radius -func SearchForLocations() { - locationService := location.NewLocationService(os.Getenv("M3O_API_TOKEN")) - rsp, err := locationService.Search(&location.SearchRequest{ - Center: &location.Point{ - Latitude: 51.511061, - Longitude: -0.120022, - }, -NumEntities: 10, -Radius: 100, -Type: "bike", - - }) - fmt.Println(rsp, err) -} -``` ## Save Save an entity's current position @@ -97,5 +37,68 @@ func SaveAnEntity() { }) fmt.Println(rsp, err) + +} +``` +## Read + +Read an entity by its ID + + +[https://m3o.com/location/api#Read](https://m3o.com/location/api#Read) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/location" +) + +// Read an entity by its ID +func GetLocationById() { + locationService := location.NewLocationService(os.Getenv("M3O_API_TOKEN")) + rsp, err := locationService.Read(&location.ReadRequest{ + Id: "1", + + }) + fmt.Println(rsp, err) + +} +``` +## Search + +Search for entities in a given radius + + +[https://m3o.com/location/api#Search](https://m3o.com/location/api#Search) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/location" +) + +// Search for entities in a given radius +func SearchForLocations() { + locationService := location.NewLocationService(os.Getenv("M3O_API_TOKEN")) + rsp, err := locationService.Search(&location.SearchRequest{ + Center: &location.Point{ + Latitude: 51.511061, + Longitude: -0.120022, + }, +NumEntities: 10, +Radius: 100, +Type: "bike", + + }) + fmt.Println(rsp, err) + } ``` diff --git a/examples/mq/README.md b/examples/mq/README.md index b6a63bf..8153f1c 100755 --- a/examples/mq/README.md +++ b/examples/mq/README.md @@ -26,14 +26,15 @@ 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", }) fmt.Println(rsp, err) + } ``` ## Subscribe @@ -56,10 +57,24 @@ import( // Subscribe to messages for a given topic. func SubscribeToAtopic() { mqService := mq.NewMqService(os.Getenv("M3O_API_TOKEN")) - rsp, err := mqService.Subscribe(&mq.SubscribeRequest{ + + stream, err := mqService.Subscribe(&mq.SubscribeRequest{ Topic: "events", }) - fmt.Println(rsp, err) + 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/notes/README.md b/examples/notes/README.md index 81a5075..d3734ad 100755 --- a/examples/notes/README.md +++ b/examples/notes/README.md @@ -4,6 +4,104 @@ 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 + + +[https://m3o.com/notes/api#Create](https://m3o.com/notes/api#Create) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/notes" +) + +// Create a new note +func CreateAnote() { + notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN")) + rsp, err := notesService.Create(¬es.CreateRequest{ + Text: "This is my note", +Title: "New Note", + + }) + fmt.Println(rsp, err) + +} +``` +## Read + +Read a note + + +[https://m3o.com/notes/api#Read](https://m3o.com/notes/api#Read) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/notes" +) + +// Read a note +func ReadAnote() { + notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN")) + rsp, err := notesService.Read(¬es.ReadRequest{ + Id: "63c0cdf8-2121-11ec-a881-0242e36f037a", + + }) + fmt.Println(rsp, err) + +} +``` ## List List all the notes @@ -28,6 +126,7 @@ func ListAllNotes() { }) fmt.Println(rsp, err) + } ``` ## Update @@ -59,6 +158,7 @@ func UpdateAnote() { }) fmt.Println(rsp, err) + } ``` ## Delete @@ -86,87 +186,6 @@ func DeleteAnote() { }) fmt.Println(rsp, err) -} -``` -## 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")) - rsp, err := notesService.Events(¬es.EventsRequest{ - Id: "63c0cdf8-2121-11ec-a881-0242e36f037a", - - }) - fmt.Println(rsp, err) -} -``` -## Create - -Create a new note - - -[https://m3o.com/notes/api#Create](https://m3o.com/notes/api#Create) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/notes" -) - -// Create a new note -func CreateAnote() { - notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN")) - rsp, err := notesService.Create(¬es.CreateRequest{ - Text: "This is my note", -Title: "New Note", - - }) - fmt.Println(rsp, err) -} -``` -## Read - -Read a note - - -[https://m3o.com/notes/api#Read](https://m3o.com/notes/api#Read) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/notes" -) - -// Read a note -func ReadAnote() { - notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN")) - rsp, err := notesService.Read(¬es.ReadRequest{ - Id: "63c0cdf8-2121-11ec-a881-0242e36f037a", - - }) - fmt.Println(rsp, err) + } ``` diff --git a/examples/otp/README.md b/examples/otp/README.md index d1ab2a1..66d4d50 100755 --- a/examples/otp/README.md +++ b/examples/otp/README.md @@ -4,33 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Otp/api](https Endpoints: -## Generate - -Generate an OTP (one time pass) code - - -[https://m3o.com/otp/api#Generate](https://m3o.com/otp/api#Generate) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/otp" -) - -// Generate an OTP (one time pass) code -func GenerateOtp() { - otpService := otp.NewOtpService(os.Getenv("M3O_API_TOKEN")) - rsp, err := otpService.Generate(&otp.GenerateRequest{ - Id: "asim@example.com", - - }) - fmt.Println(rsp, err) -} -``` ## Validate Validate the OTP code @@ -57,5 +30,34 @@ Id: "asim@example.com", }) fmt.Println(rsp, err) + +} +``` +## Generate + +Generate an OTP (one time pass) code + + +[https://m3o.com/otp/api#Generate](https://m3o.com/otp/api#Generate) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/otp" +) + +// Generate an OTP (one time pass) code +func GenerateOtp() { + otpService := otp.NewOtpService(os.Getenv("M3O_API_TOKEN")) + rsp, err := otpService.Generate(&otp.GenerateRequest{ + Id: "asim@example.com", + + }) + fmt.Println(rsp, err) + } ``` diff --git a/examples/postcode/README.md b/examples/postcode/README.md index 8ad6f68..cccb09a 100755 --- a/examples/postcode/README.md +++ b/examples/postcode/README.md @@ -29,6 +29,7 @@ func LookupPostcode() { }) fmt.Println(rsp, err) + } ``` ## Random @@ -55,6 +56,7 @@ func ReturnArandomPostcodeAndItsInformation() { }) fmt.Println(rsp, err) + } ``` ## Validate @@ -82,5 +84,6 @@ func ReturnArandomPostcodeAndItsInformation() { }) fmt.Println(rsp, err) + } ``` diff --git a/examples/prayer/README.md b/examples/prayer/README.md index 8befb95..1ad2bf6 100755 --- a/examples/prayer/README.md +++ b/examples/prayer/README.md @@ -29,5 +29,6 @@ func PrayerTimes() { }) fmt.Println(rsp, err) + } ``` diff --git a/examples/qr/README.md b/examples/qr/README.md index 85773cd..e2f38f4 100755 --- a/examples/qr/README.md +++ b/examples/qr/README.md @@ -30,5 +30,6 @@ Text: "https://m3o.com/qr", }) fmt.Println(rsp, err) + } ``` diff --git a/examples/quran/README.md b/examples/quran/README.md index 79165db..927b4b4 100755 --- a/examples/quran/README.md +++ b/examples/quran/README.md @@ -4,33 +4,6 @@ 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) @@ -56,6 +29,7 @@ func GetChapterSummary() { }) fmt.Println(rsp, err) + } ``` ## Verses @@ -87,6 +61,7 @@ func GetVersesOfAchapter() { }) fmt.Println(rsp, err) + } ``` ## Search @@ -114,5 +89,34 @@ func SearchTheQuran() { }) fmt.Println(rsp, err) + +} +``` +## Chapters + +List the Chapters (surahs) of the Quran + + +[https://m3o.com/quran/api#Chapters](https://m3o.com/quran/api#Chapters) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/quran" +) + +// List the Chapters (surahs) of the Quran +func ListChapters() { + quranService := quran.NewQuranService(os.Getenv("M3O_API_TOKEN")) + rsp, err := quranService.Chapters(&quran.ChaptersRequest{ + Language: "en", + + }) + fmt.Println(rsp, err) + } ``` diff --git a/examples/routing/README.md b/examples/routing/README.md index 8f4968f..bd394b1 100755 --- a/examples/routing/README.md +++ b/examples/routing/README.md @@ -36,6 +36,7 @@ Origin: &routing.Point{ }) fmt.Println(rsp, err) + } ``` ## Directions @@ -70,6 +71,7 @@ Origin: &routing.Point{ }) fmt.Println(rsp, err) + } ``` ## Route @@ -104,5 +106,6 @@ Origin: &routing.Point{ }) fmt.Println(rsp, err) + } ``` diff --git a/examples/rss/README.md b/examples/rss/README.md index 439a4f5..62d0224 100755 --- a/examples/rss/README.md +++ b/examples/rss/README.md @@ -31,6 +31,7 @@ Url: "http://feeds.bbci.co.uk/news/rss.xml", }) fmt.Println(rsp, err) + } ``` ## Feed @@ -58,6 +59,7 @@ func ReadAfeed() { }) fmt.Println(rsp, err) + } ``` ## List @@ -84,6 +86,7 @@ func ListRssFeeds() { }) fmt.Println(rsp, err) + } ``` ## Remove @@ -111,5 +114,6 @@ func RemoveAfeed() { }) fmt.Println(rsp, err) + } ``` diff --git a/examples/sentiment/README.md b/examples/sentiment/README.md index 3ddbcaa..6ea4b3d 100755 --- a/examples/sentiment/README.md +++ b/examples/sentiment/README.md @@ -29,5 +29,6 @@ func AnalyzeApieceOfText() { }) fmt.Println(rsp, err) + } ``` diff --git a/examples/sms/README.md b/examples/sms/README.md index 20f47f1..bef2be7 100755 --- a/examples/sms/README.md +++ b/examples/sms/README.md @@ -31,5 +31,6 @@ To: "+447681129", }) fmt.Println(rsp, err) + } ``` diff --git a/examples/stock/README.md b/examples/stock/README.md index 01985ac..b627a34 100755 --- a/examples/stock/README.md +++ b/examples/stock/README.md @@ -4,6 +4,91 @@ 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 + + +[https://m3o.com/stock/api#History](https://m3o.com/stock/api#History) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/stock" +) + +// Get the historic open-close for a given day +func GetHistoricData() { + stockService := stock.NewStockService(os.Getenv("M3O_API_TOKEN")) + rsp, err := stockService.History(&stock.HistoryRequest{ + Date: "2020-10-01", +Stock: "AAPL", + + }) + fmt.Println(rsp, err) + +} +``` ## OrderBook Get the historic order book and each trade by timestamp @@ -33,87 +118,6 @@ Stock: "AAPL", }) fmt.Println(rsp, err) -} -``` -## 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 - - -[https://m3o.com/stock/api#History](https://m3o.com/stock/api#History) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/stock" -) - -// Get the historic open-close for a given day -func GetHistoricData() { - stockService := stock.NewStockService(os.Getenv("M3O_API_TOKEN")) - rsp, err := stockService.History(&stock.HistoryRequest{ - Date: "2020-10-01", -Stock: "AAPL", - - }) - fmt.Println(rsp, err) + } ``` diff --git a/examples/stream/README.md b/examples/stream/README.md index 28fe194..6d83f90 100755 --- a/examples/stream/README.md +++ b/examples/stream/README.md @@ -4,6 +4,33 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Stream/api](ht Endpoints: +## ListChannels + +List all the active channels + + +[https://m3o.com/stream/api#ListChannels](https://m3o.com/stream/api#ListChannels) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/stream" +) + +// List all the active channels +func ListChannels() { + streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN")) + rsp, err := streamService.ListChannels(&stream.ListChannelsRequest{ + + }) + fmt.Println(rsp, err) + +} +``` ## CreateChannel Create a channel with a given name and description. Channels are created automatically but @@ -32,6 +59,7 @@ Name: "general", }) fmt.Println(rsp, err) + } ``` ## SendMessage @@ -60,6 +88,7 @@ Text: "Hey checkout this tweet https://twitter.com/m3oservices/status/1455291054 }) fmt.Println(rsp, err) + } ``` ## ListMessages @@ -87,31 +116,6 @@ func ListMessages() { }) fmt.Println(rsp, err) -} -``` -## ListChannels - -List all the active channels - - -[https://m3o.com/stream/api#ListChannels](https://m3o.com/stream/api#ListChannels) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/stream" -) - -// List all the active channels -func ListChannels() { - streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN")) - rsp, err := streamService.ListChannels(&stream.ListChannelsRequest{ - - }) - fmt.Println(rsp, err) + } ``` diff --git a/examples/sunnah/README.md b/examples/sunnah/README.md index e450b78..0b5cf6e 100755 --- a/examples/sunnah/README.md +++ b/examples/sunnah/README.md @@ -30,6 +30,7 @@ func ListAvailableCollections() { }) fmt.Println(rsp, err) + } ``` ## Books @@ -59,6 +60,7 @@ func GetTheBooksWithinAcollection() { }) fmt.Println(rsp, err) + } ``` ## Chapters @@ -87,6 +89,7 @@ Collection: "bukhari", }) fmt.Println(rsp, err) + } ``` ## Hadiths @@ -117,5 +120,6 @@ Collection: "bukhari", }) fmt.Println(rsp, err) + } ``` diff --git a/examples/thumbnail/README.md b/examples/thumbnail/README.md index fb7f06e..8e51f01 100755 --- a/examples/thumbnail/README.md +++ b/examples/thumbnail/README.md @@ -31,5 +31,6 @@ Width: 600, }) fmt.Println(rsp, err) + } ``` diff --git a/examples/time/README.md b/examples/time/README.md index b72f4a5..73de990 100755 --- a/examples/time/README.md +++ b/examples/time/README.md @@ -4,32 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Time/api](http Endpoints: -## Now - -Get the current time - - -[https://m3o.com/time/api#Now](https://m3o.com/time/api#Now) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/time" -) - -// Get the current time -func ReturnsCurrentTimeOptionallyWithLocation() { - timeService := time.NewTimeService(os.Getenv("M3O_API_TOKEN")) - rsp, err := timeService.Now(&time.NowRequest{ - - }) - fmt.Println(rsp, err) -} -``` ## Zone Get the timezone info for a specific location @@ -55,5 +29,33 @@ func GetTheTimezoneInfoForAspecificLocation() { }) fmt.Println(rsp, err) + +} +``` +## Now + +Get the current time + + +[https://m3o.com/time/api#Now](https://m3o.com/time/api#Now) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/time" +) + +// Get the current time +func ReturnsCurrentTimeOptionallyWithLocation() { + timeService := time.NewTimeService(os.Getenv("M3O_API_TOKEN")) + rsp, err := timeService.Now(&time.NowRequest{ + + }) + fmt.Println(rsp, err) + } ``` diff --git a/examples/twitter/README.md b/examples/twitter/README.md index c20e9a4..e099911 100755 --- a/examples/twitter/README.md +++ b/examples/twitter/README.md @@ -4,6 +4,35 @@ 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 @@ -29,6 +58,7 @@ func SearchForTweets() { }) fmt.Println(rsp, err) + } ``` ## Trends @@ -55,6 +85,7 @@ func GetTheCurrentGlobalTrendingTopics() { }) fmt.Println(rsp, err) + } ``` ## User @@ -82,33 +113,6 @@ func GetAusersTwitterProfile() { }) fmt.Println(rsp, err) -} -``` -## 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 314e672..20c224a 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 information on all the shortened URLs that you have created @@ -28,6 +55,7 @@ func ListYourShortenedUrls() { }) fmt.Println(rsp, err) + } ``` ## Shorten @@ -54,31 +82,6 @@ func ShortenAlongUrl() { }) fmt.Println(rsp, err) -} -``` -## 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 515c957..53f6fed 100755 --- a/examples/user/README.md +++ b/examples/user/README.md @@ -4,6 +4,205 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/User/api](http Endpoints: +## Read + +Read an account by id, username or email. Only one need to be specified. + + +[https://m3o.com/user/api#Read](https://m3o.com/user/api#Read) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Read an account by id, username or email. Only one need to be specified. +func ReadAnAccountById() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.Read(&user.ReadRequest{ + Id: "usrid-1", + + }) + fmt.Println(rsp, err) + +} +``` +## Read + +Read an account by id, username or email. Only one need to be specified. + + +[https://m3o.com/user/api#Read](https://m3o.com/user/api#Read) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Read an account by id, username or email. Only one need to be specified. +func ReadAccountByUsernameOrEmail() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.Read(&user.ReadRequest{ + Username: "usrname-1", + + }) + fmt.Println(rsp, err) + +} +``` +## Read + +Read an account by id, username or email. Only one need to be specified. + + +[https://m3o.com/user/api#Read](https://m3o.com/user/api#Read) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Read an account by id, username or email. Only one need to be specified. +func ReadAccountByEmail() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.Read(&user.ReadRequest{ + Email: "joe@example.com", + + }) + 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: "t2323t232t", + + }) + 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: "fdf34f34f34-f34f34-f43f43f34-f4f34f", + + }) + 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: "sds34s34s34-s34s34-s43s43s34-s4s34s", + + }) + 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: "usrid-1", +Password: "mySecretPass123", +Username: "usrname-1", + + }) + fmt.Println(rsp, err) + +} +``` ## Update Update the account username or email @@ -30,6 +229,7 @@ Id: "usrid-1", }) fmt.Println(rsp, err) + } ``` ## UpdatePassword @@ -59,6 +259,7 @@ OldPassword: "mySecretPass123", }) fmt.Println(rsp, err) + } ``` ## SendVerificationEmail @@ -105,33 +306,7 @@ Please verify your email by clicking this link: $micro_verification_link`, }) fmt.Println(rsp, err) -} -``` -## Delete - -Delete an account by id - - -[https://m3o.com/user/api#Delete](https://m3o.com/user/api#Delete) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/user" -) - -// Delete an account by id -func DeleteUserAccount() { - userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.Delete(&user.DeleteRequest{ - Id: "fdf34f34f34-f34f34-f43f43f34-f4f34f", - - }) - fmt.Println(rsp, err) + } ``` ## Login @@ -162,171 +337,7 @@ Password: "mySecretPass123", }) 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: "usrid-1", -Password: "mySecretPass123", -Username: "usrname-1", - - }) - fmt.Println(rsp, err) -} -``` -## Read - -Read an account by id, username or email. Only one need to be specified. - - -[https://m3o.com/user/api#Read](https://m3o.com/user/api#Read) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/user" -) - -// Read an account by id, username or email. Only one need to be specified. -func ReadAnAccountById() { - userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.Read(&user.ReadRequest{ - Id: "usrid-1", - - }) - fmt.Println(rsp, err) -} -``` -## Read - -Read an account by id, username or email. Only one need to be specified. - - -[https://m3o.com/user/api#Read](https://m3o.com/user/api#Read) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/user" -) - -// Read an account by id, username or email. Only one need to be specified. -func ReadAccountByUsernameOrEmail() { - userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.Read(&user.ReadRequest{ - Username: "usrname-1", - - }) - fmt.Println(rsp, err) -} -``` -## Read - -Read an account by id, username or email. Only one need to be specified. - - -[https://m3o.com/user/api#Read](https://m3o.com/user/api#Read) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/user" -) - -// Read an account by id, username or email. Only one need to be specified. -func ReadAccountByEmail() { - userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.Read(&user.ReadRequest{ - Email: "joe@example.com", - - }) - 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: "t2323t232t", - - }) - 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: "sds34s34s34-s34s34-s43s43s34-s4s34s", - - }) - fmt.Println(rsp, err) + } ``` ## ReadSession @@ -354,5 +365,6 @@ func ReadAsessionByTheSessionId() { }) fmt.Println(rsp, err) + } ``` diff --git a/examples/vehicle/README.md b/examples/vehicle/README.md index ed48549..e2b8847 100755 --- a/examples/vehicle/README.md +++ b/examples/vehicle/README.md @@ -29,5 +29,6 @@ func LookupVehicle() { }) fmt.Println(rsp, err) + } ``` diff --git a/examples/weather/README.md b/examples/weather/README.md index 13cea01..c29cb3d 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 @@ -30,32 +58,6 @@ Location: "London", }) fmt.Println(rsp, err) -} -``` -## 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) + } ``` diff --git a/examples/youtube/README.md b/examples/youtube/README.md index edb5c83..e61b735 100755 --- a/examples/youtube/README.md +++ b/examples/youtube/README.md @@ -29,5 +29,6 @@ func SearchForVideos() { }) fmt.Println(rsp, err) + } ```