diff --git a/examples/address/README.md b/examples/address/README.md new file mode 100755 index 0000000..4677456 --- /dev/null +++ b/examples/address/README.md @@ -0,0 +1,33 @@ +# Address + +An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Address/api](https://m3o.com/Address/api). + +Endpoints: + +## LookupPostcode + +Lookup a list of UK addresses by postcode + + +[https://m3o.com/address/api#LookupPostcode](https://m3o.com/address/api#LookupPostcode) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/address" +) + +// Lookup a list of UK addresses by postcode +func LookupPostcode() { + addressService := address.NewAddressService(os.Getenv("M3O_API_TOKEN")) + rsp, err := addressService.LookupPostcode(&address.LookupPostcodeRequest{ + Postcode: "SW1A 2AA", + + }) + fmt.Println(rsp, err) +} +``` diff --git a/examples/address/lookupPostcode/lookupPostcode.go b/examples/address/lookupPostcode/lookupPostcode.go new file mode 100755 index 0000000..456412d --- /dev/null +++ b/examples/address/lookupPostcode/lookupPostcode.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/address" +) + +// Lookup a list of UK addresses by postcode +func LookupPostcode() { + addressService := address.NewAddressService(os.Getenv("M3O_API_TOKEN")) + rsp, err := addressService.LookupPostcode(&address.LookupPostcodeRequest{ + Postcode: "SW1A 2AA", + }) + fmt.Println(rsp, err) +} diff --git a/examples/answer/README.md b/examples/answer/README.md new file mode 100755 index 0000000..c56dfe6 --- /dev/null +++ b/examples/answer/README.md @@ -0,0 +1,33 @@ +# Answer + +An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Answer/api](https://m3o.com/Answer/api). + +Endpoints: + +## Question + +Ask a question and receive an instant answer + + +[https://m3o.com/answer/api#Question](https://m3o.com/answer/api#Question) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/answer" +) + +// Ask a question and receive an instant answer +func AskAquestion() { + answerService := answer.NewAnswerService(os.Getenv("M3O_API_TOKEN")) + rsp, err := answerService.Question(&answer.QuestionRequest{ + Query: "microsoft", + + }) + fmt.Println(rsp, err) +} +``` diff --git a/examples/answer/question/askAQuestion.go b/examples/answer/question/askAQuestion.go new file mode 100755 index 0000000..14f96c1 --- /dev/null +++ b/examples/answer/question/askAQuestion.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/answer" +) + +// Ask a question and receive an instant answer +func AskAquestion() { + answerService := answer.NewAnswerService(os.Getenv("M3O_API_TOKEN")) + rsp, err := answerService.Question(&answer.QuestionRequest{ + Query: "microsoft", + }) + fmt.Println(rsp, err) +} diff --git a/examples/cache/README.md b/examples/cache/README.md new file mode 100755 index 0000000..7a06dbf --- /dev/null +++ b/examples/cache/README.md @@ -0,0 +1,144 @@ +# Cache + +An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Cache/api](https://m3o.com/Cache/api). + +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" + + "github.com/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 + + +[https://m3o.com/cache/api#Get](https://m3o.com/cache/api#Get) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/cache" +) + +// Get an item from the cache by key +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 + + +[https://m3o.com/cache/api#Delete](https://m3o.com/cache/api#Delete) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/cache" +) + +// Delete a value from the cache +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) + + +[https://m3o.com/cache/api#Increment](https://m3o.com/cache/api#Increment) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/cache" +) + +// Increment a value (if it's a number) +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) + + +[https://m3o.com/cache/api#Decrement](https://m3o.com/cache/api#Decrement) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/cache" +) + +// Decrement a value (if it's a number) +func DecrementAvalue() { + cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN")) + rsp, err := cacheService.Decrement(&cache.DecrementRequest{ + Key: "counter", +Value: 2, + + }) + fmt.Println(rsp, err) +} +``` diff --git a/examples/cache/decrement/decrementAValue.go b/examples/cache/decrement/decrementAValue.go new file mode 100755 index 0000000..21526f9 --- /dev/null +++ b/examples/cache/decrement/decrementAValue.go @@ -0,0 +1,18 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/cache" +) + +// Decrement a value (if it's a number) +func DecrementAvalue() { + cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN")) + rsp, err := cacheService.Decrement(&cache.DecrementRequest{ + Key: "counter", + Value: 2, + }) + fmt.Println(rsp, err) +} diff --git a/examples/cache/delete/deleteAValue.go b/examples/cache/delete/deleteAValue.go new file mode 100755 index 0000000..47f34b5 --- /dev/null +++ b/examples/cache/delete/deleteAValue.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/cache" +) + +// Delete a value from the cache +func DeleteAvalue() { + cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN")) + rsp, err := cacheService.Delete(&cache.DeleteRequest{ + Key: "foo", + }) + fmt.Println(rsp, err) +} diff --git a/examples/cache/get/getAValue.go b/examples/cache/get/getAValue.go new file mode 100755 index 0000000..95858cb --- /dev/null +++ b/examples/cache/get/getAValue.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/cache" +) + +// Get an item from the cache by key +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/cache/increment/incrementAValue.go b/examples/cache/increment/incrementAValue.go new file mode 100755 index 0000000..f43c563 --- /dev/null +++ b/examples/cache/increment/incrementAValue.go @@ -0,0 +1,18 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/cache" +) + +// Increment a value (if it's a number) +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/cache/set/setAValue.go b/examples/cache/set/setAValue.go new file mode 100755 index 0000000..a7879c3 --- /dev/null +++ b/examples/cache/set/setAValue.go @@ -0,0 +1,18 @@ +package example + +import ( + "fmt" + "os" + + "github.com/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) +} diff --git a/examples/crypto/README.md b/examples/crypto/README.md new file mode 100755 index 0000000..803a8e4 --- /dev/null +++ b/examples/crypto/README.md @@ -0,0 +1,114 @@ +# Crypto + +An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Crypto/api](https://m3o.com/Crypto/api). + +Endpoints: + +## Quote + +Get the last quote for a given crypto ticker + + +[https://m3o.com/crypto/api#Quote](https://m3o.com/crypto/api#Quote) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/crypto" +) + +// Get the last quote for a given crypto ticker +func GetAcryptocurrencyQuote() { + cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN")) + rsp, err := cryptoService.Quote(&crypto.QuoteRequest{ + Symbol: "BTCUSD", + + }) + fmt.Println(rsp, err) +} +``` +## History + +Returns the history for the previous close + + +[https://m3o.com/crypto/api#History](https://m3o.com/crypto/api#History) + +```go +package example + +import( + "fmt" + "os" + + "github.com/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 + + +[https://m3o.com/crypto/api#News](https://m3o.com/crypto/api#News) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/crypto" +) + +// Get news related to a currency +func GetCryptocurrencyNews() { + cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN")) + rsp, err := cryptoService.News(&crypto.NewsRequest{ + Symbol: "BTCUSD", + + }) + fmt.Println(rsp, err) +} +``` +## Price + +Get the last price for a given crypto ticker + + +[https://m3o.com/crypto/api#Price](https://m3o.com/crypto/api#Price) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/crypto" +) + +// Get the last price for a given crypto ticker +func GetCryptocurrencyPrice() { + cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN")) + rsp, err := cryptoService.Price(&crypto.PriceRequest{ + Symbol: "BTCUSD", + + }) + fmt.Println(rsp, err) +} +``` diff --git a/examples/crypto/history/getPreviousClose.go b/examples/crypto/history/getPreviousClose.go new file mode 100755 index 0000000..5105c5d --- /dev/null +++ b/examples/crypto/history/getPreviousClose.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/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/crypto/news/getCryptocurrencyNews.go b/examples/crypto/news/getCryptocurrencyNews.go new file mode 100755 index 0000000..76df79e --- /dev/null +++ b/examples/crypto/news/getCryptocurrencyNews.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/crypto" +) + +// Get news related to a currency +func GetCryptocurrencyNews() { + cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN")) + rsp, err := cryptoService.News(&crypto.NewsRequest{ + Symbol: "BTCUSD", + }) + fmt.Println(rsp, err) +} diff --git a/examples/crypto/price/getCryptocurrencyPrice.go b/examples/crypto/price/getCryptocurrencyPrice.go new file mode 100755 index 0000000..ab37217 --- /dev/null +++ b/examples/crypto/price/getCryptocurrencyPrice.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/crypto" +) + +// Get the last price for a given crypto ticker +func GetCryptocurrencyPrice() { + cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN")) + rsp, err := cryptoService.Price(&crypto.PriceRequest{ + Symbol: "BTCUSD", + }) + fmt.Println(rsp, err) +} diff --git a/examples/crypto/quote/getACryptocurrencyQuote.go b/examples/crypto/quote/getACryptocurrencyQuote.go new file mode 100755 index 0000000..31ab9cc --- /dev/null +++ b/examples/crypto/quote/getACryptocurrencyQuote.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/crypto" +) + +// Get the last quote for a given crypto ticker +func GetAcryptocurrencyQuote() { + cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN")) + rsp, err := cryptoService.Quote(&crypto.QuoteRequest{ + Symbol: "BTCUSD", + }) + fmt.Println(rsp, err) +} diff --git a/examples/currency/README.md b/examples/currency/README.md new file mode 100755 index 0000000..4647616 --- /dev/null +++ b/examples/currency/README.md @@ -0,0 +1,144 @@ +# Currency + +An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Currency/api](https://m3o.com/Currency/api). + +Endpoints: + +## Codes + +Codes returns the supported currency codes for the API + + +[https://m3o.com/currency/api#Codes](https://m3o.com/currency/api#Codes) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/currency" +) + +// Codes returns the supported currency codes for the API +func GetSupportedCodes() { + currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN")) + rsp, err := currencyService.Codes(¤cy.CodesRequest{ + + }) + fmt.Println(rsp, err) +} +``` +## Rates + +Rates returns the currency rates for a given code e.g USD + + +[https://m3o.com/currency/api#Rates](https://m3o.com/currency/api#Rates) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/currency" +) + +// Rates returns the currency rates for a given code e.g USD +func GetRatesForUsd() { + currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN")) + rsp, err := currencyService.Rates(¤cy.RatesRequest{ + Code: "USD", + + }) + fmt.Println(rsp, err) +} +``` +## Convert + +Convert returns the currency conversion rate between two pairs e.g USD/GBP + + +[https://m3o.com/currency/api#Convert](https://m3o.com/currency/api#Convert) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/currency" +) + +// Convert returns the currency conversion rate between two pairs e.g USD/GBP +func ConvertUsdToGbp() { + currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN")) + rsp, err := currencyService.Convert(¤cy.ConvertRequest{ + From: "USD", +To: "GBP", + + }) + fmt.Println(rsp, err) +} +``` +## Convert + +Convert returns the currency conversion rate between two pairs e.g USD/GBP + + +[https://m3o.com/currency/api#Convert](https://m3o.com/currency/api#Convert) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/currency" +) + +// Convert returns the currency conversion rate between two pairs e.g USD/GBP +func Convert10usdToGbp() { + currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN")) + rsp, err := currencyService.Convert(¤cy.ConvertRequest{ + Amount: 10, +From: "USD", +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" + + "github.com/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/currency/codes/getSupportedCodes.go b/examples/currency/codes/getSupportedCodes.go new file mode 100755 index 0000000..7b1510f --- /dev/null +++ b/examples/currency/codes/getSupportedCodes.go @@ -0,0 +1,15 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/currency" +) + +// Codes returns the supported currency codes for the API +func GetSupportedCodes() { + currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN")) + rsp, err := currencyService.Codes(¤cy.CodesRequest{}) + fmt.Println(rsp, err) +} diff --git a/examples/currency/convert/convert10UsdToGbp.go b/examples/currency/convert/convert10UsdToGbp.go new file mode 100755 index 0000000..f813626 --- /dev/null +++ b/examples/currency/convert/convert10UsdToGbp.go @@ -0,0 +1,19 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/currency" +) + +// Convert returns the currency conversion rate between two pairs e.g USD/GBP +func Convert10usdToGbp() { + currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN")) + rsp, err := currencyService.Convert(¤cy.ConvertRequest{ + Amount: 10, + From: "USD", + To: "GBP", + }) + fmt.Println(rsp, err) +} diff --git a/examples/currency/convert/convertUsdToGbp.go b/examples/currency/convert/convertUsdToGbp.go new file mode 100755 index 0000000..34e83f9 --- /dev/null +++ b/examples/currency/convert/convertUsdToGbp.go @@ -0,0 +1,18 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/currency" +) + +// Convert returns the currency conversion rate between two pairs e.g USD/GBP +func ConvertUsdToGbp() { + currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN")) + rsp, err := currencyService.Convert(¤cy.ConvertRequest{ + From: "USD", + To: "GBP", + }) + fmt.Println(rsp, err) +} diff --git a/examples/currency/history/historicRatesForACurrency.go b/examples/currency/history/historicRatesForACurrency.go new file mode 100755 index 0000000..81ee458 --- /dev/null +++ b/examples/currency/history/historicRatesForACurrency.go @@ -0,0 +1,18 @@ +package example + +import ( + "fmt" + "os" + + "github.com/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/currency/rates/getRatesForUsd.go b/examples/currency/rates/getRatesForUsd.go new file mode 100755 index 0000000..51225e5 --- /dev/null +++ b/examples/currency/rates/getRatesForUsd.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/currency" +) + +// Rates returns the currency rates for a given code e.g USD +func GetRatesForUsd() { + currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN")) + rsp, err := currencyService.Rates(¤cy.RatesRequest{ + Code: "USD", + }) + fmt.Println(rsp, err) +} diff --git a/examples/db/README.md b/examples/db/README.md new file mode 100755 index 0000000..9007c85 --- /dev/null +++ b/examples/db/README.md @@ -0,0 +1,180 @@ +# Db + +An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Db/api](https://m3o.com/Db/api). + +Endpoints: + +## Create + +Create a record in the database. Optionally include an "id" field otherwise it's set automatically. + + +[https://m3o.com/db/api#Create](https://m3o.com/db/api#Create) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/db" +) + +// Create a record in the database. Optionally include an "id" field otherwise it's set automatically. +func CreateArecord() { + dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) + rsp, err := dbService.Create(&db.CreateRequest{ + Record: map[string]interface{}{ + "id": "1", + "name": "Jane", + "age": 42, + "isActive": true, +}, +Table: "users", + + }) + 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" + + "github.com/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{}{ + "age": 43, + "id": "1", +}, +Table: "users", + + }) + fmt.Println(rsp, err) +} +``` +## Read + +Read data from a table. Lookup can be by ID or via querying any field in the record. + + +[https://m3o.com/db/api#Read](https://m3o.com/db/api#Read) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/db" +) + +// Read data from a table. Lookup can be by ID or via querying any field in the record. +func ReadRecords() { + dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) + rsp, err := dbService.Read(&db.ReadRequest{ + Query: "age == 43", +Table: "users", + + }) + fmt.Println(rsp, err) +} +``` +## Delete + +Delete a record in the database by id. + + +[https://m3o.com/db/api#Delete](https://m3o.com/db/api#Delete) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/db" +) + +// Delete a record in the database by id. +func DeleteArecord() { + dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) + rsp, err := dbService.Delete(&db.DeleteRequest{ + Id: "1", +Table: "users", + + }) + 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" + + "github.com/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: "users", + + }) + 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" + + "github.com/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/count/countEntriesInATable.go b/examples/db/count/countEntriesInATable.go new file mode 100755 index 0000000..695365c --- /dev/null +++ b/examples/db/count/countEntriesInATable.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/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.go b/examples/db/create/createARecord.go new file mode 100755 index 0000000..3c7d116 --- /dev/null +++ b/examples/db/create/createARecord.go @@ -0,0 +1,23 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/db" +) + +// Create a record in the database. Optionally include an "id" field otherwise it's set automatically. +func CreateArecord() { + dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) + rsp, err := dbService.Create(&db.CreateRequest{ + Record: map[string]interface{}{ + "id": "1", + "name": "Jane", + "age": 42, + "isActive": true, + }, + Table: "users", + }) + fmt.Println(rsp, err) +} diff --git a/examples/db/delete/deleteARecord.go b/examples/db/delete/deleteARecord.go new file mode 100755 index 0000000..e43cffb --- /dev/null +++ b/examples/db/delete/deleteARecord.go @@ -0,0 +1,18 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/db" +) + +// Delete a record in the database by id. +func DeleteArecord() { + dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) + rsp, err := dbService.Delete(&db.DeleteRequest{ + Id: "1", + Table: "users", + }) + fmt.Println(rsp, err) +} diff --git a/examples/db/read/readRecords.go b/examples/db/read/readRecords.go new file mode 100755 index 0000000..d6b229d --- /dev/null +++ b/examples/db/read/readRecords.go @@ -0,0 +1,18 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/db" +) + +// Read data from a table. Lookup can be by ID or via querying any field in the record. +func ReadRecords() { + dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) + rsp, err := dbService.Read(&db.ReadRequest{ + Query: "age == 43", + Table: "users", + }) + fmt.Println(rsp, err) +} diff --git a/examples/db/truncate/truncateTable.go b/examples/db/truncate/truncateTable.go new file mode 100755 index 0000000..6e69533 --- /dev/null +++ b/examples/db/truncate/truncateTable.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/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: "users", + }) + fmt.Println(rsp, err) +} diff --git a/examples/db/update/updateARecord.go b/examples/db/update/updateARecord.go new file mode 100755 index 0000000..16042c0 --- /dev/null +++ b/examples/db/update/updateARecord.go @@ -0,0 +1,21 @@ +package example + +import ( + "fmt" + "os" + + "github.com/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{}{ + "age": 43, + "id": "1", + }, + Table: "users", + }) + fmt.Println(rsp, err) +} diff --git a/examples/email/README.md b/examples/email/README.md new file mode 100755 index 0000000..519bcc2 --- /dev/null +++ b/examples/email/README.md @@ -0,0 +1,37 @@ +# Email + +An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Email/api](https://m3o.com/Email/api). + +Endpoints: + +## Send + +Send an email by passing in from, to, subject, and a text or html body + + +[https://m3o.com/email/api#Send](https://m3o.com/email/api#Send) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/email" +) + +// Send an email by passing in from, to, subject, and a text or html body +func SendEmail() { + emailService := email.NewEmailService(os.Getenv("M3O_API_TOKEN")) + rsp, err := emailService.Send(&email.SendRequest{ + From: "Awesome Dot Com", +Subject: "Email verification", +TextBody: `Hi there, + +Please verify your email by clicking this link: $micro_verification_link`, + + }) + fmt.Println(rsp, err) +} +``` diff --git a/examples/email/send/sendEmail.go b/examples/email/send/sendEmail.go new file mode 100755 index 0000000..6f382b8 --- /dev/null +++ b/examples/email/send/sendEmail.go @@ -0,0 +1,21 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/email" +) + +// Send an email by passing in from, to, subject, and a text or html body +func SendEmail() { + emailService := email.NewEmailService(os.Getenv("M3O_API_TOKEN")) + rsp, err := emailService.Send(&email.SendRequest{ + From: "Awesome Dot Com", + Subject: "Email verification", + TextBody: `Hi there, + +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 new file mode 100755 index 0000000..74b334a --- /dev/null +++ b/examples/emoji/README.md @@ -0,0 +1,117 @@ +# Emoji + +An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Emoji/api](https://m3o.com/Emoji/api). + +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" + + "github.com/go.m3o.com/emoji" +) + +// Find an emoji by its alias e.g :beer: +func FindEmoji() { + emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN")) + rsp, err := emojiService.Find(&emoji.FindRequest{ + Alias: ":beer:", + + }) + fmt.Println(rsp, err) +} +``` +## Flag + +Get the flag for a country. Requires country code e.g GB for great britain + + +[https://m3o.com/emoji/api#Flag](https://m3o.com/emoji/api#Flag) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/emoji" +) + +// Get the flag for a country. Requires country code e.g GB for great britain +func GetFlagByCountryCode() { + emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN")) + rsp, err := emojiService.Flag(&emoji.FlagRequest{ + + }) + fmt.Println(rsp, err) +} +``` +## Print + +Print text and renders the emojis with aliases e.g +let's grab a :beer: becomes let's grab a 🍺 + + +[https://m3o.com/emoji/api#Print](https://m3o.com/emoji/api#Print) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/emoji" +) + +// Print text and renders the emojis with aliases e.g +// let's grab a :beer: becomes let's grab a 🍺 +func PrintTextIncludingEmoji() { + emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN")) + rsp, err := emojiService.Print(&emoji.PrintRequest{ + Text: "let's grab a :beer:", + + }) + fmt.Println(rsp, err) +} +``` +## Send + +Send an emoji to anyone via SMS. Messages are sent in the form ' Sent from ' + + +[https://m3o.com/emoji/api#Send](https://m3o.com/emoji/api#Send) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/emoji" +) + +// Send an emoji to anyone via SMS. Messages are sent in the form ' Sent from ' +func SendAtextContainingAnEmojiToAnyoneViaSms() { + emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN")) + rsp, err := emojiService.Send(&emoji.SendRequest{ + From: "Alice", +Message: "let's grab a :beer:", +To: "+44782669123", + + }) + fmt.Println(rsp, err) +} +``` diff --git a/examples/emoji/find/findEmoji.go b/examples/emoji/find/findEmoji.go new file mode 100755 index 0000000..33acd3f --- /dev/null +++ b/examples/emoji/find/findEmoji.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/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/emoji/flag/getFlagByCountryCode.go b/examples/emoji/flag/getFlagByCountryCode.go new file mode 100755 index 0000000..6ec6bf7 --- /dev/null +++ b/examples/emoji/flag/getFlagByCountryCode.go @@ -0,0 +1,15 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/emoji" +) + +// Get the flag for a country. Requires country code e.g GB for great britain +func GetFlagByCountryCode() { + emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN")) + rsp, err := emojiService.Flag(&emoji.FlagRequest{}) + fmt.Println(rsp, err) +} diff --git a/examples/emoji/print/printTextIncludingEmoji.go b/examples/emoji/print/printTextIncludingEmoji.go new file mode 100755 index 0000000..065de45 --- /dev/null +++ b/examples/emoji/print/printTextIncludingEmoji.go @@ -0,0 +1,18 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/emoji" +) + +// Print text and renders the emojis with aliases e.g +// let's grab a :beer: becomes let's grab a 🍺 +func PrintTextIncludingEmoji() { + emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN")) + rsp, err := emojiService.Print(&emoji.PrintRequest{ + Text: "let's grab a :beer:", + }) + fmt.Println(rsp, err) +} diff --git a/examples/emoji/send/sendATextContainingAnEmojiToAnyoneViaSms.go b/examples/emoji/send/sendATextContainingAnEmojiToAnyoneViaSms.go new file mode 100755 index 0000000..3448d7f --- /dev/null +++ b/examples/emoji/send/sendATextContainingAnEmojiToAnyoneViaSms.go @@ -0,0 +1,19 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/emoji" +) + +// Send an emoji to anyone via SMS. Messages are sent in the form ' Sent from ' +func SendAtextContainingAnEmojiToAnyoneViaSms() { + emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN")) + rsp, err := emojiService.Send(&emoji.SendRequest{ + From: "Alice", + Message: "let's grab a :beer:", + To: "+44782669123", + }) + fmt.Println(rsp, err) +} diff --git a/examples/evchargers/README.md b/examples/evchargers/README.md new file mode 100755 index 0000000..627f7be --- /dev/null +++ b/examples/evchargers/README.md @@ -0,0 +1,123 @@ +# Evchargers + +An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Evchargers/api](https://m3o.com/Evchargers/api). + +Endpoints: + +## Search + +Search by giving a coordinate and a max distance, or bounding box and optional filters + + +[https://m3o.com/evchargers/api#Search](https://m3o.com/evchargers/api#Search) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/evchargers" +) + +// Search by giving a coordinate and a max distance, or bounding box and optional filters +func SearchByLocation() { + evchargersService := evchargers.NewEvchargersService(os.Getenv("M3O_API_TOKEN")) + rsp, err := evchargersService.Search(&evchargers.SearchRequest{ + Distance: 2000, +Location: &evchargers.Coordinates{ + Latitude: 51.53336351319885, + Longitude: -0.0252, +}, + + }) + fmt.Println(rsp, err) +} +``` +## Search + +Search by giving a coordinate and a max distance, or bounding box and optional filters + + +[https://m3o.com/evchargers/api#Search](https://m3o.com/evchargers/api#Search) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/evchargers" +) + +// Search by giving a coordinate and a max distance, or bounding box and optional filters +func SearchByBoundingBox() { + evchargersService := evchargers.NewEvchargersService(os.Getenv("M3O_API_TOKEN")) + rsp, err := evchargersService.Search(&evchargers.SearchRequest{ + Box: &evchargers.BoundingBox{ + }, + + }) + fmt.Println(rsp, err) +} +``` +## Search + +Search by giving a coordinate and a max distance, or bounding box and optional filters + + +[https://m3o.com/evchargers/api#Search](https://m3o.com/evchargers/api#Search) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/evchargers" +) + +// Search by giving a coordinate and a max distance, or bounding box and optional filters +func SearchWithFiltersFastChargersOnly() { + evchargersService := evchargers.NewEvchargersService(os.Getenv("M3O_API_TOKEN")) + rsp, err := evchargersService.Search(&evchargers.SearchRequest{ + Distance: 2000, +Levels: []string{"3"}, +Location: &evchargers.Coordinates{ + Latitude: 51.53336351319885, + Longitude: -0.0252, +}, + + }) + fmt.Println(rsp, err) +} +``` +## ReferenceData + +Retrieve reference data as used by this API and in conjunction with the Search endpoint + + +[https://m3o.com/evchargers/api#ReferenceData](https://m3o.com/evchargers/api#ReferenceData) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/evchargers" +) + +// Retrieve reference data as used by this API and in conjunction with the Search endpoint +func GetReferenceData() { + evchargersService := evchargers.NewEvchargersService(os.Getenv("M3O_API_TOKEN")) + rsp, err := evchargersService.ReferenceData(&evchargers.ReferenceDataRequest{ + + }) + fmt.Println(rsp, err) +} +``` diff --git a/examples/evchargers/referenceData/getReferenceData.go b/examples/evchargers/referenceData/getReferenceData.go new file mode 100755 index 0000000..e31eaf4 --- /dev/null +++ b/examples/evchargers/referenceData/getReferenceData.go @@ -0,0 +1,15 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/evchargers" +) + +// Retrieve reference data as used by this API and in conjunction with the Search endpoint +func GetReferenceData() { + evchargersService := evchargers.NewEvchargersService(os.Getenv("M3O_API_TOKEN")) + rsp, err := evchargersService.ReferenceData(&evchargers.ReferenceDataRequest{}) + fmt.Println(rsp, err) +} diff --git a/examples/evchargers/search/searchByBoundingBox.go b/examples/evchargers/search/searchByBoundingBox.go new file mode 100755 index 0000000..6f5e71a --- /dev/null +++ b/examples/evchargers/search/searchByBoundingBox.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/evchargers" +) + +// Search by giving a coordinate and a max distance, or bounding box and optional filters +func SearchByBoundingBox() { + evchargersService := evchargers.NewEvchargersService(os.Getenv("M3O_API_TOKEN")) + rsp, err := evchargersService.Search(&evchargers.SearchRequest{ + Box: &evchargers.BoundingBox{}, + }) + fmt.Println(rsp, err) +} diff --git a/examples/evchargers/search/searchByLocation.go b/examples/evchargers/search/searchByLocation.go new file mode 100755 index 0000000..df0ae26 --- /dev/null +++ b/examples/evchargers/search/searchByLocation.go @@ -0,0 +1,21 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/evchargers" +) + +// Search by giving a coordinate and a max distance, or bounding box and optional filters +func SearchByLocation() { + evchargersService := evchargers.NewEvchargersService(os.Getenv("M3O_API_TOKEN")) + rsp, err := evchargersService.Search(&evchargers.SearchRequest{ + Distance: 2000, + Location: &evchargers.Coordinates{ + Latitude: 51.53336351319885, + Longitude: -0.0252, + }, + }) + fmt.Println(rsp, err) +} diff --git a/examples/evchargers/search/searchWithFiltersFastChargersOnly.go b/examples/evchargers/search/searchWithFiltersFastChargersOnly.go new file mode 100755 index 0000000..7a43c3a --- /dev/null +++ b/examples/evchargers/search/searchWithFiltersFastChargersOnly.go @@ -0,0 +1,22 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/evchargers" +) + +// Search by giving a coordinate and a max distance, or bounding box and optional filters +func SearchWithFiltersFastChargersOnly() { + evchargersService := evchargers.NewEvchargersService(os.Getenv("M3O_API_TOKEN")) + rsp, err := evchargersService.Search(&evchargers.SearchRequest{ + Distance: 2000, + Levels: []string{"3"}, + Location: &evchargers.Coordinates{ + Latitude: 51.53336351319885, + Longitude: -0.0252, + }, + }) + fmt.Println(rsp, err) +} diff --git a/examples/file/README.md b/examples/file/README.md new file mode 100755 index 0000000..d5e9b51 --- /dev/null +++ b/examples/file/README.md @@ -0,0 +1,120 @@ +# File + +An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/File/api](https://m3o.com/File/api). + +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" + + "github.com/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" + + "github.com/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" + + "github.com/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 + + +[https://m3o.com/file/api#Save](https://m3o.com/file/api#Save) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/file" +) + +// Save a file +func SaveFile() { + fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN")) + rsp, err := fileService.Save(&file.SaveRequest{ + File: &file.Record{ + Content: "file content example", + Path: "/document/text-files/file.txt", + Project: "examples", + }, + + }) + fmt.Println(rsp, err) +} +``` diff --git a/examples/file/delete/deleteFile.go b/examples/file/delete/deleteFile.go new file mode 100755 index 0000000..9db89e0 --- /dev/null +++ b/examples/file/delete/deleteFile.go @@ -0,0 +1,18 @@ +package example + +import ( + "fmt" + "os" + + "github.com/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) +} diff --git a/examples/file/list/listFiles.go b/examples/file/list/listFiles.go new file mode 100755 index 0000000..83f570b --- /dev/null +++ b/examples/file/list/listFiles.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/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) +} diff --git a/examples/file/read/readFile.go b/examples/file/read/readFile.go new file mode 100755 index 0000000..1ec71fa --- /dev/null +++ b/examples/file/read/readFile.go @@ -0,0 +1,18 @@ +package example + +import ( + "fmt" + "os" + + "github.com/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/file/save/saveFile.go b/examples/file/save/saveFile.go new file mode 100755 index 0000000..d588765 --- /dev/null +++ b/examples/file/save/saveFile.go @@ -0,0 +1,21 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/file" +) + +// Save a file +func SaveFile() { + fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN")) + rsp, err := fileService.Save(&file.SaveRequest{ + File: &file.Record{ + Content: "file content example", + Path: "/document/text-files/file.txt", + Project: "examples", + }, + }) + fmt.Println(rsp, err) +} diff --git a/examples/forex/README.md b/examples/forex/README.md new file mode 100755 index 0000000..f750a23 --- /dev/null +++ b/examples/forex/README.md @@ -0,0 +1,87 @@ +# Forex + +An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Forex/api](https://m3o.com/Forex/api). + +Endpoints: + +## Price + +Get the latest price for a given forex ticker + + +[https://m3o.com/forex/api#Price](https://m3o.com/forex/api#Price) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/forex" +) + +// Get the latest price for a given forex ticker +func GetAnFxPrice() { + forexService := forex.NewForexService(os.Getenv("M3O_API_TOKEN")) + rsp, err := forexService.Price(&forex.PriceRequest{ + Symbol: "GBPUSD", + + }) + fmt.Println(rsp, err) +} +``` +## Quote + +Get the latest quote for the forex + + +[https://m3o.com/forex/api#Quote](https://m3o.com/forex/api#Quote) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/forex" +) + +// Get the latest quote for the forex +func GetAfxQuote() { + forexService := forex.NewForexService(os.Getenv("M3O_API_TOKEN")) + rsp, err := forexService.Quote(&forex.QuoteRequest{ + Symbol: "GBPUSD", + + }) + fmt.Println(rsp, err) +} +``` +## History + +Returns the data for the previous close + + +[https://m3o.com/forex/api#History](https://m3o.com/forex/api#History) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/forex" +) + +// Returns the data for the previous close +func GetPreviousClose() { + forexService := forex.NewForexService(os.Getenv("M3O_API_TOKEN")) + rsp, err := forexService.History(&forex.HistoryRequest{ + Symbol: "GBPUSD", + + }) + fmt.Println(rsp, err) +} +``` diff --git a/examples/forex/history/getPreviousClose.go b/examples/forex/history/getPreviousClose.go new file mode 100755 index 0000000..5efaf11 --- /dev/null +++ b/examples/forex/history/getPreviousClose.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/forex" +) + +// Returns the data for the previous close +func GetPreviousClose() { + forexService := forex.NewForexService(os.Getenv("M3O_API_TOKEN")) + rsp, err := forexService.History(&forex.HistoryRequest{ + Symbol: "GBPUSD", + }) + fmt.Println(rsp, err) +} diff --git a/examples/forex/price/getAnFxPrice.go b/examples/forex/price/getAnFxPrice.go new file mode 100755 index 0000000..27fc948 --- /dev/null +++ b/examples/forex/price/getAnFxPrice.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/forex" +) + +// Get the latest price for a given forex ticker +func GetAnFxPrice() { + forexService := forex.NewForexService(os.Getenv("M3O_API_TOKEN")) + rsp, err := forexService.Price(&forex.PriceRequest{ + Symbol: "GBPUSD", + }) + fmt.Println(rsp, err) +} diff --git a/examples/forex/quote/getAFxQuote.go b/examples/forex/quote/getAFxQuote.go new file mode 100755 index 0000000..8c3de35 --- /dev/null +++ b/examples/forex/quote/getAFxQuote.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/forex" +) + +// Get the latest quote for the forex +func GetAfxQuote() { + forexService := forex.NewForexService(os.Getenv("M3O_API_TOKEN")) + rsp, err := forexService.Quote(&forex.QuoteRequest{ + Symbol: "GBPUSD", + }) + fmt.Println(rsp, err) +} diff --git a/examples/function/README.md b/examples/function/README.md new file mode 100755 index 0000000..6275b69 --- /dev/null +++ b/examples/function/README.md @@ -0,0 +1,148 @@ +# Function + +An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Function/api](https://m3o.com/Function/api). + +Endpoints: + +## 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" + + "github.com/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 + + +[https://m3o.com/function/api#Deploy](https://m3o.com/function/api#Deploy) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/function" +) + +// Deploy a group of functions +func DeployAfunction() { + functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) + rsp, err := functionService.Deploy(&function.DeployRequest{ + Entrypoint: "helloworld", +Name: "my-first-func", +Project: "tests", +Repo: "github.com/m3o/nodejs-function-example", +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" + + "github.com/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" + + "github.com/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" + + "github.com/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) +} +``` diff --git a/examples/function/call/callAFunction.go b/examples/function/call/callAFunction.go new file mode 100755 index 0000000..b97aff8 --- /dev/null +++ b/examples/function/call/callAFunction.go @@ -0,0 +1,18 @@ +package example + +import ( + "fmt" + "os" + + "github.com/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) +} diff --git a/examples/function/delete/deleteAFunction.go b/examples/function/delete/deleteAFunction.go new file mode 100755 index 0000000..a24fe75 --- /dev/null +++ b/examples/function/delete/deleteAFunction.go @@ -0,0 +1,18 @@ +package example + +import ( + "fmt" + "os" + + "github.com/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) +} diff --git a/examples/function/deploy/deployAFunction.go b/examples/function/deploy/deployAFunction.go new file mode 100755 index 0000000..6ddfb3f --- /dev/null +++ b/examples/function/deploy/deployAFunction.go @@ -0,0 +1,21 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/function" +) + +// Deploy a group of functions +func DeployAfunction() { + functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) + rsp, err := functionService.Deploy(&function.DeployRequest{ + Entrypoint: "helloworld", + Name: "my-first-func", + Project: "tests", + Repo: "github.com/m3o/nodejs-function-example", + Runtime: "nodejs14", + }) + fmt.Println(rsp, err) +} diff --git a/examples/function/describe/describeFunctionStatus.go b/examples/function/describe/describeFunctionStatus.go new file mode 100755 index 0000000..cb44f0a --- /dev/null +++ b/examples/function/describe/describeFunctionStatus.go @@ -0,0 +1,18 @@ +package example + +import ( + "fmt" + "os" + + "github.com/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/function/list/listFunctions.go b/examples/function/list/listFunctions.go new file mode 100755 index 0000000..07f6efd --- /dev/null +++ b/examples/function/list/listFunctions.go @@ -0,0 +1,15 @@ +package example + +import ( + "fmt" + "os" + + "github.com/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) +} diff --git a/examples/geocoding/README.md b/examples/geocoding/README.md new file mode 100755 index 0000000..822f3e7 --- /dev/null +++ b/examples/geocoding/README.md @@ -0,0 +1,64 @@ +# Geocoding + +An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Geocoding/api](https://m3o.com/Geocoding/api). + +Endpoints: + +## Lookup + +Lookup returns a geocoded address including normalized address and gps coordinates. All fields are optional, provide more to get more accurate results + + +[https://m3o.com/geocoding/api#Lookup](https://m3o.com/geocoding/api#Lookup) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/geocoding" +) + +// Lookup returns a geocoded address including normalized address and gps coordinates. All fields are optional, provide more to get more accurate results +func GeocodeAnAddress() { + geocodingService := geocoding.NewGeocodingService(os.Getenv("M3O_API_TOKEN")) + rsp, err := geocodingService.Lookup(&geocoding.LookupRequest{ + Address: "10 russell st", +City: "london", +Country: "uk", +Postcode: "wc2b", + + }) + fmt.Println(rsp, err) +} +``` +## 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" + + "github.com/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/geocoding/lookup/geocodeAnAddress.go b/examples/geocoding/lookup/geocodeAnAddress.go new file mode 100755 index 0000000..c66d775 --- /dev/null +++ b/examples/geocoding/lookup/geocodeAnAddress.go @@ -0,0 +1,20 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/geocoding" +) + +// Lookup returns a geocoded address including normalized address and gps coordinates. All fields are optional, provide more to get more accurate results +func GeocodeAnAddress() { + geocodingService := geocoding.NewGeocodingService(os.Getenv("M3O_API_TOKEN")) + rsp, err := geocodingService.Lookup(&geocoding.LookupRequest{ + Address: "10 russell st", + City: "london", + Country: "uk", + Postcode: "wc2b", + }) + fmt.Println(rsp, err) +} diff --git a/examples/geocoding/reverse/reverseGeocodeLocation.go b/examples/geocoding/reverse/reverseGeocodeLocation.go new file mode 100755 index 0000000..1884546 --- /dev/null +++ b/examples/geocoding/reverse/reverseGeocodeLocation.go @@ -0,0 +1,18 @@ +package example + +import ( + "fmt" + "os" + + "github.com/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/gifs/README.md b/examples/gifs/README.md new file mode 100755 index 0000000..6f26ddb --- /dev/null +++ b/examples/gifs/README.md @@ -0,0 +1,34 @@ +# Gifs + +An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Gifs/api](https://m3o.com/Gifs/api). + +Endpoints: + +## Search + +Search for a GIF + + +[https://m3o.com/gifs/api#Search](https://m3o.com/gifs/api#Search) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/gifs" +) + +// Search for a GIF +func Search() { + gifsService := gifs.NewGifsService(os.Getenv("M3O_API_TOKEN")) + rsp, err := gifsService.Search(&gifs.SearchRequest{ + Limit: 2, +Query: "dogs", + + }) + fmt.Println(rsp, err) +} +``` diff --git a/examples/gifs/search/search.go b/examples/gifs/search/search.go new file mode 100755 index 0000000..1bb75dc --- /dev/null +++ b/examples/gifs/search/search.go @@ -0,0 +1,18 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/gifs" +) + +// Search for a GIF +func Search() { + gifsService := gifs.NewGifsService(os.Getenv("M3O_API_TOKEN")) + rsp, err := gifsService.Search(&gifs.SearchRequest{ + Limit: 2, + Query: "dogs", + }) + fmt.Println(rsp, err) +} diff --git a/examples/google/README.md b/examples/google/README.md new file mode 100755 index 0000000..5474e56 --- /dev/null +++ b/examples/google/README.md @@ -0,0 +1,33 @@ +# Google + +An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Google/api](https://m3o.com/Google/api). + +Endpoints: + +## Search + +Search for videos on Google + + +[https://m3o.com/google/api#Search](https://m3o.com/google/api#Search) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/google" +) + +// Search for videos on Google +func SearchForVideos() { + googleService := google.NewGoogleService(os.Getenv("M3O_API_TOKEN")) + rsp, err := googleService.Search(&google.SearchRequest{ + Query: "how to make donuts", + + }) + fmt.Println(rsp, err) +} +``` diff --git a/examples/google/search/searchForVideos.go b/examples/google/search/searchForVideos.go new file mode 100755 index 0000000..9becc9b --- /dev/null +++ b/examples/google/search/searchForVideos.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/google" +) + +// Search for videos on Google +func SearchForVideos() { + googleService := google.NewGoogleService(os.Getenv("M3O_API_TOKEN")) + rsp, err := googleService.Search(&google.SearchRequest{ + Query: "how to make donuts", + }) + fmt.Println(rsp, err) +} diff --git a/examples/helloworld/README.md b/examples/helloworld/README.md new file mode 100755 index 0000000..03d21a0 --- /dev/null +++ b/examples/helloworld/README.md @@ -0,0 +1,60 @@ +# Helloworld + +An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Helloworld/api](https://m3o.com/Helloworld/api). + +Endpoints: + +## Call + +Call returns a personalised "Hello $name" response + + +[https://m3o.com/helloworld/api#Call](https://m3o.com/helloworld/api#Call) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/helloworld" +) + +// Call returns a personalised "Hello $name" response +func CallTheHelloworldService() { + helloworldService := helloworld.NewHelloworldService(os.Getenv("M3O_API_TOKEN")) + rsp, err := helloworldService.Call(&helloworld.CallRequest{ + Name: "John", + + }) + fmt.Println(rsp, err) +} +``` +## Stream + +Stream returns a stream of "Hello $name" responses + + +[https://m3o.com/helloworld/api#Stream](https://m3o.com/helloworld/api#Stream) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/helloworld" +) + +// Stream returns a stream of "Hello $name" responses +func StreamsAreCurrentlyTemporarilyNotSupportedInClients() { + helloworldService := helloworld.NewHelloworldService(os.Getenv("M3O_API_TOKEN")) + rsp, err := helloworldService.Stream(&helloworld.StreamRequest{ + Name: "not supported", + + }) + fmt.Println(rsp, err) +} +``` diff --git a/examples/helloworld/call/callTheHelloworldService.go b/examples/helloworld/call/callTheHelloworldService.go new file mode 100755 index 0000000..5d8c928 --- /dev/null +++ b/examples/helloworld/call/callTheHelloworldService.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/helloworld" +) + +// Call returns a personalised "Hello $name" response +func CallTheHelloworldService() { + helloworldService := helloworld.NewHelloworldService(os.Getenv("M3O_API_TOKEN")) + rsp, err := helloworldService.Call(&helloworld.CallRequest{ + Name: "John", + }) + fmt.Println(rsp, err) +} diff --git a/examples/helloworld/stream/streamsAreCurrentlyTemporarilyNotSupportedInClients.go b/examples/helloworld/stream/streamsAreCurrentlyTemporarilyNotSupportedInClients.go new file mode 100755 index 0000000..c20d842 --- /dev/null +++ b/examples/helloworld/stream/streamsAreCurrentlyTemporarilyNotSupportedInClients.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/helloworld" +) + +// Stream returns a stream of "Hello $name" responses +func StreamsAreCurrentlyTemporarilyNotSupportedInClients() { + helloworldService := helloworld.NewHelloworldService(os.Getenv("M3O_API_TOKEN")) + rsp, err := helloworldService.Stream(&helloworld.StreamRequest{ + Name: "not supported", + }) + fmt.Println(rsp, err) +} diff --git a/examples/holidays/README.md b/examples/holidays/README.md new file mode 100755 index 0000000..1879561 --- /dev/null +++ b/examples/holidays/README.md @@ -0,0 +1,59 @@ +# Holidays + +An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Holidays/api](https://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" + + "github.com/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 + + +[https://m3o.com/holidays/api#List](https://m3o.com/holidays/api#List) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/holidays" +) + +// List the holiday dates for a given country and year +func GetHolidays() { + holidaysService := holidays.NewHolidaysService(os.Getenv("M3O_API_TOKEN")) + rsp, err := holidaysService.List(&holidays.ListRequest{ + Year: 2022, + + }) + fmt.Println(rsp, err) +} +``` diff --git a/examples/holidays/countries/listCountries.go b/examples/holidays/countries/listCountries.go new file mode 100755 index 0000000..ceba9a1 --- /dev/null +++ b/examples/holidays/countries/listCountries.go @@ -0,0 +1,15 @@ +package example + +import ( + "fmt" + "os" + + "github.com/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/holidays/list/getHolidays.go b/examples/holidays/list/getHolidays.go new file mode 100755 index 0000000..82a5093 --- /dev/null +++ b/examples/holidays/list/getHolidays.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/holidays" +) + +// List the holiday dates for a given country and year +func GetHolidays() { + holidaysService := holidays.NewHolidaysService(os.Getenv("M3O_API_TOKEN")) + rsp, err := holidaysService.List(&holidays.ListRequest{ + Year: 2022, + }) + fmt.Println(rsp, err) +} diff --git a/examples/id/README.md b/examples/id/README.md new file mode 100755 index 0000000..94f7cc7 --- /dev/null +++ b/examples/id/README.md @@ -0,0 +1,140 @@ +# Id + +An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Id/api](https://m3o.com/Id/api). + +Endpoints: + +## Generate + +Generate a unique ID. Defaults to uuid. + + +[https://m3o.com/id/api#Generate](https://m3o.com/id/api#Generate) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/id" +) + +// Generate a unique ID. Defaults to uuid. +func GenerateAuniqueId() { + idService := id.NewIdService(os.Getenv("M3O_API_TOKEN")) + rsp, err := idService.Generate(&id.GenerateRequest{ + Type: "uuid", + + }) + fmt.Println(rsp, err) +} +``` +## Generate + +Generate a unique ID. Defaults to uuid. + + +[https://m3o.com/id/api#Generate](https://m3o.com/id/api#Generate) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/id" +) + +// Generate a unique ID. Defaults to uuid. +func GenerateAshortId() { + idService := id.NewIdService(os.Getenv("M3O_API_TOKEN")) + rsp, err := idService.Generate(&id.GenerateRequest{ + Type: "shortid", + + }) + fmt.Println(rsp, err) +} +``` +## Generate + +Generate a unique ID. Defaults to uuid. + + +[https://m3o.com/id/api#Generate](https://m3o.com/id/api#Generate) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/id" +) + +// Generate a unique ID. Defaults to uuid. +func GenerateAsnowflakeId() { + idService := id.NewIdService(os.Getenv("M3O_API_TOKEN")) + rsp, err := idService.Generate(&id.GenerateRequest{ + Type: "snowflake", + + }) + fmt.Println(rsp, err) +} +``` +## Generate + +Generate a unique ID. Defaults to uuid. + + +[https://m3o.com/id/api#Generate](https://m3o.com/id/api#Generate) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/id" +) + +// Generate a unique ID. Defaults to uuid. +func GenerateAbigflakeId() { + idService := id.NewIdService(os.Getenv("M3O_API_TOKEN")) + rsp, err := idService.Generate(&id.GenerateRequest{ + Type: "bigflake", + + }) + fmt.Println(rsp, err) +} +``` +## Types + +List the types of IDs available. No query params needed. + + +[https://m3o.com/id/api#Types](https://m3o.com/id/api#Types) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/id" +) + +// List the types of IDs available. No query params needed. +func ListTheTypesOfIdsAvailable() { + idService := id.NewIdService(os.Getenv("M3O_API_TOKEN")) + rsp, err := idService.Types(&id.TypesRequest{ + + }) + fmt.Println(rsp, err) +} +``` diff --git a/examples/id/generate/generateABigflakeId.go b/examples/id/generate/generateABigflakeId.go new file mode 100755 index 0000000..69f7a6d --- /dev/null +++ b/examples/id/generate/generateABigflakeId.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/id" +) + +// Generate a unique ID. Defaults to uuid. +func GenerateAbigflakeId() { + idService := id.NewIdService(os.Getenv("M3O_API_TOKEN")) + rsp, err := idService.Generate(&id.GenerateRequest{ + Type: "bigflake", + }) + fmt.Println(rsp, err) +} diff --git a/examples/id/generate/generateAShortId.go b/examples/id/generate/generateAShortId.go new file mode 100755 index 0000000..ba0ac4b --- /dev/null +++ b/examples/id/generate/generateAShortId.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/id" +) + +// Generate a unique ID. Defaults to uuid. +func GenerateAshortId() { + idService := id.NewIdService(os.Getenv("M3O_API_TOKEN")) + rsp, err := idService.Generate(&id.GenerateRequest{ + Type: "shortid", + }) + fmt.Println(rsp, err) +} diff --git a/examples/id/generate/generateASnowflakeId.go b/examples/id/generate/generateASnowflakeId.go new file mode 100755 index 0000000..8572130 --- /dev/null +++ b/examples/id/generate/generateASnowflakeId.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/id" +) + +// Generate a unique ID. Defaults to uuid. +func GenerateAsnowflakeId() { + idService := id.NewIdService(os.Getenv("M3O_API_TOKEN")) + rsp, err := idService.Generate(&id.GenerateRequest{ + Type: "snowflake", + }) + fmt.Println(rsp, err) +} diff --git a/examples/id/generate/generateAUniqueId.go b/examples/id/generate/generateAUniqueId.go new file mode 100755 index 0000000..980eb55 --- /dev/null +++ b/examples/id/generate/generateAUniqueId.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/id" +) + +// Generate a unique ID. Defaults to uuid. +func GenerateAuniqueId() { + idService := id.NewIdService(os.Getenv("M3O_API_TOKEN")) + rsp, err := idService.Generate(&id.GenerateRequest{ + Type: "uuid", + }) + fmt.Println(rsp, err) +} diff --git a/examples/id/types/listTheTypesOfIdsAvailable.go b/examples/id/types/listTheTypesOfIdsAvailable.go new file mode 100755 index 0000000..50dd9ba --- /dev/null +++ b/examples/id/types/listTheTypesOfIdsAvailable.go @@ -0,0 +1,15 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/id" +) + +// List the types of IDs available. No query params needed. +func ListTheTypesOfIdsAvailable() { + idService := id.NewIdService(os.Getenv("M3O_API_TOKEN")) + rsp, err := idService.Types(&id.TypesRequest{}) + fmt.Println(rsp, err) +} diff --git a/examples/image/README.md b/examples/image/README.md new file mode 100755 index 0000000..09b6966 --- /dev/null +++ b/examples/image/README.md @@ -0,0 +1,200 @@ +# Image + +An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Image/api](https://m3o.com/Image/api). + +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. + + +[https://m3o.com/image/api#Resize](https://m3o.com/image/api#Resize) + +```go +package example + +import( + "fmt" + "os" + + "github.com/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. +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. + + +[https://m3o.com/image/api#Resize](https://m3o.com/image/api#Resize) + +```go +package example + +import( + "fmt" + "os" + + "github.com/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. +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. + + +[https://m3o.com/image/api#Resize](https://m3o.com/image/api#Resize) + +```go +package example + +import( + "fmt" + "os" + + "github.com/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. +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), +or by uploading the conversion result. + + +[https://m3o.com/image/api#Convert](https://m3o.com/image/api#Convert) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/image" +) + +// Convert an image from one format (jpeg, png etc.) to an other either on the fly (from base64 to base64), +// or by uploading the conversion result. +func ConvertApngImageToAjpegTakenFromAurlAndSavedToAurlOnMicrosCdn() { + imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN")) + rsp, err := imageService.Convert(&image.ConvertRequest{ + Name: "cat.jpeg", +Url: "somewebsite.com/cat.png", + + }) + fmt.Println(rsp, err) +} +``` +## Upload + +Upload an image by either sending a base64 encoded image to this endpoint or a URL. +To resize an image before uploading, see the Resize endpoint. + + +[https://m3o.com/image/api#Upload](https://m3o.com/image/api#Upload) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/image" +) + +// Upload an image by either sending a base64 encoded image to this endpoint or a URL. +// To resize an image before uploading, see the Resize endpoint. +func UploadAbase64imageToMicrosCdn() { + imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN")) + rsp, err := imageService.Upload(&image.UploadRequest{ + Base64: "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAx0lEQVR4nOzaMaoDMQyE4ZHj+x82vVdhwQoTkzKQEcwP5r0ihT7sbjUTeAJ4HCegXQJYfOYefOyjDuBiz3yjwJBoCIl6QZOeUjTC1Ix1IxEJXF9+0KWsf2bD4bn37OO/c/wuQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9Sa/NG94Tf3j4WBdaxudMEkn4IM2rZBA0wBrvo7aOcpj2emXvLeVt0IGm0GVXUj91mvAAAA//+V2CZl+4AKXwAAAABJRU5ErkJggg==", +Name: "cat.jpeg", + + }) + fmt.Println(rsp, err) +} +``` +## Upload + +Upload an image by either sending a base64 encoded image to this endpoint or a URL. +To resize an image before uploading, see the Resize endpoint. + + +[https://m3o.com/image/api#Upload](https://m3o.com/image/api#Upload) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/image" +) + +// Upload an image by either sending a base64 encoded image to this endpoint or a URL. +// To resize an image before uploading, see the Resize endpoint. +func UploadAnImageFromAurlToMicrosCdn() { + imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN")) + rsp, err := imageService.Upload(&image.UploadRequest{ + Name: "cat.jpeg", +Url: "somewebsite.com/cat.png", + + }) + fmt.Println(rsp, err) +} +``` diff --git a/examples/image/convert/convertAPngImageToAJpegTakenFromAUrlAndSavedToAUrlOnMicrosCdn.go b/examples/image/convert/convertAPngImageToAJpegTakenFromAUrlAndSavedToAUrlOnMicrosCdn.go new file mode 100755 index 0000000..21e6abb --- /dev/null +++ b/examples/image/convert/convertAPngImageToAJpegTakenFromAUrlAndSavedToAUrlOnMicrosCdn.go @@ -0,0 +1,19 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/image" +) + +// Convert an image from one format (jpeg, png etc.) to an other either on the fly (from base64 to base64), +// or by uploading the conversion result. +func ConvertApngImageToAjpegTakenFromAurlAndSavedToAurlOnMicrosCdn() { + imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN")) + rsp, err := imageService.Convert(&image.ConvertRequest{ + Name: "cat.jpeg", + Url: "somewebsite.com/cat.png", + }) + fmt.Println(rsp, err) +} diff --git a/examples/image/resize/base64ToBase64Image.go b/examples/image/resize/base64ToBase64Image.go new file mode 100755 index 0000000..2cfe417 --- /dev/null +++ b/examples/image/resize/base64ToBase64Image.go @@ -0,0 +1,21 @@ +package example + +import ( + "fmt" + "os" + + "github.com/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. +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) +} diff --git a/examples/image/resize/base64ToBase64ImageWithCropping.go b/examples/image/resize/base64ToBase64ImageWithCropping.go new file mode 100755 index 0000000..bfdafab --- /dev/null +++ b/examples/image/resize/base64ToBase64ImageWithCropping.go @@ -0,0 +1,25 @@ +package example + +import ( + "fmt" + "os" + + "github.com/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. +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/image/resize/base64ToHostedImage.go b/examples/image/resize/base64ToHostedImage.go new file mode 100755 index 0000000..b73542e --- /dev/null +++ b/examples/image/resize/base64ToHostedImage.go @@ -0,0 +1,22 @@ +package example + +import ( + "fmt" + "os" + + "github.com/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. +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) +} diff --git a/examples/image/upload/uploadABase64ImageToMicrosCdn.go b/examples/image/upload/uploadABase64ImageToMicrosCdn.go new file mode 100755 index 0000000..8bb6a94 --- /dev/null +++ b/examples/image/upload/uploadABase64ImageToMicrosCdn.go @@ -0,0 +1,19 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/image" +) + +// Upload an image by either sending a base64 encoded image to this endpoint or a URL. +// To resize an image before uploading, see the Resize endpoint. +func UploadAbase64imageToMicrosCdn() { + imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN")) + rsp, err := imageService.Upload(&image.UploadRequest{ + Base64: "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAx0lEQVR4nOzaMaoDMQyE4ZHj+x82vVdhwQoTkzKQEcwP5r0ihT7sbjUTeAJ4HCegXQJYfOYefOyjDuBiz3yjwJBoCIl6QZOeUjTC1Ix1IxEJXF9+0KWsf2bD4bn37OO/c/wuQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9Sa/NG94Tf3j4WBdaxudMEkn4IM2rZBA0wBrvo7aOcpj2emXvLeVt0IGm0GVXUj91mvAAAA//+V2CZl+4AKXwAAAABJRU5ErkJggg==", + Name: "cat.jpeg", + }) + fmt.Println(rsp, err) +} diff --git a/examples/image/upload/uploadAnImageFromAUrlToMicrosCdn.go b/examples/image/upload/uploadAnImageFromAUrlToMicrosCdn.go new file mode 100755 index 0000000..3f60ed3 --- /dev/null +++ b/examples/image/upload/uploadAnImageFromAUrlToMicrosCdn.go @@ -0,0 +1,19 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/image" +) + +// Upload an image by either sending a base64 encoded image to this endpoint or a URL. +// To resize an image before uploading, see the Resize endpoint. +func UploadAnImageFromAurlToMicrosCdn() { + imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN")) + rsp, err := imageService.Upload(&image.UploadRequest{ + Name: "cat.jpeg", + Url: "somewebsite.com/cat.png", + }) + fmt.Println(rsp, err) +} diff --git a/examples/ip/README.md b/examples/ip/README.md new file mode 100755 index 0000000..3b550b5 --- /dev/null +++ b/examples/ip/README.md @@ -0,0 +1,33 @@ +# Ip + +An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Ip/api](https://m3o.com/Ip/api). + +Endpoints: + +## Lookup + +Lookup the geolocation information for an IP address + + +[https://m3o.com/ip/api#Lookup](https://m3o.com/ip/api#Lookup) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/ip" +) + +// Lookup the geolocation information for an IP address +func LookupIpInfo() { + ipService := ip.NewIpService(os.Getenv("M3O_API_TOKEN")) + rsp, err := ipService.Lookup(&ip.LookupRequest{ + Ip: "93.148.214.31", + + }) + fmt.Println(rsp, err) +} +``` diff --git a/examples/ip/lookup/lookupIpInfo.go b/examples/ip/lookup/lookupIpInfo.go new file mode 100755 index 0000000..b7461d8 --- /dev/null +++ b/examples/ip/lookup/lookupIpInfo.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/ip" +) + +// Lookup the geolocation information for an IP address +func LookupIpInfo() { + ipService := ip.NewIpService(os.Getenv("M3O_API_TOKEN")) + rsp, err := ipService.Lookup(&ip.LookupRequest{ + Ip: "93.148.214.31", + }) + fmt.Println(rsp, err) +} diff --git a/examples/location/README.md b/examples/location/README.md new file mode 100755 index 0000000..713d40a --- /dev/null +++ b/examples/location/README.md @@ -0,0 +1,101 @@ +# Location + +An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Location/api](https://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" + + "github.com/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 + + +[https://m3o.com/location/api#Read](https://m3o.com/location/api#Read) + +```go +package example + +import( + "fmt" + "os" + + "github.com/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" + + "github.com/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/location/read/getLocationById.go b/examples/location/read/getLocationById.go new file mode 100755 index 0000000..e5a5656 --- /dev/null +++ b/examples/location/read/getLocationById.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/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) +} diff --git a/examples/location/save/saveAnEntity.go b/examples/location/save/saveAnEntity.go new file mode 100755 index 0000000..002af1a --- /dev/null +++ b/examples/location/save/saveAnEntity.go @@ -0,0 +1,25 @@ +package example + +import ( + "fmt" + "os" + + "github.com/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/location/search/searchForLocations.go b/examples/location/search/searchForLocations.go new file mode 100755 index 0000000..2f385f6 --- /dev/null +++ b/examples/location/search/searchForLocations.go @@ -0,0 +1,23 @@ +package example + +import ( + "fmt" + "os" + + "github.com/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/notes/README.md b/examples/notes/README.md new file mode 100755 index 0000000..8a52c9b --- /dev/null +++ b/examples/notes/README.md @@ -0,0 +1,145 @@ +# Notes + +An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Notes/api](https://m3o.com/Notes/api). + +Endpoints: + +## Read + +Read a note + + +[https://m3o.com/notes/api#Read](https://m3o.com/notes/api#Read) + +```go +package example + +import( + "fmt" + "os" + + "github.com/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 + + +[https://m3o.com/notes/api#List](https://m3o.com/notes/api#List) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/notes" +) + +// List all the notes +func ListAllNotes() { + notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN")) + rsp, err := notesService.List(¬es.ListRequest{ + + }) + fmt.Println(rsp, err) +} +``` +## Update + +Update a note + + +[https://m3o.com/notes/api#Update](https://m3o.com/notes/api#Update) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/notes" +) + +// Update a note +func UpdateAnote() { + notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN")) + rsp, err := notesService.Update(¬es.UpdateRequest{ + Note: ¬es.Note{ + Id: "63c0cdf8-2121-11ec-a881-0242e36f037a", + Text: "Updated note text", + Title: "Update Note", + }, + + }) + fmt.Println(rsp, err) +} +``` +## Delete + +Delete a note + + +[https://m3o.com/notes/api#Delete](https://m3o.com/notes/api#Delete) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/notes" +) + +// Delete a note +func DeleteAnote() { + notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN")) + rsp, err := notesService.Delete(¬es.DeleteRequest{ + Id: "63c0cdf8-2121-11ec-a881-0242e36f037a", + + }) + fmt.Println(rsp, err) +} +``` +## Create + +Create a new note + + +[https://m3o.com/notes/api#Create](https://m3o.com/notes/api#Create) + +```go +package example + +import( + "fmt" + "os" + + "github.com/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) +} +``` diff --git a/examples/notes/create/createANote.go b/examples/notes/create/createANote.go new file mode 100755 index 0000000..4e76635 --- /dev/null +++ b/examples/notes/create/createANote.go @@ -0,0 +1,18 @@ +package example + +import ( + "fmt" + "os" + + "github.com/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) +} diff --git a/examples/notes/delete/deleteANote.go b/examples/notes/delete/deleteANote.go new file mode 100755 index 0000000..712ded7 --- /dev/null +++ b/examples/notes/delete/deleteANote.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/notes" +) + +// Delete a note +func DeleteAnote() { + notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN")) + rsp, err := notesService.Delete(¬es.DeleteRequest{ + Id: "63c0cdf8-2121-11ec-a881-0242e36f037a", + }) + fmt.Println(rsp, err) +} diff --git a/examples/notes/list/listAllNotes.go b/examples/notes/list/listAllNotes.go new file mode 100755 index 0000000..8885823 --- /dev/null +++ b/examples/notes/list/listAllNotes.go @@ -0,0 +1,15 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/notes" +) + +// List all the notes +func ListAllNotes() { + notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN")) + rsp, err := notesService.List(¬es.ListRequest{}) + fmt.Println(rsp, err) +} diff --git a/examples/notes/read/readANote.go b/examples/notes/read/readANote.go new file mode 100755 index 0000000..d9858d8 --- /dev/null +++ b/examples/notes/read/readANote.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/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/notes/update/updateANote.go b/examples/notes/update/updateANote.go new file mode 100755 index 0000000..2ae701b --- /dev/null +++ b/examples/notes/update/updateANote.go @@ -0,0 +1,21 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/notes" +) + +// Update a note +func UpdateAnote() { + notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN")) + rsp, err := notesService.Update(¬es.UpdateRequest{ + Note: ¬es.Note{ + Id: "63c0cdf8-2121-11ec-a881-0242e36f037a", + Text: "Updated note text", + Title: "Update Note", + }, + }) + fmt.Println(rsp, err) +} diff --git a/examples/otp/README.md b/examples/otp/README.md new file mode 100755 index 0000000..c3a956b --- /dev/null +++ b/examples/otp/README.md @@ -0,0 +1,61 @@ +# Otp + +An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Otp/api](https://m3o.com/Otp/api). + +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" + + "github.com/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 + + +[https://m3o.com/otp/api#Validate](https://m3o.com/otp/api#Validate) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/otp" +) + +// Validate the OTP code +func ValidateOtp() { + otpService := otp.NewOtpService(os.Getenv("M3O_API_TOKEN")) + rsp, err := otpService.Validate(&otp.ValidateRequest{ + Code: "656211", +Id: "asim@example.com", + + }) + fmt.Println(rsp, err) +} +``` diff --git a/examples/otp/generate/generateOtp.go b/examples/otp/generate/generateOtp.go new file mode 100755 index 0000000..49a3f0d --- /dev/null +++ b/examples/otp/generate/generateOtp.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/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/otp/validate/validateOtp.go b/examples/otp/validate/validateOtp.go new file mode 100755 index 0000000..824ab7c --- /dev/null +++ b/examples/otp/validate/validateOtp.go @@ -0,0 +1,18 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/otp" +) + +// Validate the OTP code +func ValidateOtp() { + otpService := otp.NewOtpService(os.Getenv("M3O_API_TOKEN")) + rsp, err := otpService.Validate(&otp.ValidateRequest{ + Code: "656211", + Id: "asim@example.com", + }) + fmt.Println(rsp, err) +} diff --git a/examples/postcode/README.md b/examples/postcode/README.md new file mode 100755 index 0000000..d7ce589 --- /dev/null +++ b/examples/postcode/README.md @@ -0,0 +1,86 @@ +# Postcode + +An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Postcode/api](https://m3o.com/Postcode/api). + +Endpoints: + +## Lookup + +Lookup a postcode to retrieve the related region, county, etc + + +[https://m3o.com/postcode/api#Lookup](https://m3o.com/postcode/api#Lookup) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/postcode" +) + +// Lookup a postcode to retrieve the related region, county, etc +func LookupPostcode() { + postcodeService := postcode.NewPostcodeService(os.Getenv("M3O_API_TOKEN")) + rsp, err := postcodeService.Lookup(&postcode.LookupRequest{ + Postcode: "SW1A 2AA", + + }) + fmt.Println(rsp, err) +} +``` +## Random + +Return a random postcode and its related info + + +[https://m3o.com/postcode/api#Random](https://m3o.com/postcode/api#Random) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/postcode" +) + +// Return a random postcode and its related info +func ReturnArandomPostcodeAndItsInformation() { + postcodeService := postcode.NewPostcodeService(os.Getenv("M3O_API_TOKEN")) + rsp, err := postcodeService.Random(&postcode.RandomRequest{ + + }) + fmt.Println(rsp, err) +} +``` +## Validate + +Validate a postcode. + + +[https://m3o.com/postcode/api#Validate](https://m3o.com/postcode/api#Validate) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/postcode" +) + +// Validate a postcode. +func ReturnArandomPostcodeAndItsInformation() { + postcodeService := postcode.NewPostcodeService(os.Getenv("M3O_API_TOKEN")) + rsp, err := postcodeService.Validate(&postcode.ValidateRequest{ + Postcode: "SW1A 2AA", + + }) + fmt.Println(rsp, err) +} +``` diff --git a/examples/postcode/lookup/lookupPostcode.go b/examples/postcode/lookup/lookupPostcode.go new file mode 100755 index 0000000..5324faa --- /dev/null +++ b/examples/postcode/lookup/lookupPostcode.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/postcode" +) + +// Lookup a postcode to retrieve the related region, county, etc +func LookupPostcode() { + postcodeService := postcode.NewPostcodeService(os.Getenv("M3O_API_TOKEN")) + rsp, err := postcodeService.Lookup(&postcode.LookupRequest{ + Postcode: "SW1A 2AA", + }) + fmt.Println(rsp, err) +} diff --git a/examples/postcode/random/returnARandomPostcodeAndItsInformation.go b/examples/postcode/random/returnARandomPostcodeAndItsInformation.go new file mode 100755 index 0000000..b869d28 --- /dev/null +++ b/examples/postcode/random/returnARandomPostcodeAndItsInformation.go @@ -0,0 +1,15 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/postcode" +) + +// Return a random postcode and its related info +func ReturnArandomPostcodeAndItsInformation() { + postcodeService := postcode.NewPostcodeService(os.Getenv("M3O_API_TOKEN")) + rsp, err := postcodeService.Random(&postcode.RandomRequest{}) + fmt.Println(rsp, err) +} diff --git a/examples/postcode/validate/returnARandomPostcodeAndItsInformation.go b/examples/postcode/validate/returnARandomPostcodeAndItsInformation.go new file mode 100755 index 0000000..7377c8e --- /dev/null +++ b/examples/postcode/validate/returnARandomPostcodeAndItsInformation.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/postcode" +) + +// Validate a postcode. +func ReturnArandomPostcodeAndItsInformation() { + postcodeService := postcode.NewPostcodeService(os.Getenv("M3O_API_TOKEN")) + rsp, err := postcodeService.Validate(&postcode.ValidateRequest{ + Postcode: "SW1A 2AA", + }) + fmt.Println(rsp, err) +} diff --git a/examples/prayer/README.md b/examples/prayer/README.md new file mode 100755 index 0000000..a2ccbd2 --- /dev/null +++ b/examples/prayer/README.md @@ -0,0 +1,33 @@ +# Prayer + +An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Prayer/api](https://m3o.com/Prayer/api). + +Endpoints: + +## Times + +Get the prayer (salah) times for a location on a given date + + +[https://m3o.com/prayer/api#Times](https://m3o.com/prayer/api#Times) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/prayer" +) + +// Get the prayer (salah) times for a location on a given date +func PrayerTimes() { + prayerService := prayer.NewPrayerService(os.Getenv("M3O_API_TOKEN")) + rsp, err := prayerService.Times(&prayer.TimesRequest{ + Location: "london", + + }) + fmt.Println(rsp, err) +} +``` diff --git a/examples/prayer/times/prayerTimes.go b/examples/prayer/times/prayerTimes.go new file mode 100755 index 0000000..3a067e9 --- /dev/null +++ b/examples/prayer/times/prayerTimes.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/prayer" +) + +// Get the prayer (salah) times for a location on a given date +func PrayerTimes() { + prayerService := prayer.NewPrayerService(os.Getenv("M3O_API_TOKEN")) + rsp, err := prayerService.Times(&prayer.TimesRequest{ + Location: "london", + }) + fmt.Println(rsp, err) +} diff --git a/examples/qr/README.md b/examples/qr/README.md new file mode 100755 index 0000000..4d5d129 --- /dev/null +++ b/examples/qr/README.md @@ -0,0 +1,34 @@ +# Qr + +An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Qr/api](https://m3o.com/Qr/api). + +Endpoints: + +## Generate + +Generate a QR code with a specific text and size + + +[https://m3o.com/qr/api#Generate](https://m3o.com/qr/api#Generate) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/qr" +) + +// Generate a QR code with a specific text and size +func GenerateAqrCode() { + qrService := qr.NewQrService(os.Getenv("M3O_API_TOKEN")) + rsp, err := qrService.Generate(&qr.GenerateRequest{ + Size: 300, +Text: "https://m3o.com/qr", + + }) + fmt.Println(rsp, err) +} +``` diff --git a/examples/qr/generate/generateAQrCode.go b/examples/qr/generate/generateAQrCode.go new file mode 100755 index 0000000..012f3e9 --- /dev/null +++ b/examples/qr/generate/generateAQrCode.go @@ -0,0 +1,18 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/qr" +) + +// Generate a QR code with a specific text and size +func GenerateAqrCode() { + qrService := qr.NewQrService(os.Getenv("M3O_API_TOKEN")) + rsp, err := qrService.Generate(&qr.GenerateRequest{ + Size: 300, + Text: "https://m3o.com/qr", + }) + fmt.Println(rsp, err) +} diff --git a/examples/quran/README.md b/examples/quran/README.md new file mode 100755 index 0000000..af10716 --- /dev/null +++ b/examples/quran/README.md @@ -0,0 +1,118 @@ +# Quran + +An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Quran/api](https://m3o.com/Quran/api). + +Endpoints: + +## Verses + +Lookup the verses (ayahs) for a chapter including +translation, interpretation and breakdown by individual +words. + + +[https://m3o.com/quran/api#Verses](https://m3o.com/quran/api#Verses) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/quran" +) + +// Lookup the verses (ayahs) for a chapter including +// translation, interpretation and breakdown by individual +// words. +func GetVersesOfAchapter() { + quranService := quran.NewQuranService(os.Getenv("M3O_API_TOKEN")) + rsp, err := quranService.Verses(&quran.VersesRequest{ + Chapter: 1, + + }) + fmt.Println(rsp, err) +} +``` +## 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" + + "github.com/go.m3o.com/quran" +) + +// Search the Quran for any form of query or questions +func SearchTheQuran() { + quranService := quran.NewQuranService(os.Getenv("M3O_API_TOKEN")) + rsp, err := quranService.Search(&quran.SearchRequest{ + Query: "messenger", + + }) + fmt.Println(rsp, err) +} +``` +## Chapters + +List the Chapters (surahs) of the Quran + + +[https://m3o.com/quran/api#Chapters](https://m3o.com/quran/api#Chapters) + +```go +package example + +import( + "fmt" + "os" + + "github.com/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) + + +[https://m3o.com/quran/api#Summary](https://m3o.com/quran/api#Summary) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/quran" +) + +// Get a summary for a given chapter (surah) +func GetChapterSummary() { + quranService := quran.NewQuranService(os.Getenv("M3O_API_TOKEN")) + rsp, err := quranService.Summary(&quran.SummaryRequest{ + Chapter: 1, + + }) + fmt.Println(rsp, err) +} +``` diff --git a/examples/quran/chapters/listChapters.go b/examples/quran/chapters/listChapters.go new file mode 100755 index 0000000..5392f2f --- /dev/null +++ b/examples/quran/chapters/listChapters.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/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/quran/search/searchTheQuran.go b/examples/quran/search/searchTheQuran.go new file mode 100755 index 0000000..892dfb8 --- /dev/null +++ b/examples/quran/search/searchTheQuran.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/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/quran/summary/getChapterSummary.go b/examples/quran/summary/getChapterSummary.go new file mode 100755 index 0000000..c114d77 --- /dev/null +++ b/examples/quran/summary/getChapterSummary.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/quran" +) + +// Get a summary for a given chapter (surah) +func GetChapterSummary() { + quranService := quran.NewQuranService(os.Getenv("M3O_API_TOKEN")) + rsp, err := quranService.Summary(&quran.SummaryRequest{ + Chapter: 1, + }) + fmt.Println(rsp, err) +} diff --git a/examples/quran/verses/getVersesOfAChapter.go b/examples/quran/verses/getVersesOfAChapter.go new file mode 100755 index 0000000..27eb428 --- /dev/null +++ b/examples/quran/verses/getVersesOfAChapter.go @@ -0,0 +1,19 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/quran" +) + +// Lookup the verses (ayahs) for a chapter including +// translation, interpretation and breakdown by individual +// words. +func GetVersesOfAchapter() { + quranService := quran.NewQuranService(os.Getenv("M3O_API_TOKEN")) + rsp, err := quranService.Verses(&quran.VersesRequest{ + Chapter: 1, + }) + fmt.Println(rsp, err) +} diff --git a/examples/routing/README.md b/examples/routing/README.md new file mode 100755 index 0000000..540ca23 --- /dev/null +++ b/examples/routing/README.md @@ -0,0 +1,108 @@ +# Routing + +An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Routing/api](https://m3o.com/Routing/api). + +Endpoints: + +## Eta + +Get the eta for a route from origin to destination. The eta is an estimated time based on car routes + + +[https://m3o.com/routing/api#Eta](https://m3o.com/routing/api#Eta) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/routing" +) + +// Get the eta for a route from origin to destination. The eta is an estimated time based on car routes +func EtaFromPointAtoPointB() { + routingService := routing.NewRoutingService(os.Getenv("M3O_API_TOKEN")) + rsp, err := routingService.Eta(&routing.EtaRequest{ + Destination: &routing.Point{ + Latitude: 52.529407, + Longitude: 13.397634, +}, +Origin: &routing.Point{ + Latitude: 52.517037, + Longitude: 13.38886, +}, + + }) + fmt.Println(rsp, err) +} +``` +## Directions + +Turn by turn directions from a start point to an end point including maneuvers and bearings + + +[https://m3o.com/routing/api#Directions](https://m3o.com/routing/api#Directions) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/routing" +) + +// Turn by turn directions from a start point to an end point including maneuvers and bearings +func TurnByTurnDirections() { + routingService := routing.NewRoutingService(os.Getenv("M3O_API_TOKEN")) + rsp, err := routingService.Directions(&routing.DirectionsRequest{ + Destination: &routing.Point{ + Latitude: 52.529407, + Longitude: 13.397634, +}, +Origin: &routing.Point{ + Latitude: 52.517037, + Longitude: 13.38886, +}, + + }) + fmt.Println(rsp, err) +} +``` +## Route + +Retrieve a route as a simple list of gps points along with total distance and estimated duration + + +[https://m3o.com/routing/api#Route](https://m3o.com/routing/api#Route) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/routing" +) + +// Retrieve a route as a simple list of gps points along with total distance and estimated duration +func GpsPointsForAroute() { + routingService := routing.NewRoutingService(os.Getenv("M3O_API_TOKEN")) + rsp, err := routingService.Route(&routing.RouteRequest{ + Destination: &routing.Point{ + Latitude: 52.529407, + Longitude: 13.397634, +}, +Origin: &routing.Point{ + Latitude: 52.517037, + Longitude: 13.38886, +}, + + }) + fmt.Println(rsp, err) +} +``` diff --git a/examples/routing/directions/turnByTurnDirections.go b/examples/routing/directions/turnByTurnDirections.go new file mode 100755 index 0000000..1ec4469 --- /dev/null +++ b/examples/routing/directions/turnByTurnDirections.go @@ -0,0 +1,24 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/routing" +) + +// Turn by turn directions from a start point to an end point including maneuvers and bearings +func TurnByTurnDirections() { + routingService := routing.NewRoutingService(os.Getenv("M3O_API_TOKEN")) + rsp, err := routingService.Directions(&routing.DirectionsRequest{ + Destination: &routing.Point{ + Latitude: 52.529407, + Longitude: 13.397634, + }, + Origin: &routing.Point{ + Latitude: 52.517037, + Longitude: 13.38886, + }, + }) + fmt.Println(rsp, err) +} diff --git a/examples/routing/eta/etaFromPointAToPointB.go b/examples/routing/eta/etaFromPointAToPointB.go new file mode 100755 index 0000000..fb2d9ee --- /dev/null +++ b/examples/routing/eta/etaFromPointAToPointB.go @@ -0,0 +1,24 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/routing" +) + +// Get the eta for a route from origin to destination. The eta is an estimated time based on car routes +func EtaFromPointAtoPointB() { + routingService := routing.NewRoutingService(os.Getenv("M3O_API_TOKEN")) + rsp, err := routingService.Eta(&routing.EtaRequest{ + Destination: &routing.Point{ + Latitude: 52.529407, + Longitude: 13.397634, + }, + Origin: &routing.Point{ + Latitude: 52.517037, + Longitude: 13.38886, + }, + }) + fmt.Println(rsp, err) +} diff --git a/examples/routing/route/gpsPointsForARoute.go b/examples/routing/route/gpsPointsForARoute.go new file mode 100755 index 0000000..2b1cd7e --- /dev/null +++ b/examples/routing/route/gpsPointsForARoute.go @@ -0,0 +1,24 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/routing" +) + +// Retrieve a route as a simple list of gps points along with total distance and estimated duration +func GpsPointsForAroute() { + routingService := routing.NewRoutingService(os.Getenv("M3O_API_TOKEN")) + rsp, err := routingService.Route(&routing.RouteRequest{ + Destination: &routing.Point{ + Latitude: 52.529407, + Longitude: 13.397634, + }, + Origin: &routing.Point{ + Latitude: 52.517037, + Longitude: 13.38886, + }, + }) + fmt.Println(rsp, err) +} diff --git a/examples/rss/README.md b/examples/rss/README.md new file mode 100755 index 0000000..527fe1d --- /dev/null +++ b/examples/rss/README.md @@ -0,0 +1,115 @@ +# Rss + +An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Rss/api](https://m3o.com/Rss/api). + +Endpoints: + +## Add + +Add a new RSS feed with a name, url, and category + + +[https://m3o.com/rss/api#Add](https://m3o.com/rss/api#Add) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/rss" +) + +// Add a new RSS feed with a name, url, and category +func AddAnewFeed() { + rssService := rss.NewRssService(os.Getenv("M3O_API_TOKEN")) + rsp, err := rssService.Add(&rss.AddRequest{ + Category: "news", +Name: "bbc", +Url: "http://feeds.bbci.co.uk/news/rss.xml", + + }) + fmt.Println(rsp, err) +} +``` +## Feed + +Get an RSS feed by name. If no name is given, all feeds are returned. Default limit is 25 entries. + + +[https://m3o.com/rss/api#Feed](https://m3o.com/rss/api#Feed) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/rss" +) + +// Get an RSS feed by name. If no name is given, all feeds are returned. Default limit is 25 entries. +func ReadAfeed() { + rssService := rss.NewRssService(os.Getenv("M3O_API_TOKEN")) + rsp, err := rssService.Feed(&rss.FeedRequest{ + Name: "bbc", + + }) + fmt.Println(rsp, err) +} +``` +## List + +List the saved RSS fields + + +[https://m3o.com/rss/api#List](https://m3o.com/rss/api#List) + +```go +package example + +import( + "fmt" + "os" + + "github.com/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" + + "github.com/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/rss/add/addANewFeed.go b/examples/rss/add/addANewFeed.go new file mode 100755 index 0000000..eea53da --- /dev/null +++ b/examples/rss/add/addANewFeed.go @@ -0,0 +1,19 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/rss" +) + +// Add a new RSS feed with a name, url, and category +func AddAnewFeed() { + rssService := rss.NewRssService(os.Getenv("M3O_API_TOKEN")) + rsp, err := rssService.Add(&rss.AddRequest{ + Category: "news", + Name: "bbc", + Url: "http://feeds.bbci.co.uk/news/rss.xml", + }) + fmt.Println(rsp, err) +} diff --git a/examples/rss/feed/readAFeed.go b/examples/rss/feed/readAFeed.go new file mode 100755 index 0000000..562a949 --- /dev/null +++ b/examples/rss/feed/readAFeed.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/rss" +) + +// Get an RSS feed by name. If no name is given, all feeds are returned. Default limit is 25 entries. +func ReadAfeed() { + rssService := rss.NewRssService(os.Getenv("M3O_API_TOKEN")) + rsp, err := rssService.Feed(&rss.FeedRequest{ + Name: "bbc", + }) + fmt.Println(rsp, err) +} diff --git a/examples/rss/list/listRssFeeds.go b/examples/rss/list/listRssFeeds.go new file mode 100755 index 0000000..f8b3873 --- /dev/null +++ b/examples/rss/list/listRssFeeds.go @@ -0,0 +1,15 @@ +package example + +import ( + "fmt" + "os" + + "github.com/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) +} diff --git a/examples/rss/remove/removeAFeed.go b/examples/rss/remove/removeAFeed.go new file mode 100755 index 0000000..cb09213 --- /dev/null +++ b/examples/rss/remove/removeAFeed.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/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/sentiment/README.md b/examples/sentiment/README.md new file mode 100755 index 0000000..4fdecc2 --- /dev/null +++ b/examples/sentiment/README.md @@ -0,0 +1,33 @@ +# Sentiment + +An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Sentiment/api](https://m3o.com/Sentiment/api). + +Endpoints: + +## Analyze + +Analyze and score a piece of text + + +[https://m3o.com/sentiment/api#Analyze](https://m3o.com/sentiment/api#Analyze) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/sentiment" +) + +// Analyze and score a piece of text +func AnalyzeApieceOfText() { + sentimentService := sentiment.NewSentimentService(os.Getenv("M3O_API_TOKEN")) + rsp, err := sentimentService.Analyze(&sentiment.AnalyzeRequest{ + Text: "this is amazing", + + }) + fmt.Println(rsp, err) +} +``` diff --git a/examples/sentiment/analyze/analyzeAPieceOfText.go b/examples/sentiment/analyze/analyzeAPieceOfText.go new file mode 100755 index 0000000..c1be3d7 --- /dev/null +++ b/examples/sentiment/analyze/analyzeAPieceOfText.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/sentiment" +) + +// Analyze and score a piece of text +func AnalyzeApieceOfText() { + sentimentService := sentiment.NewSentimentService(os.Getenv("M3O_API_TOKEN")) + rsp, err := sentimentService.Analyze(&sentiment.AnalyzeRequest{ + Text: "this is amazing", + }) + fmt.Println(rsp, err) +} diff --git a/examples/sms/README.md b/examples/sms/README.md new file mode 100755 index 0000000..cfaf1dc --- /dev/null +++ b/examples/sms/README.md @@ -0,0 +1,35 @@ +# Sms + +An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Sms/api](https://m3o.com/Sms/api). + +Endpoints: + +## Send + +Send an SMS. + + +[https://m3o.com/sms/api#Send](https://m3o.com/sms/api#Send) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/sms" +) + +// Send an SMS. +func SendSms() { + smsService := sms.NewSmsService(os.Getenv("M3O_API_TOKEN")) + rsp, err := smsService.Send(&sms.SendRequest{ + From: "Alice", +Message: "Hi there!", +To: "+447681129", + + }) + fmt.Println(rsp, err) +} +``` diff --git a/examples/sms/send/sendSms.go b/examples/sms/send/sendSms.go new file mode 100755 index 0000000..8609f3e --- /dev/null +++ b/examples/sms/send/sendSms.go @@ -0,0 +1,19 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/sms" +) + +// Send an SMS. +func SendSms() { + smsService := sms.NewSmsService(os.Getenv("M3O_API_TOKEN")) + rsp, err := smsService.Send(&sms.SendRequest{ + From: "Alice", + Message: "Hi there!", + To: "+447681129", + }) + fmt.Println(rsp, err) +} diff --git a/examples/stock/README.md b/examples/stock/README.md new file mode 100755 index 0000000..c0f9fce --- /dev/null +++ b/examples/stock/README.md @@ -0,0 +1,119 @@ +# Stock + +An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Stock/api](https://m3o.com/Stock/api). + +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" + + "github.com/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" + + "github.com/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" + + "github.com/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 + + +[https://m3o.com/stock/api#OrderBook](https://m3o.com/stock/api#OrderBook) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/stock" +) + +// Get the historic order book and each trade by timestamp +func OrderBookHistory() { + stockService := stock.NewStockService(os.Getenv("M3O_API_TOKEN")) + rsp, err := stockService.OrderBook(&stock.OrderBookRequest{ + Date: "2020-10-01", +End: "2020-10-01T11:00:00Z", +Limit: 3, +Start: "2020-10-01T10:00:00Z", +Stock: "AAPL", + + }) + fmt.Println(rsp, err) +} +``` diff --git a/examples/stock/history/getHistoricData.go b/examples/stock/history/getHistoricData.go new file mode 100755 index 0000000..2fed994 --- /dev/null +++ b/examples/stock/history/getHistoricData.go @@ -0,0 +1,18 @@ +package example + +import ( + "fmt" + "os" + + "github.com/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/stock/orderBook/orderBookHistory.go b/examples/stock/orderBook/orderBookHistory.go new file mode 100755 index 0000000..6d27a5a --- /dev/null +++ b/examples/stock/orderBook/orderBookHistory.go @@ -0,0 +1,21 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/stock" +) + +// Get the historic order book and each trade by timestamp +func OrderBookHistory() { + stockService := stock.NewStockService(os.Getenv("M3O_API_TOKEN")) + rsp, err := stockService.OrderBook(&stock.OrderBookRequest{ + Date: "2020-10-01", + End: "2020-10-01T11:00:00Z", + Limit: 3, + Start: "2020-10-01T10:00:00Z", + Stock: "AAPL", + }) + fmt.Println(rsp, err) +} diff --git a/examples/stock/price/getAStockPrice.go b/examples/stock/price/getAStockPrice.go new file mode 100755 index 0000000..734671f --- /dev/null +++ b/examples/stock/price/getAStockPrice.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/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) +} diff --git a/examples/stock/quote/getAStockQuote.go b/examples/stock/quote/getAStockQuote.go new file mode 100755 index 0000000..919acb3 --- /dev/null +++ b/examples/stock/quote/getAStockQuote.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/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 new file mode 100755 index 0000000..2505227 --- /dev/null +++ b/examples/stream/README.md @@ -0,0 +1,65 @@ +# Stream + +An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Stream/api](https://m3o.com/Stream/api). + +Endpoints: + +## Subscribe + +Subscribe to messages for a given topic. + + +[https://m3o.com/stream/api#Subscribe](https://m3o.com/stream/api#Subscribe) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/stream" +) + +// Subscribe to messages for a given topic. +func SubscribeToAtopic() { + streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN")) + rsp, err := streamService.Subscribe(&stream.SubscribeRequest{ + Topic: "events", + + }) + fmt.Println(rsp, err) +} +``` +## Publish + +Publish a message to the stream. Specify a topic to group messages for a specific topic. + + +[https://m3o.com/stream/api#Publish](https://m3o.com/stream/api#Publish) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/stream" +) + +// Publish a message to the stream. Specify a topic to group messages for a specific topic. +func PublishAmessage() { + streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN")) + rsp, err := streamService.Publish(&stream.PublishRequest{ + Message: map[string]interface{}{ + "id": "1", + "type": "signup", + "user": "john", +}, +Topic: "events", + + }) + fmt.Println(rsp, err) +} +``` diff --git a/examples/stream/publish/publishAMessage.go b/examples/stream/publish/publishAMessage.go new file mode 100755 index 0000000..50e774b --- /dev/null +++ b/examples/stream/publish/publishAMessage.go @@ -0,0 +1,22 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/stream" +) + +// Publish a message to the stream. Specify a topic to group messages for a specific topic. +func PublishAmessage() { + streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN")) + rsp, err := streamService.Publish(&stream.PublishRequest{ + Message: map[string]interface{}{ + "id": "1", + "type": "signup", + "user": "john", + }, + Topic: "events", + }) + fmt.Println(rsp, err) +} diff --git a/examples/stream/subscribe/subscribeToATopic.go b/examples/stream/subscribe/subscribeToATopic.go new file mode 100755 index 0000000..695ccfb --- /dev/null +++ b/examples/stream/subscribe/subscribeToATopic.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/stream" +) + +// Subscribe to messages for a given topic. +func SubscribeToAtopic() { + streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN")) + rsp, err := streamService.Subscribe(&stream.SubscribeRequest{ + Topic: "events", + }) + fmt.Println(rsp, err) +} diff --git a/examples/sunnah/README.md b/examples/sunnah/README.md new file mode 100755 index 0000000..c296d95 --- /dev/null +++ b/examples/sunnah/README.md @@ -0,0 +1,121 @@ +# Sunnah + +An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Sunnah/api](https://m3o.com/Sunnah/api). + +Endpoints: + +## Collections + +Get a list of available collections. A collection is +a compilation of hadiths collected and written by an author. + + +[https://m3o.com/sunnah/api#Collections](https://m3o.com/sunnah/api#Collections) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/sunnah" +) + +// Get a list of available collections. A collection is +// a compilation of hadiths collected and written by an author. +func ListAvailableCollections() { + sunnahService := sunnah.NewSunnahService(os.Getenv("M3O_API_TOKEN")) + rsp, err := sunnahService.Collections(&sunnah.CollectionsRequest{ + + }) + fmt.Println(rsp, err) +} +``` +## Books + +Get a list of books from within a collection. A book can contain many chapters +each with its own hadiths. + + +[https://m3o.com/sunnah/api#Books](https://m3o.com/sunnah/api#Books) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/sunnah" +) + +// Get a list of books from within a collection. A book can contain many chapters +// each with its own hadiths. +func GetTheBooksWithinAcollection() { + sunnahService := sunnah.NewSunnahService(os.Getenv("M3O_API_TOKEN")) + rsp, err := sunnahService.Books(&sunnah.BooksRequest{ + Collection: "bukhari", + + }) + fmt.Println(rsp, err) +} +``` +## Chapters + +Get all the chapters of a given book within a collection. + + +[https://m3o.com/sunnah/api#Chapters](https://m3o.com/sunnah/api#Chapters) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/sunnah" +) + +// Get all the chapters of a given book within a collection. +func ListTheChaptersInAbook() { + sunnahService := sunnah.NewSunnahService(os.Getenv("M3O_API_TOKEN")) + rsp, err := sunnahService.Chapters(&sunnah.ChaptersRequest{ + Book: 1, +Collection: "bukhari", + + }) + fmt.Println(rsp, err) +} +``` +## Hadiths + +Hadiths returns a list of hadiths and their corresponding text for a +given book within a collection. + + +[https://m3o.com/sunnah/api#Hadiths](https://m3o.com/sunnah/api#Hadiths) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/sunnah" +) + +// Hadiths returns a list of hadiths and their corresponding text for a +// given book within a collection. +func ListTheHadithsInAbook() { + sunnahService := sunnah.NewSunnahService(os.Getenv("M3O_API_TOKEN")) + rsp, err := sunnahService.Hadiths(&sunnah.HadithsRequest{ + Book: 1, +Collection: "bukhari", + + }) + fmt.Println(rsp, err) +} +``` diff --git a/examples/sunnah/books/getTheBooksWithinACollection.go b/examples/sunnah/books/getTheBooksWithinACollection.go new file mode 100755 index 0000000..e10205e --- /dev/null +++ b/examples/sunnah/books/getTheBooksWithinACollection.go @@ -0,0 +1,18 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/sunnah" +) + +// Get a list of books from within a collection. A book can contain many chapters +// each with its own hadiths. +func GetTheBooksWithinAcollection() { + sunnahService := sunnah.NewSunnahService(os.Getenv("M3O_API_TOKEN")) + rsp, err := sunnahService.Books(&sunnah.BooksRequest{ + Collection: "bukhari", + }) + fmt.Println(rsp, err) +} diff --git a/examples/sunnah/chapters/listTheChaptersInABook.go b/examples/sunnah/chapters/listTheChaptersInABook.go new file mode 100755 index 0000000..e72eae1 --- /dev/null +++ b/examples/sunnah/chapters/listTheChaptersInABook.go @@ -0,0 +1,18 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/sunnah" +) + +// Get all the chapters of a given book within a collection. +func ListTheChaptersInAbook() { + sunnahService := sunnah.NewSunnahService(os.Getenv("M3O_API_TOKEN")) + rsp, err := sunnahService.Chapters(&sunnah.ChaptersRequest{ + Book: 1, + Collection: "bukhari", + }) + fmt.Println(rsp, err) +} diff --git a/examples/sunnah/collections/listAvailableCollections.go b/examples/sunnah/collections/listAvailableCollections.go new file mode 100755 index 0000000..9062864 --- /dev/null +++ b/examples/sunnah/collections/listAvailableCollections.go @@ -0,0 +1,16 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/sunnah" +) + +// Get a list of available collections. A collection is +// a compilation of hadiths collected and written by an author. +func ListAvailableCollections() { + sunnahService := sunnah.NewSunnahService(os.Getenv("M3O_API_TOKEN")) + rsp, err := sunnahService.Collections(&sunnah.CollectionsRequest{}) + fmt.Println(rsp, err) +} diff --git a/examples/sunnah/hadiths/listTheHadithsInABook.go b/examples/sunnah/hadiths/listTheHadithsInABook.go new file mode 100755 index 0000000..d0fac10 --- /dev/null +++ b/examples/sunnah/hadiths/listTheHadithsInABook.go @@ -0,0 +1,19 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/sunnah" +) + +// Hadiths returns a list of hadiths and their corresponding text for a +// given book within a collection. +func ListTheHadithsInAbook() { + sunnahService := sunnah.NewSunnahService(os.Getenv("M3O_API_TOKEN")) + rsp, err := sunnahService.Hadiths(&sunnah.HadithsRequest{ + Book: 1, + Collection: "bukhari", + }) + fmt.Println(rsp, err) +} diff --git a/examples/thumbnail/README.md b/examples/thumbnail/README.md new file mode 100755 index 0000000..122f20b --- /dev/null +++ b/examples/thumbnail/README.md @@ -0,0 +1,35 @@ +# Thumbnail + +An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Thumbnail/api](https://m3o.com/Thumbnail/api). + +Endpoints: + +## Screenshot + +Create a thumbnail screenshot by passing in a url, height and width + + +[https://m3o.com/thumbnail/api#Screenshot](https://m3o.com/thumbnail/api#Screenshot) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/thumbnail" +) + +// Create a thumbnail screenshot by passing in a url, height and width +func TakeScreenshotOfAurl() { + thumbnailService := thumbnail.NewThumbnailService(os.Getenv("M3O_API_TOKEN")) + rsp, err := thumbnailService.Screenshot(&thumbnail.ScreenshotRequest{ + Height: 600, +Url: "https://m3o.com", +Width: 600, + + }) + fmt.Println(rsp, err) +} +``` diff --git a/examples/thumbnail/screenshot/takeScreenshotOfAUrl.go b/examples/thumbnail/screenshot/takeScreenshotOfAUrl.go new file mode 100755 index 0000000..a73666c --- /dev/null +++ b/examples/thumbnail/screenshot/takeScreenshotOfAUrl.go @@ -0,0 +1,19 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/thumbnail" +) + +// Create a thumbnail screenshot by passing in a url, height and width +func TakeScreenshotOfAurl() { + thumbnailService := thumbnail.NewThumbnailService(os.Getenv("M3O_API_TOKEN")) + rsp, err := thumbnailService.Screenshot(&thumbnail.ScreenshotRequest{ + Height: 600, + Url: "https://m3o.com", + Width: 600, + }) + fmt.Println(rsp, err) +} diff --git a/examples/time/README.md b/examples/time/README.md new file mode 100755 index 0000000..3813acb --- /dev/null +++ b/examples/time/README.md @@ -0,0 +1,59 @@ +# Time + +An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Time/api](https://m3o.com/Time/api). + +Endpoints: + +## Now + +Get the current time + + +[https://m3o.com/time/api#Now](https://m3o.com/time/api#Now) + +```go +package example + +import( + "fmt" + "os" + + "github.com/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 + + +[https://m3o.com/time/api#Zone](https://m3o.com/time/api#Zone) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/time" +) + +// Get the timezone info for a specific location +func GetTheTimezoneInfoForAspecificLocation() { + timeService := time.NewTimeService(os.Getenv("M3O_API_TOKEN")) + rsp, err := timeService.Zone(&time.ZoneRequest{ + Location: "London", + + }) + fmt.Println(rsp, err) +} +``` diff --git a/examples/time/now/returnsCurrentTimeOptionallyWithLocation.go b/examples/time/now/returnsCurrentTimeOptionallyWithLocation.go new file mode 100755 index 0000000..205d308 --- /dev/null +++ b/examples/time/now/returnsCurrentTimeOptionallyWithLocation.go @@ -0,0 +1,15 @@ +package example + +import ( + "fmt" + "os" + + "github.com/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/time/zone/getTheTimezoneInfoForASpecificLocation.go b/examples/time/zone/getTheTimezoneInfoForASpecificLocation.go new file mode 100755 index 0000000..5248639 --- /dev/null +++ b/examples/time/zone/getTheTimezoneInfoForASpecificLocation.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/time" +) + +// Get the timezone info for a specific location +func GetTheTimezoneInfoForAspecificLocation() { + timeService := time.NewTimeService(os.Getenv("M3O_API_TOKEN")) + rsp, err := timeService.Zone(&time.ZoneRequest{ + Location: "London", + }) + fmt.Println(rsp, err) +} diff --git a/examples/twitter/README.md b/examples/twitter/README.md new file mode 100755 index 0000000..a7d09a3 --- /dev/null +++ b/examples/twitter/README.md @@ -0,0 +1,114 @@ +# Twitter + +An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Twitter/api](https://m3o.com/Twitter/api). + +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" + + "github.com/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 + + +[https://m3o.com/twitter/api#Search](https://m3o.com/twitter/api#Search) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/twitter" +) + +// Search for tweets with a simple query +func SearchForTweets() { + twitterService := twitter.NewTwitterService(os.Getenv("M3O_API_TOKEN")) + rsp, err := twitterService.Search(&twitter.SearchRequest{ + Query: "cats", + + }) + fmt.Println(rsp, err) +} +``` +## Trends + +Get the current global trending topics + + +[https://m3o.com/twitter/api#Trends](https://m3o.com/twitter/api#Trends) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/twitter" +) + +// Get the current global trending topics +func GetTheCurrentGlobalTrendingTopics() { + twitterService := twitter.NewTwitterService(os.Getenv("M3O_API_TOKEN")) + rsp, err := twitterService.Trends(&twitter.TrendsRequest{ + + }) + fmt.Println(rsp, err) +} +``` +## User + +Get a user's twitter profile + + +[https://m3o.com/twitter/api#User](https://m3o.com/twitter/api#User) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/twitter" +) + +// Get a user's twitter profile +func GetAusersTwitterProfile() { + twitterService := twitter.NewTwitterService(os.Getenv("M3O_API_TOKEN")) + rsp, err := twitterService.User(&twitter.UserRequest{ + Username: "crufter", + + }) + fmt.Println(rsp, err) +} +``` diff --git a/examples/twitter/search/searchForTweets.go b/examples/twitter/search/searchForTweets.go new file mode 100755 index 0000000..ac14763 --- /dev/null +++ b/examples/twitter/search/searchForTweets.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/twitter" +) + +// Search for tweets with a simple query +func SearchForTweets() { + twitterService := twitter.NewTwitterService(os.Getenv("M3O_API_TOKEN")) + rsp, err := twitterService.Search(&twitter.SearchRequest{ + Query: "cats", + }) + fmt.Println(rsp, err) +} diff --git a/examples/twitter/timeline/getATwitterTimeline.go b/examples/twitter/timeline/getATwitterTimeline.go new file mode 100755 index 0000000..2af525d --- /dev/null +++ b/examples/twitter/timeline/getATwitterTimeline.go @@ -0,0 +1,18 @@ +package example + +import ( + "fmt" + "os" + + "github.com/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/twitter/trends/getTheCurrentGlobalTrendingTopics.go b/examples/twitter/trends/getTheCurrentGlobalTrendingTopics.go new file mode 100755 index 0000000..401de10 --- /dev/null +++ b/examples/twitter/trends/getTheCurrentGlobalTrendingTopics.go @@ -0,0 +1,15 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/twitter" +) + +// Get the current global trending topics +func GetTheCurrentGlobalTrendingTopics() { + twitterService := twitter.NewTwitterService(os.Getenv("M3O_API_TOKEN")) + rsp, err := twitterService.Trends(&twitter.TrendsRequest{}) + fmt.Println(rsp, err) +} diff --git a/examples/twitter/user/getAUsersTwitterProfile.go b/examples/twitter/user/getAUsersTwitterProfile.go new file mode 100755 index 0000000..dd5067b --- /dev/null +++ b/examples/twitter/user/getAUsersTwitterProfile.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/twitter" +) + +// Get a user's twitter profile +func GetAusersTwitterProfile() { + twitterService := twitter.NewTwitterService(os.Getenv("M3O_API_TOKEN")) + rsp, err := twitterService.User(&twitter.UserRequest{ + Username: "crufter", + }) + fmt.Println(rsp, err) +} diff --git a/examples/url/README.md b/examples/url/README.md new file mode 100755 index 0000000..ea1c632 --- /dev/null +++ b/examples/url/README.md @@ -0,0 +1,84 @@ +# Url + +An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Url/api](https://m3o.com/Url/api). + +Endpoints: + +## List + +List information on all the shortened URLs that you have created + + +[https://m3o.com/url/api#List](https://m3o.com/url/api#List) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/url" +) + +// List information on all the shortened URLs that you have created +func ListYourShortenedUrls() { + urlService := url.NewUrlService(os.Getenv("M3O_API_TOKEN")) + rsp, err := urlService.List(&url.ListRequest{ + + }) + fmt.Println(rsp, err) +} +``` +## Shorten + +Shortens a destination URL and returns a full short URL. + + +[https://m3o.com/url/api#Shorten](https://m3o.com/url/api#Shorten) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/url" +) + +// Shortens a destination URL and returns a full short URL. +func ShortenAlongUrl() { + urlService := url.NewUrlService(os.Getenv("M3O_API_TOKEN")) + rsp, err := urlService.Shorten(&url.ShortenRequest{ + + }) + 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" + + "github.com/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/url/list/listYourShortenedUrls.go b/examples/url/list/listYourShortenedUrls.go new file mode 100755 index 0000000..f595cd5 --- /dev/null +++ b/examples/url/list/listYourShortenedUrls.go @@ -0,0 +1,15 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/url" +) + +// List information on all the shortened URLs that you have created +func ListYourShortenedUrls() { + urlService := url.NewUrlService(os.Getenv("M3O_API_TOKEN")) + rsp, err := urlService.List(&url.ListRequest{}) + fmt.Println(rsp, err) +} diff --git a/examples/url/proxy/resolveAShortUrlToALongDestinationUrl.go b/examples/url/proxy/resolveAShortUrlToALongDestinationUrl.go new file mode 100755 index 0000000..a475152 --- /dev/null +++ b/examples/url/proxy/resolveAShortUrlToALongDestinationUrl.go @@ -0,0 +1,15 @@ +package example + +import ( + "fmt" + "os" + + "github.com/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/url/shorten/shortenALongUrl.go b/examples/url/shorten/shortenALongUrl.go new file mode 100755 index 0000000..f0577ab --- /dev/null +++ b/examples/url/shorten/shortenALongUrl.go @@ -0,0 +1,15 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/url" +) + +// Shortens a destination URL and returns a full short URL. +func ShortenAlongUrl() { + urlService := url.NewUrlService(os.Getenv("M3O_API_TOKEN")) + rsp, err := urlService.Shorten(&url.ShortenRequest{}) + fmt.Println(rsp, err) +} diff --git a/examples/user/README.md b/examples/user/README.md new file mode 100755 index 0000000..d748341 --- /dev/null +++ b/examples/user/README.md @@ -0,0 +1,358 @@ +# User + +An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/User/api](https://m3o.com/User/api). + +Endpoints: + +## UpdatePassword + +Update the account password + + +[https://m3o.com/user/api#UpdatePassword](https://m3o.com/user/api#UpdatePassword) + +```go +package example + +import( + "fmt" + "os" + + "github.com/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: "myEvenMoreSecretPass123", +NewPassword: "myEvenMoreSecretPass123", +OldPassword: "mySecretPass123", + + }) + 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" + + "github.com/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" + + "github.com/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" + + "github.com/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) +} +``` +## Logout + +Logout a user account + + +[https://m3o.com/user/api#Logout](https://m3o.com/user/api#Logout) + +```go +package example + +import( + "fmt" + "os" + + "github.com/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 + +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" + + "github.com/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: "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" + + "github.com/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 + + +[https://m3o.com/user/api#Update](https://m3o.com/user/api#Update) + +```go +package example + +import( + "fmt" + "os" + + "github.com/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: "joeotheremail@example.com", +Id: "usrid-1", + + }) + fmt.Println(rsp, err) +} +``` +## SendVerificationEmail + +Send a verification email +to the user being signed up. Email from will be from 'support@m3o.com', +but you can provide the title and contents. +The verification link will be injected in to the email as a template variable, $micro_verification_link. +Example: 'Hi there, welcome onboard! Use the link below to verify your email: $micro_verification_link' +The variable will be replaced with an actual url that will look similar to this: +'https://user.m3o.com/user/verify?token=a-verification-token&redirectUrl=your-redir-url' + + +[https://m3o.com/user/api#SendVerificationEmail](https://m3o.com/user/api#SendVerificationEmail) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/user" +) + +// Send a verification email +// to the user being signed up. Email from will be from 'support@m3o.com', +// but you can provide the title and contents. +// The verification link will be injected in to the email as a template variable, $micro_verification_link. +// Example: 'Hi there, welcome onboard! Use the link below to verify your email: $micro_verification_link' +// The variable will be replaced with an actual url that will look similar to this: +// 'https://user.m3o.com/user/verify?token=a-verification-token&redirectUrl=your-redir-url' +func SendVerificationEmail() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.SendVerificationEmail(&user.SendVerificationEmailRequest{ + Email: "joe@example.com", +FailureRedirectUrl: "https://m3o.com/verification-failed", +FromName: "Awesome Dot Com", +RedirectUrl: "https://m3o.com", +Subject: "Email verification", +TextContent: `Hi there, + +Please verify your email by clicking this link: $micro_verification_link`, + + }) + fmt.Println(rsp, err) +} +``` +## VerifyEmail + +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" + + "github.com/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" + + "github.com/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 + +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" + + "github.com/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{ + Email: "joe@example.com", +Password: "mySecretPass123", + + }) + fmt.Println(rsp, err) +} +``` diff --git a/examples/user/create/createAnAccount.go b/examples/user/create/createAnAccount.go new file mode 100755 index 0000000..f37fcaa --- /dev/null +++ b/examples/user/create/createAnAccount.go @@ -0,0 +1,20 @@ +package example + +import ( + "fmt" + "os" + + "github.com/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) +} diff --git a/examples/user/delete/deleteUserAccount.go b/examples/user/delete/deleteUserAccount.go new file mode 100755 index 0000000..bd04441 --- /dev/null +++ b/examples/user/delete/deleteUserAccount.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/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) +} diff --git a/examples/user/login/logAUserIn.go b/examples/user/login/logAUserIn.go new file mode 100755 index 0000000..15fd9bc --- /dev/null +++ b/examples/user/login/logAUserIn.go @@ -0,0 +1,19 @@ +package example + +import ( + "fmt" + "os" + + "github.com/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{ + Email: "joe@example.com", + Password: "mySecretPass123", + }) + fmt.Println(rsp, err) +} diff --git a/examples/user/logout/logAUserOut.go b/examples/user/logout/logAUserOut.go new file mode 100755 index 0000000..409aa8c --- /dev/null +++ b/examples/user/logout/logAUserOut.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/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) +} diff --git a/examples/user/read/readAccountByEmail.go b/examples/user/read/readAccountByEmail.go new file mode 100755 index 0000000..daef3a2 --- /dev/null +++ b/examples/user/read/readAccountByEmail.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/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) +} diff --git a/examples/user/read/readAccountByUsernameOrEmail.go b/examples/user/read/readAccountByUsernameOrEmail.go new file mode 100755 index 0000000..6cd3a13 --- /dev/null +++ b/examples/user/read/readAccountByUsernameOrEmail.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/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) +} diff --git a/examples/user/read/readAnAccountById.go b/examples/user/read/readAnAccountById.go new file mode 100755 index 0000000..cd67096 --- /dev/null +++ b/examples/user/read/readAnAccountById.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/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) +} diff --git a/examples/user/readSession/readASessionByTheSessionId.go b/examples/user/readSession/readASessionByTheSessionId.go new file mode 100755 index 0000000..547f0fc --- /dev/null +++ b/examples/user/readSession/readASessionByTheSessionId.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/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: "sds34s34s34-s34s34-s43s43s34-s4s34s", + }) + fmt.Println(rsp, err) +} diff --git a/examples/user/sendVerificationEmail/sendVerificationEmail.go b/examples/user/sendVerificationEmail/sendVerificationEmail.go new file mode 100755 index 0000000..0bd1c66 --- /dev/null +++ b/examples/user/sendVerificationEmail/sendVerificationEmail.go @@ -0,0 +1,30 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/user" +) + +// Send a verification email +// to the user being signed up. Email from will be from 'support@m3o.com', +// but you can provide the title and contents. +// The verification link will be injected in to the email as a template variable, $micro_verification_link. +// Example: 'Hi there, welcome onboard! Use the link below to verify your email: $micro_verification_link' +// The variable will be replaced with an actual url that will look similar to this: +// 'https://user.m3o.com/user/verify?token=a-verification-token&redirectUrl=your-redir-url' +func SendVerificationEmail() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.SendVerificationEmail(&user.SendVerificationEmailRequest{ + Email: "joe@example.com", + FailureRedirectUrl: "https://m3o.com/verification-failed", + FromName: "Awesome Dot Com", + RedirectUrl: "https://m3o.com", + Subject: "Email verification", + TextContent: `Hi there, + +Please verify your email by clicking this link: $micro_verification_link`, + }) + fmt.Println(rsp, err) +} diff --git a/examples/user/update/updateAnAccount.go b/examples/user/update/updateAnAccount.go new file mode 100755 index 0000000..a355ef3 --- /dev/null +++ b/examples/user/update/updateAnAccount.go @@ -0,0 +1,18 @@ +package example + +import ( + "fmt" + "os" + + "github.com/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: "joeotheremail@example.com", + Id: "usrid-1", + }) + fmt.Println(rsp, err) +} diff --git a/examples/user/updatePassword/updateTheAccountPassword.go b/examples/user/updatePassword/updateTheAccountPassword.go new file mode 100755 index 0000000..6f002c0 --- /dev/null +++ b/examples/user/updatePassword/updateTheAccountPassword.go @@ -0,0 +1,19 @@ +package example + +import ( + "fmt" + "os" + + "github.com/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: "myEvenMoreSecretPass123", + NewPassword: "myEvenMoreSecretPass123", + OldPassword: "mySecretPass123", + }) + fmt.Println(rsp, err) +} diff --git a/examples/user/verifyEmail/verifyEmail.go b/examples/user/verifyEmail/verifyEmail.go new file mode 100755 index 0000000..ac42870 --- /dev/null +++ b/examples/user/verifyEmail/verifyEmail.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/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) +} diff --git a/examples/vehicle/README.md b/examples/vehicle/README.md new file mode 100755 index 0000000..8d83ec3 --- /dev/null +++ b/examples/vehicle/README.md @@ -0,0 +1,33 @@ +# Vehicle + +An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Vehicle/api](https://m3o.com/Vehicle/api). + +Endpoints: + +## Lookup + +Lookup a UK vehicle by it's registration number + + +[https://m3o.com/vehicle/api#Lookup](https://m3o.com/vehicle/api#Lookup) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/vehicle" +) + +// Lookup a UK vehicle by it's registration number +func LookupVehicle() { + vehicleService := vehicle.NewVehicleService(os.Getenv("M3O_API_TOKEN")) + rsp, err := vehicleService.Lookup(&vehicle.LookupRequest{ + Registration: "LC60OTA", + + }) + fmt.Println(rsp, err) +} +``` diff --git a/examples/vehicle/lookup/lookupVehicle.go b/examples/vehicle/lookup/lookupVehicle.go new file mode 100755 index 0000000..3d15ec2 --- /dev/null +++ b/examples/vehicle/lookup/lookupVehicle.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/vehicle" +) + +// Lookup a UK vehicle by it's registration number +func LookupVehicle() { + vehicleService := vehicle.NewVehicleService(os.Getenv("M3O_API_TOKEN")) + rsp, err := vehicleService.Lookup(&vehicle.LookupRequest{ + Registration: "LC60OTA", + }) + fmt.Println(rsp, err) +} diff --git a/examples/weather/README.md b/examples/weather/README.md new file mode 100755 index 0000000..eb7d869 --- /dev/null +++ b/examples/weather/README.md @@ -0,0 +1,61 @@ +# Weather + +An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Weather/api](https://m3o.com/Weather/api). + +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" + + "github.com/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 + + +[https://m3o.com/weather/api#Forecast](https://m3o.com/weather/api#Forecast) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/weather" +) + +// Get the weather forecast for the next 1-10 days +func ForecastWeather() { + weatherService := weather.NewWeatherService(os.Getenv("M3O_API_TOKEN")) + rsp, err := weatherService.Forecast(&weather.ForecastRequest{ + Days: 2, +Location: "London", + + }) + fmt.Println(rsp, err) +} +``` diff --git a/examples/weather/forecast/forecastWeather.go b/examples/weather/forecast/forecastWeather.go new file mode 100755 index 0000000..5cb3320 --- /dev/null +++ b/examples/weather/forecast/forecastWeather.go @@ -0,0 +1,18 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/weather" +) + +// Get the weather forecast for the next 1-10 days +func ForecastWeather() { + weatherService := weather.NewWeatherService(os.Getenv("M3O_API_TOKEN")) + rsp, err := weatherService.Forecast(&weather.ForecastRequest{ + Days: 2, + Location: "London", + }) + fmt.Println(rsp, err) +} diff --git a/examples/weather/now/getCurrentWeather.go b/examples/weather/now/getCurrentWeather.go new file mode 100755 index 0000000..469e121 --- /dev/null +++ b/examples/weather/now/getCurrentWeather.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/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 new file mode 100755 index 0000000..6fe1bfb --- /dev/null +++ b/examples/youtube/README.md @@ -0,0 +1,33 @@ +# Youtube + +An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Youtube/api](https://m3o.com/Youtube/api). + +Endpoints: + +## Search + +Search for videos on YouTube + + +[https://m3o.com/youtube/api#Search](https://m3o.com/youtube/api#Search) + +```go +package example + +import( + "fmt" + "os" + + "github.com/go.m3o.com/youtube" +) + +// Search for videos on YouTube +func SearchForVideos() { + youtubeService := youtube.NewYoutubeService(os.Getenv("M3O_API_TOKEN")) + rsp, err := youtubeService.Search(&youtube.SearchRequest{ + Query: "donuts", + + }) + fmt.Println(rsp, err) +} +``` diff --git a/examples/youtube/search/searchForVideos.go b/examples/youtube/search/searchForVideos.go new file mode 100755 index 0000000..ce7e839 --- /dev/null +++ b/examples/youtube/search/searchForVideos.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/go.m3o.com/youtube" +) + +// Search for videos on YouTube +func SearchForVideos() { + youtubeService := youtube.NewYoutubeService(os.Getenv("M3O_API_TOKEN")) + rsp, err := youtubeService.Search(&youtube.SearchRequest{ + Query: "donuts", + }) + fmt.Println(rsp, err) +} diff --git a/m3o.go b/m3o.go index ce3091d..129114d 100755 --- a/m3o.go +++ b/m3o.go @@ -1,48 +1,48 @@ package m3o import ( - "github.com/micro/services/clients/go/address" - "github.com/micro/services/clients/go/answer" - "github.com/micro/services/clients/go/cache" - "github.com/micro/services/clients/go/crypto" - "github.com/micro/services/clients/go/currency" - "github.com/micro/services/clients/go/db" - "github.com/micro/services/clients/go/email" - "github.com/micro/services/clients/go/emoji" - "github.com/micro/services/clients/go/evchargers" - "github.com/micro/services/clients/go/file" - "github.com/micro/services/clients/go/forex" - "github.com/micro/services/clients/go/function" - "github.com/micro/services/clients/go/geocoding" - "github.com/micro/services/clients/go/gifs" - "github.com/micro/services/clients/go/google" - "github.com/micro/services/clients/go/helloworld" - "github.com/micro/services/clients/go/holidays" - "github.com/micro/services/clients/go/id" - "github.com/micro/services/clients/go/image" - "github.com/micro/services/clients/go/ip" - "github.com/micro/services/clients/go/location" - "github.com/micro/services/clients/go/notes" - "github.com/micro/services/clients/go/otp" - "github.com/micro/services/clients/go/postcode" - "github.com/micro/services/clients/go/prayer" - "github.com/micro/services/clients/go/qr" - "github.com/micro/services/clients/go/quran" - "github.com/micro/services/clients/go/routing" - "github.com/micro/services/clients/go/rss" - "github.com/micro/services/clients/go/sentiment" - "github.com/micro/services/clients/go/sms" - "github.com/micro/services/clients/go/stock" - "github.com/micro/services/clients/go/stream" - "github.com/micro/services/clients/go/sunnah" - "github.com/micro/services/clients/go/thumbnail" - "github.com/micro/services/clients/go/time" - "github.com/micro/services/clients/go/twitter" - "github.com/micro/services/clients/go/url" - "github.com/micro/services/clients/go/user" - "github.com/micro/services/clients/go/vehicle" - "github.com/micro/services/clients/go/weather" - "github.com/micro/services/clients/go/youtube" + "github.com/m3o/m3o-go/address" + "github.com/m3o/m3o-go/answer" + "github.com/m3o/m3o-go/cache" + "github.com/m3o/m3o-go/crypto" + "github.com/m3o/m3o-go/currency" + "github.com/m3o/m3o-go/db" + "github.com/m3o/m3o-go/email" + "github.com/m3o/m3o-go/emoji" + "github.com/m3o/m3o-go/evchargers" + "github.com/m3o/m3o-go/file" + "github.com/m3o/m3o-go/forex" + "github.com/m3o/m3o-go/function" + "github.com/m3o/m3o-go/geocoding" + "github.com/m3o/m3o-go/gifs" + "github.com/m3o/m3o-go/google" + "github.com/m3o/m3o-go/helloworld" + "github.com/m3o/m3o-go/holidays" + "github.com/m3o/m3o-go/id" + "github.com/m3o/m3o-go/image" + "github.com/m3o/m3o-go/ip" + "github.com/m3o/m3o-go/location" + "github.com/m3o/m3o-go/notes" + "github.com/m3o/m3o-go/otp" + "github.com/m3o/m3o-go/postcode" + "github.com/m3o/m3o-go/prayer" + "github.com/m3o/m3o-go/qr" + "github.com/m3o/m3o-go/quran" + "github.com/m3o/m3o-go/routing" + "github.com/m3o/m3o-go/rss" + "github.com/m3o/m3o-go/sentiment" + "github.com/m3o/m3o-go/sms" + "github.com/m3o/m3o-go/stock" + "github.com/m3o/m3o-go/stream" + "github.com/m3o/m3o-go/sunnah" + "github.com/m3o/m3o-go/thumbnail" + "github.com/m3o/m3o-go/time" + "github.com/m3o/m3o-go/twitter" + "github.com/m3o/m3o-go/url" + "github.com/m3o/m3o-go/user" + "github.com/m3o/m3o-go/vehicle" + "github.com/m3o/m3o-go/weather" + "github.com/m3o/m3o-go/youtube" ) func NewClient(token string) *Client {