From c6b213570ba5bcbedbf4f85ed4637e67261ab73d Mon Sep 17 00:00:00 2001 From: m3o-actions <> Date: Wed, 3 Nov 2021 10:19:08 +0000 Subject: [PATCH] Commit from m3o/m3o action --- .../lookupPostcode/lookupPostcode/main.go | 17 ++ examples/answer/question/askAQuestion/main.go | 17 ++ examples/cache/README.md | 56 ++-- .../cache/decrement/decrementAValue/main.go | 18 ++ examples/cache/delete/deleteAValue/main.go | 17 ++ examples/cache/get/getAValue/main.go | 17 ++ .../cache/increment/incrementAValue/main.go | 18 ++ examples/cache/set/setAValue/main.go | 18 ++ .../crypto/history/getPreviousClose/main.go | 17 ++ .../crypto/news/getCryptocurrencyNews/main.go | 17 ++ .../price/getCryptocurrencyPrice/main.go | 17 ++ .../quote/getACryptocurrencyQuote/main.go | 17 ++ .../currency/codes/getSupportedCodes/main.go | 15 + .../convert/convert10UsdToGbp/main.go | 19 ++ .../currency/convert/convertUsdToGbp/main.go | 18 ++ .../history/historicRatesForACurrency/main.go | 18 ++ .../currency/rates/getRatesForUsd/main.go | 17 ++ examples/db/README.md | 66 ++-- .../db/count/countEntriesInATable/main.go | 17 ++ examples/db/create/createARecord/main.go | 23 ++ examples/db/delete/deleteARecord/main.go | 18 ++ examples/db/read/readRecords/main.go | 18 ++ examples/db/truncate/truncateTable/main.go | 17 ++ examples/db/update/updateARecord/main.go | 21 ++ examples/email/send/sendEmail/main.go | 21 ++ examples/emoji/find/findEmoji/main.go | 17 ++ .../emoji/flag/getFlagByCountryCode/main.go | 15 + .../print/printTextIncludingEmoji/main.go | 18 ++ .../main.go | 19 ++ examples/evchargers/README.md | 52 ++-- .../referenceData/getReferenceData/main.go | 15 + .../search/searchByBoundingBox/main.go | 17 ++ .../search/searchByLocation/main.go | 21 ++ .../searchWithFiltersFastChargersOnly/main.go | 22 ++ examples/event/README.md | 2 +- .../event/consume/consumeFromATopic/main.go | 17 ++ examples/event/publish/publishAnEvent/main.go | 22 ++ .../event/read/readEventsOnATopic/main.go | 17 ++ examples/file/delete/deleteFile/main.go | 18 ++ examples/file/list/listFiles/main.go | 17 ++ examples/file/read/readFile/main.go | 18 ++ examples/file/save/saveFile/main.go | 21 ++ examples/forex/README.md | 54 ++-- .../forex/history/getPreviousClose/main.go | 17 ++ examples/forex/price/getAnFxPrice/main.go | 17 ++ examples/forex/quote/getAFxQuote/main.go | 17 ++ examples/function/README.md | 62 ++-- examples/function/call/callAFunction/main.go | 18 ++ .../function/delete/deleteAFunction/main.go | 18 ++ .../function/deploy/deployAFunction/main.go | 21 ++ .../describe/describeFunctionStatus/main.go | 18 ++ examples/function/list/listFunctions/main.go | 15 + .../geocoding/lookup/geocodeAnAddress/main.go | 20 ++ .../reverse/reverseGeocodeLocation/main.go | 18 ++ examples/gifs/search/search/main.go | 18 ++ .../google/search/searchForVideos/main.go | 17 ++ .../call/callTheHelloworldService/main.go | 17 ++ .../main.go | 17 ++ .../holidays/countries/listCountries/main.go | 15 + examples/holidays/list/getHolidays/main.go | 17 ++ .../id/generate/generateABigflakeId/main.go | 17 ++ examples/id/generate/generateAShortId/main.go | 17 ++ .../id/generate/generateASnowflakeId/main.go | 17 ++ .../id/generate/generateAUniqueId/main.go | 17 ++ .../types/listTheTypesOfIdsAvailable/main.go | 15 + examples/image/README.md | 120 ++++---- .../main.go | 19 ++ .../image/resize/base64ToBase64Image/main.go | 21 ++ .../base64ToBase64ImageWithCropping/main.go | 25 ++ .../image/resize/base64ToHostedImage/main.go | 22 ++ .../uploadABase64ImageToMicrosCdn/main.go | 19 ++ .../uploadAnImageFromAUrlToMicrosCdn/main.go | 19 ++ examples/ip/lookup/lookupIpInfo/main.go | 17 ++ examples/location/README.md | 66 ++-- .../location/read/getLocationById/main.go | 17 ++ examples/location/save/saveAnEntity/main.go | 25 ++ .../search/searchForLocations/main.go | 23 ++ examples/mq/README.md | 2 +- examples/mq/publish/publishAMessage/main.go | 22 ++ .../mq/subscribe/subscribeToATopic/main.go | 17 ++ examples/notes/README.md | 56 ++-- examples/notes/create/createANote/main.go | 18 ++ examples/notes/delete/deleteANote/main.go | 17 ++ .../notes/events/subscribeToEvents/main.go | 17 ++ examples/notes/list/listAllNotes/main.go | 15 + examples/notes/read/readANote/main.go | 17 ++ examples/notes/update/updateANote/main.go | 21 ++ examples/otp/generate/generateOtp/main.go | 17 ++ examples/otp/validate/validateOtp/main.go | 18 ++ .../postcode/lookup/lookupPostcode/main.go | 17 ++ .../main.go | 15 + .../main.go | 17 ++ examples/prayer/times/prayerTimes/main.go | 17 ++ examples/qr/generate/generateAQrCode/main.go | 18 ++ examples/quran/README.md | 54 ++-- examples/quran/chapters/listChapters/main.go | 17 ++ examples/quran/search/searchTheQuran/main.go | 17 ++ .../quran/summary/getChapterSummary/main.go | 17 ++ .../quran/verses/getVersesOfAChapter/main.go | 19 ++ examples/routing/README.md | 68 ++--- .../directions/turnByTurnDirections/main.go | 24 ++ .../routing/eta/etaFromPointAToPointB/main.go | 24 ++ .../routing/route/gpsPointsForARoute/main.go | 24 ++ examples/rss/add/addANewFeed/main.go | 19 ++ examples/rss/feed/readAFeed/main.go | 17 ++ examples/rss/list/listRssFeeds/main.go | 15 + examples/rss/remove/removeAFeed/main.go | 17 ++ .../analyze/analyzeAPieceOfText/main.go | 17 ++ examples/sms/send/sendSms/main.go | 19 ++ examples/stock/README.md | 54 ++-- .../stock/history/getHistoricData/main.go | 18 ++ .../stock/orderBook/orderBookHistory/main.go | 21 ++ examples/stock/price/getAStockPrice/main.go | 17 ++ examples/stock/quote/getAStockQuote/main.go | 17 ++ examples/stream/README.md | 54 ++-- .../stream/publish/publishAMessage/main.go | 22 ++ .../subscribe/subscribeToATopic/main.go | 17 ++ .../getTheBooksWithinACollection/main.go | 18 ++ .../chapters/listTheChaptersInABook/main.go | 18 ++ .../listAvailableCollections/main.go | 16 + .../hadiths/listTheHadithsInABook/main.go | 19 ++ .../screenshot/takeScreenshotOfAUrl/main.go | 19 ++ .../main.go | 15 + .../main.go | 17 ++ examples/twitter/README.md | 56 ++-- .../twitter/search/searchForTweets/main.go | 17 ++ .../timeline/getATwitterTimeline/main.go | 18 ++ .../getTheCurrentGlobalTrendingTopics/main.go | 15 + .../user/getAUsersTwitterProfile/main.go | 17 ++ .../url/list/listYourShortenedUrls/main.go | 15 + .../main.go | 15 + examples/url/shorten/shortenALongUrl/main.go | 15 + examples/user/README.md | 282 +++++++++--------- examples/user/create/createAnAccount/main.go | 20 ++ .../user/delete/deleteUserAccount/main.go | 17 ++ examples/user/login/logAUserIn/main.go | 19 ++ examples/user/logout/logAUserOut/main.go | 17 ++ examples/user/read/readAccountByEmail/main.go | 17 ++ .../read/readAccountByUsernameOrEmail/main.go | 17 ++ examples/user/read/readAnAccountById/main.go | 17 ++ .../readASessionByTheSessionId/main.go | 17 ++ .../sendVerificationEmail/main.go | 30 ++ examples/user/update/updateAnAccount/main.go | 18 ++ .../updateTheAccountPassword/main.go | 19 ++ examples/user/verifyEmail/verifyEmail/main.go | 17 ++ examples/vehicle/lookup/lookupVehicle/main.go | 17 ++ .../weather/forecast/forecastWeather/main.go | 18 ++ .../weather/now/getCurrentWeather/main.go | 17 ++ .../youtube/search/searchForVideos/main.go | 17 ++ 149 files changed, 2957 insertions(+), 552 deletions(-) create mode 100755 examples/address/lookupPostcode/lookupPostcode/main.go create mode 100755 examples/answer/question/askAQuestion/main.go create mode 100755 examples/cache/decrement/decrementAValue/main.go create mode 100755 examples/cache/delete/deleteAValue/main.go create mode 100755 examples/cache/get/getAValue/main.go create mode 100755 examples/cache/increment/incrementAValue/main.go create mode 100755 examples/cache/set/setAValue/main.go create mode 100755 examples/crypto/history/getPreviousClose/main.go create mode 100755 examples/crypto/news/getCryptocurrencyNews/main.go create mode 100755 examples/crypto/price/getCryptocurrencyPrice/main.go create mode 100755 examples/crypto/quote/getACryptocurrencyQuote/main.go create mode 100755 examples/currency/codes/getSupportedCodes/main.go create mode 100755 examples/currency/convert/convert10UsdToGbp/main.go create mode 100755 examples/currency/convert/convertUsdToGbp/main.go create mode 100755 examples/currency/history/historicRatesForACurrency/main.go create mode 100755 examples/currency/rates/getRatesForUsd/main.go create mode 100755 examples/db/count/countEntriesInATable/main.go create mode 100755 examples/db/create/createARecord/main.go create mode 100755 examples/db/delete/deleteARecord/main.go create mode 100755 examples/db/read/readRecords/main.go create mode 100755 examples/db/truncate/truncateTable/main.go create mode 100755 examples/db/update/updateARecord/main.go create mode 100755 examples/email/send/sendEmail/main.go create mode 100755 examples/emoji/find/findEmoji/main.go create mode 100755 examples/emoji/flag/getFlagByCountryCode/main.go create mode 100755 examples/emoji/print/printTextIncludingEmoji/main.go create mode 100755 examples/emoji/send/sendATextContainingAnEmojiToAnyoneViaSms/main.go create mode 100755 examples/evchargers/referenceData/getReferenceData/main.go create mode 100755 examples/evchargers/search/searchByBoundingBox/main.go create mode 100755 examples/evchargers/search/searchByLocation/main.go create mode 100755 examples/evchargers/search/searchWithFiltersFastChargersOnly/main.go create mode 100755 examples/event/consume/consumeFromATopic/main.go create mode 100755 examples/event/publish/publishAnEvent/main.go create mode 100755 examples/event/read/readEventsOnATopic/main.go create mode 100755 examples/file/delete/deleteFile/main.go create mode 100755 examples/file/list/listFiles/main.go create mode 100755 examples/file/read/readFile/main.go create mode 100755 examples/file/save/saveFile/main.go create mode 100755 examples/forex/history/getPreviousClose/main.go create mode 100755 examples/forex/price/getAnFxPrice/main.go create mode 100755 examples/forex/quote/getAFxQuote/main.go create mode 100755 examples/function/call/callAFunction/main.go create mode 100755 examples/function/delete/deleteAFunction/main.go create mode 100755 examples/function/deploy/deployAFunction/main.go create mode 100755 examples/function/describe/describeFunctionStatus/main.go create mode 100755 examples/function/list/listFunctions/main.go create mode 100755 examples/geocoding/lookup/geocodeAnAddress/main.go create mode 100755 examples/geocoding/reverse/reverseGeocodeLocation/main.go create mode 100755 examples/gifs/search/search/main.go create mode 100755 examples/google/search/searchForVideos/main.go create mode 100755 examples/helloworld/call/callTheHelloworldService/main.go create mode 100755 examples/helloworld/stream/streamsAreCurrentlyTemporarilyNotSupportedInClients/main.go create mode 100755 examples/holidays/countries/listCountries/main.go create mode 100755 examples/holidays/list/getHolidays/main.go create mode 100755 examples/id/generate/generateABigflakeId/main.go create mode 100755 examples/id/generate/generateAShortId/main.go create mode 100755 examples/id/generate/generateASnowflakeId/main.go create mode 100755 examples/id/generate/generateAUniqueId/main.go create mode 100755 examples/id/types/listTheTypesOfIdsAvailable/main.go create mode 100755 examples/image/convert/convertAPngImageToAJpegTakenFromAUrlAndSavedToAUrlOnMicrosCdn/main.go create mode 100755 examples/image/resize/base64ToBase64Image/main.go create mode 100755 examples/image/resize/base64ToBase64ImageWithCropping/main.go create mode 100755 examples/image/resize/base64ToHostedImage/main.go create mode 100755 examples/image/upload/uploadABase64ImageToMicrosCdn/main.go create mode 100755 examples/image/upload/uploadAnImageFromAUrlToMicrosCdn/main.go create mode 100755 examples/ip/lookup/lookupIpInfo/main.go create mode 100755 examples/location/read/getLocationById/main.go create mode 100755 examples/location/save/saveAnEntity/main.go create mode 100755 examples/location/search/searchForLocations/main.go create mode 100755 examples/mq/publish/publishAMessage/main.go create mode 100755 examples/mq/subscribe/subscribeToATopic/main.go create mode 100755 examples/notes/create/createANote/main.go create mode 100755 examples/notes/delete/deleteANote/main.go create mode 100755 examples/notes/events/subscribeToEvents/main.go create mode 100755 examples/notes/list/listAllNotes/main.go create mode 100755 examples/notes/read/readANote/main.go create mode 100755 examples/notes/update/updateANote/main.go create mode 100755 examples/otp/generate/generateOtp/main.go create mode 100755 examples/otp/validate/validateOtp/main.go create mode 100755 examples/postcode/lookup/lookupPostcode/main.go create mode 100755 examples/postcode/random/returnARandomPostcodeAndItsInformation/main.go create mode 100755 examples/postcode/validate/returnARandomPostcodeAndItsInformation/main.go create mode 100755 examples/prayer/times/prayerTimes/main.go create mode 100755 examples/qr/generate/generateAQrCode/main.go create mode 100755 examples/quran/chapters/listChapters/main.go create mode 100755 examples/quran/search/searchTheQuran/main.go create mode 100755 examples/quran/summary/getChapterSummary/main.go create mode 100755 examples/quran/verses/getVersesOfAChapter/main.go create mode 100755 examples/routing/directions/turnByTurnDirections/main.go create mode 100755 examples/routing/eta/etaFromPointAToPointB/main.go create mode 100755 examples/routing/route/gpsPointsForARoute/main.go create mode 100755 examples/rss/add/addANewFeed/main.go create mode 100755 examples/rss/feed/readAFeed/main.go create mode 100755 examples/rss/list/listRssFeeds/main.go create mode 100755 examples/rss/remove/removeAFeed/main.go create mode 100755 examples/sentiment/analyze/analyzeAPieceOfText/main.go create mode 100755 examples/sms/send/sendSms/main.go create mode 100755 examples/stock/history/getHistoricData/main.go create mode 100755 examples/stock/orderBook/orderBookHistory/main.go create mode 100755 examples/stock/price/getAStockPrice/main.go create mode 100755 examples/stock/quote/getAStockQuote/main.go create mode 100755 examples/stream/publish/publishAMessage/main.go create mode 100755 examples/stream/subscribe/subscribeToATopic/main.go create mode 100755 examples/sunnah/books/getTheBooksWithinACollection/main.go create mode 100755 examples/sunnah/chapters/listTheChaptersInABook/main.go create mode 100755 examples/sunnah/collections/listAvailableCollections/main.go create mode 100755 examples/sunnah/hadiths/listTheHadithsInABook/main.go create mode 100755 examples/thumbnail/screenshot/takeScreenshotOfAUrl/main.go create mode 100755 examples/time/now/returnsCurrentTimeOptionallyWithLocation/main.go create mode 100755 examples/time/zone/getTheTimezoneInfoForASpecificLocation/main.go create mode 100755 examples/twitter/search/searchForTweets/main.go create mode 100755 examples/twitter/timeline/getATwitterTimeline/main.go create mode 100755 examples/twitter/trends/getTheCurrentGlobalTrendingTopics/main.go create mode 100755 examples/twitter/user/getAUsersTwitterProfile/main.go create mode 100755 examples/url/list/listYourShortenedUrls/main.go create mode 100755 examples/url/proxy/resolveAShortUrlToALongDestinationUrl/main.go create mode 100755 examples/url/shorten/shortenALongUrl/main.go create mode 100755 examples/user/create/createAnAccount/main.go create mode 100755 examples/user/delete/deleteUserAccount/main.go create mode 100755 examples/user/login/logAUserIn/main.go create mode 100755 examples/user/logout/logAUserOut/main.go create mode 100755 examples/user/read/readAccountByEmail/main.go create mode 100755 examples/user/read/readAccountByUsernameOrEmail/main.go create mode 100755 examples/user/read/readAnAccountById/main.go create mode 100755 examples/user/readSession/readASessionByTheSessionId/main.go create mode 100755 examples/user/sendVerificationEmail/sendVerificationEmail/main.go create mode 100755 examples/user/update/updateAnAccount/main.go create mode 100755 examples/user/updatePassword/updateTheAccountPassword/main.go create mode 100755 examples/user/verifyEmail/verifyEmail/main.go create mode 100755 examples/vehicle/lookup/lookupVehicle/main.go create mode 100755 examples/weather/forecast/forecastWeather/main.go create mode 100755 examples/weather/now/getCurrentWeather/main.go create mode 100755 examples/youtube/search/searchForVideos/main.go diff --git a/examples/address/lookupPostcode/lookupPostcode/main.go b/examples/address/lookupPostcode/lookupPostcode/main.go new file mode 100755 index 0000000..f1e2135 --- /dev/null +++ b/examples/address/lookupPostcode/lookupPostcode/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/address" +) + +// Lookup a list of UK addresses by postcode +func main() { + 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/question/askAQuestion/main.go b/examples/answer/question/askAQuestion/main.go new file mode 100755 index 0000000..48f6322 --- /dev/null +++ b/examples/answer/question/askAQuestion/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/answer" +) + +// Ask a question and receive an instant answer +func main() { + 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 index 9172036..8355dcc 100755 --- a/examples/cache/README.md +++ b/examples/cache/README.md @@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Cache/api](htt Endpoints: +## Set + +Set an item in the cache. Overwrites any existing value already set. + + +[https://m3o.com/cache/api#Set](https://m3o.com/cache/api#Set) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/cache" +) + +// Set an item in the cache. Overwrites any existing value already set. +func SetAvalue() { + cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN")) + rsp, err := cacheService.Set(&cache.SetRequest{ + Key: "foo", +Value: "bar", + + }) + fmt.Println(rsp, err) +} +``` ## Get Get an item from the cache by key @@ -114,31 +142,3 @@ Value: 2, fmt.Println(rsp, err) } ``` -## Set - -Set an item in the cache. Overwrites any existing value already set. - - -[https://m3o.com/cache/api#Set](https://m3o.com/cache/api#Set) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/cache" -) - -// Set an item in the cache. Overwrites any existing value already set. -func SetAvalue() { - cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN")) - rsp, err := cacheService.Set(&cache.SetRequest{ - Key: "foo", -Value: "bar", - - }) - fmt.Println(rsp, err) -} -``` diff --git a/examples/cache/decrement/decrementAValue/main.go b/examples/cache/decrement/decrementAValue/main.go new file mode 100755 index 0000000..83dbaf5 --- /dev/null +++ b/examples/cache/decrement/decrementAValue/main.go @@ -0,0 +1,18 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/cache" +) + +// Decrement a value (if it's a number) +func main() { + 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/main.go b/examples/cache/delete/deleteAValue/main.go new file mode 100755 index 0000000..285fa47 --- /dev/null +++ b/examples/cache/delete/deleteAValue/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/cache" +) + +// Delete a value from the cache +func main() { + 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/main.go b/examples/cache/get/getAValue/main.go new file mode 100755 index 0000000..652187e --- /dev/null +++ b/examples/cache/get/getAValue/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/cache" +) + +// Get an item from the cache by key +func main() { + 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/main.go b/examples/cache/increment/incrementAValue/main.go new file mode 100755 index 0000000..f2e1c95 --- /dev/null +++ b/examples/cache/increment/incrementAValue/main.go @@ -0,0 +1,18 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/cache" +) + +// Increment a value (if it's a number) +func main() { + 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/main.go b/examples/cache/set/setAValue/main.go new file mode 100755 index 0000000..de832c1 --- /dev/null +++ b/examples/cache/set/setAValue/main.go @@ -0,0 +1,18 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/cache" +) + +// Set an item in the cache. Overwrites any existing value already set. +func main() { + 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/history/getPreviousClose/main.go b/examples/crypto/history/getPreviousClose/main.go new file mode 100755 index 0000000..3edca22 --- /dev/null +++ b/examples/crypto/history/getPreviousClose/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/crypto" +) + +// Returns the history for the previous close +func main() { + 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/main.go b/examples/crypto/news/getCryptocurrencyNews/main.go new file mode 100755 index 0000000..af5412c --- /dev/null +++ b/examples/crypto/news/getCryptocurrencyNews/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/crypto" +) + +// Get news related to a currency +func main() { + 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/main.go b/examples/crypto/price/getCryptocurrencyPrice/main.go new file mode 100755 index 0000000..4bba4fe --- /dev/null +++ b/examples/crypto/price/getCryptocurrencyPrice/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/crypto" +) + +// Get the last price for a given crypto ticker +func main() { + 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/main.go b/examples/crypto/quote/getACryptocurrencyQuote/main.go new file mode 100755 index 0000000..464fce7 --- /dev/null +++ b/examples/crypto/quote/getACryptocurrencyQuote/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/crypto" +) + +// Get the last quote for a given crypto ticker +func main() { + 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/codes/getSupportedCodes/main.go b/examples/currency/codes/getSupportedCodes/main.go new file mode 100755 index 0000000..17d658e --- /dev/null +++ b/examples/currency/codes/getSupportedCodes/main.go @@ -0,0 +1,15 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/currency" +) + +// Codes returns the supported currency codes for the API +func main() { + 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/main.go b/examples/currency/convert/convert10UsdToGbp/main.go new file mode 100755 index 0000000..75aa7b5 --- /dev/null +++ b/examples/currency/convert/convert10UsdToGbp/main.go @@ -0,0 +1,19 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/currency" +) + +// Convert returns the currency conversion rate between two pairs e.g USD/GBP +func main() { + 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/main.go b/examples/currency/convert/convertUsdToGbp/main.go new file mode 100755 index 0000000..2a87d8d --- /dev/null +++ b/examples/currency/convert/convertUsdToGbp/main.go @@ -0,0 +1,18 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/currency" +) + +// Convert returns the currency conversion rate between two pairs e.g USD/GBP +func main() { + 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/main.go b/examples/currency/history/historicRatesForACurrency/main.go new file mode 100755 index 0000000..1a6de42 --- /dev/null +++ b/examples/currency/history/historicRatesForACurrency/main.go @@ -0,0 +1,18 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/currency" +) + +// Returns the historic rates for a currency on a given date +func main() { + 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/main.go b/examples/currency/rates/getRatesForUsd/main.go new file mode 100755 index 0000000..5d86627 --- /dev/null +++ b/examples/currency/rates/getRatesForUsd/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/currency" +) + +// Rates returns the currency rates for a given code e.g USD +func main() { + 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 index a242107..961d750 100755 --- a/examples/db/README.md +++ b/examples/db/README.md @@ -4,37 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Db/api](https: Endpoints: -## Update - -Update a record in the database. Include an "id" in the record to update. - - -[https://m3o.com/db/api#Update](https://m3o.com/db/api#Update) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/db" -) - -// Update a record in the database. Include an "id" in the record to update. -func UpdateArecord() { - dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) - rsp, err := dbService.Update(&db.UpdateRequest{ - Record: map[string]interface{}{ - "id": "1", - "age": 43, -}, -Table: "users", - - }) - fmt.Println(rsp, err) -} -``` ## Read Read data from a table. Lookup can be by ID or via querying any field in the record. @@ -167,10 +136,41 @@ func CreateArecord() { dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) rsp, err := dbService.Create(&db.CreateRequest{ Record: map[string]interface{}{ - "age": 42, - "isActive": true, "id": "1", "name": "Jane", + "age": 42, + "isActive": true, +}, +Table: "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" + + "go.m3o.com/db" +) + +// Update a record in the database. Include an "id" in the record to update. +func UpdateArecord() { + dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) + rsp, err := dbService.Update(&db.UpdateRequest{ + Record: map[string]interface{}{ + "id": "1", + "age": 43, }, Table: "users", diff --git a/examples/db/count/countEntriesInATable/main.go b/examples/db/count/countEntriesInATable/main.go new file mode 100755 index 0000000..26500a0 --- /dev/null +++ b/examples/db/count/countEntriesInATable/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/db" +) + +// Count records in a table +func main() { + dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) + rsp, err := dbService.Count(&db.CountRequest{ + Table: "users", + }) + fmt.Println(rsp, err) +} diff --git a/examples/db/create/createARecord/main.go b/examples/db/create/createARecord/main.go new file mode 100755 index 0000000..d4b3272 --- /dev/null +++ b/examples/db/create/createARecord/main.go @@ -0,0 +1,23 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/db" +) + +// Create a record in the database. Optionally include an "id" field otherwise it's set automatically. +func main() { + dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) + rsp, err := dbService.Create(&db.CreateRequest{ + Record: map[string]interface{}{ + "id": "1", + "name": "Jane", + "age": 42, + "isActive": true, + }, + Table: "users", + }) + fmt.Println(rsp, err) +} diff --git a/examples/db/delete/deleteARecord/main.go b/examples/db/delete/deleteARecord/main.go new file mode 100755 index 0000000..a3a9513 --- /dev/null +++ b/examples/db/delete/deleteARecord/main.go @@ -0,0 +1,18 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/db" +) + +// Delete a record in the database by id. +func main() { + 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/main.go b/examples/db/read/readRecords/main.go new file mode 100755 index 0000000..2329dcb --- /dev/null +++ b/examples/db/read/readRecords/main.go @@ -0,0 +1,18 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/db" +) + +// Read data from a table. Lookup can be by ID or via querying any field in the record. +func main() { + 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/main.go b/examples/db/truncate/truncateTable/main.go new file mode 100755 index 0000000..d2e9af8 --- /dev/null +++ b/examples/db/truncate/truncateTable/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/db" +) + +// Truncate the records in a table +func main() { + 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/main.go b/examples/db/update/updateARecord/main.go new file mode 100755 index 0000000..b226b80 --- /dev/null +++ b/examples/db/update/updateARecord/main.go @@ -0,0 +1,21 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/db" +) + +// Update a record in the database. Include an "id" in the record to update. +func main() { + dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) + rsp, err := dbService.Update(&db.UpdateRequest{ + Record: map[string]interface{}{ + "id": "1", + "age": 43, + }, + Table: "users", + }) + fmt.Println(rsp, err) +} diff --git a/examples/email/send/sendEmail/main.go b/examples/email/send/sendEmail/main.go new file mode 100755 index 0000000..51a86b4 --- /dev/null +++ b/examples/email/send/sendEmail/main.go @@ -0,0 +1,21 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/email" +) + +// Send an email by passing in from, to, subject, and a text or html body +func main() { + 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/find/findEmoji/main.go b/examples/emoji/find/findEmoji/main.go new file mode 100755 index 0000000..941278e --- /dev/null +++ b/examples/emoji/find/findEmoji/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/emoji" +) + +// Find an emoji by its alias e.g :beer: +func main() { + 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/main.go b/examples/emoji/flag/getFlagByCountryCode/main.go new file mode 100755 index 0000000..d8d302e --- /dev/null +++ b/examples/emoji/flag/getFlagByCountryCode/main.go @@ -0,0 +1,15 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/emoji" +) + +// Get the flag for a country. Requires country code e.g GB for great britain +func main() { + 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/main.go b/examples/emoji/print/printTextIncludingEmoji/main.go new file mode 100755 index 0000000..ed604d7 --- /dev/null +++ b/examples/emoji/print/printTextIncludingEmoji/main.go @@ -0,0 +1,18 @@ +package main + +import ( + "fmt" + "os" + + "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 main() { + 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/main.go b/examples/emoji/send/sendATextContainingAnEmojiToAnyoneViaSms/main.go new file mode 100755 index 0000000..459dde3 --- /dev/null +++ b/examples/emoji/send/sendATextContainingAnEmojiToAnyoneViaSms/main.go @@ -0,0 +1,19 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/emoji" +) + +// Send an emoji to anyone via SMS. Messages are sent in the form ' Sent from ' +func main() { + 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 index d687fe8..81daae4 100755 --- a/examples/evchargers/README.md +++ b/examples/evchargers/README.md @@ -4,32 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Evchargers/api Endpoints: -## ReferenceData - -Retrieve reference data as used by this API and in conjunction with the Search endpoint - - -[https://m3o.com/evchargers/api#ReferenceData](https://m3o.com/evchargers/api#ReferenceData) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/evchargers" -) - -// Retrieve reference data as used by this API and in conjunction with the Search endpoint -func GetReferenceData() { - evchargersService := evchargers.NewEvchargersService(os.Getenv("M3O_API_TOKEN")) - rsp, err := evchargersService.ReferenceData(&evchargers.ReferenceDataRequest{ - - }) - fmt.Println(rsp, err) -} -``` ## Search Search by giving a coordinate and a max distance, or bounding box and optional filters @@ -121,3 +95,29 @@ Location: &evchargers.Coordinates{ 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" + + "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/main.go b/examples/evchargers/referenceData/getReferenceData/main.go new file mode 100755 index 0000000..5860273 --- /dev/null +++ b/examples/evchargers/referenceData/getReferenceData/main.go @@ -0,0 +1,15 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/evchargers" +) + +// Retrieve reference data as used by this API and in conjunction with the Search endpoint +func main() { + 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/main.go b/examples/evchargers/search/searchByBoundingBox/main.go new file mode 100755 index 0000000..ec4095f --- /dev/null +++ b/examples/evchargers/search/searchByBoundingBox/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/evchargers" +) + +// Search by giving a coordinate and a max distance, or bounding box and optional filters +func main() { + 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/main.go b/examples/evchargers/search/searchByLocation/main.go new file mode 100755 index 0000000..1bcc6eb --- /dev/null +++ b/examples/evchargers/search/searchByLocation/main.go @@ -0,0 +1,21 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/evchargers" +) + +// Search by giving a coordinate and a max distance, or bounding box and optional filters +func main() { + 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/main.go b/examples/evchargers/search/searchWithFiltersFastChargersOnly/main.go new file mode 100755 index 0000000..b35f129 --- /dev/null +++ b/examples/evchargers/search/searchWithFiltersFastChargersOnly/main.go @@ -0,0 +1,22 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/evchargers" +) + +// Search by giving a coordinate and a max distance, or bounding box and optional filters +func main() { + 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/event/README.md b/examples/event/README.md index 8c6d736..38d6199 100755 --- a/examples/event/README.md +++ b/examples/event/README.md @@ -26,9 +26,9 @@ func PublishAnEvent() { eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN")) rsp, err := eventService.Publish(&event.PublishRequest{ Message: map[string]interface{}{ - "user": "john", "id": "1", "type": "signup", + "user": "john", }, Topic: "user", diff --git a/examples/event/consume/consumeFromATopic/main.go b/examples/event/consume/consumeFromATopic/main.go new file mode 100755 index 0000000..b45abf4 --- /dev/null +++ b/examples/event/consume/consumeFromATopic/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/event" +) + +// Consume events from a given topic. +func main() { + eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN")) + rsp, err := eventService.Consume(&event.ConsumeRequest{ + Topic: "user", + }) + fmt.Println(rsp, err) +} diff --git a/examples/event/publish/publishAnEvent/main.go b/examples/event/publish/publishAnEvent/main.go new file mode 100755 index 0000000..eb4cfd3 --- /dev/null +++ b/examples/event/publish/publishAnEvent/main.go @@ -0,0 +1,22 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/event" +) + +// Publish a event to the event stream. +func main() { + eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN")) + rsp, err := eventService.Publish(&event.PublishRequest{ + Message: map[string]interface{}{ + "user": "john", + "id": "1", + "type": "signup", + }, + Topic: "user", + }) + fmt.Println(rsp, err) +} diff --git a/examples/event/read/readEventsOnATopic/main.go b/examples/event/read/readEventsOnATopic/main.go new file mode 100755 index 0000000..3d0e67a --- /dev/null +++ b/examples/event/read/readEventsOnATopic/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/event" +) + +// Read stored events +func main() { + eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN")) + rsp, err := eventService.Read(&event.ReadRequest{ + Topic: "user", + }) + fmt.Println(rsp, err) +} diff --git a/examples/file/delete/deleteFile/main.go b/examples/file/delete/deleteFile/main.go new file mode 100755 index 0000000..841ed3b --- /dev/null +++ b/examples/file/delete/deleteFile/main.go @@ -0,0 +1,18 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/file" +) + +// Delete a file by project name/path +func main() { + 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/main.go b/examples/file/list/listFiles/main.go new file mode 100755 index 0000000..cbc502c --- /dev/null +++ b/examples/file/list/listFiles/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/file" +) + +// List files by their project and optionally a path. +func main() { + 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/main.go b/examples/file/read/readFile/main.go new file mode 100755 index 0000000..a64f84c --- /dev/null +++ b/examples/file/read/readFile/main.go @@ -0,0 +1,18 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/file" +) + +// Read a file by path +func main() { + 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/main.go b/examples/file/save/saveFile/main.go new file mode 100755 index 0000000..178b924 --- /dev/null +++ b/examples/file/save/saveFile/main.go @@ -0,0 +1,21 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/file" +) + +// Save a file +func main() { + 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 index 3cea13c..8fe80a6 100755 --- a/examples/forex/README.md +++ b/examples/forex/README.md @@ -4,33 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Forex/api](htt Endpoints: -## History - -Returns the data for the previous close - - -[https://m3o.com/forex/api#History](https://m3o.com/forex/api#History) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/forex" -) - -// Returns the data for the previous close -func GetPreviousClose() { - forexService := forex.NewForexService(os.Getenv("M3O_API_TOKEN")) - rsp, err := forexService.History(&forex.HistoryRequest{ - Symbol: "GBPUSD", - - }) - fmt.Println(rsp, err) -} -``` ## Price Get the latest price for a given forex ticker @@ -85,3 +58,30 @@ func GetAfxQuote() { 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" + + "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/main.go b/examples/forex/history/getPreviousClose/main.go new file mode 100755 index 0000000..63da6aa --- /dev/null +++ b/examples/forex/history/getPreviousClose/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/forex" +) + +// Returns the data for the previous close +func main() { + 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/main.go b/examples/forex/price/getAnFxPrice/main.go new file mode 100755 index 0000000..291f0ae --- /dev/null +++ b/examples/forex/price/getAnFxPrice/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/forex" +) + +// Get the latest price for a given forex ticker +func main() { + 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/main.go b/examples/forex/quote/getAFxQuote/main.go new file mode 100755 index 0000000..3dc6e99 --- /dev/null +++ b/examples/forex/quote/getAFxQuote/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/forex" +) + +// Get the latest quote for the forex +func main() { + 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 index 13108b1..3a72ea5 100755 --- a/examples/function/README.md +++ b/examples/function/README.md @@ -4,6 +4,37 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Function/api]( Endpoints: +## Deploy + +Deploy a group of functions + + +[https://m3o.com/function/api#Deploy](https://m3o.com/function/api#Deploy) + +```go +package example + +import( + "fmt" + "os" + + "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 @@ -115,34 +146,3 @@ 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" - - "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/call/callAFunction/main.go b/examples/function/call/callAFunction/main.go new file mode 100755 index 0000000..a39a95e --- /dev/null +++ b/examples/function/call/callAFunction/main.go @@ -0,0 +1,18 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/function" +) + +// Call a function by name +func main() { + 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/main.go b/examples/function/delete/deleteAFunction/main.go new file mode 100755 index 0000000..30b37fd --- /dev/null +++ b/examples/function/delete/deleteAFunction/main.go @@ -0,0 +1,18 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/function" +) + +// Delete a function by name +func main() { + 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/main.go b/examples/function/deploy/deployAFunction/main.go new file mode 100755 index 0000000..4ee23e4 --- /dev/null +++ b/examples/function/deploy/deployAFunction/main.go @@ -0,0 +1,21 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/function" +) + +// Deploy a group of functions +func main() { + 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/main.go b/examples/function/describe/describeFunctionStatus/main.go new file mode 100755 index 0000000..0e2df81 --- /dev/null +++ b/examples/function/describe/describeFunctionStatus/main.go @@ -0,0 +1,18 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/function" +) + +// Get the info for a deployed function +func main() { + 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/main.go b/examples/function/list/listFunctions/main.go new file mode 100755 index 0000000..109cd6a --- /dev/null +++ b/examples/function/list/listFunctions/main.go @@ -0,0 +1,15 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/function" +) + +// List all the deployed functions +func main() { + functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) + rsp, err := functionService.List(&function.ListRequest{}) + fmt.Println(rsp, err) +} diff --git a/examples/geocoding/lookup/geocodeAnAddress/main.go b/examples/geocoding/lookup/geocodeAnAddress/main.go new file mode 100755 index 0000000..eeb3ae9 --- /dev/null +++ b/examples/geocoding/lookup/geocodeAnAddress/main.go @@ -0,0 +1,20 @@ +package main + +import ( + "fmt" + "os" + + "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 main() { + 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/main.go b/examples/geocoding/reverse/reverseGeocodeLocation/main.go new file mode 100755 index 0000000..1285f0e --- /dev/null +++ b/examples/geocoding/reverse/reverseGeocodeLocation/main.go @@ -0,0 +1,18 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/geocoding" +) + +// Reverse lookup an address from gps coordinates +func main() { + 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/search/search/main.go b/examples/gifs/search/search/main.go new file mode 100755 index 0000000..60535bb --- /dev/null +++ b/examples/gifs/search/search/main.go @@ -0,0 +1,18 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/gifs" +) + +// Search for a GIF +func main() { + 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/search/searchForVideos/main.go b/examples/google/search/searchForVideos/main.go new file mode 100755 index 0000000..f305ce8 --- /dev/null +++ b/examples/google/search/searchForVideos/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/google" +) + +// Search for videos on Google +func main() { + 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/call/callTheHelloworldService/main.go b/examples/helloworld/call/callTheHelloworldService/main.go new file mode 100755 index 0000000..886f101 --- /dev/null +++ b/examples/helloworld/call/callTheHelloworldService/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/helloworld" +) + +// Call returns a personalised "Hello $name" response +func main() { + 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/main.go b/examples/helloworld/stream/streamsAreCurrentlyTemporarilyNotSupportedInClients/main.go new file mode 100755 index 0000000..a81aaa5 --- /dev/null +++ b/examples/helloworld/stream/streamsAreCurrentlyTemporarilyNotSupportedInClients/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/helloworld" +) + +// Stream returns a stream of "Hello $name" responses +func main() { + 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/countries/listCountries/main.go b/examples/holidays/countries/listCountries/main.go new file mode 100755 index 0000000..3dc2dc6 --- /dev/null +++ b/examples/holidays/countries/listCountries/main.go @@ -0,0 +1,15 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/holidays" +) + +// Get the list of countries that are supported by this API +func main() { + 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/main.go b/examples/holidays/list/getHolidays/main.go new file mode 100755 index 0000000..1391a60 --- /dev/null +++ b/examples/holidays/list/getHolidays/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/holidays" +) + +// List the holiday dates for a given country and year +func main() { + 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/generate/generateABigflakeId/main.go b/examples/id/generate/generateABigflakeId/main.go new file mode 100755 index 0000000..8d8bc5f --- /dev/null +++ b/examples/id/generate/generateABigflakeId/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/id" +) + +// Generate a unique ID. Defaults to uuid. +func main() { + 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/main.go b/examples/id/generate/generateAShortId/main.go new file mode 100755 index 0000000..c68843e --- /dev/null +++ b/examples/id/generate/generateAShortId/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/id" +) + +// Generate a unique ID. Defaults to uuid. +func main() { + 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/main.go b/examples/id/generate/generateASnowflakeId/main.go new file mode 100755 index 0000000..4194e0c --- /dev/null +++ b/examples/id/generate/generateASnowflakeId/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/id" +) + +// Generate a unique ID. Defaults to uuid. +func main() { + 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/main.go b/examples/id/generate/generateAUniqueId/main.go new file mode 100755 index 0000000..934d6c4 --- /dev/null +++ b/examples/id/generate/generateAUniqueId/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/id" +) + +// Generate a unique ID. Defaults to uuid. +func main() { + 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/main.go b/examples/id/types/listTheTypesOfIdsAvailable/main.go new file mode 100755 index 0000000..ce5f77e --- /dev/null +++ b/examples/id/types/listTheTypesOfIdsAvailable/main.go @@ -0,0 +1,15 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/id" +) + +// List the types of IDs available. No query params needed. +func main() { + 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 index 1d58d10..e590a10 100755 --- a/examples/image/README.md +++ b/examples/image/README.md @@ -4,6 +4,66 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Image/api](htt Endpoints: +## Upload + +Upload an image by either sending a base64 encoded image to this endpoint or a URL. +To resize an image before uploading, see the Resize endpoint. + + +[https://m3o.com/image/api#Upload](https://m3o.com/image/api#Upload) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/image" +) + +// Upload an image by either sending a base64 encoded image to this endpoint or a URL. +// To resize an image before uploading, see the Resize endpoint. +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" + + "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) +} +``` ## 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. @@ -138,63 +198,3 @@ 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" - - "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" - - "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/main.go b/examples/image/convert/convertAPngImageToAJpegTakenFromAUrlAndSavedToAUrlOnMicrosCdn/main.go new file mode 100755 index 0000000..f700a86 --- /dev/null +++ b/examples/image/convert/convertAPngImageToAJpegTakenFromAUrlAndSavedToAUrlOnMicrosCdn/main.go @@ -0,0 +1,19 @@ +package main + +import ( + "fmt" + "os" + + "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 main() { + 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/main.go b/examples/image/resize/base64ToBase64Image/main.go new file mode 100755 index 0000000..1a236e1 --- /dev/null +++ b/examples/image/resize/base64ToBase64Image/main.go @@ -0,0 +1,21 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/image" +) + +// Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters. +// If one of width or height is 0, the image aspect ratio is preserved. +// Optional cropping. +func main() { + 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/main.go b/examples/image/resize/base64ToBase64ImageWithCropping/main.go new file mode 100755 index 0000000..4448207 --- /dev/null +++ b/examples/image/resize/base64ToBase64ImageWithCropping/main.go @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/image" +) + +// Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters. +// If one of width or height is 0, the image aspect ratio is preserved. +// Optional cropping. +func main() { + 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/main.go b/examples/image/resize/base64ToHostedImage/main.go new file mode 100755 index 0000000..ed31ece --- /dev/null +++ b/examples/image/resize/base64ToHostedImage/main.go @@ -0,0 +1,22 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/image" +) + +// Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters. +// If one of width or height is 0, the image aspect ratio is preserved. +// Optional cropping. +func main() { + 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/main.go b/examples/image/upload/uploadABase64ImageToMicrosCdn/main.go new file mode 100755 index 0000000..646899d --- /dev/null +++ b/examples/image/upload/uploadABase64ImageToMicrosCdn/main.go @@ -0,0 +1,19 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/image" +) + +// Upload an image by either sending a base64 encoded image to this endpoint or a URL. +// To resize an image before uploading, see the Resize endpoint. +func main() { + 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/main.go b/examples/image/upload/uploadAnImageFromAUrlToMicrosCdn/main.go new file mode 100755 index 0000000..11b51fb --- /dev/null +++ b/examples/image/upload/uploadAnImageFromAUrlToMicrosCdn/main.go @@ -0,0 +1,19 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/image" +) + +// Upload an image by either sending a base64 encoded image to this endpoint or a URL. +// To resize an image before uploading, see the Resize endpoint. +func main() { + 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/lookup/lookupIpInfo/main.go b/examples/ip/lookup/lookupIpInfo/main.go new file mode 100755 index 0000000..75269c6 --- /dev/null +++ b/examples/ip/lookup/lookupIpInfo/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/ip" +) + +// Lookup the geolocation information for an IP address +func main() { + 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 index 828fe78..999a2ca 100755 --- a/examples/location/README.md +++ b/examples/location/README.md @@ -4,6 +4,39 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Location/api]( Endpoints: +## Search + +Search for entities in a given radius + + +[https://m3o.com/location/api#Search](https://m3o.com/location/api#Search) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/location" +) + +// Search for entities in a given radius +func SearchForLocations() { + locationService := location.NewLocationService(os.Getenv("M3O_API_TOKEN")) + rsp, err := locationService.Search(&location.SearchRequest{ + Center: &location.Point{ + Latitude: 51.511061, + Longitude: -0.120022, + }, +NumEntities: 10, +Radius: 100, +Type: "bike", + + }) + fmt.Println(rsp, err) +} +``` ## Save Save an entity's current position @@ -66,36 +99,3 @@ func GetLocationById() { fmt.Println(rsp, err) } ``` -## Search - -Search for entities in a given radius - - -[https://m3o.com/location/api#Search](https://m3o.com/location/api#Search) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/location" -) - -// Search for entities in a given radius -func SearchForLocations() { - locationService := location.NewLocationService(os.Getenv("M3O_API_TOKEN")) - rsp, err := locationService.Search(&location.SearchRequest{ - Center: &location.Point{ - Latitude: 51.511061, - Longitude: -0.120022, - }, -NumEntities: 10, -Radius: 100, -Type: "bike", - - }) - fmt.Println(rsp, err) -} -``` diff --git a/examples/location/read/getLocationById/main.go b/examples/location/read/getLocationById/main.go new file mode 100755 index 0000000..bbc21cd --- /dev/null +++ b/examples/location/read/getLocationById/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/location" +) + +// Read an entity by its ID +func main() { + 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/main.go b/examples/location/save/saveAnEntity/main.go new file mode 100755 index 0000000..dc9ff51 --- /dev/null +++ b/examples/location/save/saveAnEntity/main.go @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/location" +) + +// Save an entity's current position +func main() { + 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/main.go b/examples/location/search/searchForLocations/main.go new file mode 100755 index 0000000..a0aec8b --- /dev/null +++ b/examples/location/search/searchForLocations/main.go @@ -0,0 +1,23 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/location" +) + +// Search for entities in a given radius +func main() { + locationService := location.NewLocationService(os.Getenv("M3O_API_TOKEN")) + rsp, err := locationService.Search(&location.SearchRequest{ + Center: &location.Point{ + Latitude: 51.511061, + Longitude: -0.120022, + }, + NumEntities: 10, + Radius: 100, + Type: "bike", + }) + fmt.Println(rsp, err) +} diff --git a/examples/mq/README.md b/examples/mq/README.md index 9c6a065..b6a63bf 100755 --- a/examples/mq/README.md +++ b/examples/mq/README.md @@ -26,9 +26,9 @@ func PublishAmessage() { mqService := mq.NewMqService(os.Getenv("M3O_API_TOKEN")) rsp, err := mqService.Publish(&mq.PublishRequest{ Message: map[string]interface{}{ - "user": "john", "id": "1", "type": "signup", + "user": "john", }, Topic: "events", diff --git a/examples/mq/publish/publishAMessage/main.go b/examples/mq/publish/publishAMessage/main.go new file mode 100755 index 0000000..ad993e2 --- /dev/null +++ b/examples/mq/publish/publishAMessage/main.go @@ -0,0 +1,22 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/mq" +) + +// Publish a message. Specify a topic to group messages for a specific topic. +func main() { + mqService := mq.NewMqService(os.Getenv("M3O_API_TOKEN")) + rsp, err := mqService.Publish(&mq.PublishRequest{ + Message: map[string]interface{}{ + "id": "1", + "type": "signup", + "user": "john", + }, + Topic: "events", + }) + fmt.Println(rsp, err) +} diff --git a/examples/mq/subscribe/subscribeToATopic/main.go b/examples/mq/subscribe/subscribeToATopic/main.go new file mode 100755 index 0000000..111aea8 --- /dev/null +++ b/examples/mq/subscribe/subscribeToATopic/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/mq" +) + +// Subscribe to messages for a given topic. +func main() { + mqService := mq.NewMqService(os.Getenv("M3O_API_TOKEN")) + rsp, err := mqService.Subscribe(&mq.SubscribeRequest{ + Topic: "events", + }) + fmt.Println(rsp, err) +} diff --git a/examples/notes/README.md b/examples/notes/README.md index ee3f1a7..bf9f0b9 100755 --- a/examples/notes/README.md +++ b/examples/notes/README.md @@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Notes/api](htt Endpoints: +## Create + +Create a new note + + +[https://m3o.com/notes/api#Create](https://m3o.com/notes/api#Create) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/notes" +) + +// Create a new note +func CreateAnote() { + notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN")) + rsp, err := notesService.Create(¬es.CreateRequest{ + Text: "This is my note", +Title: "New Note", + + }) + fmt.Println(rsp, err) +} +``` ## Read Read a note @@ -142,31 +170,3 @@ func SubscribeToEvents() { fmt.Println(rsp, err) } ``` -## Create - -Create a new note - - -[https://m3o.com/notes/api#Create](https://m3o.com/notes/api#Create) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/notes" -) - -// Create a new note -func CreateAnote() { - notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN")) - rsp, err := notesService.Create(¬es.CreateRequest{ - Text: "This is my note", -Title: "New Note", - - }) - fmt.Println(rsp, err) -} -``` diff --git a/examples/notes/create/createANote/main.go b/examples/notes/create/createANote/main.go new file mode 100755 index 0000000..56ab7ca --- /dev/null +++ b/examples/notes/create/createANote/main.go @@ -0,0 +1,18 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/notes" +) + +// Create a new note +func main() { + 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/main.go b/examples/notes/delete/deleteANote/main.go new file mode 100755 index 0000000..a102cb0 --- /dev/null +++ b/examples/notes/delete/deleteANote/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/notes" +) + +// Delete a note +func main() { + 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/events/subscribeToEvents/main.go b/examples/notes/events/subscribeToEvents/main.go new file mode 100755 index 0000000..c9008bc --- /dev/null +++ b/examples/notes/events/subscribeToEvents/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/notes" +) + +// Subscribe to notes events +func main() { + notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN")) + rsp, err := notesService.Events(¬es.EventsRequest{ + Id: "63c0cdf8-2121-11ec-a881-0242e36f037a", + }) + fmt.Println(rsp, err) +} diff --git a/examples/notes/list/listAllNotes/main.go b/examples/notes/list/listAllNotes/main.go new file mode 100755 index 0000000..9fc1dca --- /dev/null +++ b/examples/notes/list/listAllNotes/main.go @@ -0,0 +1,15 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/notes" +) + +// List all the notes +func main() { + 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/main.go b/examples/notes/read/readANote/main.go new file mode 100755 index 0000000..8c292bf --- /dev/null +++ b/examples/notes/read/readANote/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/notes" +) + +// Read a note +func main() { + 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/main.go b/examples/notes/update/updateANote/main.go new file mode 100755 index 0000000..c2fbc16 --- /dev/null +++ b/examples/notes/update/updateANote/main.go @@ -0,0 +1,21 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/notes" +) + +// Update a note +func main() { + 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/generate/generateOtp/main.go b/examples/otp/generate/generateOtp/main.go new file mode 100755 index 0000000..4085622 --- /dev/null +++ b/examples/otp/generate/generateOtp/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/otp" +) + +// Generate an OTP (one time pass) code +func main() { + 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/main.go b/examples/otp/validate/validateOtp/main.go new file mode 100755 index 0000000..4b27d65 --- /dev/null +++ b/examples/otp/validate/validateOtp/main.go @@ -0,0 +1,18 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/otp" +) + +// Validate the OTP code +func main() { + 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/lookup/lookupPostcode/main.go b/examples/postcode/lookup/lookupPostcode/main.go new file mode 100755 index 0000000..5903e45 --- /dev/null +++ b/examples/postcode/lookup/lookupPostcode/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/postcode" +) + +// Lookup a postcode to retrieve the related region, county, etc +func main() { + 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/main.go b/examples/postcode/random/returnARandomPostcodeAndItsInformation/main.go new file mode 100755 index 0000000..a150b95 --- /dev/null +++ b/examples/postcode/random/returnARandomPostcodeAndItsInformation/main.go @@ -0,0 +1,15 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/postcode" +) + +// Return a random postcode and its related info +func main() { + 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/main.go b/examples/postcode/validate/returnARandomPostcodeAndItsInformation/main.go new file mode 100755 index 0000000..55f04f0 --- /dev/null +++ b/examples/postcode/validate/returnARandomPostcodeAndItsInformation/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/postcode" +) + +// Validate a postcode. +func main() { + 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/times/prayerTimes/main.go b/examples/prayer/times/prayerTimes/main.go new file mode 100755 index 0000000..9b127c5 --- /dev/null +++ b/examples/prayer/times/prayerTimes/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/prayer" +) + +// Get the prayer (salah) times for a location on a given date +func main() { + 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/generate/generateAQrCode/main.go b/examples/qr/generate/generateAQrCode/main.go new file mode 100755 index 0000000..21fd932 --- /dev/null +++ b/examples/qr/generate/generateAQrCode/main.go @@ -0,0 +1,18 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/qr" +) + +// Generate a QR code with a specific text and size +func main() { + 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 index 1e8ba4d..79165db 100755 --- a/examples/quran/README.md +++ b/examples/quran/README.md @@ -4,6 +4,33 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Quran/api](htt Endpoints: +## Chapters + +List the Chapters (surahs) of the Quran + + +[https://m3o.com/quran/api#Chapters](https://m3o.com/quran/api#Chapters) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/quran" +) + +// List the Chapters (surahs) of the Quran +func ListChapters() { + quranService := quran.NewQuranService(os.Getenv("M3O_API_TOKEN")) + rsp, err := quranService.Chapters(&quran.ChaptersRequest{ + Language: "en", + + }) + fmt.Println(rsp, err) +} +``` ## Summary Get a summary for a given chapter (surah) @@ -89,30 +116,3 @@ func SearchTheQuran() { fmt.Println(rsp, err) } ``` -## Chapters - -List the Chapters (surahs) of the Quran - - -[https://m3o.com/quran/api#Chapters](https://m3o.com/quran/api#Chapters) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/quran" -) - -// List the Chapters (surahs) of the Quran -func ListChapters() { - quranService := quran.NewQuranService(os.Getenv("M3O_API_TOKEN")) - rsp, err := quranService.Chapters(&quran.ChaptersRequest{ - Language: "en", - - }) - fmt.Println(rsp, err) -} -``` diff --git a/examples/quran/chapters/listChapters/main.go b/examples/quran/chapters/listChapters/main.go new file mode 100755 index 0000000..6b70221 --- /dev/null +++ b/examples/quran/chapters/listChapters/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/quran" +) + +// List the Chapters (surahs) of the Quran +func main() { + 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/main.go b/examples/quran/search/searchTheQuran/main.go new file mode 100755 index 0000000..55ff062 --- /dev/null +++ b/examples/quran/search/searchTheQuran/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/quran" +) + +// Search the Quran for any form of query or questions +func main() { + 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/main.go b/examples/quran/summary/getChapterSummary/main.go new file mode 100755 index 0000000..6dca3fa --- /dev/null +++ b/examples/quran/summary/getChapterSummary/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/quran" +) + +// Get a summary for a given chapter (surah) +func main() { + 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/main.go b/examples/quran/verses/getVersesOfAChapter/main.go new file mode 100755 index 0000000..5ea0718 --- /dev/null +++ b/examples/quran/verses/getVersesOfAChapter/main.go @@ -0,0 +1,19 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/quran" +) + +// Lookup the verses (ayahs) for a chapter including +// translation, interpretation and breakdown by individual +// words. +func main() { + 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 index 1f0e61c..8f4968f 100755 --- a/examples/routing/README.md +++ b/examples/routing/README.md @@ -4,6 +4,40 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Routing/api](h 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" + + "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 @@ -72,37 +106,3 @@ Origin: &routing.Point{ fmt.Println(rsp, err) } ``` -## Eta - -Get the eta for a route from origin to destination. The eta is an estimated time based on car routes - - -[https://m3o.com/routing/api#Eta](https://m3o.com/routing/api#Eta) - -```go -package example - -import( - "fmt" - "os" - - "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/directions/turnByTurnDirections/main.go b/examples/routing/directions/turnByTurnDirections/main.go new file mode 100755 index 0000000..e9526af --- /dev/null +++ b/examples/routing/directions/turnByTurnDirections/main.go @@ -0,0 +1,24 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/routing" +) + +// Turn by turn directions from a start point to an end point including maneuvers and bearings +func main() { + 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/main.go b/examples/routing/eta/etaFromPointAToPointB/main.go new file mode 100755 index 0000000..10ac617 --- /dev/null +++ b/examples/routing/eta/etaFromPointAToPointB/main.go @@ -0,0 +1,24 @@ +package main + +import ( + "fmt" + "os" + + "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 main() { + 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/main.go b/examples/routing/route/gpsPointsForARoute/main.go new file mode 100755 index 0000000..0970236 --- /dev/null +++ b/examples/routing/route/gpsPointsForARoute/main.go @@ -0,0 +1,24 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/routing" +) + +// Retrieve a route as a simple list of gps points along with total distance and estimated duration +func main() { + 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/add/addANewFeed/main.go b/examples/rss/add/addANewFeed/main.go new file mode 100755 index 0000000..87191ea --- /dev/null +++ b/examples/rss/add/addANewFeed/main.go @@ -0,0 +1,19 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/rss" +) + +// Add a new RSS feed with a name, url, and category +func main() { + 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/main.go b/examples/rss/feed/readAFeed/main.go new file mode 100755 index 0000000..4c9a358 --- /dev/null +++ b/examples/rss/feed/readAFeed/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "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 main() { + 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/main.go b/examples/rss/list/listRssFeeds/main.go new file mode 100755 index 0000000..853a946 --- /dev/null +++ b/examples/rss/list/listRssFeeds/main.go @@ -0,0 +1,15 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/rss" +) + +// List the saved RSS fields +func main() { + 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/main.go b/examples/rss/remove/removeAFeed/main.go new file mode 100755 index 0000000..594472e --- /dev/null +++ b/examples/rss/remove/removeAFeed/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/rss" +) + +// Remove an RSS feed by name +func main() { + 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/analyze/analyzeAPieceOfText/main.go b/examples/sentiment/analyze/analyzeAPieceOfText/main.go new file mode 100755 index 0000000..a7446d9 --- /dev/null +++ b/examples/sentiment/analyze/analyzeAPieceOfText/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/sentiment" +) + +// Analyze and score a piece of text +func main() { + 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/send/sendSms/main.go b/examples/sms/send/sendSms/main.go new file mode 100755 index 0000000..edda18c --- /dev/null +++ b/examples/sms/send/sendSms/main.go @@ -0,0 +1,19 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/sms" +) + +// Send an SMS. +func main() { + 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 index 88bbec7..264b273 100755 --- a/examples/stock/README.md +++ b/examples/stock/README.md @@ -4,33 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Stock/api](htt Endpoints: -## Price - -Get the last price for a given stock ticker - - -[https://m3o.com/stock/api#Price](https://m3o.com/stock/api#Price) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/stock" -) - -// Get the last price for a given stock ticker -func GetAstockPrice() { - stockService := stock.NewStockService(os.Getenv("M3O_API_TOKEN")) - rsp, err := stockService.Price(&stock.PriceRequest{ - Symbol: "AAPL", - - }) - fmt.Println(rsp, err) -} -``` ## Quote Get the last quote for the stock @@ -117,3 +90,30 @@ Stock: "AAPL", fmt.Println(rsp, err) } ``` +## Price + +Get the last price for a given stock ticker + + +[https://m3o.com/stock/api#Price](https://m3o.com/stock/api#Price) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/stock" +) + +// Get the last price for a given stock ticker +func GetAstockPrice() { + stockService := stock.NewStockService(os.Getenv("M3O_API_TOKEN")) + rsp, err := stockService.Price(&stock.PriceRequest{ + Symbol: "AAPL", + + }) + fmt.Println(rsp, err) +} +``` diff --git a/examples/stock/history/getHistoricData/main.go b/examples/stock/history/getHistoricData/main.go new file mode 100755 index 0000000..5898d67 --- /dev/null +++ b/examples/stock/history/getHistoricData/main.go @@ -0,0 +1,18 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/stock" +) + +// Get the historic open-close for a given day +func main() { + 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/main.go b/examples/stock/orderBook/orderBookHistory/main.go new file mode 100755 index 0000000..4e14b0d --- /dev/null +++ b/examples/stock/orderBook/orderBookHistory/main.go @@ -0,0 +1,21 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/stock" +) + +// Get the historic order book and each trade by timestamp +func main() { + 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/main.go b/examples/stock/price/getAStockPrice/main.go new file mode 100755 index 0000000..ea3dcba --- /dev/null +++ b/examples/stock/price/getAStockPrice/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/stock" +) + +// Get the last price for a given stock ticker +func main() { + 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/main.go b/examples/stock/quote/getAStockQuote/main.go new file mode 100755 index 0000000..2702907 --- /dev/null +++ b/examples/stock/quote/getAStockQuote/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/stock" +) + +// Get the last quote for the stock +func main() { + stockService := stock.NewStockService(os.Getenv("M3O_API_TOKEN")) + rsp, err := stockService.Quote(&stock.QuoteRequest{ + Symbol: "AAPL", + }) + fmt.Println(rsp, err) +} diff --git a/examples/stream/README.md b/examples/stream/README.md index b67534c..21899b7 100755 --- a/examples/stream/README.md +++ b/examples/stream/README.md @@ -4,6 +4,33 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Stream/api](ht Endpoints: +## 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" + + "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. @@ -36,30 +63,3 @@ Topic: "events", fmt.Println(rsp, err) } ``` -## 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" - - "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/stream/publish/publishAMessage/main.go b/examples/stream/publish/publishAMessage/main.go new file mode 100755 index 0000000..c61f493 --- /dev/null +++ b/examples/stream/publish/publishAMessage/main.go @@ -0,0 +1,22 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/stream" +) + +// Publish a message to the stream. Specify a topic to group messages for a specific topic. +func main() { + 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/main.go b/examples/stream/subscribe/subscribeToATopic/main.go new file mode 100755 index 0000000..4c79071 --- /dev/null +++ b/examples/stream/subscribe/subscribeToATopic/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/stream" +) + +// Subscribe to messages for a given topic. +func main() { + 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/books/getTheBooksWithinACollection/main.go b/examples/sunnah/books/getTheBooksWithinACollection/main.go new file mode 100755 index 0000000..397bd23 --- /dev/null +++ b/examples/sunnah/books/getTheBooksWithinACollection/main.go @@ -0,0 +1,18 @@ +package main + +import ( + "fmt" + "os" + + "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 main() { + 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/main.go b/examples/sunnah/chapters/listTheChaptersInABook/main.go new file mode 100755 index 0000000..d38375c --- /dev/null +++ b/examples/sunnah/chapters/listTheChaptersInABook/main.go @@ -0,0 +1,18 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/sunnah" +) + +// Get all the chapters of a given book within a collection. +func main() { + 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/main.go b/examples/sunnah/collections/listAvailableCollections/main.go new file mode 100755 index 0000000..d97caa8 --- /dev/null +++ b/examples/sunnah/collections/listAvailableCollections/main.go @@ -0,0 +1,16 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/sunnah" +) + +// Get a list of available collections. A collection is +// a compilation of hadiths collected and written by an author. +func main() { + 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/main.go b/examples/sunnah/hadiths/listTheHadithsInABook/main.go new file mode 100755 index 0000000..897ffc5 --- /dev/null +++ b/examples/sunnah/hadiths/listTheHadithsInABook/main.go @@ -0,0 +1,19 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/sunnah" +) + +// Hadiths returns a list of hadiths and their corresponding text for a +// given book within a collection. +func main() { + 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/screenshot/takeScreenshotOfAUrl/main.go b/examples/thumbnail/screenshot/takeScreenshotOfAUrl/main.go new file mode 100755 index 0000000..6109aba --- /dev/null +++ b/examples/thumbnail/screenshot/takeScreenshotOfAUrl/main.go @@ -0,0 +1,19 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/thumbnail" +) + +// Create a thumbnail screenshot by passing in a url, height and width +func main() { + 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/now/returnsCurrentTimeOptionallyWithLocation/main.go b/examples/time/now/returnsCurrentTimeOptionallyWithLocation/main.go new file mode 100755 index 0000000..5770dc1 --- /dev/null +++ b/examples/time/now/returnsCurrentTimeOptionallyWithLocation/main.go @@ -0,0 +1,15 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/time" +) + +// Get the current time +func main() { + 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/main.go b/examples/time/zone/getTheTimezoneInfoForASpecificLocation/main.go new file mode 100755 index 0000000..9a2a98f --- /dev/null +++ b/examples/time/zone/getTheTimezoneInfoForASpecificLocation/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/time" +) + +// Get the timezone info for a specific location +func main() { + 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 index c20e9a4..5abfe70 100755 --- a/examples/twitter/README.md +++ b/examples/twitter/README.md @@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Twitter/api](h Endpoints: +## Timeline + +Get the timeline for a given user + + +[https://m3o.com/twitter/api#Timeline](https://m3o.com/twitter/api#Timeline) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/twitter" +) + +// Get the timeline for a given user +func GetAtwitterTimeline() { + twitterService := twitter.NewTwitterService(os.Getenv("M3O_API_TOKEN")) + rsp, err := twitterService.Timeline(&twitter.TimelineRequest{ + Limit: 1, +Username: "m3oservices", + + }) + fmt.Println(rsp, err) +} +``` ## Search Search for tweets with a simple query @@ -84,31 +112,3 @@ func GetAusersTwitterProfile() { fmt.Println(rsp, err) } ``` -## Timeline - -Get the timeline for a given user - - -[https://m3o.com/twitter/api#Timeline](https://m3o.com/twitter/api#Timeline) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/twitter" -) - -// Get the timeline for a given user -func GetAtwitterTimeline() { - twitterService := twitter.NewTwitterService(os.Getenv("M3O_API_TOKEN")) - rsp, err := twitterService.Timeline(&twitter.TimelineRequest{ - Limit: 1, -Username: "m3oservices", - - }) - fmt.Println(rsp, err) -} -``` diff --git a/examples/twitter/search/searchForTweets/main.go b/examples/twitter/search/searchForTweets/main.go new file mode 100755 index 0000000..ad8aa8d --- /dev/null +++ b/examples/twitter/search/searchForTweets/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/twitter" +) + +// Search for tweets with a simple query +func main() { + 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/main.go b/examples/twitter/timeline/getATwitterTimeline/main.go new file mode 100755 index 0000000..c1be363 --- /dev/null +++ b/examples/twitter/timeline/getATwitterTimeline/main.go @@ -0,0 +1,18 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/twitter" +) + +// Get the timeline for a given user +func main() { + 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/main.go b/examples/twitter/trends/getTheCurrentGlobalTrendingTopics/main.go new file mode 100755 index 0000000..eacab68 --- /dev/null +++ b/examples/twitter/trends/getTheCurrentGlobalTrendingTopics/main.go @@ -0,0 +1,15 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/twitter" +) + +// Get the current global trending topics +func main() { + 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/main.go b/examples/twitter/user/getAUsersTwitterProfile/main.go new file mode 100755 index 0000000..7fb502e --- /dev/null +++ b/examples/twitter/user/getAUsersTwitterProfile/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/twitter" +) + +// Get a user's twitter profile +func main() { + 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/list/listYourShortenedUrls/main.go b/examples/url/list/listYourShortenedUrls/main.go new file mode 100755 index 0000000..51656af --- /dev/null +++ b/examples/url/list/listYourShortenedUrls/main.go @@ -0,0 +1,15 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/url" +) + +// List information on all the shortened URLs that you have created +func main() { + 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/main.go b/examples/url/proxy/resolveAShortUrlToALongDestinationUrl/main.go new file mode 100755 index 0000000..91414c4 --- /dev/null +++ b/examples/url/proxy/resolveAShortUrlToALongDestinationUrl/main.go @@ -0,0 +1,15 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/url" +) + +// Proxy returns the destination URL of a short URL. +func main() { + 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/main.go b/examples/url/shorten/shortenALongUrl/main.go new file mode 100755 index 0000000..fcec9c6 --- /dev/null +++ b/examples/url/shorten/shortenALongUrl/main.go @@ -0,0 +1,15 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/url" +) + +// Shortens a destination URL and returns a full short URL. +func main() { + 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 index 1b81a16..50a2974 100755 --- a/examples/user/README.md +++ b/examples/user/README.md @@ -4,33 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/User/api](http Endpoints: -## VerifyEmail - -Verify the email address of an account from a token sent in an email to the user. - - -[https://m3o.com/user/api#VerifyEmail](https://m3o.com/user/api#VerifyEmail) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/user" -) - -// Verify the email address of an account from a token sent in an email to the user. -func VerifyEmail() { - userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.VerifyEmail(&user.VerifyEmailRequest{ - Token: "t2323t232t", - - }) - fmt.Println(rsp, err) -} -``` ## Login Login using username or email. The response will return a new session for successful login, @@ -61,6 +34,33 @@ Password: "mySecretPass123", fmt.Println(rsp, err) } ``` +## Logout + +Logout a user account + + +[https://m3o.com/user/api#Logout](https://m3o.com/user/api#Logout) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Logout a user account +func LogAuserOut() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.Logout(&user.LogoutRequest{ + SessionId: "sds34s34s34-s34s34-s43s43s34-s4s34s", + + }) + fmt.Println(rsp, err) +} +``` ## ReadSession Read a session by the session id. In the event it has expired or is not found and error is returned. @@ -88,6 +88,64 @@ func ReadAsessionByTheSessionId() { fmt.Println(rsp, err) } ``` +## Create + +Create a new user account. The email address and username for the account must be unique. + + +[https://m3o.com/user/api#Create](https://m3o.com/user/api#Create) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Create a new user account. The email address and username for the account must be unique. +func CreateAnAccount() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.Create(&user.CreateRequest{ + Email: "joe@example.com", +Id: "usrid-1", +Password: "mySecretPass123", +Username: "usrname-1", + + }) + fmt.Println(rsp, err) +} +``` +## Update + +Update the account username or email + + +[https://m3o.com/user/api#Update](https://m3o.com/user/api#Update) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Update the account username or email +func UpdateAnAccount() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.Update(&user.UpdateRequest{ + Email: "joeotheremail@example.com", +Id: "usrid-1", + + }) + fmt.Println(rsp, err) +} +``` ## Read Read an account by id, username or email. Only one need to be specified. @@ -169,63 +227,6 @@ func ReadAccountByEmail() { fmt.Println(rsp, err) } ``` -## Update - -Update the account username or email - - -[https://m3o.com/user/api#Update](https://m3o.com/user/api#Update) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/user" -) - -// Update the account username or email -func UpdateAnAccount() { - userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.Update(&user.UpdateRequest{ - Email: "joeotheremail@example.com", -Id: "usrid-1", - - }) - fmt.Println(rsp, err) -} -``` -## UpdatePassword - -Update the account password - - -[https://m3o.com/user/api#UpdatePassword](https://m3o.com/user/api#UpdatePassword) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/user" -) - -// Update the account password -func UpdateTheAccountPassword() { - userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.UpdatePassword(&user.UpdatePasswordRequest{ - ConfirmPassword: "myEvenMoreSecretPass123", -NewPassword: "myEvenMoreSecretPass123", -OldPassword: "mySecretPass123", - - }) - fmt.Println(rsp, err) -} -``` ## SendVerificationEmail Send a verification email @@ -272,6 +273,62 @@ 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" + + "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) +} +``` +## UpdatePassword + +Update the account password + + +[https://m3o.com/user/api#UpdatePassword](https://m3o.com/user/api#UpdatePassword) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Update the account password +func UpdateTheAccountPassword() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.UpdatePassword(&user.UpdatePasswordRequest{ + ConfirmPassword: "myEvenMoreSecretPass123", +NewPassword: "myEvenMoreSecretPass123", +OldPassword: "mySecretPass123", + + }) + fmt.Println(rsp, err) +} +``` ## Delete Delete an account by id @@ -299,60 +356,3 @@ func DeleteUserAccount() { fmt.Println(rsp, err) } ``` -## Logout - -Logout a user account - - -[https://m3o.com/user/api#Logout](https://m3o.com/user/api#Logout) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/user" -) - -// Logout a user account -func LogAuserOut() { - userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.Logout(&user.LogoutRequest{ - SessionId: "sds34s34s34-s34s34-s43s43s34-s4s34s", - - }) - fmt.Println(rsp, err) -} -``` -## Create - -Create a new user account. The email address and username for the account must be unique. - - -[https://m3o.com/user/api#Create](https://m3o.com/user/api#Create) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/user" -) - -// Create a new user account. The email address and username for the account must be unique. -func CreateAnAccount() { - userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.Create(&user.CreateRequest{ - Email: "joe@example.com", -Id: "usrid-1", -Password: "mySecretPass123", -Username: "usrname-1", - - }) - fmt.Println(rsp, err) -} -``` diff --git a/examples/user/create/createAnAccount/main.go b/examples/user/create/createAnAccount/main.go new file mode 100755 index 0000000..8668db4 --- /dev/null +++ b/examples/user/create/createAnAccount/main.go @@ -0,0 +1,20 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Create a new user account. The email address and username for the account must be unique. +func main() { + 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/main.go b/examples/user/delete/deleteUserAccount/main.go new file mode 100755 index 0000000..ee1196e --- /dev/null +++ b/examples/user/delete/deleteUserAccount/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Delete an account by id +func main() { + 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/main.go b/examples/user/login/logAUserIn/main.go new file mode 100755 index 0000000..8c8f5c1 --- /dev/null +++ b/examples/user/login/logAUserIn/main.go @@ -0,0 +1,19 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Login using username or email. The response will return a new session for successful login, +// 401 in the case of login failure and 500 for any other error +func main() { + 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/main.go b/examples/user/logout/logAUserOut/main.go new file mode 100755 index 0000000..548573d --- /dev/null +++ b/examples/user/logout/logAUserOut/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Logout a user account +func main() { + 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/main.go b/examples/user/read/readAccountByEmail/main.go new file mode 100755 index 0000000..f5b9f0a --- /dev/null +++ b/examples/user/read/readAccountByEmail/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Read an account by id, username or email. Only one need to be specified. +func main() { + 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/main.go b/examples/user/read/readAccountByUsernameOrEmail/main.go new file mode 100755 index 0000000..7258bc7 --- /dev/null +++ b/examples/user/read/readAccountByUsernameOrEmail/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Read an account by id, username or email. Only one need to be specified. +func main() { + 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/main.go b/examples/user/read/readAnAccountById/main.go new file mode 100755 index 0000000..fc3d1d9 --- /dev/null +++ b/examples/user/read/readAnAccountById/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Read an account by id, username or email. Only one need to be specified. +func main() { + 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/main.go b/examples/user/readSession/readASessionByTheSessionId/main.go new file mode 100755 index 0000000..83811ae --- /dev/null +++ b/examples/user/readSession/readASessionByTheSessionId/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Read a session by the session id. In the event it has expired or is not found and error is returned. +func main() { + 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/main.go b/examples/user/sendVerificationEmail/sendVerificationEmail/main.go new file mode 100755 index 0000000..0623336 --- /dev/null +++ b/examples/user/sendVerificationEmail/sendVerificationEmail/main.go @@ -0,0 +1,30 @@ +package main + +import ( + "fmt" + "os" + + "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 main() { + 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/main.go b/examples/user/update/updateAnAccount/main.go new file mode 100755 index 0000000..be24112 --- /dev/null +++ b/examples/user/update/updateAnAccount/main.go @@ -0,0 +1,18 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Update the account username or email +func main() { + 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/main.go b/examples/user/updatePassword/updateTheAccountPassword/main.go new file mode 100755 index 0000000..94e6496 --- /dev/null +++ b/examples/user/updatePassword/updateTheAccountPassword/main.go @@ -0,0 +1,19 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Update the account password +func main() { + 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/main.go b/examples/user/verifyEmail/verifyEmail/main.go new file mode 100755 index 0000000..a0099de --- /dev/null +++ b/examples/user/verifyEmail/verifyEmail/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Verify the email address of an account from a token sent in an email to the user. +func main() { + 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/lookup/lookupVehicle/main.go b/examples/vehicle/lookup/lookupVehicle/main.go new file mode 100755 index 0000000..f5e2383 --- /dev/null +++ b/examples/vehicle/lookup/lookupVehicle/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/vehicle" +) + +// Lookup a UK vehicle by it's registration number +func main() { + 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/forecast/forecastWeather/main.go b/examples/weather/forecast/forecastWeather/main.go new file mode 100755 index 0000000..d8d2841 --- /dev/null +++ b/examples/weather/forecast/forecastWeather/main.go @@ -0,0 +1,18 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/weather" +) + +// Get the weather forecast for the next 1-10 days +func main() { + 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/main.go b/examples/weather/now/getCurrentWeather/main.go new file mode 100755 index 0000000..7c9ca4e --- /dev/null +++ b/examples/weather/now/getCurrentWeather/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/weather" +) + +// Get the current weather report for a location by postcode, city, zip code, ip address +func main() { + 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/search/searchForVideos/main.go b/examples/youtube/search/searchForVideos/main.go new file mode 100755 index 0000000..af5292e --- /dev/null +++ b/examples/youtube/search/searchForVideos/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/youtube" +) + +// Search for videos on YouTube +func main() { + youtubeService := youtube.NewYoutubeService(os.Getenv("M3O_API_TOKEN")) + rsp, err := youtubeService.Search(&youtube.SearchRequest{ + Query: "donuts", + }) + fmt.Println(rsp, err) +}