From 3c1c9769fb79a6d878ad17106361e4bbde49c83b Mon Sep 17 00:00:00 2001 From: m3o-actions <> Date: Wed, 10 Nov 2021 09:21:08 +0000 Subject: [PATCH] Commit from m3o/m3o action --- examples/currency/README.md | 110 ++--- examples/db/README.md | 56 +-- examples/evchargers/README.md | 54 +-- examples/event/publish/publishAnEvent/main.go | 2 +- examples/forex/README.md | 56 +-- examples/function/README.md | 124 ++--- examples/image/README.md | 180 +++---- examples/location/README.md | 72 +-- examples/mq/publish/publishAMessage/main.go | 2 +- examples/otp/README.md | 56 +-- examples/stock/README.md | 112 ++--- examples/stream/README.md | 56 +-- examples/time/README.md | 54 +-- examples/twitter/README.md | 56 +-- examples/user/README.md | 444 +++++++++--------- 15 files changed, 717 insertions(+), 717 deletions(-) diff --git a/examples/currency/README.md b/examples/currency/README.md index bf674d6..65a799d 100755 --- a/examples/currency/README.md +++ b/examples/currency/README.md @@ -4,6 +4,61 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Currency/api]( Endpoints: +## Codes + +Codes returns the supported currency codes for the API + + +[https://m3o.com/currency/api#Codes](https://m3o.com/currency/api#Codes) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/currency" +) + +// Codes returns the supported currency codes for the API +func GetSupportedCodes() { + currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN")) + rsp, err := currencyService.Codes(¤cy.CodesRequest{ + + }) + fmt.Println(rsp, err) + +} +``` +## Rates + +Rates returns the currency rates for a given code e.g USD + + +[https://m3o.com/currency/api#Rates](https://m3o.com/currency/api#Rates) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/currency" +) + +// Rates returns the currency rates for a given code e.g USD +func GetRatesForUsd() { + currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN")) + rsp, err := currencyService.Rates(¤cy.RatesRequest{ + Code: "USD", + + }) + fmt.Println(rsp, err) + +} +``` ## Convert Convert returns the currency conversion rate between two pairs e.g USD/GBP @@ -92,58 +147,3 @@ Date: "2021-05-30", } ``` -## Codes - -Codes returns the supported currency codes for the API - - -[https://m3o.com/currency/api#Codes](https://m3o.com/currency/api#Codes) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/currency" -) - -// Codes returns the supported currency codes for the API -func GetSupportedCodes() { - currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN")) - rsp, err := currencyService.Codes(¤cy.CodesRequest{ - - }) - fmt.Println(rsp, err) - -} -``` -## Rates - -Rates returns the currency rates for a given code e.g USD - - -[https://m3o.com/currency/api#Rates](https://m3o.com/currency/api#Rates) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/currency" -) - -// Rates returns the currency rates for a given code e.g USD -func GetRatesForUsd() { - currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN")) - rsp, err := currencyService.Rates(¤cy.RatesRequest{ - Code: "USD", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/db/README.md b/examples/db/README.md index e390a54..2738df7 100755 --- a/examples/db/README.md +++ b/examples/db/README.md @@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Db/api](https: Endpoints: +## Count + +Count records in a table + + +[https://m3o.com/db/api#Count](https://m3o.com/db/api#Count) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/db" +) + +// Count records in a table +func CountEntriesInAtable() { + dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) + rsp, err := dbService.Count(&db.CountRequest{ + Table: "users", + + }) + fmt.Println(rsp, err) + +} +``` ## Create Create a record in the database. Optionally include an "id" field otherwise it's set automatically. @@ -156,31 +184,3 @@ func TruncateTable() { } ``` -## Count - -Count records in a table - - -[https://m3o.com/db/api#Count](https://m3o.com/db/api#Count) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/db" -) - -// Count records in a table -func CountEntriesInAtable() { - dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) - rsp, err := dbService.Count(&db.CountRequest{ - Table: "users", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/evchargers/README.md b/examples/evchargers/README.md index 335b9e3..5aa9e11 100755 --- a/examples/evchargers/README.md +++ b/examples/evchargers/README.md @@ -4,6 +4,33 @@ 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 @@ -98,30 +125,3 @@ Location: &evchargers.Coordinates{ } ``` -## ReferenceData - -Retrieve reference data as used by this API and in conjunction with the Search endpoint - - -[https://m3o.com/evchargers/api#ReferenceData](https://m3o.com/evchargers/api#ReferenceData) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/evchargers" -) - -// Retrieve reference data as used by this API and in conjunction with the Search endpoint -func GetReferenceData() { - evchargersService := evchargers.NewEvchargersService(os.Getenv("M3O_API_TOKEN")) - rsp, err := evchargersService.ReferenceData(&evchargers.ReferenceDataRequest{ - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/event/publish/publishAnEvent/main.go b/examples/event/publish/publishAnEvent/main.go index 49e4e18..037cd17 100755 --- a/examples/event/publish/publishAnEvent/main.go +++ b/examples/event/publish/publishAnEvent/main.go @@ -12,9 +12,9 @@ func main() { eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN")) rsp, err := eventService.Publish(&event.PublishRequest{ Message: map[string]interface{}{ - "id": "1", "type": "signup", "user": "john", + "id": "1", }, Topic: "user", }) diff --git a/examples/forex/README.md b/examples/forex/README.md index 0a103c1..076f73a 100755 --- a/examples/forex/README.md +++ b/examples/forex/README.md @@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Forex/api](htt Endpoints: +## Price + +Get the latest price for a given forex ticker + + +[https://m3o.com/forex/api#Price](https://m3o.com/forex/api#Price) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/forex" +) + +// Get the latest price for a given forex ticker +func GetAnFxPrice() { + forexService := forex.NewForexService(os.Getenv("M3O_API_TOKEN")) + rsp, err := forexService.Price(&forex.PriceRequest{ + Symbol: "GBPUSD", + + }) + fmt.Println(rsp, err) + +} +``` ## Quote Get the latest quote for the forex @@ -60,31 +88,3 @@ func GetPreviousClose() { } ``` -## Price - -Get the latest price for a given forex ticker - - -[https://m3o.com/forex/api#Price](https://m3o.com/forex/api#Price) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/forex" -) - -// Get the latest price for a given forex ticker -func GetAnFxPrice() { - forexService := forex.NewForexService(os.Getenv("M3O_API_TOKEN")) - rsp, err := forexService.Price(&forex.PriceRequest{ - Symbol: "GBPUSD", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/function/README.md b/examples/function/README.md index 0889d21..483ac58 100755 --- a/examples/function/README.md +++ b/examples/function/README.md @@ -4,68 +4,6 @@ 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 - - -[https://m3o.com/function/api#Call](https://m3o.com/function/api#Call) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/function" -) - -// Call a function by name -func CallAfunction() { - functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) - rsp, err := functionService.Call(&function.CallRequest{ - Name: "my-first-func", -Request: map[string]interface{}{ -}, - - }) - fmt.Println(rsp, err) - -} -``` ## List List all the deployed functions @@ -151,3 +89,65 @@ Project: "tests", } ``` +## 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 + + +[https://m3o.com/function/api#Call](https://m3o.com/function/api#Call) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/function" +) + +// Call a function by name +func CallAfunction() { + functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) + rsp, err := functionService.Call(&function.CallRequest{ + Name: "my-first-func", +Request: map[string]interface{}{ +}, + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/image/README.md b/examples/image/README.md index 3cd6835..8515906 100755 --- a/examples/image/README.md +++ b/examples/image/README.md @@ -4,96 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Image/api](htt Endpoints: -## Upload - -Upload an image by either sending a base64 encoded image to this endpoint or a URL. -To resize an image before uploading, see the Resize endpoint. - - -[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) - -} -``` -## Delete - -Delete an image previously uploaded. - - -[https://m3o.com/image/api#Delete](https://m3o.com/image/api#Delete) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/image" -) - -// Delete an image previously uploaded. -func DeleteAnUploadedImage() { - imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN")) - rsp, err := imageService.Delete(&image.DeleteRequest{ - Url: "https://cdn.m3ocontent.com/micro/images/micro/41e23b39-48dd-42b6-9738-79a313414bb8/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. @@ -232,3 +142,93 @@ Url: "somewebsite.com/cat.png", } ``` +## Upload + +Upload an image by either sending a base64 encoded image to this endpoint or a URL. +To resize an image before uploading, see the Resize endpoint. + + +[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) + +} +``` +## Delete + +Delete an image previously uploaded. + + +[https://m3o.com/image/api#Delete](https://m3o.com/image/api#Delete) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/image" +) + +// Delete an image previously uploaded. +func DeleteAnUploadedImage() { + imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN")) + rsp, err := imageService.Delete(&image.DeleteRequest{ + Url: "https://cdn.m3ocontent.com/micro/images/micro/41e23b39-48dd-42b6-9738-79a313414bb8/cat.png", + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/location/README.md b/examples/location/README.md index 9d51b7a..83046bb 100755 --- a/examples/location/README.md +++ b/examples/location/README.md @@ -4,6 +4,42 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Location/api]( Endpoints: +## Save + +Save an entity's current position + + +[https://m3o.com/location/api#Save](https://m3o.com/location/api#Save) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/location" +) + +// Save an entity's current position +func SaveAnEntity() { + locationService := location.NewLocationService(os.Getenv("M3O_API_TOKEN")) + rsp, err := locationService.Save(&location.SaveRequest{ + Entity: &location.Entity{ + Id: "1", + Location: &location.Point{ + Latitude: 51.511061, + Longitude: -0.120022, + Timestamp: 1622802761, +}, + Type: "bike", +}, + + }) + fmt.Println(rsp, err) + +} +``` ## Read Read an entity by its ID @@ -66,39 +102,3 @@ Type: "bike", } ``` -## Save - -Save an entity's current position - - -[https://m3o.com/location/api#Save](https://m3o.com/location/api#Save) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/location" -) - -// Save an entity's current position -func SaveAnEntity() { - locationService := location.NewLocationService(os.Getenv("M3O_API_TOKEN")) - rsp, err := locationService.Save(&location.SaveRequest{ - Entity: &location.Entity{ - Id: "1", - Location: &location.Point{ - Latitude: 51.511061, - Longitude: -0.120022, - Timestamp: 1622802761, -}, - Type: "bike", -}, - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/mq/publish/publishAMessage/main.go b/examples/mq/publish/publishAMessage/main.go index ebf73a2..d5d14f2 100755 --- a/examples/mq/publish/publishAMessage/main.go +++ b/examples/mq/publish/publishAMessage/main.go @@ -12,9 +12,9 @@ func main() { mqService := mq.NewMqService(os.Getenv("M3O_API_TOKEN")) rsp, err := mqService.Publish(&mq.PublishRequest{ Message: map[string]interface{}{ - "user": "john", "id": "1", "type": "signup", + "user": "john", }, Topic: "events", }) diff --git a/examples/otp/README.md b/examples/otp/README.md index 66d4d50..c643291 100755 --- a/examples/otp/README.md +++ b/examples/otp/README.md @@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Otp/api](https Endpoints: +## Generate + +Generate an OTP (one time pass) code + + +[https://m3o.com/otp/api#Generate](https://m3o.com/otp/api#Generate) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/otp" +) + +// Generate an OTP (one time pass) code +func GenerateOtp() { + otpService := otp.NewOtpService(os.Getenv("M3O_API_TOKEN")) + rsp, err := otpService.Generate(&otp.GenerateRequest{ + Id: "asim@example.com", + + }) + fmt.Println(rsp, err) + +} +``` ## Validate Validate the OTP code @@ -33,31 +61,3 @@ Id: "asim@example.com", } ``` -## Generate - -Generate an OTP (one time pass) code - - -[https://m3o.com/otp/api#Generate](https://m3o.com/otp/api#Generate) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/otp" -) - -// Generate an OTP (one time pass) code -func GenerateOtp() { - otpService := otp.NewOtpService(os.Getenv("M3O_API_TOKEN")) - rsp, err := otpService.Generate(&otp.GenerateRequest{ - Id: "asim@example.com", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/stock/README.md b/examples/stock/README.md index ed80709..b627a34 100755 --- a/examples/stock/README.md +++ b/examples/stock/README.md @@ -4,6 +4,62 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Stock/api](htt Endpoints: +## Price + +Get the last price for a given stock ticker + + +[https://m3o.com/stock/api#Price](https://m3o.com/stock/api#Price) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/stock" +) + +// Get the last price for a given stock ticker +func GetAstockPrice() { + stockService := stock.NewStockService(os.Getenv("M3O_API_TOKEN")) + rsp, err := stockService.Price(&stock.PriceRequest{ + Symbol: "AAPL", + + }) + fmt.Println(rsp, err) + +} +``` +## Quote + +Get the last quote for the stock + + +[https://m3o.com/stock/api#Quote](https://m3o.com/stock/api#Quote) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/stock" +) + +// Get the last quote for the stock +func GetAstockQuote() { + stockService := stock.NewStockService(os.Getenv("M3O_API_TOKEN")) + rsp, err := stockService.Quote(&stock.QuoteRequest{ + Symbol: "AAPL", + + }) + fmt.Println(rsp, err) + +} +``` ## History Get the historic open-close for a given day @@ -65,59 +121,3 @@ Stock: "AAPL", } ``` -## Price - -Get the last price for a given stock ticker - - -[https://m3o.com/stock/api#Price](https://m3o.com/stock/api#Price) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/stock" -) - -// Get the last price for a given stock ticker -func GetAstockPrice() { - stockService := stock.NewStockService(os.Getenv("M3O_API_TOKEN")) - rsp, err := stockService.Price(&stock.PriceRequest{ - Symbol: "AAPL", - - }) - fmt.Println(rsp, err) - -} -``` -## Quote - -Get the last quote for the stock - - -[https://m3o.com/stock/api#Quote](https://m3o.com/stock/api#Quote) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/stock" -) - -// Get the last quote for the stock -func GetAstockQuote() { - stockService := stock.NewStockService(os.Getenv("M3O_API_TOKEN")) - rsp, err := stockService.Quote(&stock.QuoteRequest{ - Symbol: "AAPL", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/stream/README.md b/examples/stream/README.md index 6d83f90..0fd96c4 100755 --- a/examples/stream/README.md +++ b/examples/stream/README.md @@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Stream/api](ht Endpoints: +## ListMessages + +List messages for a given channel + + +[https://m3o.com/stream/api#ListMessages](https://m3o.com/stream/api#ListMessages) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/stream" +) + +// List messages for a given channel +func ListMessages() { + streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN")) + rsp, err := streamService.ListMessages(&stream.ListMessagesRequest{ + Channel: "general", + + }) + fmt.Println(rsp, err) + +} +``` ## ListChannels List all the active channels @@ -91,31 +119,3 @@ Text: "Hey checkout this tweet https://twitter.com/m3oservices/status/1455291054 } ``` -## ListMessages - -List messages for a given channel - - -[https://m3o.com/stream/api#ListMessages](https://m3o.com/stream/api#ListMessages) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/stream" -) - -// List messages for a given channel -func ListMessages() { - streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN")) - rsp, err := streamService.ListMessages(&stream.ListMessagesRequest{ - Channel: "general", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/time/README.md b/examples/time/README.md index 29b28b8..73de990 100755 --- a/examples/time/README.md +++ b/examples/time/README.md @@ -4,33 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Time/api](http Endpoints: -## Now - -Get the current time - - -[https://m3o.com/time/api#Now](https://m3o.com/time/api#Now) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/time" -) - -// Get the current time -func ReturnsCurrentTimeOptionallyWithLocation() { - timeService := time.NewTimeService(os.Getenv("M3O_API_TOKEN")) - rsp, err := timeService.Now(&time.NowRequest{ - - }) - fmt.Println(rsp, err) - -} -``` ## Zone Get the timezone info for a specific location @@ -59,3 +32,30 @@ func GetTheTimezoneInfoForAspecificLocation() { } ``` +## Now + +Get the current time + + +[https://m3o.com/time/api#Now](https://m3o.com/time/api#Now) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/time" +) + +// Get the current time +func ReturnsCurrentTimeOptionallyWithLocation() { + timeService := time.NewTimeService(os.Getenv("M3O_API_TOKEN")) + rsp, err := timeService.Now(&time.NowRequest{ + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/twitter/README.md b/examples/twitter/README.md index 15ebde2..f11d086 100755 --- a/examples/twitter/README.md +++ b/examples/twitter/README.md @@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Twitter/api](h Endpoints: -## Search - -Search for tweets with a simple query - - -[https://m3o.com/twitter/api#Search](https://m3o.com/twitter/api#Search) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/twitter" -) - -// Search for tweets with a simple query -func SearchForTweets() { - twitterService := twitter.NewTwitterService(os.Getenv("M3O_API_TOKEN")) - rsp, err := twitterService.Search(&twitter.SearchRequest{ - Query: "cats", - - }) - fmt.Println(rsp, err) - -} -``` ## Trends Get the current global trending topics @@ -116,3 +88,31 @@ Username: "m3oservices", } ``` +## Search + +Search for tweets with a simple query + + +[https://m3o.com/twitter/api#Search](https://m3o.com/twitter/api#Search) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/twitter" +) + +// Search for tweets with a simple query +func SearchForTweets() { + twitterService := twitter.NewTwitterService(os.Getenv("M3O_API_TOKEN")) + rsp, err := twitterService.Search(&twitter.SearchRequest{ + Query: "cats", + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/user/README.md b/examples/user/README.md index ae5341b..8820b61 100755 --- a/examples/user/README.md +++ b/examples/user/README.md @@ -4,91 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/User/api](http Endpoints: -## 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. - - -[https://m3o.com/user/api#ReadSession](https://m3o.com/user/api#ReadSession) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/user" -) - -// Read a session by the session id. In the event it has expired or is not found and error is returned. -func ReadAsessionByTheSessionId() { - userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.ReadSession(&user.ReadSessionRequest{ - SessionId: "sds34s34s34-s34s34-s43s43s34-s4s34s", - - }) - 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 @@ -117,143 +32,6 @@ OldPassword: "mySecretPass123", }) fmt.Println(rsp, err) -} -``` -## SendVerificationEmail - -Send a verification email -to the user being signed up. Email from will be from 'support@m3o.com', -but you can provide the title and contents. -The verification link will be injected in to the email as a template variable, $micro_verification_link. -Example: 'Hi there, welcome onboard! Use the link below to verify your email: $micro_verification_link' -The variable will be replaced with an actual url that will look similar to this: -'https://user.m3o.com/user/verify?token=a-verification-token&redirectUrl=your-redir-url' - - -[https://m3o.com/user/api#SendVerificationEmail](https://m3o.com/user/api#SendVerificationEmail) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/user" -) - -// Send a verification email -// to the user being signed up. Email from will be from 'support@m3o.com', -// but you can provide the title and contents. -// The verification link will be injected in to the email as a template variable, $micro_verification_link. -// Example: 'Hi there, welcome onboard! Use the link below to verify your email: $micro_verification_link' -// The variable will be replaced with an actual url that will look similar to this: -// 'https://user.m3o.com/user/verify?token=a-verification-token&redirectUrl=your-redir-url' -func SendVerificationEmail() { - userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.SendVerificationEmail(&user.SendVerificationEmailRequest{ - Email: "joe@example.com", -FailureRedirectUrl: "https://m3o.com/verification-failed", -FromName: "Awesome Dot Com", -RedirectUrl: "https://m3o.com", -Subject: "Email verification", -TextContent: `Hi there, - -Please verify your email by clicking this link: $micro_verification_link`, - - }) - fmt.Println(rsp, err) - -} -``` -## Delete - -Delete an account by id - - -[https://m3o.com/user/api#Delete](https://m3o.com/user/api#Delete) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/user" -) - -// Delete an account by id -func DeleteUserAccount() { - userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.Delete(&user.DeleteRequest{ - Id: "fdf34f34f34-f34f34-f43f43f34-f4f34f", - - }) - fmt.Println(rsp, err) - -} -``` -## Login - -Login using username or email. The response will return a new session for successful login, -401 in the case of login failure and 500 for any other error - - -[https://m3o.com/user/api#Login](https://m3o.com/user/api#Login) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/user" -) - -// Login using username or email. The response will return a new session for successful login, -// 401 in the case of login failure and 500 for any other error -func LogAuserIn() { - userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.Login(&user.LoginRequest{ - Email: "joe@example.com", -Password: "mySecretPass123", - - }) - fmt.Println(rsp, err) - -} -``` -## Create - -Create a new user account. The email address and username for the account must be unique. - - -[https://m3o.com/user/api#Create](https://m3o.com/user/api#Create) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/user" -) - -// Create a new user account. The email address and username for the account must be unique. -func CreateAnAccount() { - userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.Create(&user.CreateRequest{ - Email: "joe@example.com", -Id: "usrid-1", -Password: "mySecretPass123", -Username: "usrname-1", - - }) - fmt.Println(rsp, err) - } ``` ## Read @@ -368,3 +146,225 @@ func VerifyEmail() { } ``` +## Delete + +Delete an account by id + + +[https://m3o.com/user/api#Delete](https://m3o.com/user/api#Delete) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Delete an account by id +func DeleteUserAccount() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.Delete(&user.DeleteRequest{ + Id: "fdf34f34f34-f34f34-f43f43f34-f4f34f", + + }) + fmt.Println(rsp, err) + +} +``` +## Logout + +Logout a user account + + +[https://m3o.com/user/api#Logout](https://m3o.com/user/api#Logout) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Logout a user account +func LogAuserOut() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.Logout(&user.LogoutRequest{ + SessionId: "sds34s34s34-s34s34-s43s43s34-s4s34s", + + }) + fmt.Println(rsp, err) + +} +``` +## ReadSession + +Read a session by the session id. In the event it has expired or is not found and error is returned. + + +[https://m3o.com/user/api#ReadSession](https://m3o.com/user/api#ReadSession) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Read a session by the session id. In the event it has expired or is not found and error is returned. +func ReadAsessionByTheSessionId() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.ReadSession(&user.ReadSessionRequest{ + SessionId: "sds34s34s34-s34s34-s43s43s34-s4s34s", + + }) + fmt.Println(rsp, err) + +} +``` +## Create + +Create a new user account. The email address and username for the account must be unique. + + +[https://m3o.com/user/api#Create](https://m3o.com/user/api#Create) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Create a new user account. The email address and username for the account must be unique. +func CreateAnAccount() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.Create(&user.CreateRequest{ + Email: "joe@example.com", +Id: "usrid-1", +Password: "mySecretPass123", +Username: "usrname-1", + + }) + fmt.Println(rsp, err) + +} +``` +## Update + +Update the account username or email + + +[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) + +} +``` +## SendVerificationEmail + +Send a verification email +to the user being signed up. Email from will be from 'support@m3o.com', +but you can provide the title and contents. +The verification link will be injected in to the email as a template variable, $micro_verification_link. +Example: 'Hi there, welcome onboard! Use the link below to verify your email: $micro_verification_link' +The variable will be replaced with an actual url that will look similar to this: +'https://user.m3o.com/user/verify?token=a-verification-token&redirectUrl=your-redir-url' + + +[https://m3o.com/user/api#SendVerificationEmail](https://m3o.com/user/api#SendVerificationEmail) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Send a verification email +// to the user being signed up. Email from will be from 'support@m3o.com', +// but you can provide the title and contents. +// The verification link will be injected in to the email as a template variable, $micro_verification_link. +// Example: 'Hi there, welcome onboard! Use the link below to verify your email: $micro_verification_link' +// The variable will be replaced with an actual url that will look similar to this: +// 'https://user.m3o.com/user/verify?token=a-verification-token&redirectUrl=your-redir-url' +func SendVerificationEmail() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.SendVerificationEmail(&user.SendVerificationEmailRequest{ + Email: "joe@example.com", +FailureRedirectUrl: "https://m3o.com/verification-failed", +FromName: "Awesome Dot Com", +RedirectUrl: "https://m3o.com", +Subject: "Email verification", +TextContent: `Hi there, + +Please verify your email by clicking this link: $micro_verification_link`, + + }) + fmt.Println(rsp, err) + +} +``` +## Login + +Login using username or email. The response will return a new session for successful login, +401 in the case of login failure and 500 for any other error + + +[https://m3o.com/user/api#Login](https://m3o.com/user/api#Login) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Login using username or email. The response will return a new session for successful login, +// 401 in the case of login failure and 500 for any other error +func LogAuserIn() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.Login(&user.LoginRequest{ + Email: "joe@example.com", +Password: "mySecretPass123", + + }) + fmt.Println(rsp, err) + +} +```