diff --git a/examples/app/README.md b/examples/app/README.md index 47d0f0f..adff04f 100755 --- a/examples/app/README.md +++ b/examples/app/README.md @@ -4,6 +4,90 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/app/api](https Endpoints: +## Resolve + +Resolve an app by id to its raw backend endpoint + + +[https://m3o.com/app/api#Resolve](https://m3o.com/app/api#Resolve) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/app" +) + +// Resolve an app by id to its raw backend endpoint +func ResolveAppById() { + appService := app.NewAppService(os.Getenv("M3O_API_TOKEN")) + rsp, err := appService.Resolve(&app.ResolveRequest{ + Id: "helloworld", + + }) + fmt.Println(rsp, err) + +} +``` +## Update + +Update the app. The latest source code will be downloaded, built and deployed. + + +[https://m3o.com/app/api#Update](https://m3o.com/app/api#Update) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/app" +) + +// Update the app. The latest source code will be downloaded, built and deployed. +func UpdateAnApp() { + appService := app.NewAppService(os.Getenv("M3O_API_TOKEN")) + rsp, err := appService.Update(&app.UpdateRequest{ + Name: "helloworld", + + }) + fmt.Println(rsp, err) + +} +``` +## Delete + +Delete an app + + +[https://m3o.com/app/api#Delete](https://m3o.com/app/api#Delete) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/app" +) + +// Delete an app +func DeleteAnApp() { + appService := app.NewAppService(os.Getenv("M3O_API_TOKEN")) + rsp, err := appService.Delete(&app.DeleteRequest{ + Name: "helloworld", + + }) + fmt.Println(rsp, err) + +} +``` ## Reserve Reserve apps beyond the free quota. Call Run after. @@ -146,87 +230,3 @@ func GetTheStatusOfAnApp() { } ``` -## Resolve - -Resolve an app by id to its raw backend endpoint - - -[https://m3o.com/app/api#Resolve](https://m3o.com/app/api#Resolve) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/app" -) - -// Resolve an app by id to its raw backend endpoint -func ResolveAppById() { - appService := app.NewAppService(os.Getenv("M3O_API_TOKEN")) - rsp, err := appService.Resolve(&app.ResolveRequest{ - Id: "helloworld", - - }) - fmt.Println(rsp, err) - -} -``` -## Update - -Update the app. The latest source code will be downloaded, built and deployed. - - -[https://m3o.com/app/api#Update](https://m3o.com/app/api#Update) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/app" -) - -// Update the app. The latest source code will be downloaded, built and deployed. -func UpdateAnApp() { - appService := app.NewAppService(os.Getenv("M3O_API_TOKEN")) - rsp, err := appService.Update(&app.UpdateRequest{ - Name: "helloworld", - - }) - fmt.Println(rsp, err) - -} -``` -## Delete - -Delete an app - - -[https://m3o.com/app/api#Delete](https://m3o.com/app/api#Delete) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/app" -) - -// Delete an app -func DeleteAnApp() { - appService := app.NewAppService(os.Getenv("M3O_API_TOKEN")) - rsp, err := appService.Delete(&app.DeleteRequest{ - Name: "helloworld", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/cache/README.md b/examples/cache/README.md index 359c982..575e286 100755 --- a/examples/cache/README.md +++ b/examples/cache/README.md @@ -4,63 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/cache/api](htt Endpoints: -## Set - -Set an item in the cache. Overwrites any existing value already set. - - -[https://m3o.com/cache/api#Set](https://m3o.com/cache/api#Set) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/cache" -) - -// Set an item in the cache. Overwrites any existing value already set. -func SetAvalue() { - cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN")) - rsp, err := cacheService.Set(&cache.SetRequest{ - Key: "foo", -Value: "bar", - - }) - fmt.Println(rsp, err) - -} -``` -## Get - -Get an item from the cache by key. If key is not found, an empty response is returned. - - -[https://m3o.com/cache/api#Get](https://m3o.com/cache/api#Get) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/cache" -) - -// Get an item from the cache by key. If key is not found, an empty response is returned. -func GetAvalue() { - cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN")) - rsp, err := cacheService.Get(&cache.GetRequest{ - Key: "foo", - - }) - fmt.Println(rsp, err) - -} -``` ## Delete Delete a value from the cache. If key not found a success response is returned. @@ -174,3 +117,60 @@ func ListTheKeys() { } ``` +## Set + +Set an item in the cache. Overwrites any existing value already set. + + +[https://m3o.com/cache/api#Set](https://m3o.com/cache/api#Set) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/cache" +) + +// Set an item in the cache. Overwrites any existing value already set. +func SetAvalue() { + cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN")) + rsp, err := cacheService.Set(&cache.SetRequest{ + Key: "foo", +Value: "bar", + + }) + fmt.Println(rsp, err) + +} +``` +## Get + +Get an item from the cache by key. If key is not found, an empty response is returned. + + +[https://m3o.com/cache/api#Get](https://m3o.com/cache/api#Get) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/cache" +) + +// Get an item from the cache by key. If key is not found, an empty response is returned. +func GetAvalue() { + cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN")) + rsp, err := cacheService.Get(&cache.GetRequest{ + Key: "foo", + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/contact/README.md b/examples/contact/README.md index e52974c..9a0ba7e 100755 --- a/examples/contact/README.md +++ b/examples/contact/README.md @@ -4,6 +4,107 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/contact/api](h Endpoints: +## Create + + + + +[https://m3o.com/contact/api#Create](https://m3o.com/contact/api#Create) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/contact" +) + +// +func CreateAcontact() { + contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN")) + rsp, err := contactService.Create(&contact.CreateRequest{ + Addresses: []contact.Address{ +contact.Address{ + Label: "company address", + Location: "123 street address", +}}, +Birthday: "1995-01-01", +Emails: []contact.Email{ +contact.Email{ + Address: "home@example.com", + Label: "home", +}}, +Links: []contact.Link{ +contact.Link{ + Label: "blog", + Url: "https://blog.joe.me", +}}, +Name: "joe", +Note: "this person is very important", +Phones: []contact.Phone{ +contact.Phone{ + Label: "home", + Number: "010-12345678", +}}, + + }) + fmt.Println(rsp, err) + +} +``` +## Update + + + + +[https://m3o.com/contact/api#Update](https://m3o.com/contact/api#Update) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/contact" +) + +// +func UpdateAcontact() { + contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN")) + rsp, err := contactService.Update(&contact.UpdateRequest{ + Addresses: []contact.Address{ +contact.Address{ + Label: "company address", + Location: "123 street address", +}}, +Birthday: "1995-01-01", +Emails: []contact.Email{ +contact.Email{ + Address: "home@example.com", + Label: "home", +}}, +Id: "42e48a3c-6221-11ec-96d2-acde48001122", +Links: []contact.Link{ +contact.Link{ + Label: "blog", + Url: "https://blog.joe.me", +}}, +Name: "joe", +Note: "this person is very important", +Phones: []contact.Phone{ +contact.Phone{ + Label: "home", + Number: "010-12345678", +}}, + + }) + fmt.Println(rsp, err) + +} +``` ## Read @@ -116,104 +217,3 @@ Offset: 1, } ``` -## Create - - - - -[https://m3o.com/contact/api#Create](https://m3o.com/contact/api#Create) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/contact" -) - -// -func CreateAcontact() { - contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN")) - rsp, err := contactService.Create(&contact.CreateRequest{ - Addresses: []contact.Address{ -contact.Address{ - Label: "company address", - Location: "123 street address", -}}, -Birthday: "1995-01-01", -Emails: []contact.Email{ -contact.Email{ - Address: "home@example.com", - Label: "home", -}}, -Links: []contact.Link{ -contact.Link{ - Label: "blog", - Url: "https://blog.joe.me", -}}, -Name: "joe", -Note: "this person is very important", -Phones: []contact.Phone{ -contact.Phone{ - Label: "home", - Number: "010-12345678", -}}, - - }) - fmt.Println(rsp, err) - -} -``` -## Update - - - - -[https://m3o.com/contact/api#Update](https://m3o.com/contact/api#Update) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/contact" -) - -// -func UpdateAcontact() { - contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN")) - rsp, err := contactService.Update(&contact.UpdateRequest{ - Addresses: []contact.Address{ -contact.Address{ - Label: "company address", - Location: "123 street address", -}}, -Birthday: "1995-01-01", -Emails: []contact.Email{ -contact.Email{ - Address: "home@example.com", - Label: "home", -}}, -Id: "42e48a3c-6221-11ec-96d2-acde48001122", -Links: []contact.Link{ -contact.Link{ - Label: "blog", - Url: "https://blog.joe.me", -}}, -Name: "joe", -Note: "this person is very important", -Phones: []contact.Phone{ -contact.Phone{ - Label: "home", - Number: "010-12345678", -}}, - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/crypto/README.md b/examples/crypto/README.md index 4f0aca0..ceb1de4 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: +## History + +Returns the history for the previous close + + +[https://m3o.com/crypto/api#History](https://m3o.com/crypto/api#History) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/crypto" +) + +// Returns the history for the previous close +func GetPreviousClose() { + cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN")) + rsp, err := cryptoService.History(&crypto.HistoryRequest{ + Symbol: "BTCUSD", + + }) + fmt.Println(rsp, err) + +} +``` ## News Get news related to a currency @@ -88,31 +116,3 @@ func GetAcryptocurrencyQuote() { } ``` -## History - -Returns the history for the previous close - - -[https://m3o.com/crypto/api#History](https://m3o.com/crypto/api#History) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/crypto" -) - -// Returns the history for the previous close -func GetPreviousClose() { - cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN")) - rsp, err := cryptoService.History(&crypto.HistoryRequest{ - Symbol: "BTCUSD", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/db/README.md b/examples/db/README.md index 5ed2bb1..9fb0f59 100755 --- a/examples/db/README.md +++ b/examples/db/README.md @@ -4,6 +4,33 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/db/api](https: Endpoints: +## ListTables + +List tables in the DB + + +[https://m3o.com/db/api#ListTables](https://m3o.com/db/api#ListTables) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/db" +) + +// List tables in the DB +func ListTables() { + dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) + rsp, err := dbService.ListTables(&db.ListTablesRequest{ + + }) + fmt.Println(rsp, err) + +} +``` ## Create Create a record in the database. Optionally include an "id" field otherwise it's set automatically. @@ -36,66 +63,6 @@ Table: "example", }) fmt.Println(rsp, err) -} -``` -## Update - -Update a record in the database. Include an "id" in the record to update. - - -[https://m3o.com/db/api#Update](https://m3o.com/db/api#Update) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/db" -) - -// Update a record in the database. Include an "id" in the record to update. -func UpdateArecord() { - dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) - rsp, err := dbService.Update(&db.UpdateRequest{ - Record: map[string]interface{}{ - "id": "1", - "age": 43, -}, -Table: "example", - - }) - fmt.Println(rsp, err) - -} -``` -## Truncate - -Truncate the records in a table - - -[https://m3o.com/db/api#Truncate](https://m3o.com/db/api#Truncate) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/db" -) - -// Truncate the records in a table -func TruncateTable() { - dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) - rsp, err := dbService.Truncate(&db.TruncateRequest{ - Table: "example", - - }) - fmt.Println(rsp, err) - } ``` ## Read @@ -154,6 +121,34 @@ 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 @@ -182,6 +177,38 @@ func DropTable() { }) fmt.Println(rsp, err) +} +``` +## Update + +Update a record in the database. Include an "id" in the record to update. + + +[https://m3o.com/db/api#Update](https://m3o.com/db/api#Update) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/db" +) + +// Update a record in the database. Include an "id" in the record to update. +func UpdateArecord() { + dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) + rsp, err := dbService.Update(&db.UpdateRequest{ + Record: map[string]interface{}{ + "id": "1", + "age": 43, +}, +Table: "example", + + }) + fmt.Println(rsp, err) + } ``` ## Count @@ -210,33 +237,6 @@ func CountEntriesInAtable() { }) fmt.Println(rsp, err) -} -``` -## ListTables - -List tables in the DB - - -[https://m3o.com/db/api#ListTables](https://m3o.com/db/api#ListTables) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/db" -) - -// List tables in the DB -func ListTables() { - dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) - rsp, err := dbService.ListTables(&db.ListTablesRequest{ - - }) - fmt.Println(rsp, err) - } ``` ## RenameTable diff --git a/examples/db/create/createARecord/main.go b/examples/db/create/createARecord/main.go index f258334..f094c0c 100755 --- a/examples/db/create/createARecord/main.go +++ b/examples/db/create/createARecord/main.go @@ -12,10 +12,10 @@ func main() { dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) rsp, err := dbService.Create(&db.CreateRequest{ Record: map[string]interface{}{ - "id": "1", - "name": "Jane", "age": 42, "isActive": true, + "id": "1", + "name": "Jane", }, Table: "example", }) diff --git a/examples/emoji/README.md b/examples/emoji/README.md index ea3a4ee..f347720 100755 --- a/examples/emoji/README.md +++ b/examples/emoji/README.md @@ -4,34 +4,6 @@ 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 @@ -119,3 +91,31 @@ 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) + +} +``` diff --git a/examples/event/README.md b/examples/event/README.md index a478169..c8f6f43 100755 --- a/examples/event/README.md +++ b/examples/event/README.md @@ -26,9 +26,9 @@ func PublishAnEvent() { eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN")) rsp, err := eventService.Publish(&event.PublishRequest{ Message: map[string]interface{}{ - "user": "john", "id": "1", "type": "signup", + "user": "john", }, Topic: "user", diff --git a/examples/event/publish/publishAnEvent/main.go b/examples/event/publish/publishAnEvent/main.go index 287af64..5c63360 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{}{ - "id": "1", "type": "signup", "user": "john", + "id": "1", }, Topic: "user", }) diff --git a/examples/function/README.md b/examples/function/README.md index b31f293..d1b3f8d 100755 --- a/examples/function/README.md +++ b/examples/function/README.md @@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/function/api]( Endpoints: +## 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) + +} +``` ## Deploy Deploy a group of functions @@ -94,12 +122,12 @@ func ReserveAfunction() { } ``` -## Proxy +## Delete -Return the backend url for proxying +Delete a function by name -[https://m3o.com/function/api#Proxy](https://m3o.com/function/api#Proxy) +[https://m3o.com/function/api#Delete](https://m3o.com/function/api#Delete) ```go package example @@ -111,15 +139,42 @@ import( "go.m3o.com/function" ) -// Return the backend url for proxying -func ProxyUrl() { +// Delete a function by name +func DeleteAfunction() { functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) - rsp, err := functionService.Proxy(&function.ProxyRequest{ - Id: "helloworld", + rsp, err := functionService.Delete(&function.DeleteRequest{ + 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) + } ``` ## Update @@ -208,58 +263,3 @@ func ListFunctions() { } ``` -## Delete - -Delete a function by name - - -[https://m3o.com/function/api#Delete](https://m3o.com/function/api#Delete) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/function" -) - -// Delete a function by name -func DeleteAfunction() { - functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) - rsp, err := functionService.Delete(&function.DeleteRequest{ - Name: "helloworld", - - }) - fmt.Println(rsp, err) - -} -``` -## 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) - -} -``` diff --git a/examples/geocoding/README.md b/examples/geocoding/README.md index b29fb43..ffc18bb 100755 --- a/examples/geocoding/README.md +++ b/examples/geocoding/README.md @@ -4,35 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/geocoding/api] Endpoints: -## Reverse - -Reverse lookup an address from gps coordinates - - -[https://m3o.com/geocoding/api#Reverse](https://m3o.com/geocoding/api#Reverse) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/geocoding" -) - -// Reverse lookup an address from gps coordinates -func ReverseGeocodeLocation() { - geocodingService := geocoding.NewGeocodingService(os.Getenv("M3O_API_TOKEN")) - rsp, err := geocodingService.Reverse(&geocoding.ReverseRequest{ - Latitude: 51.5123064, -Longitude: -0.1216235, - - }) - fmt.Println(rsp, err) - -} -``` ## Lookup Lookup returns a geocoded address including normalized address and gps coordinates. All fields are optional, provide more to get more accurate results @@ -64,3 +35,32 @@ Postcode: "wc2b", } ``` +## Reverse + +Reverse lookup an address from gps coordinates + + +[https://m3o.com/geocoding/api#Reverse](https://m3o.com/geocoding/api#Reverse) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/geocoding" +) + +// Reverse lookup an address from gps coordinates +func ReverseGeocodeLocation() { + geocodingService := geocoding.NewGeocodingService(os.Getenv("M3O_API_TOKEN")) + rsp, err := geocodingService.Reverse(&geocoding.ReverseRequest{ + Latitude: 51.5123064, +Longitude: -0.1216235, + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/image/README.md b/examples/image/README.md index 6b5b4b5..8da67d8 100755 --- a/examples/image/README.md +++ b/examples/image/README.md @@ -4,125 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/image/api](htt Endpoints: -## Resize - -Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters. -If one of width or height is 0, the image aspect ratio is preserved. -Optional cropping. -To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json -with each parameter as a form field. - - -[https://m3o.com/image/api#Resize](https://m3o.com/image/api#Resize) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/image" -) - -// Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters. -// If one of width or height is 0, the image aspect ratio is preserved. -// Optional cropping. -// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json -// with each parameter as a form field. -func Base64toHostedImage() { - imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN")) - rsp, err := imageService.Resize(&image.ResizeRequest{ - Base64: "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==", -Height: 100, -Name: "cat.png", -Width: 100, - - }) - fmt.Println(rsp, err) - -} -``` -## Resize - -Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters. -If one of width or height is 0, the image aspect ratio is preserved. -Optional cropping. -To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json -with each parameter as a form field. - - -[https://m3o.com/image/api#Resize](https://m3o.com/image/api#Resize) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/image" -) - -// Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters. -// If one of width or height is 0, the image aspect ratio is preserved. -// Optional cropping. -// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json -// with each parameter as a form field. -func Base64toBase64image() { - imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN")) - rsp, err := imageService.Resize(&image.ResizeRequest{ - Base64: "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==", -Height: 100, -Width: 100, - - }) - fmt.Println(rsp, err) - -} -``` -## Resize - -Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters. -If one of width or height is 0, the image aspect ratio is preserved. -Optional cropping. -To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json -with each parameter as a form field. - - -[https://m3o.com/image/api#Resize](https://m3o.com/image/api#Resize) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/image" -) - -// Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters. -// If one of width or height is 0, the image aspect ratio is preserved. -// Optional cropping. -// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json -// with each parameter as a form field. -func Base64toBase64imageWithCropping() { - imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN")) - rsp, err := imageService.Resize(&image.ResizeRequest{ - Base64: "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==", -CropOptions: &image.CropOptions{ - Height: 50, - Width: 50, -}, -Height: 100, -Width: 100, - - }) - fmt.Println(rsp, err) - -} -``` ## Convert Convert an image from one format (jpeg, png etc.) to an other either on the fly (from base64 to base64), @@ -256,3 +137,122 @@ func DeleteAnUploadedImage() { } ``` +## Resize + +Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters. +If one of width or height is 0, the image aspect ratio is preserved. +Optional cropping. +To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json +with each parameter as a form field. + + +[https://m3o.com/image/api#Resize](https://m3o.com/image/api#Resize) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/image" +) + +// Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters. +// If one of width or height is 0, the image aspect ratio is preserved. +// Optional cropping. +// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json +// with each parameter as a form field. +func Base64toHostedImage() { + imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN")) + rsp, err := imageService.Resize(&image.ResizeRequest{ + Base64: "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==", +Height: 100, +Name: "cat.png", +Width: 100, + + }) + fmt.Println(rsp, err) + +} +``` +## Resize + +Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters. +If one of width or height is 0, the image aspect ratio is preserved. +Optional cropping. +To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json +with each parameter as a form field. + + +[https://m3o.com/image/api#Resize](https://m3o.com/image/api#Resize) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/image" +) + +// Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters. +// If one of width or height is 0, the image aspect ratio is preserved. +// Optional cropping. +// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json +// with each parameter as a form field. +func Base64toBase64image() { + imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN")) + rsp, err := imageService.Resize(&image.ResizeRequest{ + Base64: "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==", +Height: 100, +Width: 100, + + }) + fmt.Println(rsp, err) + +} +``` +## Resize + +Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters. +If one of width or height is 0, the image aspect ratio is preserved. +Optional cropping. +To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json +with each parameter as a form field. + + +[https://m3o.com/image/api#Resize](https://m3o.com/image/api#Resize) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/image" +) + +// Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters. +// If one of width or height is 0, the image aspect ratio is preserved. +// Optional cropping. +// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json +// with each parameter as a form field. +func Base64toBase64imageWithCropping() { + imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN")) + rsp, err := imageService.Resize(&image.ResizeRequest{ + Base64: "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==", +CropOptions: &image.CropOptions{ + Height: 50, + Width: 50, +}, +Height: 100, +Width: 100, + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/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/minecraft/README.md b/examples/minecraft/README.md new file mode 100755 index 0000000..33ed863 --- /dev/null +++ b/examples/minecraft/README.md @@ -0,0 +1,34 @@ +# Minecraft + +An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/minecraft/api](https://m3o.com/minecraft/api). + +Endpoints: + +## Ping + +Ping a minecraft server + + +[https://m3o.com/minecraft/api#Ping](https://m3o.com/minecraft/api#Ping) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/minecraft" +) + +// Ping a minecraft server +func PingAminecraftServer() { + minecraftService := minecraft.NewMinecraftService(os.Getenv("M3O_API_TOKEN")) + rsp, err := minecraftService.Ping(&minecraft.PingRequest{ + Address: "funcraft.net", + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/minecraft/ping/pingAMinecraftServer/main.go b/examples/minecraft/ping/pingAMinecraftServer/main.go new file mode 100755 index 0000000..d7f4ff8 --- /dev/null +++ b/examples/minecraft/ping/pingAMinecraftServer/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/minecraft" +) + +// Ping a minecraft server +func main() { + minecraftService := minecraft.NewMinecraftService(os.Getenv("M3O_API_TOKEN")) + rsp, err := minecraftService.Ping(&minecraft.PingRequest{ + Address: "funcraft.net", + }) + 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 9e98ae9..6d6064b 100755 --- a/examples/notes/README.md +++ b/examples/notes/README.md @@ -4,63 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/notes/api](htt Endpoints: -## 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 @@ -189,3 +132,60 @@ func SubscribeToEvents() { } } ``` +## 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/ping/README.md b/examples/ping/README.md new file mode 100755 index 0000000..54dea8b --- /dev/null +++ b/examples/ping/README.md @@ -0,0 +1,90 @@ +# Ping + +An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/ping/api](https://m3o.com/ping/api). + +Endpoints: + +## Ip + +Ping an IP address + + +[https://m3o.com/ping/api#Ip](https://m3o.com/ping/api#Ip) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/ping" +) + +// Ping an IP address +func PingAnIp() { + pingService := ping.NewPingService(os.Getenv("M3O_API_TOKEN")) + rsp, err := pingService.Ip(&ping.IpRequest{ + Address: "google.com", + + }) + fmt.Println(rsp, err) + +} +``` +## Tcp + +Ping a TCP port is open + + +[https://m3o.com/ping/api#Tcp](https://m3o.com/ping/api#Tcp) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/ping" +) + +// Ping a TCP port is open +func DialAtcpAddress() { + pingService := ping.NewPingService(os.Getenv("M3O_API_TOKEN")) + rsp, err := pingService.Tcp(&ping.TcpRequest{ + Address: "google.com:80", + + }) + fmt.Println(rsp, err) + +} +``` +## 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/ping/ip/pingAnIp/main.go b/examples/ping/ip/pingAnIp/main.go new file mode 100755 index 0000000..994c49d --- /dev/null +++ b/examples/ping/ip/pingAnIp/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/ping" +) + +// Ping an IP address +func main() { + pingService := ping.NewPingService(os.Getenv("M3O_API_TOKEN")) + rsp, err := pingService.Ip(&ping.IpRequest{ + Address: "google.com", + }) + fmt.Println(rsp, err) +} diff --git a/examples/ping/tcp/dialATcpAddress/main.go b/examples/ping/tcp/dialATcpAddress/main.go new file mode 100755 index 0000000..6100917 --- /dev/null +++ b/examples/ping/tcp/dialATcpAddress/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/ping" +) + +// Ping a TCP port is open +func main() { + pingService := ping.NewPingService(os.Getenv("M3O_API_TOKEN")) + rsp, err := pingService.Tcp(&ping.TcpRequest{ + Address: "google.com:80", + }) + fmt.Println(rsp, err) +} diff --git a/examples/ping/url/checkAUrl/main.go b/examples/ping/url/checkAUrl/main.go new file mode 100755 index 0000000..a23ca47 --- /dev/null +++ b/examples/ping/url/checkAUrl/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/ping" +) + +// Ping a HTTP URL +func main() { + 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/quran/README.md b/examples/quran/README.md index e007ded..7381cb5 100755 --- a/examples/quran/README.md +++ b/examples/quran/README.md @@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/quran/api](htt Endpoints: -## Search - -Search the Quran for any form of query or questions - - -[https://m3o.com/quran/api#Search](https://m3o.com/quran/api#Search) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/quran" -) - -// Search the Quran for any form of query or questions -func SearchTheQuran() { - quranService := quran.NewQuranService(os.Getenv("M3O_API_TOKEN")) - rsp, err := quranService.Search(&quran.SearchRequest{ - Query: "messenger", - - }) - fmt.Println(rsp, err) - -} -``` ## Chapters List the Chapters (surahs) of the Quran @@ -120,3 +92,31 @@ func GetVersesOfAchapter() { } ``` +## Search + +Search the Quran for any form of query or questions + + +[https://m3o.com/quran/api#Search](https://m3o.com/quran/api#Search) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/quran" +) + +// Search the Quran for any form of query or questions +func SearchTheQuran() { + quranService := quran.NewQuranService(os.Getenv("M3O_API_TOKEN")) + rsp, err := quranService.Search(&quran.SearchRequest{ + Query: "messenger", + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/rss/README.md b/examples/rss/README.md index 5cda3e4..81d4c6b 100755 --- a/examples/rss/README.md +++ b/examples/rss/README.md @@ -4,6 +4,61 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/rss/api](https Endpoints: +## List + +List the saved RSS fields + + +[https://m3o.com/rss/api#List](https://m3o.com/rss/api#List) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/rss" +) + +// List the saved RSS fields +func ListRssFeeds() { + rssService := rss.NewRssService(os.Getenv("M3O_API_TOKEN")) + rsp, err := rssService.List(&rss.ListRequest{ + + }) + fmt.Println(rsp, err) + +} +``` +## Remove + +Remove an RSS feed by name + + +[https://m3o.com/rss/api#Remove](https://m3o.com/rss/api#Remove) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/rss" +) + +// Remove an RSS feed by name +func RemoveAfeed() { + rssService := rss.NewRssService(os.Getenv("M3O_API_TOKEN")) + rsp, err := rssService.Remove(&rss.RemoveRequest{ + Name: "bbc", + + }) + fmt.Println(rsp, err) + +} +``` ## Add Add a new RSS feed with a name, url, and category @@ -62,58 +117,3 @@ func ReadAfeed() { } ``` -## List - -List the saved RSS fields - - -[https://m3o.com/rss/api#List](https://m3o.com/rss/api#List) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/rss" -) - -// List the saved RSS fields -func ListRssFeeds() { - rssService := rss.NewRssService(os.Getenv("M3O_API_TOKEN")) - rsp, err := rssService.List(&rss.ListRequest{ - - }) - fmt.Println(rsp, err) - -} -``` -## Remove - -Remove an RSS feed by name - - -[https://m3o.com/rss/api#Remove](https://m3o.com/rss/api#Remove) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/rss" -) - -// Remove an RSS feed by name -func RemoveAfeed() { - rssService := rss.NewRssService(os.Getenv("M3O_API_TOKEN")) - rsp, err := rssService.Remove(&rss.RemoveRequest{ - Name: "bbc", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/search/README.md b/examples/search/README.md index be3999d..d16563c 100755 --- a/examples/search/README.md +++ b/examples/search/README.md @@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/search/api](ht Endpoints: +## 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 @@ -55,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", }, @@ -184,31 +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) - -} -``` diff --git a/examples/stock/README.md b/examples/stock/README.md index 83cd80a..0d497b8 100755 --- a/examples/stock/README.md +++ b/examples/stock/README.md @@ -4,6 +4,62 @@ 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 @@ -65,59 +121,3 @@ Stock: "AAPL", } ``` -## Price - -Get the last price for a given stock ticker - - -[https://m3o.com/stock/api#Price](https://m3o.com/stock/api#Price) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/stock" -) - -// Get the last price for a given stock ticker -func GetAstockPrice() { - stockService := stock.NewStockService(os.Getenv("M3O_API_TOKEN")) - rsp, err := stockService.Price(&stock.PriceRequest{ - Symbol: "AAPL", - - }) - fmt.Println(rsp, err) - -} -``` -## Quote - -Get the last quote for the stock - - -[https://m3o.com/stock/api#Quote](https://m3o.com/stock/api#Quote) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/stock" -) - -// Get the last quote for the stock -func GetAstockQuote() { - stockService := stock.NewStockService(os.Getenv("M3O_API_TOKEN")) - rsp, err := stockService.Quote(&stock.QuoteRequest{ - Symbol: "AAPL", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/stream/README.md b/examples/stream/README.md index 232026e..d35da4f 100755 --- a/examples/stream/README.md +++ b/examples/stream/README.md @@ -4,6 +4,33 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/stream/api](ht Endpoints: +## ListChannels + +List all the active channels + + +[https://m3o.com/stream/api#ListChannels](https://m3o.com/stream/api#ListChannels) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/stream" +) + +// List all the active channels +func ListChannels() { + streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN")) + rsp, err := streamService.ListChannels(&stream.ListChannelsRequest{ + + }) + fmt.Println(rsp, err) + +} +``` ## CreateChannel Create a channel with a given name and description. Channels are created automatically but @@ -92,30 +119,3 @@ func ListMessages() { } ``` -## ListChannels - -List all the active channels - - -[https://m3o.com/stream/api#ListChannels](https://m3o.com/stream/api#ListChannels) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/stream" -) - -// List all the active channels -func ListChannels() { - streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN")) - rsp, err := streamService.ListChannels(&stream.ListChannelsRequest{ - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/twitter/README.md b/examples/twitter/README.md index 19128ad..b65c6ac 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 @@ -87,32 +116,3 @@ func GetAusersTwitterProfile() { } ``` -## Timeline - -Get the timeline for a given user - - -[https://m3o.com/twitter/api#Timeline](https://m3o.com/twitter/api#Timeline) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/twitter" -) - -// Get the timeline for a given user -func GetAtwitterTimeline() { - twitterService := twitter.NewTwitterService(os.Getenv("M3O_API_TOKEN")) - rsp, err := twitterService.Timeline(&twitter.TimelineRequest{ - Limit: 1, -Username: "m3oservices", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/user/README.md b/examples/user/README.md index 3e4dc4e..1b4cd8b 100755 --- a/examples/user/README.md +++ b/examples/user/README.md @@ -4,12 +4,13 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/user/api](http Endpoints: -## UpdatePassword +## Login -Update the account password +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#UpdatePassword](https://m3o.com/user/api#UpdatePassword) +[https://m3o.com/user/api#Login](https://m3o.com/user/api#Login) ```go package example @@ -21,73 +22,13 @@ import( "go.m3o.com/user" ) -// Update the account password -func UpdateTheAccountPassword() { +// 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.UpdatePassword(&user.UpdatePasswordRequest{ - ConfirmPassword: "Password2", -NewPassword: "Password2", -OldPassword: "Password1", -UserId: "user-1", - - }) - 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) - -} -``` -## 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", + rsp, err := userService.Login(&user.LoginRequest{ + Email: "joe@example.com", +Password: "Password1", }) fmt.Println(rsp, err) @@ -125,13 +66,12 @@ Username: "joe", } ``` -## SendPasswordResetEmail +## Logout -Send an email with a verification code to reset password. -Call "ResetPassword" endpoint once user provides the code. +Logout a user account -[https://m3o.com/user/api#SendPasswordResetEmail](https://m3o.com/user/api#SendPasswordResetEmail) +[https://m3o.com/user/api#Logout](https://m3o.com/user/api#Logout) ```go package example @@ -143,16 +83,71 @@ import( "go.m3o.com/user" ) -// Send an email with a verification code to reset password. -// Call "ResetPassword" endpoint once user provides the code. -func SendPasswordResetEmail() { +// Logout a user account +func LogAuserOut() { 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`, + rsp, err := userService.Logout(&user.LogoutRequest{ + SessionId: "df91a612-5b24-4634-99ff-240220ab8f55", + + }) + fmt.Println(rsp, err) + +} +``` +## List + +List all users. Returns a paged list of results + + +[https://m3o.com/user/api#List](https://m3o.com/user/api#List) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/user" +) + +// List all users. Returns a paged list of results +func ListAllUsers() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.List(&user.ListRequest{ + Limit: 100, +Offset: 0, + + }) + fmt.Println(rsp, err) + +} +``` +## UpdatePassword + +Update the account password + + +[https://m3o.com/user/api#UpdatePassword](https://m3o.com/user/api#UpdatePassword) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Update the account password +func UpdateTheAccountPassword() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.UpdatePassword(&user.UpdatePasswordRequest{ + ConfirmPassword: "Password2", +NewPassword: "Password2", +OldPassword: "Password1", +UserId: "user-1", }) fmt.Println(rsp, err) @@ -241,6 +236,132 @@ func ReadAccountByEmail() { }) 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) + +} +``` +## SendMagicLink + +Login using email only - Passwordless + + +[https://m3o.com/user/api#SendMagicLink](https://m3o.com/user/api#SendMagicLink) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Login using email only - Passwordless +func SendAmagicLink() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.SendMagicLink(&user.SendMagicLinkRequest{ + Address: "www.example.com", +Email: "joe@example.com", +Endpoint: "verifytoken", +FromName: "Awesome Dot Com", +Subject: "MagicLink to access your account", +TextContent: `Hi there, + +Click here to access your account $micro_verification_link`, + + }) + fmt.Println(rsp, err) + +} +``` +## VerifyToken + +Check whether the token attached to MagicLink is valid or not. +Ideally, you need to call this endpoint from your http request +handler that handles the endpoint which is specified in the +SendMagicLink request. + + +[https://m3o.com/user/api#VerifyToken](https://m3o.com/user/api#VerifyToken) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Check whether the token attached to MagicLink is valid or not. +// Ideally, you need to call this endpoint from your http request +// handler that handles the endpoint which is specified in the +// SendMagicLink request. +func VerifyAtoken() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.VerifyToken(&user.VerifyTokenRequest{ + Token: "EdsUiidouJJJLldjlloofUiorkojflsWWdld", + + }) + fmt.Println(rsp, err) + +} +``` +## Update + +Update the account username or email + + +[https://m3o.com/user/api#Update](https://m3o.com/user/api#Update) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Update the account username or email +func UpdateAnAccount() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.Update(&user.UpdateRequest{ + Email: "joe+2@example.com", +Id: "user-1", + + }) + fmt.Println(rsp, err) + } ``` ## SendVerificationEmail @@ -290,12 +411,13 @@ Please verify your email by clicking this link: $micro_verification_link`, } ``` -## VerifyEmail +## SendPasswordResetEmail -Verify the email address of an account from a token sent in an email to the user. +Send an email with a verification code to reset password. +Call "ResetPassword" endpoint once user provides the code. -[https://m3o.com/user/api#VerifyEmail](https://m3o.com/user/api#VerifyEmail) +[https://m3o.com/user/api#SendPasswordResetEmail](https://m3o.com/user/api#SendPasswordResetEmail) ```go package example @@ -307,89 +429,28 @@ import( "go.m3o.com/user" ) -// Verify the email address of an account from a token sent in an email to the user. -func VerifyEmail() { +// 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.VerifyEmail(&user.VerifyEmailRequest{ - Token: "012345", - - }) - fmt.Println(rsp, err) - -} -``` -## Login - -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#Login](https://m3o.com/user/api#Login) - -```go -package example - -import( - "fmt" - "os" - - "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() { - userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.Login(&user.LoginRequest{ + rsp, err := userService.SendPasswordResetEmail(&user.SendPasswordResetEmailRequest{ Email: "joe@example.com", -Password: "Password1", - - }) - fmt.Println(rsp, err) - -} -``` -## SendMagicLink - -Login using email only - Passwordless - - -[https://m3o.com/user/api#SendMagicLink](https://m3o.com/user/api#SendMagicLink) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/user" -) - -// Login using email only - Passwordless -func SendAmagicLink() { - userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.SendMagicLink(&user.SendMagicLinkRequest{ - Address: "www.example.com", -Email: "joe@example.com", -Endpoint: "verifytoken", FromName: "Awesome Dot Com", -Subject: "MagicLink to access your account", +Subject: "Password reset", TextContent: `Hi there, - -Click here to access your account $micro_verification_link`, + click here to reset your password: myapp.com/reset/code?=$code`, }) fmt.Println(rsp, err) } ``` -## Update +## ResetPassword -Update the account username or email +Reset password with the code sent by the "SendPasswordResetEmail" endoint. -[https://m3o.com/user/api#Update](https://m3o.com/user/api#Update) +[https://m3o.com/user/api#ResetPassword](https://m3o.com/user/api#ResetPassword) ```go package example @@ -401,12 +462,14 @@ import( "go.m3o.com/user" ) -// Update the account username or email -func UpdateAnAccount() { +// Reset password with the code sent by the "SendPasswordResetEmail" endoint. +func ResetPassword() { userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.Update(&user.UpdateRequest{ - Email: "joe+2@example.com", -Id: "user-1", + rsp, err := userService.ResetPassword(&user.ResetPasswordRequest{ + Code: "012345", +ConfirmPassword: "NewPassword1", +Email: "joe@example.com", +NewPassword: "NewPassword1", }) fmt.Println(rsp, err) @@ -441,12 +504,12 @@ func DeleteUserAccount() { } ``` -## Logout +## ReadSession -Logout a user account +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#Logout](https://m3o.com/user/api#Logout) +[https://m3o.com/user/api#ReadSession](https://m3o.com/user/api#ReadSession) ```go package example @@ -458,10 +521,10 @@ import( "go.m3o.com/user" ) -// Logout a user account -func LogAuserOut() { +// 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.Logout(&user.LogoutRequest{ + rsp, err := userService.ReadSession(&user.ReadSessionRequest{ SessionId: "df91a612-5b24-4634-99ff-240220ab8f55", }) @@ -469,66 +532,3 @@ func LogAuserOut() { } ``` -## List - -List all users. Returns a paged list of results - - -[https://m3o.com/user/api#List](https://m3o.com/user/api#List) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/user" -) - -// List all users. Returns a paged list of results -func ListAllUsers() { - userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.List(&user.ListRequest{ - Limit: 100, -Offset: 0, - - }) - fmt.Println(rsp, err) - -} -``` -## VerifyToken - -Check whether the token attached to MagicLink is valid or not. -Ideally, you need to call this endpoint from your http request -handler that handles the endpoint which is specified in the -SendMagicLink request. - - -[https://m3o.com/user/api#VerifyToken](https://m3o.com/user/api#VerifyToken) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/user" -) - -// Check whether the token attached to MagicLink is valid or not. -// Ideally, you need to call this endpoint from your http request -// handler that handles the endpoint which is specified in the -// SendMagicLink request. -func VerifyAtoken() { - userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.VerifyToken(&user.VerifyTokenRequest{ - Token: "EdsUiidouJJJLldjlloofUiorkojflsWWdld", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/weather/README.md b/examples/weather/README.md index 4fa715b..43c5660 100755 --- a/examples/weather/README.md +++ b/examples/weather/README.md @@ -4,34 +4,6 @@ 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 @@ -61,3 +33,31 @@ Location: "London", } ``` +## Now + +Get the current weather report for a location by postcode, city, zip code, ip address + + +[https://m3o.com/weather/api#Now](https://m3o.com/weather/api#Now) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/weather" +) + +// Get the current weather report for a location by postcode, city, zip code, ip address +func GetCurrentWeather() { + weatherService := weather.NewWeatherService(os.Getenv("M3O_API_TOKEN")) + rsp, err := weatherService.Now(&weather.NowRequest{ + Location: "london", + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/m3o.go b/m3o.go index 838768f..666e7d9 100755 --- a/m3o.go +++ b/m3o.go @@ -28,12 +28,14 @@ import ( "go.m3o.com/ip" "go.m3o.com/joke" "go.m3o.com/location" + "go.m3o.com/minecraft" "go.m3o.com/movie" "go.m3o.com/mq" "go.m3o.com/news" "go.m3o.com/nft" "go.m3o.com/notes" "go.m3o.com/otp" + "go.m3o.com/ping" "go.m3o.com/postcode" "go.m3o.com/prayer" "go.m3o.com/qr" @@ -90,12 +92,14 @@ func NewClient(token string) *Client { IpService: ip.NewIpService(token), JokeService: joke.NewJokeService(token), LocationService: location.NewLocationService(token), + MinecraftService: minecraft.NewMinecraftService(token), MovieService: movie.NewMovieService(token), MqService: mq.NewMqService(token), NewsService: news.NewNewsService(token), NftService: nft.NewNftService(token), NotesService: notes.NewNotesService(token), OtpService: otp.NewOtpService(token), + PingService: ping.NewPingService(token), PostcodeService: postcode.NewPostcodeService(token), PrayerService: prayer.NewPrayerService(token), QrService: qr.NewQrService(token), @@ -152,12 +156,14 @@ type Client struct { IpService *ip.IpService JokeService *joke.JokeService LocationService *location.LocationService + MinecraftService *minecraft.MinecraftService MovieService *movie.MovieService MqService *mq.MqService NewsService *news.NewsService NftService *nft.NftService NotesService *notes.NotesService OtpService *otp.OtpService + PingService *ping.PingService PostcodeService *postcode.PostcodeService PrayerService *prayer.PrayerService QrService *qr.QrService diff --git a/minecraft/minecraft.go b/minecraft/minecraft.go new file mode 100755 index 0000000..d1e2abd --- /dev/null +++ b/minecraft/minecraft.go @@ -0,0 +1,60 @@ +package minecraft + +import ( + "go.m3o.com/client" +) + +type Minecraft interface { + Ping(*PingRequest) (*PingResponse, error) +} + +func NewMinecraftService(token string) *MinecraftService { + return &MinecraftService{ + client: client.NewClient(&client.Options{ + Token: token, + }), + } +} + +type MinecraftService struct { + client *client.Client +} + +// Ping a minecraft server +func (t *MinecraftService) Ping(request *PingRequest) (*PingResponse, error) { + + rsp := &PingResponse{} + return rsp, t.client.Call("minecraft", "Ping", request, rsp) + +} + +type PingRequest struct { + // address of the server + Address string `json:"address"` +} + +type PingResponse struct { + // Favicon in base64 + Favicon string `json:"favicon"` + // Latency (ms) between us and the server (EU) + Latency int32 `json:"latency"` + // Max players ever + MaxPlayers int32 `json:"max_players"` + // Message of the day + Motd string `json:"motd"` + // Number of players online + Players int32 `json:"players"` + // Protocol number of the server + Protocol int32 `json:"protocol"` + // List of connected players + Sample []PlayerSample `json:"sample"` + // Version of the server + Version string `json:"version"` +} + +type PlayerSample struct { + // name of the player + Name string `json:"name"` + // unique id of player + Uuid string `json:"uuid"` +} diff --git a/ping/ping.go b/ping/ping.go new file mode 100755 index 0000000..48ba1be --- /dev/null +++ b/ping/ping.go @@ -0,0 +1,87 @@ +package ping + +import ( + "go.m3o.com/client" +) + +type Ping interface { + Ip(*IpRequest) (*IpResponse, error) + Tcp(*TcpRequest) (*TcpResponse, error) + Url(*UrlRequest) (*UrlResponse, error) +} + +func NewPingService(token string) *PingService { + return &PingService{ + client: client.NewClient(&client.Options{ + Token: token, + }), + } +} + +type PingService struct { + client *client.Client +} + +// Ping an IP address +func (t *PingService) Ip(request *IpRequest) (*IpResponse, error) { + + rsp := &IpResponse{} + return rsp, t.client.Call("ping", "Ip", request, rsp) + +} + +// Ping a TCP port is open +func (t *PingService) Tcp(request *TcpRequest) (*TcpResponse, error) { + + rsp := &TcpResponse{} + return rsp, t.client.Call("ping", "Tcp", request, rsp) + +} + +// Ping a HTTP URL +func (t *PingService) Url(request *UrlRequest) (*UrlResponse, error) { + + rsp := &UrlResponse{} + return rsp, t.client.Call("ping", "Url", request, rsp) + +} + +type IpRequest struct { + // address to ping + Address string `json:"address"` +} + +type IpResponse struct { + // average latency e.g 10ms + Latency string `json:"latency"` + // response status + Status string `json:"status"` +} + +type TcpRequest struct { + // address to dial + Address string `json:"address"` + // optional data to send + Data string `json:"data"` +} + +type TcpResponse struct { + // response data if any + Data string `json:"data"` + // response status + Status string `json:"status"` +} + +type UrlRequest struct { + // address to use + Address string `json:"address"` + // method of the call + Method string `json:"method"` +} + +type UrlResponse struct { + // the response code + Code int32 `json:"code"` + // the response status + Status string `json:"status"` +}