From bb0db592beb191f2d816695067e1683bb101a354 Mon Sep 17 00:00:00 2001 From: m3o-actions <> Date: Wed, 2 Mar 2022 17:02:33 +0000 Subject: [PATCH] Commit from m3o/m3o action --- examples/app/README.md | 56 +-- examples/cache/README.md | 54 +-- examples/chat/README.md | 296 ++++++------ examples/contact/README.md | 112 ++--- examples/crypto/README.md | 56 +-- examples/currency/README.md | 118 ++--- examples/db/README.md | 108 ++--- examples/email/README.md | 56 +-- examples/file/README.md | 116 ++--- examples/forex/README.md | 56 +-- examples/function/README.md | 320 ++++++------- examples/helloworld/README.md | 56 +-- examples/lists/README.md | 164 +++---- examples/mq/README.md | 2 +- examples/mq/publish/publishAMessage/main.go | 2 +- examples/notes/README.md | 140 +++--- examples/postcode/README.md | 56 +-- examples/search/README.md | 114 ++--- examples/space/README.md | 112 ++--- examples/stock/README.md | 58 +-- examples/sunnah/README.md | 118 ++--- examples/time/README.md | 54 +-- examples/twitter/README.md | 110 ++--- examples/user/README.md | 480 ++++++++++---------- examples/weather/README.md | 56 +-- 25 files changed, 1435 insertions(+), 1435 deletions(-) diff --git a/examples/app/README.md b/examples/app/README.md index 655d7f8..3692e03 100755 --- a/examples/app/README.md +++ b/examples/app/README.md @@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/app/api](https Endpoints: -## 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 @@ -230,3 +202,31 @@ func ResolveAppById() { } ``` +## 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 b6e7759..359c982 100755 --- a/examples/cache/README.md +++ b/examples/cache/README.md @@ -4,33 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/cache/api](htt Endpoints: -## ListKeys - -List all the available keys - - -[https://m3o.com/cache/api#ListKeys](https://m3o.com/cache/api#ListKeys) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/cache" -) - -// List all the available keys -func ListTheKeys() { - cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN")) - rsp, err := cacheService.ListKeys(&cache.ListKeysRequest{ - - }) - fmt.Println(rsp, err) - -} -``` ## Set Set an item in the cache. Overwrites any existing value already set. @@ -174,3 +147,30 @@ Value: 2, } ``` +## ListKeys + +List all the available keys + + +[https://m3o.com/cache/api#ListKeys](https://m3o.com/cache/api#ListKeys) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/cache" +) + +// List all the available keys +func ListTheKeys() { + cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN")) + rsp, err := cacheService.ListKeys(&cache.ListKeysRequest{ + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/chat/README.md b/examples/chat/README.md index 20e8b85..04ed29d 100755 --- a/examples/chat/README.md +++ b/examples/chat/README.md @@ -4,6 +4,154 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/chat/api](http Endpoints: +## 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) + } +} +``` +## Kick + +Kick a user from a chat room + + +[https://m3o.com/chat/api#Kick](https://m3o.com/chat/api#Kick) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/chat" +) + +// Kick a user from a chat room +func KickAuserFromAroom() { + chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN")) + rsp, err := chatService.Kick(&chat.KickRequest{ + + }) + fmt.Println(rsp, err) + +} +``` +## Leave + +Leave a chat room + + +[https://m3o.com/chat/api#Leave](https://m3o.com/chat/api#Leave) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/chat" +) + +// Leave a chat room +func LeaveAroom() { + chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN")) + rsp, err := chatService.Leave(&chat.LeaveRequest{ + + }) + fmt.Println(rsp, err) + +} +``` ## Create Create a new chat room @@ -58,33 +206,6 @@ func ListChatRooms() { }) fmt.Println(rsp, err) -} -``` -## 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) - } ``` ## Invite @@ -146,124 +267,3 @@ Text: "Hey whats up?", } ``` -## 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) - } -} -``` -## Leave - -Leave a chat room - - -[https://m3o.com/chat/api#Leave](https://m3o.com/chat/api#Leave) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/chat" -) - -// Leave a chat room -func LeaveAroom() { - chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN")) - rsp, err := chatService.Leave(&chat.LeaveRequest{ - - }) - 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) - -} -``` -## Kick - -Kick a user from a chat room - - -[https://m3o.com/chat/api#Kick](https://m3o.com/chat/api#Kick) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/chat" -) - -// Kick a user from a chat room -func KickAuserFromAroom() { - chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN")) - rsp, err := chatService.Kick(&chat.KickRequest{ - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/contact/README.md b/examples/contact/README.md index e2e01cc..6fedb2a 100755 --- a/examples/contact/README.md +++ b/examples/contact/README.md @@ -4,6 +4,62 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/contact/api](h Endpoints: +## List + +List contacts + + +[https://m3o.com/contact/api#List](https://m3o.com/contact/api#List) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/contact" +) + +// List contacts +func ListContactsWithDefaultOffsetAndLimitDefaultLimitIs20() { + contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN")) + rsp, err := contactService.List(&contact.ListRequest{ + + }) + fmt.Println(rsp, err) + +} +``` +## List + +List contacts + + +[https://m3o.com/contact/api#List](https://m3o.com/contact/api#List) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/contact" +) + +// List contacts +func ListContactsWithSpecificOffsetAndLimit() { + contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN")) + rsp, err := contactService.List(&contact.ListRequest{ + Limit: 1, +Offset: 1, + + }) + fmt.Println(rsp, err) + +} +``` ## Create Create a contact @@ -161,59 +217,3 @@ func DeleteAcontact() { } ``` -## List - -List contacts - - -[https://m3o.com/contact/api#List](https://m3o.com/contact/api#List) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/contact" -) - -// List contacts -func ListContactsWithDefaultOffsetAndLimitDefaultLimitIs20() { - contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN")) - rsp, err := contactService.List(&contact.ListRequest{ - - }) - fmt.Println(rsp, err) - -} -``` -## List - -List contacts - - -[https://m3o.com/contact/api#List](https://m3o.com/contact/api#List) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/contact" -) - -// List contacts -func ListContactsWithSpecificOffsetAndLimit() { - contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN")) - rsp, err := contactService.List(&contact.ListRequest{ - Limit: 1, -Offset: 1, - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/crypto/README.md b/examples/crypto/README.md index 8a2e169..7517ee7 100755 --- a/examples/crypto/README.md +++ b/examples/crypto/README.md @@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/crypto/api](ht Endpoints: +## History + +Returns the history for the previous close + + +[https://m3o.com/crypto/api#History](https://m3o.com/crypto/api#History) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/crypto" +) + +// Returns the history for the previous close +func GetPreviousClose() { + cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN")) + rsp, err := cryptoService.History(&crypto.HistoryRequest{ + Symbol: "BTCUSD", + + }) + fmt.Println(rsp, err) + +} +``` ## Symbols Returns the full list of supported symbols @@ -115,31 +143,3 @@ func GetAcryptocurrencyQuote() { } ``` -## History - -Returns the history for the previous close - - -[https://m3o.com/crypto/api#History](https://m3o.com/crypto/api#History) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/crypto" -) - -// Returns the history for the previous close -func GetPreviousClose() { - cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN")) - rsp, err := cryptoService.History(&crypto.HistoryRequest{ - Symbol: "BTCUSD", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/currency/README.md b/examples/currency/README.md index 208ce2d..e112f11 100755 --- a/examples/currency/README.md +++ b/examples/currency/README.md @@ -4,65 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/currency/api]( Endpoints: -## Convert - -Convert returns the currency conversion rate between two pairs e.g USD/GBP - - -[https://m3o.com/currency/api#Convert](https://m3o.com/currency/api#Convert) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/currency" -) - -// Convert returns the currency conversion rate between two pairs e.g USD/GBP -func ConvertUsdToGbp() { - currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN")) - rsp, err := currencyService.Convert(¤cy.ConvertRequest{ - From: "USD", -To: "GBP", - - }) - fmt.Println(rsp, err) - -} -``` -## Convert - -Convert returns the currency conversion rate between two pairs e.g USD/GBP - - -[https://m3o.com/currency/api#Convert](https://m3o.com/currency/api#Convert) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/currency" -) - -// Convert returns the currency conversion rate between two pairs e.g USD/GBP -func Convert10usdToGbp() { - currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN")) - rsp, err := currencyService.Convert(¤cy.ConvertRequest{ - Amount: 10, -From: "USD", -To: "GBP", - - }) - fmt.Println(rsp, err) - -} -``` ## History Returns the historic rates for a currency on a given date @@ -147,3 +88,62 @@ func GetRatesForUsd() { } ``` +## Convert + +Convert returns the currency conversion rate between two pairs e.g USD/GBP + + +[https://m3o.com/currency/api#Convert](https://m3o.com/currency/api#Convert) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/currency" +) + +// Convert returns the currency conversion rate between two pairs e.g USD/GBP +func ConvertUsdToGbp() { + currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN")) + rsp, err := currencyService.Convert(¤cy.ConvertRequest{ + From: "USD", +To: "GBP", + + }) + fmt.Println(rsp, err) + +} +``` +## Convert + +Convert returns the currency conversion rate between two pairs e.g USD/GBP + + +[https://m3o.com/currency/api#Convert](https://m3o.com/currency/api#Convert) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/currency" +) + +// Convert returns the currency conversion rate between two pairs e.g USD/GBP +func Convert10usdToGbp() { + currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN")) + rsp, err := currencyService.Convert(¤cy.ConvertRequest{ + Amount: 10, +From: "USD", +To: "GBP", + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/db/README.md b/examples/db/README.md index 960f282..e692e28 100755 --- a/examples/db/README.md +++ b/examples/db/README.md @@ -4,12 +4,12 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/db/api](https: Endpoints: -## DropTable +## RenameTable -Drop a table in the DB +Rename a table -[https://m3o.com/db/api#DropTable](https://m3o.com/db/api#DropTable) +[https://m3o.com/db/api#RenameTable](https://m3o.com/db/api#RenameTable) ```go package example @@ -21,42 +21,16 @@ import( "go.m3o.com/db" ) -// Drop a table in the DB -func DropTable() { +// Rename a table +func RenameTable() { dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) - rsp, err := dbService.DropTable(&db.DropTableRequest{ - Table: "example", + rsp, err := dbService.RenameTable(&db.RenameTableRequest{ + From: "examples2", +To: "examples3", }) fmt.Println(rsp, err) -} -``` -## ListTables - -List tables in the DB - - -[https://m3o.com/db/api#ListTables](https://m3o.com/db/api#ListTables) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/db" -) - -// List tables in the DB -func ListTables() { - dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) - rsp, err := dbService.ListTables(&db.ListTablesRequest{ - - }) - fmt.Println(rsp, err) - } ``` ## Delete @@ -88,12 +62,12 @@ Table: "example", } ``` -## Update +## DropTable -Update a record in the database. Include an "id" in the record to update. +Drop a table in the DB -[https://m3o.com/db/api#Update](https://m3o.com/db/api#Update) +[https://m3o.com/db/api#DropTable](https://m3o.com/db/api#DropTable) ```go package example @@ -105,15 +79,11 @@ import( "go.m3o.com/db" ) -// Update a record in the database. Include an "id" in the record to update. -func UpdateArecord() { +// Drop a table in the DB +func DropTable() { dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) - rsp, err := dbService.Update(&db.UpdateRequest{ - Record: map[string]interface{}{ - "id": "1", - "age": 43, -}, -Table: "example", + rsp, err := dbService.DropTable(&db.DropTableRequest{ + Table: "example", }) fmt.Println(rsp, err) @@ -205,12 +175,12 @@ func CountEntriesInAtable() { } ``` -## RenameTable +## ListTables -Rename a table +List tables in the DB -[https://m3o.com/db/api#RenameTable](https://m3o.com/db/api#RenameTable) +[https://m3o.com/db/api#ListTables](https://m3o.com/db/api#ListTables) ```go package example @@ -222,13 +192,11 @@ import( "go.m3o.com/db" ) -// Rename a table -func RenameTable() { +// List tables in the DB +func ListTables() { dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) - rsp, err := dbService.RenameTable(&db.RenameTableRequest{ - From: "examples2", -To: "examples3", - + rsp, err := dbService.ListTables(&db.ListTablesRequest{ + }) fmt.Println(rsp, err) @@ -268,3 +236,35 @@ Table: "example", } ``` +## 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{}{ + "age": 43, + "id": "1", +}, +Table: "example", + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/email/README.md b/examples/email/README.md index b04ca45..8e6afcf 100755 --- a/examples/email/README.md +++ b/examples/email/README.md @@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/email/api](htt Endpoints: -## Validate - -Validate an email address format - - -[https://m3o.com/email/api#Validate](https://m3o.com/email/api#Validate) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/email" -) - -// Validate an email address format -func ValidateEmail() { - emailService := email.NewEmailService(os.Getenv("M3O_API_TOKEN")) - rsp, err := emailService.Validate(&email.ValidateRequest{ - Address: "joe@example.com", - - }) - fmt.Println(rsp, err) - -} -``` ## Send Send an email by passing in from, to, subject, and a text or html body @@ -92,3 +64,31 @@ func ParseEmail() { } ``` +## Validate + +Validate an email address format + + +[https://m3o.com/email/api#Validate](https://m3o.com/email/api#Validate) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/email" +) + +// Validate an email address format +func ValidateEmail() { + emailService := email.NewEmailService(os.Getenv("M3O_API_TOKEN")) + rsp, err := emailService.Validate(&email.ValidateRequest{ + Address: "joe@example.com", + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/file/README.md b/examples/file/README.md index bd236f7..40962ee 100755 --- a/examples/file/README.md +++ b/examples/file/README.md @@ -4,6 +4,64 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/file/api](http Endpoints: +## Read + +Read a file by path + + +[https://m3o.com/file/api#Read](https://m3o.com/file/api#Read) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/file" +) + +// Read a file by path +func ReadFile() { + fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN")) + rsp, err := fileService.Read(&file.ReadRequest{ + Path: "/document/text-files/file.txt", +Project: "examples", + + }) + fmt.Println(rsp, err) + +} +``` +## Delete + +Delete a file by project name/path + + +[https://m3o.com/file/api#Delete](https://m3o.com/file/api#Delete) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/file" +) + +// Delete a file by project name/path +func DeleteFile() { + fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN")) + rsp, err := fileService.Delete(&file.DeleteRequest{ + Path: "/document/text-files/file.txt", +Project: "examples", + + }) + fmt.Println(rsp, err) + +} +``` ## Save Save a file @@ -64,61 +122,3 @@ func ListFiles() { } ``` -## Read - -Read a file by path - - -[https://m3o.com/file/api#Read](https://m3o.com/file/api#Read) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/file" -) - -// Read a file by path -func ReadFile() { - fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN")) - rsp, err := fileService.Read(&file.ReadRequest{ - Path: "/document/text-files/file.txt", -Project: "examples", - - }) - fmt.Println(rsp, err) - -} -``` -## Delete - -Delete a file by project name/path - - -[https://m3o.com/file/api#Delete](https://m3o.com/file/api#Delete) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/file" -) - -// Delete a file by project name/path -func DeleteFile() { - fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN")) - rsp, err := fileService.Delete(&file.DeleteRequest{ - Path: "/document/text-files/file.txt", -Project: "examples", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/forex/README.md b/examples/forex/README.md index a91003f..358f510 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: +## History + +Returns the data for the previous close + + +[https://m3o.com/forex/api#History](https://m3o.com/forex/api#History) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/forex" +) + +// Returns the data for the previous close +func GetPreviousClose() { + forexService := forex.NewForexService(os.Getenv("M3O_API_TOKEN")) + rsp, err := forexService.History(&forex.HistoryRequest{ + Symbol: "GBPUSD", + + }) + fmt.Println(rsp, err) + +} +``` ## Price Get the latest price for a given forex ticker @@ -60,31 +88,3 @@ func GetAfxQuote() { } ``` -## History - -Returns the data for the previous close - - -[https://m3o.com/forex/api#History](https://m3o.com/forex/api#History) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/forex" -) - -// Returns the data for the previous close -func GetPreviousClose() { - forexService := forex.NewForexService(os.Getenv("M3O_API_TOKEN")) - rsp, err := forexService.History(&forex.HistoryRequest{ - Symbol: "GBPUSD", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/function/README.md b/examples/function/README.md index 6654e4f..e75e51c 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: -## Call +## Regions -Call a function by name +Return a list of supported regions -[https://m3o.com/function/api#Call](https://m3o.com/function/api#Call) +[https://m3o.com/function/api#Regions](https://m3o.com/function/api#Regions) ```go package example @@ -21,15 +21,100 @@ import( "go.m3o.com/function" ) -// Call a function by name -func CallAfunction() { +// Return a list of supported regions +func ListRegions() { functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) - rsp, err := functionService.Call(&function.CallRequest{ - Name: "helloworld", -Request: map[string]interface{}{ - "name": "Alice", -}, + rsp, err := functionService.Regions(&function.RegionsRequest{ + + }) + fmt.Println(rsp, err) + +} +``` +## Reserve +Reserve function names and resources beyond free quota + + +[https://m3o.com/function/api#Reserve](https://m3o.com/function/api#Reserve) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/function" +) + +// Reserve function names and resources beyond free quota +func ReserveAfunction() { + functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) + rsp, err := functionService.Reserve(&function.ReserveRequest{ + Name: "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) + +} +``` +## List + +List all the deployed functions + + +[https://m3o.com/function/api#List](https://m3o.com/function/api#List) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/function" +) + +// List all the deployed functions +func ListFunctions() { + functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) + rsp, err := functionService.List(&function.ListRequest{ + }) fmt.Println(rsp, err) @@ -91,12 +176,12 @@ func DescribeFunctionStatus() { } ``` -## Regions +## Update -Return a list of supported regions +Update a function. Downloads the source, builds and redeploys -[https://m3o.com/function/api#Regions](https://m3o.com/function/api#Regions) +[https://m3o.com/function/api#Update](https://m3o.com/function/api#Update) ```go package example @@ -108,10 +193,69 @@ import( "go.m3o.com/function" ) -// Return a list of supported regions -func ListRegions() { +// Update a function. Downloads the source, builds and redeploys +func UpdateAfunction() { functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) - rsp, err := functionService.Regions(&function.RegionsRequest{ + rsp, err := functionService.Update(&function.UpdateRequest{ + Name: "helloworld", + + }) + fmt.Println(rsp, err) + +} +``` +## Call + +Call a function by name + + +[https://m3o.com/function/api#Call](https://m3o.com/function/api#Call) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/function" +) + +// Call a function by name +func CallAfunction() { + functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) + rsp, err := functionService.Call(&function.CallRequest{ + Name: "helloworld", +Request: map[string]interface{}{ + "name": "Alice", +}, + + }) + fmt.Println(rsp, err) + +} +``` +## Runtimes + +Return a list of supported runtimes + + +[https://m3o.com/function/api#Runtimes](https://m3o.com/function/api#Runtimes) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/function" +) + +// Return a list of supported runtimes +func ListRuntimes() { + functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) + rsp, err := functionService.Runtimes(&function.RuntimesRequest{ }) fmt.Println(rsp, err) @@ -146,147 +290,3 @@ func ProxyUrl() { } ``` -## 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{ - Name: "helloworld", - - }) - fmt.Println(rsp, err) - -} -``` -## List - -List all the deployed functions - - -[https://m3o.com/function/api#List](https://m3o.com/function/api#List) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/function" -) - -// List all the deployed functions -func ListFunctions() { - functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) - rsp, err := functionService.List(&function.ListRequest{ - - }) - fmt.Println(rsp, err) - -} -``` -## Reserve - -Reserve function names and resources beyond free quota - - -[https://m3o.com/function/api#Reserve](https://m3o.com/function/api#Reserve) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/function" -) - -// Reserve function names and resources beyond free quota -func ReserveAfunction() { - functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) - rsp, err := functionService.Reserve(&function.ReserveRequest{ - Name: "helloworld", - - }) - fmt.Println(rsp, err) - -} -``` -## Runtimes - -Return a list of supported runtimes - - -[https://m3o.com/function/api#Runtimes](https://m3o.com/function/api#Runtimes) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/function" -) - -// Return a list of supported runtimes -func ListRuntimes() { - functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) - rsp, err := functionService.Runtimes(&function.RuntimesRequest{ - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/helloworld/README.md b/examples/helloworld/README.md index 3a2b163..687820b 100755 --- a/examples/helloworld/README.md +++ b/examples/helloworld/README.md @@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/helloworld/api Endpoints: +## Call + +Call returns a personalised "Hello $name" response + + +[https://m3o.com/helloworld/api#Call](https://m3o.com/helloworld/api#Call) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/helloworld" +) + +// Call returns a personalised "Hello $name" response +func CallHelloworld() { + helloworldService := helloworld.NewHelloworldService(os.Getenv("M3O_API_TOKEN")) + rsp, err := helloworldService.Call(&helloworld.CallRequest{ + Name: "John", + + }) + fmt.Println(rsp, err) + +} +``` ## Stream Stream returns a stream of "Hello $name" responses @@ -46,31 +74,3 @@ Name: "John", } } ``` -## Call - -Call returns a personalised "Hello $name" response - - -[https://m3o.com/helloworld/api#Call](https://m3o.com/helloworld/api#Call) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/helloworld" -) - -// Call returns a personalised "Hello $name" response -func CallHelloworld() { - helloworldService := helloworld.NewHelloworldService(os.Getenv("M3O_API_TOKEN")) - rsp, err := helloworldService.Call(&helloworld.CallRequest{ - Name: "John", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/lists/README.md b/examples/lists/README.md index 100345a..7fe9884 100755 --- a/examples/lists/README.md +++ b/examples/lists/README.md @@ -4,6 +4,88 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/lists/api](htt Endpoints: +## Create + +Create a new list + + +[https://m3o.com/lists/api#Create](https://m3o.com/lists/api#Create) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/lists" +) + +// Create a new list +func CreateAlist() { + listsService := lists.NewListsService(os.Getenv("M3O_API_TOKEN")) + rsp, err := listsService.Create(&lists.CreateRequest{ + + }) + fmt.Println(rsp, err) + +} +``` +## Read + +Read a list + + +[https://m3o.com/lists/api#Read](https://m3o.com/lists/api#Read) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/lists" +) + +// Read a list +func ReadAlist() { + listsService := lists.NewListsService(os.Getenv("M3O_API_TOKEN")) + rsp, err := listsService.Read(&lists.ReadRequest{ + Id: "63c0cdf8-2121-11ec-a881-0242e36f037a", + + }) + fmt.Println(rsp, err) + +} +``` +## List + +List all the lists + + +[https://m3o.com/lists/api#List](https://m3o.com/lists/api#List) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/lists" +) + +// List all the lists +func ListAllLists() { + listsService := lists.NewListsService(os.Getenv("M3O_API_TOKEN")) + rsp, err := listsService.List(&lists.ListRequest{ + + }) + fmt.Println(rsp, err) + +} +``` ## Update Update a list @@ -103,85 +185,3 @@ func SubscribeToEvents() { } } ``` -## Create - -Create a new list - - -[https://m3o.com/lists/api#Create](https://m3o.com/lists/api#Create) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/lists" -) - -// Create a new list -func CreateAlist() { - listsService := lists.NewListsService(os.Getenv("M3O_API_TOKEN")) - rsp, err := listsService.Create(&lists.CreateRequest{ - - }) - fmt.Println(rsp, err) - -} -``` -## Read - -Read a list - - -[https://m3o.com/lists/api#Read](https://m3o.com/lists/api#Read) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/lists" -) - -// Read a list -func ReadAlist() { - listsService := lists.NewListsService(os.Getenv("M3O_API_TOKEN")) - rsp, err := listsService.Read(&lists.ReadRequest{ - Id: "63c0cdf8-2121-11ec-a881-0242e36f037a", - - }) - fmt.Println(rsp, err) - -} -``` -## List - -List all the lists - - -[https://m3o.com/lists/api#List](https://m3o.com/lists/api#List) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/lists" -) - -// List all the lists -func ListAllLists() { - listsService := lists.NewListsService(os.Getenv("M3O_API_TOKEN")) - rsp, err := listsService.List(&lists.ListRequest{ - - }) - 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/mq/publish/publishAMessage/main.go b/examples/mq/publish/publishAMessage/main.go index fe21c56..ad993e2 100755 --- a/examples/mq/publish/publishAMessage/main.go +++ b/examples/mq/publish/publishAMessage/main.go @@ -12,9 +12,9 @@ func main() { mqService := mq.NewMqService(os.Getenv("M3O_API_TOKEN")) rsp, err := mqService.Publish(&mq.PublishRequest{ Message: map[string]interface{}{ - "user": "john", "id": "1", "type": "signup", + "user": "john", }, Topic: "events", }) diff --git a/examples/notes/README.md b/examples/notes/README.md index 6997879..272c2eb 100755 --- a/examples/notes/README.md +++ b/examples/notes/README.md @@ -4,76 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/notes/api](htt Endpoints: -## Events - -Subscribe to notes events - - -[https://m3o.com/notes/api#Events](https://m3o.com/notes/api#Events) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/notes" -) - -// Subscribe to notes events -func SubscribeToEvents() { - notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN")) - - stream, err := notesService.Events(¬es.EventsRequest{ - Id: "63c0cdf8-2121-11ec-a881-0242e36f037a", - - }) - if err != nil { - fmt.Println(err) - return - } - - for { - rsp, err := stream.Recv() - if err != nil { - fmt.Println(err) - return - } - - fmt.Println(rsp) - } -} -``` -## 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 @@ -189,3 +119,73 @@ func DeleteAnote() { } ``` +## Events + +Subscribe to notes events + + +[https://m3o.com/notes/api#Events](https://m3o.com/notes/api#Events) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/notes" +) + +// Subscribe to notes events +func SubscribeToEvents() { + notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN")) + + stream, err := notesService.Events(¬es.EventsRequest{ + Id: "63c0cdf8-2121-11ec-a881-0242e36f037a", + + }) + if err != nil { + fmt.Println(err) + return + } + + for { + rsp, err := stream.Recv() + if err != nil { + fmt.Println(err) + return + } + + fmt.Println(rsp) + } +} +``` +## 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/postcode/README.md b/examples/postcode/README.md index a497f9c..ee2ea3c 100755 --- a/examples/postcode/README.md +++ b/examples/postcode/README.md @@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/postcode/api]( Endpoints: +## Validate + +Validate a postcode. + + +[https://m3o.com/postcode/api#Validate](https://m3o.com/postcode/api#Validate) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/postcode" +) + +// Validate a postcode. +func ReturnArandomPostcodeAndItsInformation() { + postcodeService := postcode.NewPostcodeService(os.Getenv("M3O_API_TOKEN")) + rsp, err := postcodeService.Validate(&postcode.ValidateRequest{ + Postcode: "SW1A 2AA", + + }) + fmt.Println(rsp, err) + +} +``` ## Lookup Lookup a postcode to retrieve the related region, county, etc @@ -59,31 +87,3 @@ func ReturnArandomPostcodeAndItsInformation() { } ``` -## Validate - -Validate a postcode. - - -[https://m3o.com/postcode/api#Validate](https://m3o.com/postcode/api#Validate) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/postcode" -) - -// Validate a postcode. -func ReturnArandomPostcodeAndItsInformation() { - postcodeService := postcode.NewPostcodeService(os.Getenv("M3O_API_TOKEN")) - rsp, err := postcodeService.Validate(&postcode.ValidateRequest{ - Postcode: "SW1A 2AA", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/search/README.md b/examples/search/README.md index 470b27a..3fc5086 100755 --- a/examples/search/README.md +++ b/examples/search/README.md @@ -4,62 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/search/api](ht Endpoints: -## CreateIndex - -Create an index by name - - -[https://m3o.com/search/api#CreateIndex](https://m3o.com/search/api#CreateIndex) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/search" -) - -// Create an index by name -func CreateAnIndex() { - searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN")) - rsp, err := searchService.CreateIndex(&search.CreateIndexRequest{ - Index: "customers", - - }) - fmt.Println(rsp, err) - -} -``` -## DeleteIndex - -Delete an index by name - - -[https://m3o.com/search/api#DeleteIndex](https://m3o.com/search/api#DeleteIndex) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/search" -) - -// Delete an index by name -func DeleteAnIndex() { - searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN")) - rsp, err := searchService.DeleteIndex(&search.DeleteIndexRequest{ - Index: "customers", - - }) - fmt.Println(rsp, err) - -} -``` ## Index Index a record i.e. insert a document to search for. @@ -82,9 +26,9 @@ func IndexArecord() { 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", @@ -209,3 +153,59 @@ Index: "customers", } ``` +## CreateIndex + +Create an index by name + + +[https://m3o.com/search/api#CreateIndex](https://m3o.com/search/api#CreateIndex) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/search" +) + +// Create an index by name +func CreateAnIndex() { + searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN")) + rsp, err := searchService.CreateIndex(&search.CreateIndexRequest{ + Index: "customers", + + }) + fmt.Println(rsp, err) + +} +``` +## DeleteIndex + +Delete an index by name + + +[https://m3o.com/search/api#DeleteIndex](https://m3o.com/search/api#DeleteIndex) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/search" +) + +// Delete an index by name +func DeleteAnIndex() { + searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN")) + rsp, err := searchService.DeleteIndex(&search.DeleteIndexRequest{ + Index: "customers", + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/space/README.md b/examples/space/README.md index e0dac00..d40b142 100755 --- a/examples/space/README.md +++ b/examples/space/README.md @@ -4,6 +4,62 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/space/api](htt Endpoints: +## List + +List the objects in space + + +[https://m3o.com/space/api#List](https://m3o.com/space/api#List) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/space" +) + +// List the objects in space +func ListObjectsWithPrefix() { + spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN")) + rsp, err := spaceService.List(&space.ListRequest{ + Prefix: "images/", + + }) + fmt.Println(rsp, err) + +} +``` +## Head + +Retrieve meta information about an object + + +[https://m3o.com/space/api#Head](https://m3o.com/space/api#Head) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/space" +) + +// Retrieve meta information about an object +func HeadAnObject() { + spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN")) + rsp, err := spaceService.Head(&space.HeadRequest{ + Name: "images/file.jpg", + + }) + fmt.Println(rsp, err) + +} +``` ## Read Read an object in space @@ -176,59 +232,3 @@ func DeleteAnObject() { } ``` -## List - -List the objects in space - - -[https://m3o.com/space/api#List](https://m3o.com/space/api#List) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/space" -) - -// List the objects in space -func ListObjectsWithPrefix() { - spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN")) - rsp, err := spaceService.List(&space.ListRequest{ - Prefix: "images/", - - }) - fmt.Println(rsp, err) - -} -``` -## Head - -Retrieve meta information about an object - - -[https://m3o.com/space/api#Head](https://m3o.com/space/api#Head) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/space" -) - -// Retrieve meta information about an object -func HeadAnObject() { - spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN")) - rsp, err := spaceService.Head(&space.HeadRequest{ - Name: "images/file.jpg", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/stock/README.md b/examples/stock/README.md index 2018b54..83cd80a 100755 --- a/examples/stock/README.md +++ b/examples/stock/README.md @@ -4,6 +4,35 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/stock/api](htt Endpoints: +## History + +Get the historic open-close for a given day + + +[https://m3o.com/stock/api#History](https://m3o.com/stock/api#History) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/stock" +) + +// Get the historic open-close for a given day +func GetHistoricData() { + stockService := stock.NewStockService(os.Getenv("M3O_API_TOKEN")) + rsp, err := stockService.History(&stock.HistoryRequest{ + Date: "2020-10-01", +Stock: "AAPL", + + }) + fmt.Println(rsp, err) + +} +``` ## OrderBook Get the historic order book and each trade by timestamp @@ -92,32 +121,3 @@ func GetAstockQuote() { } ``` -## History - -Get the historic open-close for a given day - - -[https://m3o.com/stock/api#History](https://m3o.com/stock/api#History) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/stock" -) - -// Get the historic open-close for a given day -func GetHistoricData() { - stockService := stock.NewStockService(os.Getenv("M3O_API_TOKEN")) - rsp, err := stockService.History(&stock.HistoryRequest{ - Date: "2020-10-01", -Stock: "AAPL", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/sunnah/README.md b/examples/sunnah/README.md index 6036ae5..d2d603b 100755 --- a/examples/sunnah/README.md +++ b/examples/sunnah/README.md @@ -4,6 +4,65 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/sunnah/api](ht Endpoints: +## Collections + +Get a list of available collections. A collection is +a compilation of hadiths collected and written by an author. + + +[https://m3o.com/sunnah/api#Collections](https://m3o.com/sunnah/api#Collections) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/sunnah" +) + +// Get a list of available collections. A collection is +// a compilation of hadiths collected and written by an author. +func ListAvailableCollections() { + sunnahService := sunnah.NewSunnahService(os.Getenv("M3O_API_TOKEN")) + rsp, err := sunnahService.Collections(&sunnah.CollectionsRequest{ + + }) + fmt.Println(rsp, err) + +} +``` +## Books + +Get a list of books from within a collection. A book can contain many chapters +each with its own hadiths. + + +[https://m3o.com/sunnah/api#Books](https://m3o.com/sunnah/api#Books) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/sunnah" +) + +// Get a list of books from within a collection. A book can contain many chapters +// each with its own hadiths. +func GetTheBooksWithinAcollection() { + sunnahService := sunnah.NewSunnahService(os.Getenv("M3O_API_TOKEN")) + rsp, err := sunnahService.Books(&sunnah.BooksRequest{ + Collection: "bukhari", + + }) + fmt.Println(rsp, err) + +} +``` ## Chapters Get all the chapters of a given book within a collection. @@ -64,62 +123,3 @@ Collection: "bukhari", } ``` -## Collections - -Get a list of available collections. A collection is -a compilation of hadiths collected and written by an author. - - -[https://m3o.com/sunnah/api#Collections](https://m3o.com/sunnah/api#Collections) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/sunnah" -) - -// Get a list of available collections. A collection is -// a compilation of hadiths collected and written by an author. -func ListAvailableCollections() { - sunnahService := sunnah.NewSunnahService(os.Getenv("M3O_API_TOKEN")) - rsp, err := sunnahService.Collections(&sunnah.CollectionsRequest{ - - }) - fmt.Println(rsp, err) - -} -``` -## Books - -Get a list of books from within a collection. A book can contain many chapters -each with its own hadiths. - - -[https://m3o.com/sunnah/api#Books](https://m3o.com/sunnah/api#Books) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/sunnah" -) - -// Get a list of books from within a collection. A book can contain many chapters -// each with its own hadiths. -func GetTheBooksWithinAcollection() { - sunnahService := sunnah.NewSunnahService(os.Getenv("M3O_API_TOKEN")) - rsp, err := sunnahService.Books(&sunnah.BooksRequest{ - Collection: "bukhari", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/time/README.md b/examples/time/README.md index c0626b7..9aad631 100755 --- a/examples/time/README.md +++ b/examples/time/README.md @@ -4,6 +4,33 @@ 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 @@ -32,30 +59,3 @@ 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..ef25975 100755 --- a/examples/twitter/README.md +++ b/examples/twitter/README.md @@ -4,6 +4,61 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/twitter/api](h Endpoints: +## Trends + +Get the current global trending topics + + +[https://m3o.com/twitter/api#Trends](https://m3o.com/twitter/api#Trends) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/twitter" +) + +// Get the current global trending topics +func GetTheCurrentGlobalTrendingTopics() { + twitterService := twitter.NewTwitterService(os.Getenv("M3O_API_TOKEN")) + rsp, err := twitterService.Trends(&twitter.TrendsRequest{ + + }) + fmt.Println(rsp, err) + +} +``` +## User + +Get a user's twitter profile + + +[https://m3o.com/twitter/api#User](https://m3o.com/twitter/api#User) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/twitter" +) + +// Get a user's twitter profile +func GetAusersTwitterProfile() { + twitterService := twitter.NewTwitterService(os.Getenv("M3O_API_TOKEN")) + rsp, err := twitterService.User(&twitter.UserRequest{ + Username: "crufter", + + }) + fmt.Println(rsp, err) + +} +``` ## Timeline Get the timeline for a given user @@ -61,58 +116,3 @@ func SearchForTweets() { } ``` -## Trends - -Get the current global trending topics - - -[https://m3o.com/twitter/api#Trends](https://m3o.com/twitter/api#Trends) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/twitter" -) - -// Get the current global trending topics -func GetTheCurrentGlobalTrendingTopics() { - twitterService := twitter.NewTwitterService(os.Getenv("M3O_API_TOKEN")) - rsp, err := twitterService.Trends(&twitter.TrendsRequest{ - - }) - fmt.Println(rsp, err) - -} -``` -## User - -Get a user's twitter profile - - -[https://m3o.com/twitter/api#User](https://m3o.com/twitter/api#User) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/twitter" -) - -// Get a user's twitter profile -func GetAusersTwitterProfile() { - twitterService := twitter.NewTwitterService(os.Getenv("M3O_API_TOKEN")) - rsp, err := twitterService.User(&twitter.UserRequest{ - Username: "crufter", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/user/README.md b/examples/user/README.md index 24118c4..ef2988e 100755 --- a/examples/user/README.md +++ b/examples/user/README.md @@ -32,37 +32,6 @@ 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) - } ``` ## Read @@ -147,6 +116,215 @@ func ReadAccountByEmail() { }) 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) + +} +``` +## 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: "8b98acbe-0b6a-4d66-a414-5ffbf666786f", + + }) + 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) + +} +``` +## 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) + +} +``` +## 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) + +} +``` +## 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 @@ -194,6 +372,37 @@ Please verify your email by clicking this link: $micro_verification_link`, }) fmt.Println(rsp, err) +} +``` +## Login + +Login using username or email. The response will return a new session for successful login, +401 in the case of login failure and 500 for any other error + + +[https://m3o.com/user/api#Login](https://m3o.com/user/api#Login) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Login using username or email. The response will return a new session for successful login, +// 401 in the case of login failure and 500 for any other error +func LogAuserIn() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.Login(&user.LoginRequest{ + Email: "joe@example.com", +Password: "Password1", + + }) + fmt.Println(rsp, err) + } ``` ## List @@ -288,215 +497,6 @@ Username: "joe", }) 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) - -} -``` -## 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) - -} -``` -## 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) - -} -``` -## 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) - -} -``` -## 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: "8b98acbe-0b6a-4d66-a414-5ffbf666786f", - - }) - 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) - } ``` ## SendPasswordResetEmail diff --git a/examples/weather/README.md b/examples/weather/README.md index 43c5660..4fa715b 100755 --- a/examples/weather/README.md +++ b/examples/weather/README.md @@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/weather/api](h Endpoints: +## Now + +Get the current weather report for a location by postcode, city, zip code, ip address + + +[https://m3o.com/weather/api#Now](https://m3o.com/weather/api#Now) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/weather" +) + +// Get the current weather report for a location by postcode, city, zip code, ip address +func GetCurrentWeather() { + weatherService := weather.NewWeatherService(os.Getenv("M3O_API_TOKEN")) + rsp, err := weatherService.Now(&weather.NowRequest{ + Location: "london", + + }) + fmt.Println(rsp, err) + +} +``` ## Forecast Get the weather forecast for the next 1-10 days @@ -33,31 +61,3 @@ Location: "London", } ``` -## Now - -Get the current weather report for a location by postcode, city, zip code, ip address - - -[https://m3o.com/weather/api#Now](https://m3o.com/weather/api#Now) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/weather" -) - -// Get the current weather report for a location by postcode, city, zip code, ip address -func GetCurrentWeather() { - weatherService := weather.NewWeatherService(os.Getenv("M3O_API_TOKEN")) - rsp, err := weatherService.Now(&weather.NowRequest{ - Location: "london", - - }) - fmt.Println(rsp, err) - -} -```