From 8e6e73a8eb007002c867d3e245b791d99058829c Mon Sep 17 00:00:00 2001 From: m3o-actions <> Date: Tue, 2 Nov 2021 19:13:21 +0000 Subject: [PATCH] Commit from m3o/m3o action --- examples/cache/README.md | 56 +++--- examples/crypto/README.md | 54 +++--- examples/db/README.md | 68 ++++---- examples/db/create/createARecord.go | 2 +- examples/db/update/updateARecord.go | 2 +- examples/emoji/README.md | 54 +++--- examples/evchargers/README.md | 52 +++--- examples/event/README.md | 2 +- examples/event/publish/publishAnEvent.go | 2 +- examples/file/README.md | 62 +++---- examples/forex/README.md | 54 +++--- examples/image/README.md | 120 ++++++------- examples/mq/README.md | 64 +++---- examples/notes/README.md | 56 +++--- examples/otp/README.md | 54 +++--- examples/quran/README.md | 54 +++--- examples/routing/README.md | 68 ++++---- examples/rss/README.md | 58 +++---- examples/twitter/README.md | 56 +++--- examples/user/README.md | 208 +++++++++++------------ m3o.go | 3 + 21 files changed, 576 insertions(+), 573 deletions(-) diff --git a/examples/cache/README.md b/examples/cache/README.md index 8355dcc..9172036 100755 --- a/examples/cache/README.md +++ b/examples/cache/README.md @@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Cache/api](htt Endpoints: -## Set - -Set an item in the cache. Overwrites any existing value already set. - - -[https://m3o.com/cache/api#Set](https://m3o.com/cache/api#Set) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/cache" -) - -// Set an item in the cache. Overwrites any existing value already set. -func SetAvalue() { - cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN")) - rsp, err := cacheService.Set(&cache.SetRequest{ - Key: "foo", -Value: "bar", - - }) - fmt.Println(rsp, err) -} -``` ## Get Get an item from the cache by key @@ -142,3 +114,31 @@ 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/crypto/README.md b/examples/crypto/README.md index e9b36a4..a74272f 100755 --- a/examples/crypto/README.md +++ b/examples/crypto/README.md @@ -4,6 +4,33 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Crypto/api](ht Endpoints: +## News + +Get news related to a currency + + +[https://m3o.com/crypto/api#News](https://m3o.com/crypto/api#News) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/crypto" +) + +// Get news related to a currency +func GetCryptocurrencyNews() { + cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN")) + rsp, err := cryptoService.News(&crypto.NewsRequest{ + Symbol: "BTCUSD", + + }) + fmt.Println(rsp, err) +} +``` ## Price Get the last price for a given crypto ticker @@ -85,30 +112,3 @@ func GetPreviousClose() { fmt.Println(rsp, err) } ``` -## News - -Get news related to a currency - - -[https://m3o.com/crypto/api#News](https://m3o.com/crypto/api#News) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/crypto" -) - -// Get news related to a currency -func GetCryptocurrencyNews() { - cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN")) - rsp, err := cryptoService.News(&crypto.NewsRequest{ - Symbol: "BTCUSD", - - }) - fmt.Println(rsp, err) -} -``` diff --git a/examples/db/README.md b/examples/db/README.md index c104606..a242107 100755 --- a/examples/db/README.md +++ b/examples/db/README.md @@ -4,39 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Db/api](https: Endpoints: -## Create - -Create a record in the database. Optionally include an "id" field otherwise it's set automatically. - - -[https://m3o.com/db/api#Create](https://m3o.com/db/api#Create) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/db" -) - -// Create a record in the database. Optionally include an "id" field otherwise it's set automatically. -func CreateArecord() { - dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) - rsp, err := dbService.Create(&db.CreateRequest{ - Record: map[string]interface{}{ - "age": 42, - "isActive": true, - "id": "1", - "name": "Jane", -}, -Table: "users", - - }) - fmt.Println(rsp, err) -} -``` ## Update Update a record in the database. Include an "id" in the record to update. @@ -59,8 +26,8 @@ func UpdateArecord() { dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) rsp, err := dbService.Update(&db.UpdateRequest{ Record: map[string]interface{}{ - "age": 43, "id": "1", + "age": 43, }, Table: "users", @@ -178,3 +145,36 @@ func CountEntriesInAtable() { fmt.Println(rsp, err) } ``` +## Create + +Create a record in the database. Optionally include an "id" field otherwise it's set automatically. + + +[https://m3o.com/db/api#Create](https://m3o.com/db/api#Create) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/db" +) + +// Create a record in the database. Optionally include an "id" field otherwise it's set automatically. +func CreateArecord() { + dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) + rsp, err := dbService.Create(&db.CreateRequest{ + Record: map[string]interface{}{ + "age": 42, + "isActive": true, + "id": "1", + "name": "Jane", +}, +Table: "users", + + }) + fmt.Println(rsp, err) +} +``` diff --git a/examples/db/create/createARecord.go b/examples/db/create/createARecord.go index 688b6e8..456564c 100755 --- a/examples/db/create/createARecord.go +++ b/examples/db/create/createARecord.go @@ -12,10 +12,10 @@ func CreateArecord() { dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) rsp, err := dbService.Create(&db.CreateRequest{ Record: map[string]interface{}{ + "id": "1", "name": "Jane", "age": 42, "isActive": true, - "id": "1", }, Table: "users", }) diff --git a/examples/db/update/updateARecord.go b/examples/db/update/updateARecord.go index 3a9822b..378a5d6 100755 --- a/examples/db/update/updateARecord.go +++ b/examples/db/update/updateARecord.go @@ -12,8 +12,8 @@ func UpdateArecord() { dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) rsp, err := dbService.Update(&db.UpdateRequest{ Record: map[string]interface{}{ - "age": 43, "id": "1", + "age": 43, }, Table: "users", }) diff --git a/examples/emoji/README.md b/examples/emoji/README.md index 8907f04..af78e78 100755 --- a/examples/emoji/README.md +++ b/examples/emoji/README.md @@ -4,6 +4,33 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Emoji/api](htt Endpoints: +## Find + +Find an emoji by its alias e.g :beer: + + +[https://m3o.com/emoji/api#Find](https://m3o.com/emoji/api#Find) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/emoji" +) + +// Find an emoji by its alias e.g :beer: +func FindEmoji() { + emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN")) + rsp, err := emojiService.Find(&emoji.FindRequest{ + Alias: ":beer:", + + }) + fmt.Println(rsp, err) +} +``` ## Flag Get the flag for a country. Requires country code e.g GB for great britain @@ -88,30 +115,3 @@ To: "+44782669123", fmt.Println(rsp, err) } ``` -## Find - -Find an emoji by its alias e.g :beer: - - -[https://m3o.com/emoji/api#Find](https://m3o.com/emoji/api#Find) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/emoji" -) - -// Find an emoji by its alias e.g :beer: -func FindEmoji() { - emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN")) - rsp, err := emojiService.Find(&emoji.FindRequest{ - Alias: ":beer:", - - }) - fmt.Println(rsp, err) -} -``` diff --git a/examples/evchargers/README.md b/examples/evchargers/README.md index 81daae4..d687fe8 100755 --- a/examples/evchargers/README.md +++ b/examples/evchargers/README.md @@ -4,6 +4,32 @@ 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 @@ -95,29 +121,3 @@ 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/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.go b/examples/event/publish/publishAnEvent.go index d202086..16e0364 100755 --- a/examples/event/publish/publishAnEvent.go +++ b/examples/event/publish/publishAnEvent.go @@ -12,9 +12,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/file/README.md b/examples/file/README.md index 21161e8..68a6a0a 100755 --- a/examples/file/README.md +++ b/examples/file/README.md @@ -4,6 +4,37 @@ 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. @@ -87,34 +118,3 @@ 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 7949019..3cea13c 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: -## 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 @@ -85,3 +58,30 @@ 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/image/README.md b/examples/image/README.md index e590a10..1d58d10 100755 --- a/examples/image/README.md +++ b/examples/image/README.md @@ -4,66 +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) -} -``` ## 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. @@ -198,3 +138,63 @@ 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/mq/README.md b/examples/mq/README.md index 84e3101..9c6a065 100755 --- a/examples/mq/README.md +++ b/examples/mq/README.md @@ -4,6 +4,38 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Mq/api](https: Endpoints: +## Publish + +Publish a message. Specify a topic to group messages for a specific topic. + + +[https://m3o.com/mq/api#Publish](https://m3o.com/mq/api#Publish) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/mq" +) + +// Publish a message. Specify a topic to group messages for a specific topic. +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", +}, +Topic: "events", + + }) + fmt.Println(rsp, err) +} +``` ## Subscribe Subscribe to messages for a given topic. @@ -31,35 +63,3 @@ func SubscribeToAtopic() { fmt.Println(rsp, err) } ``` -## Publish - -Publish a message. Specify a topic to group messages for a specific topic. - - -[https://m3o.com/mq/api#Publish](https://m3o.com/mq/api#Publish) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/mq" -) - -// Publish a message. Specify a topic to group messages for a specific topic. -func PublishAmessage() { - mqService := mq.NewMqService(os.Getenv("M3O_API_TOKEN")) - rsp, err := mqService.Publish(&mq.PublishRequest{ - Message: map[string]interface{}{ - "type": "signup", - "user": "john", - "id": "1", -}, -Topic: "events", - - }) - fmt.Println(rsp, err) -} -``` diff --git a/examples/notes/README.md b/examples/notes/README.md index bf9f0b9..ee3f1a7 100755 --- a/examples/notes/README.md +++ b/examples/notes/README.md @@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Notes/api](htt Endpoints: -## Create - -Create a new note - - -[https://m3o.com/notes/api#Create](https://m3o.com/notes/api#Create) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/notes" -) - -// Create a new note -func CreateAnote() { - notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN")) - rsp, err := notesService.Create(¬es.CreateRequest{ - Text: "This is my note", -Title: "New Note", - - }) - fmt.Println(rsp, err) -} -``` ## Read Read a note @@ -170,3 +142,31 @@ 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/otp/README.md b/examples/otp/README.md index 001b680..d1ab2a1 100755 --- a/examples/otp/README.md +++ b/examples/otp/README.md @@ -4,6 +4,33 @@ 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 @@ -32,30 +59,3 @@ Id: "asim@example.com", fmt.Println(rsp, err) } ``` -## 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/quran/README.md b/examples/quran/README.md index 42a23ca..1e8ba4d 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: +## 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 @@ -89,30 +116,3 @@ func ListChapters() { 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 ea4d745..1f0e61c 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: +## Directions + +Turn by turn directions from a start point to an end point including maneuvers and bearings + + +[https://m3o.com/routing/api#Directions](https://m3o.com/routing/api#Directions) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/routing" +) + +// Turn by turn directions from a start point to an end point including maneuvers and bearings +func TurnByTurnDirections() { + routingService := routing.NewRoutingService(os.Getenv("M3O_API_TOKEN")) + rsp, err := routingService.Directions(&routing.DirectionsRequest{ + Destination: &routing.Point{ + Latitude: 52.529407, + Longitude: 13.397634, +}, +Origin: &routing.Point{ + Latitude: 52.517037, + Longitude: 13.38886, +}, + + }) + fmt.Println(rsp, err) +} +``` ## Route Retrieve a route as a simple list of gps points along with total distance and estimated duration @@ -72,37 +106,3 @@ Origin: &routing.Point{ fmt.Println(rsp, err) } ``` -## Directions - -Turn by turn directions from a start point to an end point including maneuvers and bearings - - -[https://m3o.com/routing/api#Directions](https://m3o.com/routing/api#Directions) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/routing" -) - -// Turn by turn directions from a start point to an end point including maneuvers and bearings -func TurnByTurnDirections() { - routingService := routing.NewRoutingService(os.Getenv("M3O_API_TOKEN")) - rsp, err := routingService.Directions(&routing.DirectionsRequest{ - Destination: &routing.Point{ - Latitude: 52.529407, - Longitude: 13.397634, -}, -Origin: &routing.Point{ - Latitude: 52.517037, - Longitude: 13.38886, -}, - - }) - fmt.Println(rsp, err) -} -``` diff --git a/examples/rss/README.md b/examples/rss/README.md index b7bbb60..439a4f5 100755 --- a/examples/rss/README.md +++ b/examples/rss/README.md @@ -4,6 +4,35 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Rss/api](https Endpoints: +## Add + +Add a new RSS feed with a name, url, and category + + +[https://m3o.com/rss/api#Add](https://m3o.com/rss/api#Add) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/rss" +) + +// Add a new RSS feed with a name, url, and category +func AddAnewFeed() { + rssService := rss.NewRssService(os.Getenv("M3O_API_TOKEN")) + rsp, err := rssService.Add(&rss.AddRequest{ + Category: "news", +Name: "bbc", +Url: "http://feeds.bbci.co.uk/news/rss.xml", + + }) + fmt.Println(rsp, err) +} +``` ## Feed Get an RSS feed by name. If no name is given, all feeds are returned. Default limit is 25 entries. @@ -84,32 +113,3 @@ func RemoveAfeed() { fmt.Println(rsp, err) } ``` -## Add - -Add a new RSS feed with a name, url, and category - - -[https://m3o.com/rss/api#Add](https://m3o.com/rss/api#Add) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/rss" -) - -// Add a new RSS feed with a name, url, and category -func AddAnewFeed() { - rssService := rss.NewRssService(os.Getenv("M3O_API_TOKEN")) - rsp, err := rssService.Add(&rss.AddRequest{ - Category: "news", -Name: "bbc", -Url: "http://feeds.bbci.co.uk/news/rss.xml", - - }) - fmt.Println(rsp, err) -} -``` diff --git a/examples/twitter/README.md b/examples/twitter/README.md index 5abfe70..c20e9a4 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: -## 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 @@ -112,3 +84,31 @@ 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/user/README.md b/examples/user/README.md index d03d410..1b81a16 100755 --- a/examples/user/README.md +++ b/examples/user/README.md @@ -4,12 +4,12 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/User/api](http Endpoints: -## Create +## VerifyEmail -Create a new user account. The email address and username for the account must be unique. +Verify the email address of an account from a token sent in an email to the user. -[https://m3o.com/user/api#Create](https://m3o.com/user/api#Create) +[https://m3o.com/user/api#VerifyEmail](https://m3o.com/user/api#VerifyEmail) ```go package example @@ -21,14 +21,68 @@ import( "go.m3o.com/user" ) -// Create a new user account. The email address and username for the account must be unique. -func CreateAnAccount() { +// 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.Create(&user.CreateRequest{ + 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, +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", -Id: "usrid-1", Password: "mySecretPass123", -Username: "usrname-1", + + }) + 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) @@ -115,87 +169,6 @@ func ReadAccountByEmail() { 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) -} -``` -## 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 @@ -299,12 +272,12 @@ Please verify your email by clicking this link: $micro_verification_link`, fmt.Println(rsp, err) } ``` -## VerifyEmail +## Delete -Verify the email address of an account from a token sent in an email to the user. +Delete an account by id -[https://m3o.com/user/api#VerifyEmail](https://m3o.com/user/api#VerifyEmail) +[https://m3o.com/user/api#Delete](https://m3o.com/user/api#Delete) ```go package example @@ -316,23 +289,22 @@ import( "go.m3o.com/user" ) -// Verify the email address of an account from a token sent in an email to the user. -func VerifyEmail() { +// Delete an account by id +func DeleteUserAccount() { userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.VerifyEmail(&user.VerifyEmailRequest{ - Token: "t2323t232t", + rsp, err := userService.Delete(&user.DeleteRequest{ + Id: "fdf34f34f34-f34f34-f43f43f34-f4f34f", }) fmt.Println(rsp, err) } ``` -## Login +## Logout -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 +Logout a user account -[https://m3o.com/user/api#Login](https://m3o.com/user/api#Login) +[https://m3o.com/user/api#Logout](https://m3o.com/user/api#Logout) ```go package example @@ -344,13 +316,41 @@ import( "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() { +// Logout a user account +func LogAuserOut() { userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.Login(&user.LoginRequest{ + 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/m3o.go b/m3o.go index 5bcf974..20bc035 100755 --- a/m3o.go +++ b/m3o.go @@ -35,6 +35,7 @@ import ( "go.m3o.com/sentiment" "go.m3o.com/sms" "go.m3o.com/stock" + "go.m3o.com/stream" "go.m3o.com/sunnah" "go.m3o.com/thumbnail" "go.m3o.com/time" @@ -84,6 +85,7 @@ func NewClient(token string) *Client { SentimentService: sentiment.NewSentimentService(token), SmsService: sms.NewSmsService(token), StockService: stock.NewStockService(token), + StreamService: stream.NewStreamService(token), SunnahService: sunnah.NewSunnahService(token), ThumbnailService: thumbnail.NewThumbnailService(token), TimeService: time.NewTimeService(token), @@ -133,6 +135,7 @@ type Client struct { SentimentService *sentiment.SentimentService SmsService *sms.SmsService StockService *stock.StockService + StreamService *stream.StreamService SunnahService *sunnah.SunnahService ThumbnailService *thumbnail.ThumbnailService TimeService *time.TimeService