From 5c96743ac258f1ff5541f3e8c6d771db72fd703f Mon Sep 17 00:00:00 2001 From: m3o-actions <> Date: Thu, 4 Nov 2021 12:19:32 +0000 Subject: [PATCH] Commit from m3o/m3o action --- examples/crypto/README.md | 54 ++--- examples/currency/README.md | 106 ++++----- examples/db/README.md | 108 ++++----- examples/db/create/createARecord/main.go | 2 +- examples/event/README.md | 2 +- examples/event/publish/publishAnEvent/main.go | 2 +- examples/file/README.md | 62 ++--- examples/forex/README.md | 54 ++--- examples/function/README.md | 56 ++--- examples/geocoding/README.md | 56 ++--- examples/image/README.md | 27 +++ .../delete/deleteAnUploadedImage/main.go | 18 ++ examples/location/README.md | 70 +++--- examples/mq/README.md | 2 +- examples/quran/README.md | 108 ++++----- examples/routing/README.md | 68 +++--- examples/rss/README.md | 54 ++--- examples/stock/README.md | 108 ++++----- examples/stream/README.md | 60 ++--- examples/sunnah/README.md | 56 ++--- examples/url/README.md | 52 ++-- examples/user/README.md | 222 +++++++++--------- image/image.go | 16 ++ 23 files changed, 712 insertions(+), 651 deletions(-) create mode 100755 examples/image/delete/deleteAnUploadedImage/main.go diff --git a/examples/crypto/README.md b/examples/crypto/README.md index e9b36a4..bd5c674 100755 --- a/examples/crypto/README.md +++ b/examples/crypto/README.md @@ -4,33 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Crypto/api](ht Endpoints: -## Price - -Get the last price for a given crypto ticker - - -[https://m3o.com/crypto/api#Price](https://m3o.com/crypto/api#Price) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/crypto" -) - -// Get the last price for a given crypto ticker -func GetCryptocurrencyPrice() { - cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN")) - rsp, err := cryptoService.Price(&crypto.PriceRequest{ - Symbol: "BTCUSD", - - }) - fmt.Println(rsp, err) -} -``` ## Quote Get the last quote for a given crypto ticker @@ -112,3 +85,30 @@ func GetCryptocurrencyNews() { fmt.Println(rsp, err) } ``` +## Price + +Get the last price for a given crypto ticker + + +[https://m3o.com/crypto/api#Price](https://m3o.com/crypto/api#Price) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/crypto" +) + +// Get the last price for a given crypto ticker +func GetCryptocurrencyPrice() { + cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN")) + rsp, err := cryptoService.Price(&crypto.PriceRequest{ + Symbol: "BTCUSD", + + }) + fmt.Println(rsp, err) +} +``` diff --git a/examples/currency/README.md b/examples/currency/README.md index 1e32012..e79ce2a 100755 --- a/examples/currency/README.md +++ b/examples/currency/README.md @@ -4,59 +4,6 @@ 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 @@ -142,3 +89,56 @@ Date: "2021-05-30", fmt.Println(rsp, err) } ``` +## 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 1d5449e..d56b62e 100755 --- a/examples/db/README.md +++ b/examples/db/README.md @@ -4,6 +4,60 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Db/api](https: Endpoints: +## Truncate + +Truncate the records in a table + + +[https://m3o.com/db/api#Truncate](https://m3o.com/db/api#Truncate) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/db" +) + +// Truncate the records in a table +func TruncateTable() { + dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) + rsp, err := dbService.Truncate(&db.TruncateRequest{ + Table: "users", + + }) + fmt.Println(rsp, err) +} +``` +## Count + +Count records in a table + + +[https://m3o.com/db/api#Count](https://m3o.com/db/api#Count) + +```go +package example + +import( + "fmt" + "os" + + "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. @@ -124,57 +178,3 @@ Table: "users", fmt.Println(rsp, err) } ``` -## Truncate - -Truncate the records in a table - - -[https://m3o.com/db/api#Truncate](https://m3o.com/db/api#Truncate) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/db" -) - -// Truncate the records in a table -func TruncateTable() { - dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) - rsp, err := dbService.Truncate(&db.TruncateRequest{ - Table: "users", - - }) - fmt.Println(rsp, err) -} -``` -## Count - -Count records in a table - - -[https://m3o.com/db/api#Count](https://m3o.com/db/api#Count) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/db" -) - -// Count records in a table -func CountEntriesInAtable() { - dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) - rsp, err := dbService.Count(&db.CountRequest{ - Table: "users", - - }) - fmt.Println(rsp, err) -} -``` diff --git a/examples/db/create/createARecord/main.go b/examples/db/create/createARecord/main.go index 81f6b1b..886de82 100755 --- a/examples/db/create/createARecord/main.go +++ b/examples/db/create/createARecord/main.go @@ -12,10 +12,10 @@ func main() { dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) rsp, err := dbService.Create(&db.CreateRequest{ Record: map[string]interface{}{ - "isActive": true, "id": "1", "name": "Jane", "age": 42, + "isActive": true, }, Table: "users", }) diff --git a/examples/event/README.md b/examples/event/README.md index 38d6199..8c6d736 100755 --- a/examples/event/README.md +++ b/examples/event/README.md @@ -26,9 +26,9 @@ func PublishAnEvent() { eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN")) rsp, err := eventService.Publish(&event.PublishRequest{ Message: map[string]interface{}{ + "user": "john", "id": "1", "type": "signup", - "user": "john", }, Topic: "user", diff --git a/examples/event/publish/publishAnEvent/main.go b/examples/event/publish/publishAnEvent/main.go index c60c214..49e4e18 100755 --- a/examples/event/publish/publishAnEvent/main.go +++ b/examples/event/publish/publishAnEvent/main.go @@ -12,9 +12,9 @@ func main() { eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN")) rsp, err := eventService.Publish(&event.PublishRequest{ Message: map[string]interface{}{ - "user": "john", "id": "1", "type": "signup", + "user": "john", }, Topic: "user", }) diff --git a/examples/file/README.md b/examples/file/README.md index 68a6a0a..21161e8 100755 --- a/examples/file/README.md +++ b/examples/file/README.md @@ -4,37 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/File/api](http Endpoints: -## Save - -Save a file - - -[https://m3o.com/file/api#Save](https://m3o.com/file/api#Save) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/file" -) - -// Save a file -func SaveFile() { - fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN")) - rsp, err := fileService.Save(&file.SaveRequest{ - File: &file.Record{ - Content: "file content example", - Path: "/document/text-files/file.txt", - Project: "examples", - }, - - }) - fmt.Println(rsp, err) -} -``` ## List List files by their project and optionally a path. @@ -118,3 +87,34 @@ Project: "examples", fmt.Println(rsp, err) } ``` +## Save + +Save a file + + +[https://m3o.com/file/api#Save](https://m3o.com/file/api#Save) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/file" +) + +// Save a file +func SaveFile() { + fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN")) + rsp, err := fileService.Save(&file.SaveRequest{ + File: &file.Record{ + Content: "file content example", + Path: "/document/text-files/file.txt", + Project: "examples", + }, + + }) + fmt.Println(rsp, err) +} +``` diff --git a/examples/forex/README.md b/examples/forex/README.md index 3cea13c..7949019 100755 --- a/examples/forex/README.md +++ b/examples/forex/README.md @@ -4,6 +4,33 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Forex/api](htt Endpoints: +## Quote + +Get the latest quote for the forex + + +[https://m3o.com/forex/api#Quote](https://m3o.com/forex/api#Quote) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/forex" +) + +// Get the latest quote for the forex +func GetAfxQuote() { + forexService := forex.NewForexService(os.Getenv("M3O_API_TOKEN")) + rsp, err := forexService.Quote(&forex.QuoteRequest{ + Symbol: "GBPUSD", + + }) + fmt.Println(rsp, err) +} +``` ## History Returns the data for the previous close @@ -58,30 +85,3 @@ func GetAnFxPrice() { fmt.Println(rsp, err) } ``` -## Quote - -Get the latest quote for the forex - - -[https://m3o.com/forex/api#Quote](https://m3o.com/forex/api#Quote) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/forex" -) - -// Get the latest quote for the forex -func GetAfxQuote() { - forexService := forex.NewForexService(os.Getenv("M3O_API_TOKEN")) - rsp, err := forexService.Quote(&forex.QuoteRequest{ - Symbol: "GBPUSD", - - }) - fmt.Println(rsp, err) -} -``` diff --git a/examples/function/README.md b/examples/function/README.md index 3a72ea5..0b246b7 100755 --- a/examples/function/README.md +++ b/examples/function/README.md @@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Function/api]( Endpoints: +## Describe + +Get the info for a deployed function + + +[https://m3o.com/function/api#Describe](https://m3o.com/function/api#Describe) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/function" +) + +// Get the info for a deployed function +func DescribeFunctionStatus() { + functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) + rsp, err := functionService.Describe(&function.DescribeRequest{ + Name: "my-first-func", +Project: "tests", + + }) + fmt.Println(rsp, err) +} +``` ## Deploy Deploy a group of functions @@ -118,31 +146,3 @@ Project: "tests", fmt.Println(rsp, err) } ``` -## Describe - -Get the info for a deployed function - - -[https://m3o.com/function/api#Describe](https://m3o.com/function/api#Describe) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/function" -) - -// Get the info for a deployed function -func DescribeFunctionStatus() { - functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) - rsp, err := functionService.Describe(&function.DescribeRequest{ - Name: "my-first-func", -Project: "tests", - - }) - fmt.Println(rsp, err) -} -``` diff --git a/examples/geocoding/README.md b/examples/geocoding/README.md index 4ac78c5..448d333 100755 --- a/examples/geocoding/README.md +++ b/examples/geocoding/README.md @@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Geocoding/api] Endpoints: -## Reverse - -Reverse lookup an address from gps coordinates - - -[https://m3o.com/geocoding/api#Reverse](https://m3o.com/geocoding/api#Reverse) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/geocoding" -) - -// Reverse lookup an address from gps coordinates -func ReverseGeocodeLocation() { - geocodingService := geocoding.NewGeocodingService(os.Getenv("M3O_API_TOKEN")) - rsp, err := geocodingService.Reverse(&geocoding.ReverseRequest{ - Latitude: 51.5123064, -Longitude: -0.1216235, - - }) - fmt.Println(rsp, err) -} -``` ## Lookup Lookup returns a geocoded address including normalized address and gps coordinates. All fields are optional, provide more to get more accurate results @@ -62,3 +34,31 @@ Postcode: "wc2b", fmt.Println(rsp, err) } ``` +## Reverse + +Reverse lookup an address from gps coordinates + + +[https://m3o.com/geocoding/api#Reverse](https://m3o.com/geocoding/api#Reverse) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/geocoding" +) + +// Reverse lookup an address from gps coordinates +func ReverseGeocodeLocation() { + geocodingService := geocoding.NewGeocodingService(os.Getenv("M3O_API_TOKEN")) + rsp, err := geocodingService.Reverse(&geocoding.ReverseRequest{ + Latitude: 51.5123064, +Longitude: -0.1216235, + + }) + fmt.Println(rsp, err) +} +``` diff --git a/examples/image/README.md b/examples/image/README.md index 1d58d10..3dfb2e6 100755 --- a/examples/image/README.md +++ b/examples/image/README.md @@ -198,3 +198,30 @@ 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/image/delete/deleteAnUploadedImage/main.go b/examples/image/delete/deleteAnUploadedImage/main.go new file mode 100755 index 0000000..51bf67c --- /dev/null +++ b/examples/image/delete/deleteAnUploadedImage/main.go @@ -0,0 +1,18 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/image" +) + +// Delete an image previously uploaded. +func main() { + 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 828fe78..4db841c 100755 --- a/examples/location/README.md +++ b/examples/location/README.md @@ -4,41 +4,6 @@ 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 @@ -99,3 +64,38 @@ Type: "bike", fmt.Println(rsp, err) } ``` +## 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/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/quran/README.md b/examples/quran/README.md index 79165db..42a23ca 100755 --- a/examples/quran/README.md +++ b/examples/quran/README.md @@ -4,60 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Quran/api](htt Endpoints: -## Chapters - -List the Chapters (surahs) of the Quran - - -[https://m3o.com/quran/api#Chapters](https://m3o.com/quran/api#Chapters) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/quran" -) - -// List the Chapters (surahs) of the Quran -func ListChapters() { - quranService := quran.NewQuranService(os.Getenv("M3O_API_TOKEN")) - rsp, err := quranService.Chapters(&quran.ChaptersRequest{ - Language: "en", - - }) - fmt.Println(rsp, err) -} -``` -## Summary - -Get a summary for a given chapter (surah) - - -[https://m3o.com/quran/api#Summary](https://m3o.com/quran/api#Summary) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/quran" -) - -// Get a summary for a given chapter (surah) -func GetChapterSummary() { - quranService := quran.NewQuranService(os.Getenv("M3O_API_TOKEN")) - rsp, err := quranService.Summary(&quran.SummaryRequest{ - Chapter: 1, - - }) - fmt.Println(rsp, err) -} -``` ## Verses Lookup the verses (ayahs) for a chapter including @@ -116,3 +62,57 @@ 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) +} +``` +## Summary + +Get a summary for a given chapter (surah) + + +[https://m3o.com/quran/api#Summary](https://m3o.com/quran/api#Summary) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/quran" +) + +// Get a summary for a given chapter (surah) +func GetChapterSummary() { + quranService := quran.NewQuranService(os.Getenv("M3O_API_TOKEN")) + rsp, err := quranService.Summary(&quran.SummaryRequest{ + Chapter: 1, + + }) + fmt.Println(rsp, err) +} +``` diff --git a/examples/routing/README.md b/examples/routing/README.md index 8f4968f..ea4d745 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: +## Route + +Retrieve a route as a simple list of gps points along with total distance and estimated duration + + +[https://m3o.com/routing/api#Route](https://m3o.com/routing/api#Route) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/routing" +) + +// Retrieve a route as a simple list of gps points along with total distance and estimated duration +func GpsPointsForAroute() { + routingService := routing.NewRoutingService(os.Getenv("M3O_API_TOKEN")) + rsp, err := routingService.Route(&routing.RouteRequest{ + Destination: &routing.Point{ + Latitude: 52.529407, + Longitude: 13.397634, +}, +Origin: &routing.Point{ + Latitude: 52.517037, + Longitude: 13.38886, +}, + + }) + fmt.Println(rsp, err) +} +``` ## Eta Get the eta for a route from origin to destination. The eta is an estimated time based on car routes @@ -72,37 +106,3 @@ Origin: &routing.Point{ fmt.Println(rsp, err) } ``` -## Route - -Retrieve a route as a simple list of gps points along with total distance and estimated duration - - -[https://m3o.com/routing/api#Route](https://m3o.com/routing/api#Route) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/routing" -) - -// Retrieve a route as a simple list of gps points along with total distance and estimated duration -func GpsPointsForAroute() { - routingService := routing.NewRoutingService(os.Getenv("M3O_API_TOKEN")) - rsp, err := routingService.Route(&routing.RouteRequest{ - Destination: &routing.Point{ - Latitude: 52.529407, - Longitude: 13.397634, -}, -Origin: &routing.Point{ - Latitude: 52.517037, - Longitude: 13.38886, -}, - - }) - fmt.Println(rsp, err) -} -``` diff --git a/examples/rss/README.md b/examples/rss/README.md index 81d5cdd..b7bbb60 100755 --- a/examples/rss/README.md +++ b/examples/rss/README.md @@ -4,6 +4,33 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Rss/api](https Endpoints: +## Feed + +Get an RSS feed by name. If no name is given, all feeds are returned. Default limit is 25 entries. + + +[https://m3o.com/rss/api#Feed](https://m3o.com/rss/api#Feed) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/rss" +) + +// Get an RSS feed by name. If no name is given, all feeds are returned. Default limit is 25 entries. +func ReadAfeed() { + rssService := rss.NewRssService(os.Getenv("M3O_API_TOKEN")) + rsp, err := rssService.Feed(&rss.FeedRequest{ + Name: "bbc", + + }) + fmt.Println(rsp, err) +} +``` ## List List the saved RSS fields @@ -86,30 +113,3 @@ Url: "http://feeds.bbci.co.uk/news/rss.xml", fmt.Println(rsp, err) } ``` -## Feed - -Get an RSS feed by name. If no name is given, all feeds are returned. Default limit is 25 entries. - - -[https://m3o.com/rss/api#Feed](https://m3o.com/rss/api#Feed) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/rss" -) - -// Get an RSS feed by name. If no name is given, all feeds are returned. Default limit is 25 entries. -func ReadAfeed() { - rssService := rss.NewRssService(os.Getenv("M3O_API_TOKEN")) - rsp, err := rssService.Feed(&rss.FeedRequest{ - Name: "bbc", - - }) - fmt.Println(rsp, err) -} -``` diff --git a/examples/stock/README.md b/examples/stock/README.md index 88bbec7..9dda59f 100755 --- a/examples/stock/README.md +++ b/examples/stock/README.md @@ -4,60 +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 - - -[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 @@ -117,3 +63,57 @@ Stock: "AAPL", fmt.Println(rsp, err) } ``` +## Price + +Get the last price for a given stock ticker + + +[https://m3o.com/stock/api#Price](https://m3o.com/stock/api#Price) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/stock" +) + +// Get the last price for a given stock ticker +func GetAstockPrice() { + stockService := stock.NewStockService(os.Getenv("M3O_API_TOKEN")) + rsp, err := stockService.Price(&stock.PriceRequest{ + Symbol: "AAPL", + + }) + fmt.Println(rsp, err) +} +``` +## Quote + +Get the last quote for the stock + + +[https://m3o.com/stock/api#Quote](https://m3o.com/stock/api#Quote) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/stock" +) + +// Get the last quote for the stock +func GetAstockQuote() { + stockService := stock.NewStockService(os.Getenv("M3O_API_TOKEN")) + rsp, err := stockService.Quote(&stock.QuoteRequest{ + Symbol: "AAPL", + + }) + fmt.Println(rsp, err) +} +``` diff --git a/examples/stream/README.md b/examples/stream/README.md index 28fe194..f13af9b 100755 --- a/examples/stream/README.md +++ b/examples/stream/README.md @@ -4,36 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Stream/api](ht Endpoints: -## CreateChannel - -Create a channel with a given name and description. Channels are created automatically but -this allows you to specify a description that's persisted for the lifetime of the channel. - - -[https://m3o.com/stream/api#CreateChannel](https://m3o.com/stream/api#CreateChannel) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/stream" -) - -// Create a channel with a given name and description. Channels are created automatically but -// this allows you to specify a description that's persisted for the lifetime of the channel. -func CreateChannel() { - streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN")) - rsp, err := streamService.CreateChannel(&stream.CreateChannelRequest{ - Description: "The channel for all things", -Name: "general", - - }) - fmt.Println(rsp, err) -} -``` ## SendMessage Send a message to the stream. @@ -115,3 +85,33 @@ func ListChannels() { fmt.Println(rsp, err) } ``` +## CreateChannel + +Create a channel with a given name and description. Channels are created automatically but +this allows you to specify a description that's persisted for the lifetime of the channel. + + +[https://m3o.com/stream/api#CreateChannel](https://m3o.com/stream/api#CreateChannel) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/stream" +) + +// Create a channel with a given name and description. Channels are created automatically but +// this allows you to specify a description that's persisted for the lifetime of the channel. +func CreateChannel() { + streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN")) + rsp, err := streamService.CreateChannel(&stream.CreateChannelRequest{ + Description: "The channel for all things", +Name: "general", + + }) + fmt.Println(rsp, err) +} +``` diff --git a/examples/sunnah/README.md b/examples/sunnah/README.md index 8f2aa8f..e450b78 100755 --- a/examples/sunnah/README.md +++ b/examples/sunnah/README.md @@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Sunnah/api](ht Endpoints: +## Collections + +Get a list of available collections. A collection is +a compilation of hadiths collected and written by an author. + + +[https://m3o.com/sunnah/api#Collections](https://m3o.com/sunnah/api#Collections) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/sunnah" +) + +// Get a list of available collections. A collection is +// a compilation of hadiths collected and written by an author. +func ListAvailableCollections() { + sunnahService := sunnah.NewSunnahService(os.Getenv("M3O_API_TOKEN")) + rsp, err := sunnahService.Collections(&sunnah.CollectionsRequest{ + + }) + fmt.Println(rsp, err) +} +``` ## Books Get a list of books from within a collection. A book can contain many chapters @@ -91,31 +119,3 @@ Collection: "bukhari", fmt.Println(rsp, err) } ``` -## Collections - -Get a list of available collections. A collection is -a compilation of hadiths collected and written by an author. - - -[https://m3o.com/sunnah/api#Collections](https://m3o.com/sunnah/api#Collections) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/sunnah" -) - -// Get a list of available collections. A collection is -// a compilation of hadiths collected and written by an author. -func ListAvailableCollections() { - sunnahService := sunnah.NewSunnahService(os.Getenv("M3O_API_TOKEN")) - rsp, err := sunnahService.Collections(&sunnah.CollectionsRequest{ - - }) - fmt.Println(rsp, err) -} -``` diff --git a/examples/url/README.md b/examples/url/README.md index 314e672..ea79c77 100755 --- a/examples/url/README.md +++ b/examples/url/README.md @@ -4,6 +4,32 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Url/api](https Endpoints: +## Proxy + +Proxy returns the destination URL of a short URL. + + +[https://m3o.com/url/api#Proxy](https://m3o.com/url/api#Proxy) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/url" +) + +// Proxy returns the destination URL of a short URL. +func ResolveAshortUrlToAlongDestinationUrl() { + urlService := url.NewUrlService(os.Getenv("M3O_API_TOKEN")) + rsp, err := urlService.Proxy(&url.ProxyRequest{ + + }) + fmt.Println(rsp, err) +} +``` ## List List information on all the shortened URLs that you have created @@ -56,29 +82,3 @@ func ShortenAlongUrl() { fmt.Println(rsp, err) } ``` -## Proxy - -Proxy returns the destination URL of a short URL. - - -[https://m3o.com/url/api#Proxy](https://m3o.com/url/api#Proxy) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/url" -) - -// Proxy returns the destination URL of a short URL. -func ResolveAshortUrlToAlongDestinationUrl() { - urlService := url.NewUrlService(os.Getenv("M3O_API_TOKEN")) - rsp, err := urlService.Proxy(&url.ProxyRequest{ - - }) - fmt.Println(rsp, err) -} -``` diff --git a/examples/user/README.md b/examples/user/README.md index b5d0f2e..033bb9d 100755 --- a/examples/user/README.md +++ b/examples/user/README.md @@ -34,6 +34,90 @@ Username: "usrname-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) +} +``` +## 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) +} +``` +## 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. @@ -161,6 +245,33 @@ 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) +} +``` ## Delete Delete an account by id @@ -218,33 +329,6 @@ 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. @@ -272,87 +356,3 @@ func ReadAsessionByTheSessionId() { 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) -} -``` -## 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) -} -``` diff --git a/image/image.go b/image/image.go index dd23fcf..98aedf0 100755 --- a/image/image.go +++ b/image/image.go @@ -25,6 +25,14 @@ func (t *ImageService) Convert(request *ConvertRequest) (*ConvertResponse, error } +// Delete an image previously uploaded. +func (t *ImageService) Delete(request *DeleteRequest) (*DeleteResponse, error) { + + rsp := &DeleteResponse{} + return rsp, t.client.Call("image", "Delete", request, rsp) + +} + // 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. @@ -72,6 +80,14 @@ type CropOptions struct { Width int32 `json:"width"` } +type DeleteRequest struct { + // url of the image to delete e.g. https://cdn.m3ocontent.com/micro/images/micro/41e23b39-48dd-42b6-9738-79a313414bb8/cat.jpeg + Url string `json:"url"` +} + +type DeleteResponse struct { +} + type Point struct { X int32 `json:"x"` Y int32 `json:"y"`