From 38aea3724a9ae36611478634b32ea33cb58a60f2 Mon Sep 17 00:00:00 2001 From: m3o-actions <> Date: Thu, 24 Feb 2022 22:04:39 +0000 Subject: [PATCH] Commit from m3o/m3o action --- contact/contact.go | 10 +- examples/app/README.md | 168 ++-- examples/cache/README.md | 170 ++-- examples/chat/README.md | 188 ++--- examples/comments/README.md | 174 ++-- examples/contact/README.md | 120 +-- .../contact/create/createAContact/main.go | 2 +- .../contact/delete/deleteAContact/main.go | 2 +- .../main.go | 2 +- .../main.go | 2 +- examples/contact/read/getAContact/main.go | 2 +- .../contact/update/updateAContact/main.go | 2 +- examples/db/README.md | 194 ++--- examples/email/README.md | 64 +- examples/emoji/README.md | 56 +- examples/evchargers/README.md | 54 +- examples/event/README.md | 58 +- examples/forex/README.md | 56 +- examples/function/README.md | 154 ++-- examples/image/README.md | 238 +++--- examples/location/README.md | 72 +- examples/memegen/README.md | 54 +- examples/mq/README.md | 2 +- examples/notes/README.md | 110 +-- examples/place/README.md | 58 +- examples/routing/README.md | 70 +- examples/rss/README.md | 60 +- examples/search/index/indexARecord/main.go | 2 +- examples/space/README.md | 60 +- examples/stock/README.md | 64 +- examples/time/README.md | 54 +- examples/twitter/README.md | 58 +- examples/url/README.md | 54 +- examples/user/README.md | 772 +++++++++--------- 34 files changed, 1603 insertions(+), 1603 deletions(-) diff --git a/contact/contact.go b/contact/contact.go index 26999f4..b673a39 100755 --- a/contact/contact.go +++ b/contact/contact.go @@ -24,7 +24,7 @@ type ContactService struct { client *client.Client } -// +// Create a contact func (t *ContactService) Create(request *CreateRequest) (*CreateResponse, error) { rsp := &CreateResponse{} @@ -32,7 +32,7 @@ func (t *ContactService) Create(request *CreateRequest) (*CreateResponse, error) } -// +// Delete a contact func (t *ContactService) Delete(request *DeleteRequest) (*DeleteResponse, error) { rsp := &DeleteResponse{} @@ -40,7 +40,7 @@ func (t *ContactService) Delete(request *DeleteRequest) (*DeleteResponse, error) } -// +// List contacts func (t *ContactService) List(request *ListRequest) (*ListResponse, error) { rsp := &ListResponse{} @@ -48,7 +48,7 @@ func (t *ContactService) List(request *ListRequest) (*ListResponse, error) { } -// +// Read contact details func (t *ContactService) Read(request *ReadRequest) (*ReadResponse, error) { rsp := &ReadResponse{} @@ -56,7 +56,7 @@ func (t *ContactService) Read(request *ReadRequest) (*ReadResponse, error) { } -// +// Update a contact func (t *ContactService) Update(request *UpdateRequest) (*UpdateResponse, error) { rsp := &UpdateResponse{} diff --git a/examples/app/README.md b/examples/app/README.md index 3692e03..3c53fd6 100755 --- a/examples/app/README.md +++ b/examples/app/README.md @@ -4,6 +4,90 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/app/api](https Endpoints: +## Status + +Get the status of an app + + +[https://m3o.com/app/api#Status](https://m3o.com/app/api#Status) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/app" +) + +// Get the status of an app +func GetTheStatusOfAnApp() { + appService := app.NewAppService(os.Getenv("M3O_API_TOKEN")) + rsp, err := appService.Status(&app.StatusRequest{ + Name: "helloworld", + + }) + fmt.Println(rsp, err) + +} +``` +## Resolve + +Resolve an app by id to its raw backend endpoint + + +[https://m3o.com/app/api#Resolve](https://m3o.com/app/api#Resolve) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/app" +) + +// Resolve an app by id to its raw backend endpoint +func ResolveAppById() { + appService := app.NewAppService(os.Getenv("M3O_API_TOKEN")) + rsp, err := appService.Resolve(&app.ResolveRequest{ + Id: "helloworld", + + }) + fmt.Println(rsp, err) + +} +``` +## Update + +Update the app. The latest source code will be downloaded, built and deployed. + + +[https://m3o.com/app/api#Update](https://m3o.com/app/api#Update) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/app" +) + +// Update the app. The latest source code will be downloaded, built and deployed. +func UpdateAnApp() { + appService := app.NewAppService(os.Getenv("M3O_API_TOKEN")) + rsp, err := appService.Update(&app.UpdateRequest{ + Name: "helloworld", + + }) + fmt.Println(rsp, err) + +} +``` ## Delete Delete an app @@ -146,87 +230,3 @@ func ListRegions() { } ``` -## Status - -Get the status of an app - - -[https://m3o.com/app/api#Status](https://m3o.com/app/api#Status) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/app" -) - -// Get the status of an app -func GetTheStatusOfAnApp() { - appService := app.NewAppService(os.Getenv("M3O_API_TOKEN")) - rsp, err := appService.Status(&app.StatusRequest{ - Name: "helloworld", - - }) - fmt.Println(rsp, err) - -} -``` -## Resolve - -Resolve an app by id to its raw backend endpoint - - -[https://m3o.com/app/api#Resolve](https://m3o.com/app/api#Resolve) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/app" -) - -// Resolve an app by id to its raw backend endpoint -func ResolveAppById() { - appService := app.NewAppService(os.Getenv("M3O_API_TOKEN")) - rsp, err := appService.Resolve(&app.ResolveRequest{ - Id: "helloworld", - - }) - fmt.Println(rsp, err) - -} -``` -## Update - -Update the app. The latest source code will be downloaded, built and deployed. - - -[https://m3o.com/app/api#Update](https://m3o.com/app/api#Update) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/app" -) - -// Update the app. The latest source code will be downloaded, built and deployed. -func UpdateAnApp() { - appService := app.NewAppService(os.Getenv("M3O_API_TOKEN")) - rsp, err := appService.Update(&app.UpdateRequest{ - Name: "helloworld", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/cache/README.md b/examples/cache/README.md index 82e340c..e2c4a50 100755 --- a/examples/cache/README.md +++ b/examples/cache/README.md @@ -4,91 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/cache/api](htt Endpoints: -## Get - -Get an item from the cache by key. If key is not found, an empty response is returned. - - -[https://m3o.com/cache/api#Get](https://m3o.com/cache/api#Get) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/cache" -) - -// Get an item from the cache by key. If key is not found, an empty response is returned. -func GetAvalue() { - cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN")) - rsp, err := cacheService.Get(&cache.GetRequest{ - Key: "foo", - - }) - fmt.Println(rsp, err) - -} -``` -## Delete - -Delete a value from the cache. If key not found a success response is returned. - - -[https://m3o.com/cache/api#Delete](https://m3o.com/cache/api#Delete) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/cache" -) - -// Delete a value from the cache. If key not found a success response is returned. -func DeleteAvalue() { - cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN")) - rsp, err := cacheService.Delete(&cache.DeleteRequest{ - Key: "foo", - - }) - fmt.Println(rsp, err) - -} -``` -## Increment - -Increment a value (if it's a number). If key not found it is equivalent to set. - - -[https://m3o.com/cache/api#Increment](https://m3o.com/cache/api#Increment) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/cache" -) - -// Increment a value (if it's a number). If key not found it is equivalent to set. -func IncrementAvalue() { - cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN")) - rsp, err := cacheService.Increment(&cache.IncrementRequest{ - Key: "counter", -Value: 2, - - }) - fmt.Println(rsp, err) - -} -``` ## Decrement Decrement a value (if it's a number). If key not found it is equivalent to set. @@ -174,3 +89,88 @@ Value: "bar", } ``` +## Get + +Get an item from the cache by key. If key is not found, an empty response is returned. + + +[https://m3o.com/cache/api#Get](https://m3o.com/cache/api#Get) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/cache" +) + +// Get an item from the cache by key. If key is not found, an empty response is returned. +func GetAvalue() { + cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN")) + rsp, err := cacheService.Get(&cache.GetRequest{ + Key: "foo", + + }) + fmt.Println(rsp, err) + +} +``` +## Delete + +Delete a value from the cache. If key not found a success response is returned. + + +[https://m3o.com/cache/api#Delete](https://m3o.com/cache/api#Delete) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/cache" +) + +// Delete a value from the cache. If key not found a success response is returned. +func DeleteAvalue() { + cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN")) + rsp, err := cacheService.Delete(&cache.DeleteRequest{ + Key: "foo", + + }) + fmt.Println(rsp, err) + +} +``` +## Increment + +Increment a value (if it's a number). If key not found it is equivalent to set. + + +[https://m3o.com/cache/api#Increment](https://m3o.com/cache/api#Increment) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/cache" +) + +// Increment a value (if it's a number). If key not found it is equivalent to set. +func IncrementAvalue() { + cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN")) + rsp, err := cacheService.Increment(&cache.IncrementRequest{ + Key: "counter", +Value: 2, + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/chat/README.md b/examples/chat/README.md index d01dafd..89cdc44 100755 --- a/examples/chat/README.md +++ b/examples/chat/README.md @@ -33,6 +33,100 @@ Name: "general", } ``` +## Delete + +Delete a chat room + + +[https://m3o.com/chat/api#Delete](https://m3o.com/chat/api#Delete) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/chat" +) + +// Delete a chat room +func DeleteAchat() { + chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN")) + rsp, err := chatService.Delete(&chat.DeleteRequest{ + + }) + fmt.Println(rsp, err) + +} +``` +## History + +List the messages in a chat + + +[https://m3o.com/chat/api#History](https://m3o.com/chat/api#History) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/chat" +) + +// List the messages in a chat +func GetChatHistory() { + chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN")) + rsp, err := chatService.History(&chat.HistoryRequest{ + + }) + fmt.Println(rsp, err) + +} +``` +## Join + +Join a chat room + + +[https://m3o.com/chat/api#Join](https://m3o.com/chat/api#Join) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/chat" +) + +// Join a chat room +func JoinAroom() { + chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN")) + + stream, err := chatService.Join(&chat.JoinRequest{ + + }) + if err != nil { + fmt.Println(err) + return + } + + for { + rsp, err := stream.Recv() + if err != nil { + fmt.Println(err) + return + } + + fmt.Println(rsp) + } +} +``` ## List List available chats @@ -117,100 +211,6 @@ Text: "Hey whats up?", }) fmt.Println(rsp, err) -} -``` -## History - -List the messages in a chat - - -[https://m3o.com/chat/api#History](https://m3o.com/chat/api#History) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/chat" -) - -// List the messages in a chat -func GetChatHistory() { - chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN")) - rsp, err := chatService.History(&chat.HistoryRequest{ - - }) - fmt.Println(rsp, err) - -} -``` -## Join - -Join a chat room - - -[https://m3o.com/chat/api#Join](https://m3o.com/chat/api#Join) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/chat" -) - -// Join a chat room -func JoinAroom() { - chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN")) - - stream, err := chatService.Join(&chat.JoinRequest{ - - }) - if err != nil { - fmt.Println(err) - return - } - - for { - rsp, err := stream.Recv() - if err != nil { - fmt.Println(err) - return - } - - fmt.Println(rsp) - } -} -``` -## Delete - -Delete a chat room - - -[https://m3o.com/chat/api#Delete](https://m3o.com/chat/api#Delete) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/chat" -) - -// Delete a chat room -func DeleteAchat() { - chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN")) - rsp, err := chatService.Delete(&chat.DeleteRequest{ - - }) - fmt.Println(rsp, err) - } ``` ## Kick diff --git a/examples/comments/README.md b/examples/comments/README.md index bae93e5..15be76f 100755 --- a/examples/comments/README.md +++ b/examples/comments/README.md @@ -4,6 +4,93 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/comments/api]( Endpoints: +## List + +List all the comments + + +[https://m3o.com/comments/api#List](https://m3o.com/comments/api#List) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/comments" +) + +// List all the comments +func ListAllComments() { + commentsService := comments.NewCommentsService(os.Getenv("M3O_API_TOKEN")) + rsp, err := commentsService.List(&comments.ListRequest{ + + }) + fmt.Println(rsp, err) + +} +``` +## Update + +Update a comment + + +[https://m3o.com/comments/api#Update](https://m3o.com/comments/api#Update) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/comments" +) + +// Update a comment +func UpdateAcomment() { + commentsService := comments.NewCommentsService(os.Getenv("M3O_API_TOKEN")) + rsp, err := commentsService.Update(&comments.UpdateRequest{ + Comment: &comments.Comment{ + Id: "63c0cdf8-2121-11ec-a881-0242e36f037a", + Subject: "Update Comment", + Text: "Updated comment text", + }, + + }) + fmt.Println(rsp, err) + +} +``` +## Delete + +Delete a comment + + +[https://m3o.com/comments/api#Delete](https://m3o.com/comments/api#Delete) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/comments" +) + +// Delete a comment +func DeleteAcomment() { + commentsService := comments.NewCommentsService(os.Getenv("M3O_API_TOKEN")) + rsp, err := commentsService.Delete(&comments.DeleteRequest{ + Id: "63c0cdf8-2121-11ec-a881-0242e36f037a", + + }) + fmt.Println(rsp, err) + +} +``` ## Events Subscribe to comments events @@ -101,90 +188,3 @@ func ReadAcomment() { } ``` -## List - -List all the comments - - -[https://m3o.com/comments/api#List](https://m3o.com/comments/api#List) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/comments" -) - -// List all the comments -func ListAllComments() { - commentsService := comments.NewCommentsService(os.Getenv("M3O_API_TOKEN")) - rsp, err := commentsService.List(&comments.ListRequest{ - - }) - fmt.Println(rsp, err) - -} -``` -## Update - -Update a comment - - -[https://m3o.com/comments/api#Update](https://m3o.com/comments/api#Update) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/comments" -) - -// Update a comment -func UpdateAcomment() { - commentsService := comments.NewCommentsService(os.Getenv("M3O_API_TOKEN")) - rsp, err := commentsService.Update(&comments.UpdateRequest{ - Comment: &comments.Comment{ - Id: "63c0cdf8-2121-11ec-a881-0242e36f037a", - Subject: "Update Comment", - Text: "Updated comment text", - }, - - }) - fmt.Println(rsp, err) - -} -``` -## Delete - -Delete a comment - - -[https://m3o.com/comments/api#Delete](https://m3o.com/comments/api#Delete) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/comments" -) - -// Delete a comment -func DeleteAcomment() { - commentsService := comments.NewCommentsService(os.Getenv("M3O_API_TOKEN")) - rsp, err := commentsService.Delete(&comments.DeleteRequest{ - Id: "63c0cdf8-2121-11ec-a881-0242e36f037a", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/contact/README.md b/examples/contact/README.md index 878f816..e2e01cc 100755 --- a/examples/contact/README.md +++ b/examples/contact/README.md @@ -4,9 +4,59 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/contact/api](h Endpoints: +## Create + +Create a contact + + +[https://m3o.com/contact/api#Create](https://m3o.com/contact/api#Create) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/contact" +) + +// Create a contact +func CreateAcontact() { + contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN")) + rsp, err := contactService.Create(&contact.CreateRequest{ + Addresses: []contact.Address{ +contact.Address{ + Label: "company address", + Location: "123 street address", +}}, +Birthday: "1995-01-01", +Emails: []contact.Email{ +contact.Email{ + Address: "home@example.com", + Label: "home", +}}, +Links: []contact.Link{ +contact.Link{ + Label: "blog", + Url: "https://blog.joe.me", +}}, +Name: "joe", +Note: "this person is very important", +Phones: []contact.Phone{ +contact.Phone{ + Label: "home", + Number: "010-12345678", +}}, + + }) + fmt.Println(rsp, err) + +} +``` ## Update - +Update a contact [https://m3o.com/contact/api#Update](https://m3o.com/contact/api#Update) @@ -21,7 +71,7 @@ import( "go.m3o.com/contact" ) -// +// Update a contact func UpdateAcontact() { contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN")) rsp, err := contactService.Update(&contact.UpdateRequest{ @@ -57,7 +107,7 @@ contact.Phone{ ``` ## Read - +Read contact details [https://m3o.com/contact/api#Read](https://m3o.com/contact/api#Read) @@ -72,7 +122,7 @@ import( "go.m3o.com/contact" ) -// +// Read contact details func GetAcontact() { contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN")) rsp, err := contactService.Read(&contact.ReadRequest{ @@ -85,7 +135,7 @@ func GetAcontact() { ``` ## Delete - +Delete a contact [https://m3o.com/contact/api#Delete](https://m3o.com/contact/api#Delete) @@ -100,7 +150,7 @@ import( "go.m3o.com/contact" ) -// +// Delete a contact func DeleteAcontact() { contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN")) rsp, err := contactService.Delete(&contact.DeleteRequest{ @@ -113,7 +163,7 @@ func DeleteAcontact() { ``` ## List - +List contacts [https://m3o.com/contact/api#List](https://m3o.com/contact/api#List) @@ -128,7 +178,7 @@ import( "go.m3o.com/contact" ) -// +// List contacts func ListContactsWithDefaultOffsetAndLimitDefaultLimitIs20() { contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN")) rsp, err := contactService.List(&contact.ListRequest{ @@ -140,7 +190,7 @@ func ListContactsWithDefaultOffsetAndLimitDefaultLimitIs20() { ``` ## List - +List contacts [https://m3o.com/contact/api#List](https://m3o.com/contact/api#List) @@ -155,7 +205,7 @@ import( "go.m3o.com/contact" ) -// +// List contacts func ListContactsWithSpecificOffsetAndLimit() { contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN")) rsp, err := contactService.List(&contact.ListRequest{ @@ -167,53 +217,3 @@ Offset: 1, } ``` -## Create - - - - -[https://m3o.com/contact/api#Create](https://m3o.com/contact/api#Create) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/contact" -) - -// -func CreateAcontact() { - contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN")) - rsp, err := contactService.Create(&contact.CreateRequest{ - Addresses: []contact.Address{ -contact.Address{ - Label: "company address", - Location: "123 street address", -}}, -Birthday: "1995-01-01", -Emails: []contact.Email{ -contact.Email{ - Address: "home@example.com", - Label: "home", -}}, -Links: []contact.Link{ -contact.Link{ - Label: "blog", - Url: "https://blog.joe.me", -}}, -Name: "joe", -Note: "this person is very important", -Phones: []contact.Phone{ -contact.Phone{ - Label: "home", - Number: "010-12345678", -}}, - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/contact/create/createAContact/main.go b/examples/contact/create/createAContact/main.go index db73253..b211f8a 100755 --- a/examples/contact/create/createAContact/main.go +++ b/examples/contact/create/createAContact/main.go @@ -7,7 +7,7 @@ import ( "go.m3o.com/contact" ) -// +// Create a contact func main() { contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN")) rsp, err := contactService.Create(&contact.CreateRequest{ diff --git a/examples/contact/delete/deleteAContact/main.go b/examples/contact/delete/deleteAContact/main.go index 7944052..e23bedd 100755 --- a/examples/contact/delete/deleteAContact/main.go +++ b/examples/contact/delete/deleteAContact/main.go @@ -7,7 +7,7 @@ import ( "go.m3o.com/contact" ) -// +// Delete a contact func main() { contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN")) rsp, err := contactService.Delete(&contact.DeleteRequest{ diff --git a/examples/contact/list/listContactsWithDefaultOffsetAndLimitDefaultLimitIs20/main.go b/examples/contact/list/listContactsWithDefaultOffsetAndLimitDefaultLimitIs20/main.go index 72465e2..2d86395 100755 --- a/examples/contact/list/listContactsWithDefaultOffsetAndLimitDefaultLimitIs20/main.go +++ b/examples/contact/list/listContactsWithDefaultOffsetAndLimitDefaultLimitIs20/main.go @@ -7,7 +7,7 @@ import ( "go.m3o.com/contact" ) -// +// List contacts func main() { contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN")) rsp, err := contactService.List(&contact.ListRequest{}) diff --git a/examples/contact/list/listContactsWithSpecificOffsetAndLimit/main.go b/examples/contact/list/listContactsWithSpecificOffsetAndLimit/main.go index 821c14f..b592bc1 100755 --- a/examples/contact/list/listContactsWithSpecificOffsetAndLimit/main.go +++ b/examples/contact/list/listContactsWithSpecificOffsetAndLimit/main.go @@ -7,7 +7,7 @@ import ( "go.m3o.com/contact" ) -// +// List contacts func main() { contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN")) rsp, err := contactService.List(&contact.ListRequest{ diff --git a/examples/contact/read/getAContact/main.go b/examples/contact/read/getAContact/main.go index b80686d..61790e9 100755 --- a/examples/contact/read/getAContact/main.go +++ b/examples/contact/read/getAContact/main.go @@ -7,7 +7,7 @@ import ( "go.m3o.com/contact" ) -// +// Read contact details func main() { contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN")) rsp, err := contactService.Read(&contact.ReadRequest{ diff --git a/examples/contact/update/updateAContact/main.go b/examples/contact/update/updateAContact/main.go index 5381500..cd0e30d 100755 --- a/examples/contact/update/updateAContact/main.go +++ b/examples/contact/update/updateAContact/main.go @@ -7,7 +7,7 @@ import ( "go.m3o.com/contact" ) -// +// Update a contact func main() { contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN")) rsp, err := contactService.Update(&contact.UpdateRequest{ diff --git a/examples/db/README.md b/examples/db/README.md index 3ac93ab..20f79e4 100755 --- a/examples/db/README.md +++ b/examples/db/README.md @@ -4,66 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/db/api](https: Endpoints: -## Update - -Update a record in the database. Include an "id" in the record to update. - - -[https://m3o.com/db/api#Update](https://m3o.com/db/api#Update) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/db" -) - -// Update a record in the database. Include an "id" in the record to update. -func UpdateArecord() { - dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) - rsp, err := dbService.Update(&db.UpdateRequest{ - Record: map[string]interface{}{ - "id": "1", - "age": 43, -}, -Table: "example", - - }) - fmt.Println(rsp, err) - -} -``` -## DropTable - -Drop a table in the DB - - -[https://m3o.com/db/api#DropTable](https://m3o.com/db/api#DropTable) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/db" -) - -// Drop a table in the DB -func DropTable() { - dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) - rsp, err := dbService.DropTable(&db.DropTableRequest{ - Table: "example", - - }) - fmt.Println(rsp, err) - -} -``` ## ListTables List tables in the DB @@ -89,6 +29,35 @@ func ListTables() { }) fmt.Println(rsp, err) +} +``` +## RenameTable + +Rename a table + + +[https://m3o.com/db/api#RenameTable](https://m3o.com/db/api#RenameTable) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/db" +) + +// Rename a table +func RenameTable() { + dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) + rsp, err := dbService.RenameTable(&db.RenameTableRequest{ + From: "examples2", +To: "examples3", + + }) + fmt.Println(rsp, err) + } ``` ## Create @@ -123,35 +92,6 @@ Table: "example", }) fmt.Println(rsp, err) -} -``` -## Read - -Read data from a table. Lookup can be by ID or via querying any field in the record. - - -[https://m3o.com/db/api#Read](https://m3o.com/db/api#Read) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/db" -) - -// Read data from a table. Lookup can be by ID or via querying any field in the record. -func ReadRecords() { - dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) - rsp, err := dbService.Read(&db.ReadRequest{ - Query: "age == 43", -Table: "example", - - }) - fmt.Println(rsp, err) - } ``` ## Delete @@ -239,12 +179,12 @@ func CountEntriesInAtable() { } ``` -## RenameTable +## Update -Rename a table +Update a record in the database. Include an "id" in the record to update. -[https://m3o.com/db/api#RenameTable](https://m3o.com/db/api#RenameTable) +[https://m3o.com/db/api#Update](https://m3o.com/db/api#Update) ```go package example @@ -256,12 +196,72 @@ import( "go.m3o.com/db" ) -// Rename a table -func RenameTable() { +// Update a record in the database. Include an "id" in the record to update. +func UpdateArecord() { dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) - rsp, err := dbService.RenameTable(&db.RenameTableRequest{ - From: "examples2", -To: "examples3", + rsp, err := dbService.Update(&db.UpdateRequest{ + Record: map[string]interface{}{ + "age": 43, + "id": "1", +}, +Table: "example", + + }) + fmt.Println(rsp, err) + +} +``` +## Read + +Read data from a table. Lookup can be by ID or via querying any field in the record. + + +[https://m3o.com/db/api#Read](https://m3o.com/db/api#Read) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/db" +) + +// Read data from a table. Lookup can be by ID or via querying any field in the record. +func ReadRecords() { + dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) + rsp, err := dbService.Read(&db.ReadRequest{ + Query: "age == 43", +Table: "example", + + }) + fmt.Println(rsp, err) + +} +``` +## DropTable + +Drop a table in the DB + + +[https://m3o.com/db/api#DropTable](https://m3o.com/db/api#DropTable) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/db" +) + +// Drop a table in the DB +func DropTable() { + dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) + rsp, err := dbService.DropTable(&db.DropTableRequest{ + Table: "example", }) fmt.Println(rsp, err) diff --git a/examples/email/README.md b/examples/email/README.md index 8e6afcf..0009156 100755 --- a/examples/email/README.md +++ b/examples/email/README.md @@ -4,38 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/email/api](htt Endpoints: -## Send - -Send an email by passing in from, to, subject, and a text or html body - - -[https://m3o.com/email/api#Send](https://m3o.com/email/api#Send) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/email" -) - -// Send an email by passing in from, to, subject, and a text or html body -func SendEmail() { - emailService := email.NewEmailService(os.Getenv("M3O_API_TOKEN")) - rsp, err := emailService.Send(&email.SendRequest{ - From: "Awesome Dot Com", -Subject: "Email verification", -TextBody: `Hi there, - -Please verify your email by clicking this link: $micro_verification_link`, - - }) - fmt.Println(rsp, err) - -} -``` ## Parse Parse an RFC5322 address e.g "Joe Blogs " @@ -92,3 +60,35 @@ func ValidateEmail() { } ``` +## Send + +Send an email by passing in from, to, subject, and a text or html body + + +[https://m3o.com/email/api#Send](https://m3o.com/email/api#Send) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/email" +) + +// Send an email by passing in from, to, subject, and a text or html body +func SendEmail() { + emailService := email.NewEmailService(os.Getenv("M3O_API_TOKEN")) + rsp, err := emailService.Send(&email.SendRequest{ + From: "Awesome Dot Com", +Subject: "Email verification", +TextBody: `Hi there, + +Please verify your email by clicking this link: $micro_verification_link`, + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/emoji/README.md b/examples/emoji/README.md index 9eb6bad..dc735fb 100755 --- a/examples/emoji/README.md +++ b/examples/emoji/README.md @@ -4,6 +4,34 @@ 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 @@ -61,31 +89,3 @@ func PrintTextIncludingEmoji() { } ``` -## 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 7e1c9b6..176565e 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/README.md b/examples/event/README.md index 0a33d30..fc81ead 100755 --- a/examples/event/README.md +++ b/examples/event/README.md @@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/event/api](htt Endpoints: -## Read - -Read stored events - - -[https://m3o.com/event/api#Read](https://m3o.com/event/api#Read) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/event" -) - -// Read stored events -func ReadEventsOnAtopic() { - eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN")) - rsp, err := eventService.Read(&event.ReadRequest{ - Topic: "user", - - }) - fmt.Println(rsp, err) - -} -``` ## Publish Publish a event to the event stream. @@ -54,9 +26,9 @@ func PublishAnEvent() { 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", @@ -106,3 +78,31 @@ func ConsumeFromAtopic() { } } ``` +## Read + +Read stored events + + +[https://m3o.com/event/api#Read](https://m3o.com/event/api#Read) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/event" +) + +// Read stored events +func ReadEventsOnAtopic() { + eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN")) + rsp, err := eventService.Read(&event.ReadRequest{ + Topic: "user", + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/forex/README.md b/examples/forex/README.md index 56698bb..a91003f 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 8289b59..253e7be 100755 --- a/examples/function/README.md +++ b/examples/function/README.md @@ -4,12 +4,12 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/function/api]( Endpoints: -## Proxy +## Call -Return the backend url for proxying +Call a function by name -[https://m3o.com/function/api#Proxy](https://m3o.com/function/api#Proxy) +[https://m3o.com/function/api#Call](https://m3o.com/function/api#Call) ```go package example @@ -21,73 +21,14 @@ import( "go.m3o.com/function" ) -// Return the backend url for proxying -func ProxyUrl() { +// Call a function by name +func CallAfunction() { functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) - rsp, err := functionService.Proxy(&function.ProxyRequest{ - Id: "helloworld", - - }) - fmt.Println(rsp, err) - -} -``` -## Deploy - -Deploy a group of functions - - -[https://m3o.com/function/api#Deploy](https://m3o.com/function/api#Deploy) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/function" -) - -// Deploy a group of functions -func DeployAfunction() { - functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) - rsp, err := functionService.Deploy(&function.DeployRequest{ - Branch: "main", -Entrypoint: "Helloworld", -Name: "helloworld", -Region: "europe-west1", -Repo: "https://github.com/m3o/m3o", -Runtime: "go116", -Subfolder: "examples/go-function", - - }) - fmt.Println(rsp, err) - -} -``` -## Update - -Update a function. Downloads the source, builds and redeploys - - -[https://m3o.com/function/api#Update](https://m3o.com/function/api#Update) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/function" -) - -// Update a function. Downloads the source, builds and redeploys -func UpdateAfunction() { - functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) - rsp, err := functionService.Update(&function.UpdateRequest{ + rsp, err := functionService.Call(&function.CallRequest{ Name: "helloworld", +Request: map[string]interface{}{ + "name": "Alice", +}, }) fmt.Println(rsp, err) @@ -176,12 +117,12 @@ func ReserveAfunction() { } ``` -## Call +## Deploy -Call a function by name +Deploy a group of functions -[https://m3o.com/function/api#Call](https://m3o.com/function/api#Call) +[https://m3o.com/function/api#Deploy](https://m3o.com/function/api#Deploy) ```go package example @@ -193,14 +134,73 @@ import( "go.m3o.com/function" ) -// Call a function by name -func CallAfunction() { +// Deploy a group of functions +func DeployAfunction() { functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) - rsp, err := functionService.Call(&function.CallRequest{ + rsp, err := functionService.Deploy(&function.DeployRequest{ + Branch: "main", +Entrypoint: "Helloworld", +Name: "helloworld", +Region: "europe-west1", +Repo: "https://github.com/m3o/m3o", +Runtime: "go116", +Subfolder: "examples/go-function", + + }) + fmt.Println(rsp, err) + +} +``` +## Update + +Update a function. Downloads the source, builds and redeploys + + +[https://m3o.com/function/api#Update](https://m3o.com/function/api#Update) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/function" +) + +// Update a function. Downloads the source, builds and redeploys +func UpdateAfunction() { + functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) + rsp, err := functionService.Update(&function.UpdateRequest{ Name: "helloworld", -Request: map[string]interface{}{ - "name": "Alice", -}, + + }) + fmt.Println(rsp, err) + +} +``` +## Proxy + +Return the backend url for proxying + + +[https://m3o.com/function/api#Proxy](https://m3o.com/function/api#Proxy) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/function" +) + +// Return the backend url for proxying +func ProxyUrl() { + functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) + rsp, err := functionService.Proxy(&function.ProxyRequest{ + Id: "helloworld", }) fmt.Println(rsp, err) diff --git a/examples/image/README.md b/examples/image/README.md index 6b5b4b5..8da67d8 100755 --- a/examples/image/README.md +++ b/examples/image/README.md @@ -4,125 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/image/api](htt Endpoints: -## Resize - -Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters. -If one of width or height is 0, the image aspect ratio is preserved. -Optional cropping. -To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json -with each parameter as a form field. - - -[https://m3o.com/image/api#Resize](https://m3o.com/image/api#Resize) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/image" -) - -// Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters. -// If one of width or height is 0, the image aspect ratio is preserved. -// Optional cropping. -// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json -// with each parameter as a form field. -func Base64toHostedImage() { - imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN")) - rsp, err := imageService.Resize(&image.ResizeRequest{ - Base64: "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==", -Height: 100, -Name: "cat.png", -Width: 100, - - }) - fmt.Println(rsp, err) - -} -``` -## Resize - -Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters. -If one of width or height is 0, the image aspect ratio is preserved. -Optional cropping. -To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json -with each parameter as a form field. - - -[https://m3o.com/image/api#Resize](https://m3o.com/image/api#Resize) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/image" -) - -// Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters. -// If one of width or height is 0, the image aspect ratio is preserved. -// Optional cropping. -// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json -// with each parameter as a form field. -func Base64toBase64image() { - imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN")) - rsp, err := imageService.Resize(&image.ResizeRequest{ - Base64: "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==", -Height: 100, -Width: 100, - - }) - fmt.Println(rsp, err) - -} -``` -## Resize - -Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters. -If one of width or height is 0, the image aspect ratio is preserved. -Optional cropping. -To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json -with each parameter as a form field. - - -[https://m3o.com/image/api#Resize](https://m3o.com/image/api#Resize) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/image" -) - -// Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters. -// If one of width or height is 0, the image aspect ratio is preserved. -// Optional cropping. -// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json -// with each parameter as a form field. -func Base64toBase64imageWithCropping() { - imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN")) - rsp, err := imageService.Resize(&image.ResizeRequest{ - Base64: "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==", -CropOptions: &image.CropOptions{ - Height: 50, - Width: 50, -}, -Height: 100, -Width: 100, - - }) - fmt.Println(rsp, err) - -} -``` ## Convert Convert an image from one format (jpeg, png etc.) to an other either on the fly (from base64 to base64), @@ -256,3 +137,122 @@ func DeleteAnUploadedImage() { } ``` +## Resize + +Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters. +If one of width or height is 0, the image aspect ratio is preserved. +Optional cropping. +To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json +with each parameter as a form field. + + +[https://m3o.com/image/api#Resize](https://m3o.com/image/api#Resize) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/image" +) + +// Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters. +// If one of width or height is 0, the image aspect ratio is preserved. +// Optional cropping. +// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json +// with each parameter as a form field. +func Base64toHostedImage() { + imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN")) + rsp, err := imageService.Resize(&image.ResizeRequest{ + Base64: "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==", +Height: 100, +Name: "cat.png", +Width: 100, + + }) + fmt.Println(rsp, err) + +} +``` +## Resize + +Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters. +If one of width or height is 0, the image aspect ratio is preserved. +Optional cropping. +To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json +with each parameter as a form field. + + +[https://m3o.com/image/api#Resize](https://m3o.com/image/api#Resize) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/image" +) + +// Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters. +// If one of width or height is 0, the image aspect ratio is preserved. +// Optional cropping. +// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json +// with each parameter as a form field. +func Base64toBase64image() { + imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN")) + rsp, err := imageService.Resize(&image.ResizeRequest{ + Base64: "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==", +Height: 100, +Width: 100, + + }) + fmt.Println(rsp, err) + +} +``` +## Resize + +Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters. +If one of width or height is 0, the image aspect ratio is preserved. +Optional cropping. +To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json +with each parameter as a form field. + + +[https://m3o.com/image/api#Resize](https://m3o.com/image/api#Resize) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/image" +) + +// Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters. +// If one of width or height is 0, the image aspect ratio is preserved. +// Optional cropping. +// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json +// with each parameter as a form field. +func Base64toBase64imageWithCropping() { + imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN")) + rsp, err := imageService.Resize(&image.ResizeRequest{ + Base64: "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==", +CropOptions: &image.CropOptions{ + Height: 50, + Width: 50, +}, +Height: 100, +Width: 100, + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/location/README.md b/examples/location/README.md index a7e58ad..78700e1 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/memegen/README.md b/examples/memegen/README.md index 02370b8..a35d7c0 100755 --- a/examples/memegen/README.md +++ b/examples/memegen/README.md @@ -4,33 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/memegen/api](h Endpoints: -## Templates - -List the available templates - - -[https://m3o.com/memegen/api#Templates](https://m3o.com/memegen/api#Templates) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/memegen" -) - -// List the available templates -func MemeTemplates() { - memegenService := memegen.NewMemegenService(os.Getenv("M3O_API_TOKEN")) - rsp, err := memegenService.Templates(&memegen.TemplatesRequest{ - - }) - fmt.Println(rsp, err) - -} -``` ## Generate Generate a meme using a template @@ -59,3 +32,30 @@ func GenerateAmeme() { } ``` +## Templates + +List the available templates + + +[https://m3o.com/memegen/api#Templates](https://m3o.com/memegen/api#Templates) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/memegen" +) + +// List the available templates +func MemeTemplates() { + memegenService := memegen.NewMemegenService(os.Getenv("M3O_API_TOKEN")) + rsp, err := memegenService.Templates(&memegen.TemplatesRequest{ + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/mq/README.md b/examples/mq/README.md index 8f18a93..1582975 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/notes/README.md b/examples/notes/README.md index 3bc665d..272c2eb 100755 --- a/examples/notes/README.md +++ b/examples/notes/README.md @@ -4,6 +4,61 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/notes/api](htt Endpoints: +## Read + +Read a note + + +[https://m3o.com/notes/api#Read](https://m3o.com/notes/api#Read) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/notes" +) + +// Read a note +func ReadAnote() { + notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN")) + rsp, err := notesService.Read(¬es.ReadRequest{ + Id: "63c0cdf8-2121-11ec-a881-0242e36f037a", + + }) + fmt.Println(rsp, err) + +} +``` +## List + +List all the notes + + +[https://m3o.com/notes/api#List](https://m3o.com/notes/api#List) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/notes" +) + +// List all the notes +func ListAllNotes() { + notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN")) + rsp, err := notesService.List(¬es.ListRequest{ + + }) + fmt.Println(rsp, err) + +} +``` ## Update Update a note @@ -134,58 +189,3 @@ Title: "New Note", } ``` -## Read - -Read a note - - -[https://m3o.com/notes/api#Read](https://m3o.com/notes/api#Read) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/notes" -) - -// Read a note -func ReadAnote() { - notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN")) - rsp, err := notesService.Read(¬es.ReadRequest{ - Id: "63c0cdf8-2121-11ec-a881-0242e36f037a", - - }) - fmt.Println(rsp, err) - -} -``` -## List - -List all the notes - - -[https://m3o.com/notes/api#List](https://m3o.com/notes/api#List) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/notes" -) - -// List all the notes -func ListAllNotes() { - notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN")) - rsp, err := notesService.List(¬es.ListRequest{ - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/place/README.md b/examples/place/README.md index 4a83a0a..edccd56 100755 --- a/examples/place/README.md +++ b/examples/place/README.md @@ -4,6 +4,35 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/place/api](htt Endpoints: +## Search + +Search for places by text query + + +[https://m3o.com/place/api#Search](https://m3o.com/place/api#Search) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/place" +) + +// Search for places by text query +func SearchForPlaces() { + placeService := place.NewPlaceService(os.Getenv("M3O_API_TOKEN")) + rsp, err := placeService.Search(&place.SearchRequest{ + Location: "51.5074577,-0.1297515", +Query: "food", + + }) + fmt.Println(rsp, err) + +} +``` ## Nearby Find places nearby using a location @@ -34,32 +63,3 @@ Type: "store", } ``` -## Search - -Search for places by text query - - -[https://m3o.com/place/api#Search](https://m3o.com/place/api#Search) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/place" -) - -// Search for places by text query -func SearchForPlaces() { - placeService := place.NewPlaceService(os.Getenv("M3O_API_TOKEN")) - rsp, err := placeService.Search(&place.SearchRequest{ - Location: "51.5074577,-0.1297515", -Query: "food", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/routing/README.md b/examples/routing/README.md index b66e7d8..f133a39 100755 --- a/examples/routing/README.md +++ b/examples/routing/README.md @@ -4,6 +4,41 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/routing/api](h Endpoints: +## Eta + +Get the eta for a route from origin to destination. The eta is an estimated time based on car routes + + +[https://m3o.com/routing/api#Eta](https://m3o.com/routing/api#Eta) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/routing" +) + +// Get the eta for a route from origin to destination. The eta is an estimated time based on car routes +func EtaFromPointAtoPointB() { + routingService := routing.NewRoutingService(os.Getenv("M3O_API_TOKEN")) + rsp, err := routingService.Eta(&routing.EtaRequest{ + Destination: &routing.Point{ + Latitude: 52.529407, + Longitude: 13.397634, +}, +Origin: &routing.Point{ + Latitude: 52.517037, + Longitude: 13.38886, +}, + + }) + fmt.Println(rsp, err) + +} +``` ## Directions Turn by turn directions from a start point to an end point including maneuvers and bearings @@ -74,38 +109,3 @@ Origin: &routing.Point{ } ``` -## Eta - -Get the eta for a route from origin to destination. The eta is an estimated time based on car routes - - -[https://m3o.com/routing/api#Eta](https://m3o.com/routing/api#Eta) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/routing" -) - -// Get the eta for a route from origin to destination. The eta is an estimated time based on car routes -func EtaFromPointAtoPointB() { - routingService := routing.NewRoutingService(os.Getenv("M3O_API_TOKEN")) - rsp, err := routingService.Eta(&routing.EtaRequest{ - Destination: &routing.Point{ - Latitude: 52.529407, - Longitude: 13.397634, -}, -Origin: &routing.Point{ - Latitude: 52.517037, - Longitude: 13.38886, -}, - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/rss/README.md b/examples/rss/README.md index 528df60..5cda3e4 100755 --- a/examples/rss/README.md +++ b/examples/rss/README.md @@ -4,6 +4,36 @@ 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. @@ -87,33 +117,3 @@ func RemoveAfeed() { } ``` -## 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/search/index/indexARecord/main.go b/examples/search/index/indexARecord/main.go index 2a7b1d7..8f47156 100755 --- a/examples/search/index/indexARecord/main.go +++ b/examples/search/index/indexARecord/main.go @@ -12,9 +12,9 @@ func main() { searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN")) rsp, err := searchService.Index(&search.IndexRequest{ Data: map[string]interface{}{ + "name": "John Doe", "age": 37, "starsign": "Leo", - "name": "John Doe", }, Index: "customers", }) diff --git a/examples/space/README.md b/examples/space/README.md index f8dd335..1bf72dc 100755 --- a/examples/space/README.md +++ b/examples/space/README.md @@ -4,6 +4,36 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/space/api](htt Endpoints: +## Create + +Create an object. Returns error if object with this name already exists. Max object size of 10MB, see Upload endpoint for larger objects. If you want to update an existing object use the `Update` endpoint + + +[https://m3o.com/space/api#Create](https://m3o.com/space/api#Create) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/space" +) + +// Create an object. Returns error if object with this name already exists. Max object size of 10MB, see Upload endpoint for larger objects. If you want to update an existing object use the `Update` endpoint +func CreateAnObject() { + spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN")) + rsp, err := spaceService.Create(&space.CreateRequest{ + Name: "images/file.jpg", +Object: "", +Visibility: "public", + + }) + fmt.Println(rsp, err) + +} +``` ## Update Update an object. If an object with this name does not exist, creates a new one. @@ -202,33 +232,3 @@ func UploadAnObject() { } ``` -## Create - -Create an object. Returns error if object with this name already exists. Max object size of 10MB, see Upload endpoint for larger objects. If you want to update an existing object use the `Update` endpoint - - -[https://m3o.com/space/api#Create](https://m3o.com/space/api#Create) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/space" -) - -// Create an object. Returns error if object with this name already exists. Max object size of 10MB, see Upload endpoint for larger objects. If you want to update an existing object use the `Update` endpoint -func CreateAnObject() { - spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN")) - rsp, err := spaceService.Create(&space.CreateRequest{ - Name: "images/file.jpg", -Object: "", -Visibility: "public", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/stock/README.md b/examples/stock/README.md index 0d497b8..2018b54 100755 --- a/examples/stock/README.md +++ b/examples/stock/README.md @@ -4,6 +4,38 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/stock/api](htt Endpoints: +## OrderBook + +Get the historic order book and each trade by timestamp + + +[https://m3o.com/stock/api#OrderBook](https://m3o.com/stock/api#OrderBook) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/stock" +) + +// Get the historic order book and each trade by timestamp +func OrderBookHistory() { + stockService := stock.NewStockService(os.Getenv("M3O_API_TOKEN")) + rsp, err := stockService.OrderBook(&stock.OrderBookRequest{ + Date: "2020-10-01", +End: "2020-10-01T11:00:00Z", +Limit: 3, +Start: "2020-10-01T10:00:00Z", +Stock: "AAPL", + + }) + fmt.Println(rsp, err) + +} +``` ## Price Get the last price for a given stock ticker @@ -89,35 +121,3 @@ Stock: "AAPL", } ``` -## OrderBook - -Get the historic order book and each trade by timestamp - - -[https://m3o.com/stock/api#OrderBook](https://m3o.com/stock/api#OrderBook) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/stock" -) - -// Get the historic order book and each trade by timestamp -func OrderBookHistory() { - stockService := stock.NewStockService(os.Getenv("M3O_API_TOKEN")) - rsp, err := stockService.OrderBook(&stock.OrderBookRequest{ - Date: "2020-10-01", -End: "2020-10-01T11:00:00Z", -Limit: 3, -Start: "2020-10-01T10:00:00Z", -Stock: "AAPL", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/time/README.md b/examples/time/README.md index 9aad631..c0626b7 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 b65c6ac..19128ad 100755 --- a/examples/twitter/README.md +++ b/examples/twitter/README.md @@ -4,35 +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 @@ -116,3 +87,32 @@ func GetAusersTwitterProfile() { } ``` +## 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/url/README.md b/examples/url/README.md index 551bd38..ec670c0 100755 --- a/examples/url/README.md +++ b/examples/url/README.md @@ -4,33 +4,6 @@ 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 all the shortened URLs @@ -85,3 +58,30 @@ func ShortenAlongUrl() { } ``` +## 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 1aa49c4..3265b1c 100755 --- a/examples/user/README.md +++ b/examples/user/README.md @@ -4,392 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/user/api](http Endpoints: -## VerifyEmail - -Verify the email address of an account from a token sent in an email to the user. - - -[https://m3o.com/user/api#VerifyEmail](https://m3o.com/user/api#VerifyEmail) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/user" -) - -// Verify the email address of an account from a token sent in an email to the user. -func VerifyEmail() { - userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.VerifyEmail(&user.VerifyEmailRequest{ - Token: "012345", - - }) - 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: "df91a612-5b24-4634-99ff-240220ab8f55", - - }) - fmt.Println(rsp, err) - -} -``` -## SendMagicLink - -Login using email only - Passwordless - - -[https://m3o.com/user/api#SendMagicLink](https://m3o.com/user/api#SendMagicLink) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/user" -) - -// Login using email only - Passwordless -func SendAmagicLink() { - userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.SendMagicLink(&user.SendMagicLinkRequest{ - Address: "www.example.com", -Email: "joe@example.com", -Endpoint: "verifytoken", -FromName: "Awesome Dot Com", -Subject: "MagicLink to access your account", -TextContent: `Hi there, - -Click here to access your account $micro_verification_link`, - - }) - 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: "joe+2@example.com", -Id: "user-1", -Username: "joe", - - }) - 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: "Password2", -NewPassword: "Password2", -OldPassword: "Password1", -UserId: "user-1", - - }) - fmt.Println(rsp, err) - -} -``` -## List - -List all users. Returns a paged list of results - - -[https://m3o.com/user/api#List](https://m3o.com/user/api#List) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/user" -) - -// List all users. Returns a paged list of results -func ListAllUsers() { - userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.List(&user.ListRequest{ - Limit: 100, -Offset: 0, - - }) - fmt.Println(rsp, err) - -} -``` -## ResetPassword - -Reset password with the code sent by the "SendPasswordResetEmail" endpoint. - - -[https://m3o.com/user/api#ResetPassword](https://m3o.com/user/api#ResetPassword) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/user" -) - -// Reset password with the code sent by the "SendPasswordResetEmail" endpoint. -func ResetPassword() { - userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.ResetPassword(&user.ResetPasswordRequest{ - Code: "012345", -ConfirmPassword: "NewPassword1", -Email: "joe@example.com", -NewPassword: "NewPassword1", - - }) - 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: "df91a612-5b24-4634-99ff-240220ab8f55", - - }) - 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: "Password1", - - }) - fmt.Println(rsp, err) - -} -``` -## VerifyToken - -Check whether the token attached to MagicLink is valid or not. -Ideally, you need to call this endpoint from your http request -handler that handles the endpoint which is specified in the -SendMagicLink request. - - -[https://m3o.com/user/api#VerifyToken](https://m3o.com/user/api#VerifyToken) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/user" -) - -// Check whether the token attached to MagicLink is valid or not. -// Ideally, you need to call this endpoint from your http request -// handler that handles the endpoint which is specified in the -// SendMagicLink request. -func VerifyAtoken() { - userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.VerifyToken(&user.VerifyTokenRequest{ - Token: "EdsUiidouJJJLldjlloofUiorkojflsWWdld", - - }) - fmt.Println(rsp, err) - -} -``` -## SendVerificationEmail - -Send a verification email to a user. -Email "from" will be 'noreply@email.m3ocontent.com'. -The verification link will be injected in the email -as a template variable, $micro_verification_link e.g -'Welcome to M3O! Use the link below to verify your email: $micro_verification_link' -The variable will be replaced with a url similar to: -'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 a user. -// Email "from" will be 'noreply@email.m3ocontent.com'. -// The verification link will be injected in the email -// as a template variable, $micro_verification_link e.g -// 'Welcome to M3O! Use the link below to verify your email: $micro_verification_link' -// The variable will be replaced with a url similar to: -// '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) - -} -``` -## SendPasswordResetEmail - -Send an email with a verification code to reset password. -Call "ResetPassword" endpoint once user provides the code. - - -[https://m3o.com/user/api#SendPasswordResetEmail](https://m3o.com/user/api#SendPasswordResetEmail) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/user" -) - -// Send an email with a verification code to reset password. -// Call "ResetPassword" endpoint once user provides the code. -func SendPasswordResetEmail() { - userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.SendPasswordResetEmail(&user.SendPasswordResetEmailRequest{ - Email: "joe@example.com", -FromName: "Awesome Dot Com", -Subject: "Password reset", -TextContent: `Hi there, - click here to reset your password: myapp.com/reset/code?=$code`, - - }) - fmt.Println(rsp, err) - -} -``` ## Delete Delete an account by id @@ -447,6 +61,162 @@ Username: "joe", }) 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: "df91a612-5b24-4634-99ff-240220ab8f55", + + }) + fmt.Println(rsp, err) + +} +``` +## List + +List all users. Returns a paged list of results + + +[https://m3o.com/user/api#List](https://m3o.com/user/api#List) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/user" +) + +// List all users. Returns a paged list of results +func ListAllUsers() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.List(&user.ListRequest{ + Limit: 100, +Offset: 0, + + }) + fmt.Println(rsp, err) + +} +``` +## VerifyToken + +Check whether the token attached to MagicLink is valid or not. +Ideally, you need to call this endpoint from your http request +handler that handles the endpoint which is specified in the +SendMagicLink request. + + +[https://m3o.com/user/api#VerifyToken](https://m3o.com/user/api#VerifyToken) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Check whether the token attached to MagicLink is valid or not. +// Ideally, you need to call this endpoint from your http request +// handler that handles the endpoint which is specified in the +// SendMagicLink request. +func VerifyAtoken() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.VerifyToken(&user.VerifyTokenRequest{ + Token: "EdsUiidouJJJLldjlloofUiorkojflsWWdld", + + }) + fmt.Println(rsp, err) + +} +``` +## ResetPassword + +Reset password with the code sent by the "SendPasswordResetEmail" endpoint. + + +[https://m3o.com/user/api#ResetPassword](https://m3o.com/user/api#ResetPassword) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Reset password with the code sent by the "SendPasswordResetEmail" endpoint. +func ResetPassword() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.ResetPassword(&user.ResetPasswordRequest{ + Code: "012345", +ConfirmPassword: "NewPassword1", +Email: "joe@example.com", +NewPassword: "NewPassword1", + + }) + fmt.Println(rsp, err) + +} +``` +## SendPasswordResetEmail + +Send an email with a verification code to reset password. +Call "ResetPassword" endpoint once user provides the code. + + +[https://m3o.com/user/api#SendPasswordResetEmail](https://m3o.com/user/api#SendPasswordResetEmail) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Send an email with a verification code to reset password. +// Call "ResetPassword" endpoint once user provides the code. +func SendPasswordResetEmail() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.SendPasswordResetEmail(&user.SendPasswordResetEmailRequest{ + Email: "joe@example.com", +FromName: "Awesome Dot Com", +Subject: "Password reset", +TextContent: `Hi there, + click here to reset your password: myapp.com/reset/code?=$code`, + + }) + fmt.Println(rsp, err) + } ``` ## Read @@ -533,3 +303,233 @@ func ReadAccountByEmail() { } ``` +## 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: "Password2", +NewPassword: "Password2", +OldPassword: "Password1", +UserId: "user-1", + + }) + fmt.Println(rsp, err) + +} +``` +## SendVerificationEmail + +Send a verification email to a user. +Email "from" will be 'noreply@email.m3ocontent.com'. +The verification link will be injected in the email +as a template variable, $micro_verification_link e.g +'Welcome to M3O! Use the link below to verify your email: $micro_verification_link' +The variable will be replaced with a url similar to: +'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 a user. +// Email "from" will be 'noreply@email.m3ocontent.com'. +// The verification link will be injected in the email +// as a template variable, $micro_verification_link e.g +// 'Welcome to M3O! Use the link below to verify your email: $micro_verification_link' +// The variable will be replaced with a url similar to: +// 'https://user.m3o.com/user/verify?token=a-verification-token&redirectUrl=your-redir-url' +func SendVerificationEmail() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.SendVerificationEmail(&user.SendVerificationEmailRequest{ + Email: "joe@example.com", +FailureRedirectUrl: "https://m3o.com/verification-failed", +FromName: "Awesome Dot Com", +RedirectUrl: "https://m3o.com", +Subject: "Email verification", +TextContent: `Hi there, + +Please verify your email by clicking this link: $micro_verification_link`, + + }) + fmt.Println(rsp, err) + +} +``` +## VerifyEmail + +Verify the email address of an account from a token sent in an email to the user. + + +[https://m3o.com/user/api#VerifyEmail](https://m3o.com/user/api#VerifyEmail) + +```go +package example + +import( + "fmt" + "os" + + "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: "012345", + + }) + 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: "Password1", + + }) + 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: "df91a612-5b24-4634-99ff-240220ab8f55", + + }) + fmt.Println(rsp, err) + +} +``` +## SendMagicLink + +Login using email only - Passwordless + + +[https://m3o.com/user/api#SendMagicLink](https://m3o.com/user/api#SendMagicLink) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Login using email only - Passwordless +func SendAmagicLink() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.SendMagicLink(&user.SendMagicLinkRequest{ + Address: "www.example.com", +Email: "joe@example.com", +Endpoint: "verifytoken", +FromName: "Awesome Dot Com", +Subject: "MagicLink to access your account", +TextContent: `Hi there, + +Click here to access your account $micro_verification_link`, + + }) + 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: "joe+2@example.com", +Id: "user-1", +Username: "joe", + + }) + fmt.Println(rsp, err) + +} +```