diff --git a/examples/app/README.md b/examples/app/README.md index 9cfe535..3c53fd6 100755 --- a/examples/app/README.md +++ b/examples/app/README.md @@ -4,33 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/app/api](https Endpoints: -## Regions - -Return the support regions - - -[https://m3o.com/app/api#Regions](https://m3o.com/app/api#Regions) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/app" -) - -// Return the support regions -func ListRegions() { - appService := app.NewAppService(os.Getenv("M3O_API_TOKEN")) - rsp, err := appService.Regions(&app.RegionsRequest{ - - }) - fmt.Println(rsp, err) - -} -``` ## Status Get the status of an app @@ -230,3 +203,30 @@ Repo: "github.com/asim/helloworld", } ``` +## Regions + +Return the support regions + + +[https://m3o.com/app/api#Regions](https://m3o.com/app/api#Regions) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/app" +) + +// Return the support regions +func ListRegions() { + appService := app.NewAppService(os.Getenv("M3O_API_TOKEN")) + rsp, err := appService.Regions(&app.RegionsRequest{ + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/cache/README.md b/examples/cache/README.md index e2c4a50..359c982 100755 --- a/examples/cache/README.md +++ b/examples/cache/README.md @@ -4,62 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/cache/api](htt Endpoints: -## Decrement - -Decrement a value (if it's a number). If key not found it is equivalent to set. - - -[https://m3o.com/cache/api#Decrement](https://m3o.com/cache/api#Decrement) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/cache" -) - -// Decrement a value (if it's a number). If key not found it is equivalent to set. -func DecrementAvalue() { - cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN")) - rsp, err := cacheService.Decrement(&cache.DecrementRequest{ - Key: "counter", -Value: 2, - - }) - fmt.Println(rsp, err) - -} -``` -## 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 +118,59 @@ Value: 2, } ``` +## Decrement + +Decrement a value (if it's a number). If key not found it is equivalent to set. + + +[https://m3o.com/cache/api#Decrement](https://m3o.com/cache/api#Decrement) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/cache" +) + +// Decrement a value (if it's a number). If key not found it is equivalent to set. +func DecrementAvalue() { + cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN")) + rsp, err := cacheService.Decrement(&cache.DecrementRequest{ + Key: "counter", +Value: 2, + + }) + fmt.Println(rsp, err) + +} +``` +## 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 253362d..1da715f 100755 --- a/examples/chat/README.md +++ b/examples/chat/README.md @@ -4,12 +4,12 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/chat/api](http Endpoints: -## List +## History -List available chats +List the messages in a chat -[https://m3o.com/chat/api#List](https://m3o.com/chat/api#List) +[https://m3o.com/chat/api#History](https://m3o.com/chat/api#History) ```go package example @@ -21,88 +21,16 @@ import( "go.m3o.com/chat" ) -// List available chats -func ListChatRooms() { +// List the messages in a chat +func GetChatHistory() { chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN")) - rsp, err := chatService.List(&chat.ListRequest{ + rsp, err := chatService.History(&chat.HistoryRequest{ }) fmt.Println(rsp, err) } ``` -## Send - -Connect to a chat to receive a stream of messages -Send a message to a chat - - -[https://m3o.com/chat/api#Send](https://m3o.com/chat/api#Send) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/chat" -) - -// Connect to a chat to receive a stream of messages -// Send a message to a chat -func SendAmessage() { - chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN")) - rsp, err := chatService.Send(&chat.SendRequest{ - Client: "web", -Subject: "Random", -Text: "Hey whats up?", - - }) - 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 @@ -211,6 +139,65 @@ func DeleteAchat() { }) fmt.Println(rsp, err) +} +``` +## Send + +Connect to a chat to receive a stream of messages +Send a message to a chat + + +[https://m3o.com/chat/api#Send](https://m3o.com/chat/api#Send) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/chat" +) + +// Connect to a chat to receive a stream of messages +// Send a message to a chat +func SendAmessage() { + chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN")) + rsp, err := chatService.Send(&chat.SendRequest{ + Client: "web", +Subject: "Random", +Text: "Hey whats up?", + + }) + fmt.Println(rsp, err) + +} +``` +## List + +List available chats + + +[https://m3o.com/chat/api#List](https://m3o.com/chat/api#List) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/chat" +) + +// List available chats +func ListChatRooms() { + chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN")) + rsp, err := chatService.List(&chat.ListRequest{ + + }) + fmt.Println(rsp, err) + } ``` ## Invite @@ -240,12 +227,12 @@ func InviteAuser() { } ``` -## History +## Join -List the messages in a chat +Join a chat room -[https://m3o.com/chat/api#History](https://m3o.com/chat/api#History) +[https://m3o.com/chat/api#Join](https://m3o.com/chat/api#Join) ```go package example @@ -257,13 +244,26 @@ import( "go.m3o.com/chat" ) -// List the messages in a chat -func GetChatHistory() { +// Join a chat room +func JoinAroom() { chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN")) - rsp, err := chatService.History(&chat.HistoryRequest{ + + stream, err := chatService.Join(&chat.JoinRequest{ }) - fmt.Println(rsp, err) - + if err != nil { + fmt.Println(err) + return + } + + for { + rsp, err := stream.Recv() + if err != nil { + fmt.Println(err) + return + } + + fmt.Println(rsp) + } } ``` diff --git a/examples/comments/README.md b/examples/comments/README.md index 6e8311b..15be76f 100755 --- a/examples/comments/README.md +++ b/examples/comments/README.md @@ -4,62 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/comments/api]( Endpoints: -## Create - -Create a new comment - - -[https://m3o.com/comments/api#Create](https://m3o.com/comments/api#Create) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/comments" -) - -// Create a new comment -func CreateAcomment() { - commentsService := comments.NewCommentsService(os.Getenv("M3O_API_TOKEN")) - rsp, err := commentsService.Create(&comments.CreateRequest{ - Text: "This is my comment", - - }) - fmt.Println(rsp, err) - -} -``` -## Read - -Read a comment - - -[https://m3o.com/comments/api#Read](https://m3o.com/comments/api#Read) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/comments" -) - -// Read a comment -func ReadAcomment() { - commentsService := comments.NewCommentsService(os.Getenv("M3O_API_TOKEN")) - rsp, err := commentsService.Read(&comments.ReadRequest{ - Id: "63c0cdf8-2121-11ec-a881-0242e36f037a", - - }) - fmt.Println(rsp, err) - -} -``` ## List List all the comments @@ -188,3 +132,59 @@ func SubscribeToEvents() { } } ``` +## Create + +Create a new comment + + +[https://m3o.com/comments/api#Create](https://m3o.com/comments/api#Create) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/comments" +) + +// Create a new comment +func CreateAcomment() { + commentsService := comments.NewCommentsService(os.Getenv("M3O_API_TOKEN")) + rsp, err := commentsService.Create(&comments.CreateRequest{ + Text: "This is my comment", + + }) + fmt.Println(rsp, err) + +} +``` +## Read + +Read a comment + + +[https://m3o.com/comments/api#Read](https://m3o.com/comments/api#Read) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/comments" +) + +// Read a comment +func ReadAcomment() { + commentsService := comments.NewCommentsService(os.Getenv("M3O_API_TOKEN")) + rsp, err := commentsService.Read(&comments.ReadRequest{ + Id: "63c0cdf8-2121-11ec-a881-0242e36f037a", + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/contact/README.md b/examples/contact/README.md index 878f816..07c19b2 100755 --- a/examples/contact/README.md +++ b/examples/contact/README.md @@ -4,6 +4,112 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/contact/api](h Endpoints: +## List + + + + +[https://m3o.com/contact/api#List](https://m3o.com/contact/api#List) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/contact" +) + +// +func ListContactsWithDefaultOffsetAndLimitDefaultLimitIs20() { + contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN")) + rsp, err := contactService.List(&contact.ListRequest{ + + }) + fmt.Println(rsp, err) + +} +``` +## List + + + + +[https://m3o.com/contact/api#List](https://m3o.com/contact/api#List) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/contact" +) + +// +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 + + + + +[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) + +} +``` ## Update @@ -111,109 +217,3 @@ func DeleteAcontact() { } ``` -## List - - - - -[https://m3o.com/contact/api#List](https://m3o.com/contact/api#List) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/contact" -) - -// -func ListContactsWithDefaultOffsetAndLimitDefaultLimitIs20() { - contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN")) - rsp, err := contactService.List(&contact.ListRequest{ - - }) - fmt.Println(rsp, err) - -} -``` -## List - - - - -[https://m3o.com/contact/api#List](https://m3o.com/contact/api#List) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/contact" -) - -// -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 - - - - -[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/crypto/README.md b/examples/crypto/README.md index 4f0aca0..6434fc3 100755 --- a/examples/crypto/README.md +++ b/examples/crypto/README.md @@ -4,62 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/crypto/api](ht Endpoints: -## News - -Get news related to a currency - - -[https://m3o.com/crypto/api#News](https://m3o.com/crypto/api#News) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/crypto" -) - -// Get news related to a currency -func GetCryptocurrencyNews() { - cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN")) - rsp, err := cryptoService.News(&crypto.NewsRequest{ - Symbol: "BTCUSD", - - }) - fmt.Println(rsp, err) - -} -``` -## Price - -Get the last price for a given crypto ticker - - -[https://m3o.com/crypto/api#Price](https://m3o.com/crypto/api#Price) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/crypto" -) - -// Get the last price for a given crypto ticker -func GetCryptocurrencyPrice() { - cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN")) - rsp, err := cryptoService.Price(&crypto.PriceRequest{ - Symbol: "BTCUSD", - - }) - fmt.Println(rsp, err) - -} -``` ## Quote Get the last quote for a given crypto ticker @@ -116,3 +60,59 @@ func GetPreviousClose() { } ``` +## News + +Get news related to a currency + + +[https://m3o.com/crypto/api#News](https://m3o.com/crypto/api#News) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/crypto" +) + +// Get news related to a currency +func GetCryptocurrencyNews() { + cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN")) + rsp, err := cryptoService.News(&crypto.NewsRequest{ + Symbol: "BTCUSD", + + }) + fmt.Println(rsp, err) + +} +``` +## Price + +Get the last price for a given crypto ticker + + +[https://m3o.com/crypto/api#Price](https://m3o.com/crypto/api#Price) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/crypto" +) + +// Get the last price for a given crypto ticker +func GetCryptocurrencyPrice() { + cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN")) + rsp, err := cryptoService.Price(&crypto.PriceRequest{ + Symbol: "BTCUSD", + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/db/README.md b/examples/db/README.md index 0322ed8..4784b94 100755 --- a/examples/db/README.md +++ b/examples/db/README.md @@ -4,6 +4,152 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/db/api](https: Endpoints: +## 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) + +} +``` +## Count + +Count records in a table + + +[https://m3o.com/db/api#Count](https://m3o.com/db/api#Count) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/db" +) + +// Count records in a table +func CountEntriesInAtable() { + dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) + rsp, err := dbService.Count(&db.CountRequest{ + Table: "example", + + }) + 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) + +} +``` +## 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 + +Create a record in the database. Optionally include an "id" field otherwise it's set automatically. + + +[https://m3o.com/db/api#Create](https://m3o.com/db/api#Create) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/db" +) + +// Create a record in the database. Optionally include an "id" field otherwise it's set automatically. +func CreateArecord() { + dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) + rsp, err := dbService.Create(&db.CreateRequest{ + Record: map[string]interface{}{ + "isActive": true, + "id": "1", + "name": "Jane", + "age": 42, +}, +Table: "example", + + }) + fmt.Println(rsp, err) + +} +``` ## Update Update a record in the database. Include an "id" in the record to update. @@ -122,149 +268,3 @@ func TruncateTable() { } ``` -## 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) - -} -``` -## Create - -Create a record in the database. Optionally include an "id" field otherwise it's set automatically. - - -[https://m3o.com/db/api#Create](https://m3o.com/db/api#Create) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/db" -) - -// Create a record in the database. Optionally include an "id" field otherwise it's set automatically. -func CreateArecord() { - dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) - rsp, err := dbService.Create(&db.CreateRequest{ - Record: map[string]interface{}{ - "id": "1", - "name": "Jane", - "age": 42, - "isActive": true, -}, -Table: "example", - - }) - fmt.Println(rsp, err) - -} -``` -## Count - -Count records in a table - - -[https://m3o.com/db/api#Count](https://m3o.com/db/api#Count) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/db" -) - -// Count records in a table -func CountEntriesInAtable() { - dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) - rsp, err := dbService.Count(&db.CountRequest{ - Table: "example", - - }) - 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) - -} -``` -## 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) - -} -``` diff --git a/examples/emoji/README.md b/examples/emoji/README.md index dc735fb..9eb6bad 100755 --- a/examples/emoji/README.md +++ b/examples/emoji/README.md @@ -4,34 +4,6 @@ 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 @@ -89,3 +61,31 @@ 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/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 0833a3e..f34e6b4 100755 --- a/examples/function/README.md +++ b/examples/function/README.md @@ -4,89 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/function/api]( Endpoints: -## 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) - -} -``` -## Delete - -Delete a function by name - - -[https://m3o.com/function/api#Delete](https://m3o.com/function/api#Delete) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/function" -) - -// Delete a function by name -func DeleteAfunction() { - functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) - rsp, err := functionService.Delete(&function.DeleteRequest{ - Name: "helloworld", - - }) - fmt.Println(rsp, err) - -} -``` -## Regions - -Return a list of supported regions - - -[https://m3o.com/function/api#Regions](https://m3o.com/function/api#Regions) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/function" -) - -// Return a list of supported regions -func ListRegions() { - functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) - rsp, err := functionService.Regions(&function.RegionsRequest{ - - }) - fmt.Println(rsp, err) - -} -``` ## Reserve Reserve function names and resources beyond free quota @@ -113,6 +30,34 @@ func ReserveAfunction() { }) 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) + } ``` ## Deploy @@ -147,6 +92,34 @@ 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) + } ``` ## Call @@ -235,12 +208,12 @@ func DescribeFunctionStatus() { } ``` -## Proxy +## Delete -Return the backend url for proxying +Delete a function by name -[https://m3o.com/function/api#Proxy](https://m3o.com/function/api#Proxy) +[https://m3o.com/function/api#Delete](https://m3o.com/function/api#Delete) ```go package example @@ -252,14 +225,41 @@ import( "go.m3o.com/function" ) -// Return the backend url for proxying -func ProxyUrl() { +// Delete a function by name +func DeleteAfunction() { functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) - rsp, err := functionService.Proxy(&function.ProxyRequest{ - Id: "helloworld", + rsp, err := functionService.Delete(&function.DeleteRequest{ + Name: "helloworld", }) fmt.Println(rsp, err) } ``` +## Regions + +Return a list of supported regions + + +[https://m3o.com/function/api#Regions](https://m3o.com/function/api#Regions) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/function" +) + +// Return a list of supported regions +func ListRegions() { + functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) + rsp, err := functionService.Regions(&function.RegionsRequest{ + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/id/README.md b/examples/id/README.md index 8013667..eb26228 100755 --- a/examples/id/README.md +++ b/examples/id/README.md @@ -4,33 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/id/api](https: Endpoints: -## Types - -List the types of IDs available. No query params needed. - - -[https://m3o.com/id/api#Types](https://m3o.com/id/api#Types) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/id" -) - -// List the types of IDs available. No query params needed. -func ListTheTypesOfIdsAvailable() { - idService := id.NewIdService(os.Getenv("M3O_API_TOKEN")) - rsp, err := idService.Types(&id.TypesRequest{ - - }) - fmt.Println(rsp, err) - -} -``` ## Generate Generate a unique ID. Defaults to uuid. @@ -143,3 +116,30 @@ func GenerateAbigflakeId() { } ``` +## Types + +List the types of IDs available. No query params needed. + + +[https://m3o.com/id/api#Types](https://m3o.com/id/api#Types) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/id" +) + +// List the types of IDs available. No query params needed. +func ListTheTypesOfIdsAvailable() { + idService := id.NewIdService(os.Getenv("M3O_API_TOKEN")) + rsp, err := idService.Types(&id.TypesRequest{ + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/image/README.md b/examples/image/README.md index a05edab..f0985e4 100755 --- a/examples/image/README.md +++ b/examples/image/README.md @@ -4,6 +4,76 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/image/api](htt Endpoints: +## Upload + +Upload an image by either sending a base64 encoded image to this endpoint or a URL. +To resize an image before uploading, see the Resize endpoint. +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#Upload](https://m3o.com/image/api#Upload) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/image" +) + +// Upload an image by either sending a base64 encoded image to this endpoint or a URL. +// To resize an image before uploading, see the Resize endpoint. +// 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 UploadAbase64imageToMicrosCdn() { + imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN")) + rsp, err := imageService.Upload(&image.UploadRequest{ + Base64: "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAx0lEQVR4nOzaMaoDMQyE4ZHj+x82vVdhwQoTkzKQEcwP5r0ihT7sbjUTeAJ4HCegXQJYfOYefOyjDuBiz3yjwJBoCIl6QZOeUjTC1Ix1IxEJXF9+0KWsf2bD4bn37OO/c/wuQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9Sa/NG94Tf3j4WBdaxudMEkn4IM2rZBA0wBrvo7aOcpj2emXvLeVt0IGm0GVXUj91mvAAAA//+V2CZl+4AKXwAAAABJRU5ErkJggg==", +Name: "cat.jpeg", + + }) + fmt.Println(rsp, err) + +} +``` +## Upload + +Upload an image by either sending a base64 encoded image to this endpoint or a URL. +To resize an image before uploading, see the Resize endpoint. +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#Upload](https://m3o.com/image/api#Upload) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/image" +) + +// Upload an image by either sending a base64 encoded image to this endpoint or a URL. +// To resize an image before uploading, see the Resize endpoint. +// 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 UploadAnImageFromAurlToMicrosCdn() { + imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN")) + rsp, err := imageService.Upload(&image.UploadRequest{ + Name: "cat.jpeg", +Url: "somewebsite.com/cat.png", + + }) + fmt.Println(rsp, err) + +} +``` ## Delete Delete an image previously uploaded. @@ -186,73 +256,3 @@ Url: "somewebsite.com/cat.png", } ``` -## Upload - -Upload an image by either sending a base64 encoded image to this endpoint or a URL. -To resize an image before uploading, see the Resize endpoint. -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#Upload](https://m3o.com/image/api#Upload) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/image" -) - -// Upload an image by either sending a base64 encoded image to this endpoint or a URL. -// To resize an image before uploading, see the Resize endpoint. -// 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 UploadAbase64imageToMicrosCdn() { - imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN")) - rsp, err := imageService.Upload(&image.UploadRequest{ - Base64: "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAx0lEQVR4nOzaMaoDMQyE4ZHj+x82vVdhwQoTkzKQEcwP5r0ihT7sbjUTeAJ4HCegXQJYfOYefOyjDuBiz3yjwJBoCIl6QZOeUjTC1Ix1IxEJXF9+0KWsf2bD4bn37OO/c/wuQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9Sa/NG94Tf3j4WBdaxudMEkn4IM2rZBA0wBrvo7aOcpj2emXvLeVt0IGm0GVXUj91mvAAAA//+V2CZl+4AKXwAAAABJRU5ErkJggg==", -Name: "cat.jpeg", - - }) - fmt.Println(rsp, err) - -} -``` -## Upload - -Upload an image by either sending a base64 encoded image to this endpoint or a URL. -To resize an image before uploading, see the Resize endpoint. -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#Upload](https://m3o.com/image/api#Upload) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/image" -) - -// Upload an image by either sending a base64 encoded image to this endpoint or a URL. -// To resize an image before uploading, see the Resize endpoint. -// 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 UploadAnImageFromAurlToMicrosCdn() { - imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN")) - rsp, err := imageService.Upload(&image.UploadRequest{ - Name: "cat.jpeg", -Url: "somewebsite.com/cat.png", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/mq/README.md b/examples/mq/README.md index 1582975..8f18a93 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 e6a7451..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{}{ + "id": "1", "type": "signup", "user": "john", - "id": "1", }, Topic: "events", }) diff --git a/examples/notes/README.md b/examples/notes/README.md index 6d6064b..3bc665d 100755 --- a/examples/notes/README.md +++ b/examples/notes/README.md @@ -4,33 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/notes/api](htt Endpoints: -## 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 @@ -189,3 +162,30 @@ func ReadAnote() { } ``` +## 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/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/quran/README.md b/examples/quran/README.md index 7381cb5..ec04685 100755 --- a/examples/quran/README.md +++ b/examples/quran/README.md @@ -4,62 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/quran/api](htt Endpoints: -## Chapters - -List the Chapters (surahs) of the Quran - - -[https://m3o.com/quran/api#Chapters](https://m3o.com/quran/api#Chapters) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/quran" -) - -// List the Chapters (surahs) of the Quran -func ListChapters() { - quranService := quran.NewQuranService(os.Getenv("M3O_API_TOKEN")) - rsp, err := quranService.Chapters(&quran.ChaptersRequest{ - Language: "en", - - }) - fmt.Println(rsp, err) - -} -``` -## Summary - -Get a summary for a given chapter (surah) - - -[https://m3o.com/quran/api#Summary](https://m3o.com/quran/api#Summary) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/quran" -) - -// Get a summary for a given chapter (surah) -func GetChapterSummary() { - quranService := quran.NewQuranService(os.Getenv("M3O_API_TOKEN")) - rsp, err := quranService.Summary(&quran.SummaryRequest{ - Chapter: 1, - - }) - fmt.Println(rsp, err) - -} -``` ## Verses Lookup the verses (ayahs) for a chapter including @@ -120,3 +64,59 @@ func SearchTheQuran() { } ``` +## Chapters + +List the Chapters (surahs) of the Quran + + +[https://m3o.com/quran/api#Chapters](https://m3o.com/quran/api#Chapters) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/quran" +) + +// List the Chapters (surahs) of the Quran +func ListChapters() { + quranService := quran.NewQuranService(os.Getenv("M3O_API_TOKEN")) + rsp, err := quranService.Chapters(&quran.ChaptersRequest{ + Language: "en", + + }) + fmt.Println(rsp, err) + +} +``` +## Summary + +Get a summary for a given chapter (surah) + + +[https://m3o.com/quran/api#Summary](https://m3o.com/quran/api#Summary) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/quran" +) + +// Get a summary for a given chapter (surah) +func GetChapterSummary() { + quranService := quran.NewQuranService(os.Getenv("M3O_API_TOKEN")) + rsp, err := quranService.Summary(&quran.SummaryRequest{ + Chapter: 1, + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/space/README.md b/examples/space/README.md index caa0bf5..f8dd335 100755 --- a/examples/space/README.md +++ b/examples/space/README.md @@ -4,64 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/space/api](htt Endpoints: -## Upload - -Upload a large object (> 10MB). Returns a time limited presigned URL to be used for uploading the object - - -[https://m3o.com/space/api#Upload](https://m3o.com/space/api#Upload) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/space" -) - -// Upload a large object (> 10MB). Returns a time limited presigned URL to be used for uploading the object -func UploadAnObject() { - spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN")) - rsp, err := spaceService.Upload(&space.UploadRequest{ - Name: "images/file.jpg", - - }) - fmt.Println(rsp, err) - -} -``` -## 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. @@ -232,3 +174,61 @@ func DownloadAnObject() { } ``` +## Upload + +Upload a large object (> 10MB). Returns a time limited presigned URL to be used for uploading the object + + +[https://m3o.com/space/api#Upload](https://m3o.com/space/api#Upload) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/space" +) + +// Upload a large object (> 10MB). Returns a time limited presigned URL to be used for uploading the object +func UploadAnObject() { + spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN")) + rsp, err := spaceService.Upload(&space.UploadRequest{ + Name: "images/file.jpg", + + }) + fmt.Println(rsp, err) + +} +``` +## 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 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/url/README.md b/examples/url/README.md index ec670c0..24bd71a 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: -## List - -List all the shortened URLs - - -[https://m3o.com/url/api#List](https://m3o.com/url/api#List) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/url" -) - -// List all the shortened URLs -func ListYourShortenedUrls() { - urlService := url.NewUrlService(os.Getenv("M3O_API_TOKEN")) - rsp, err := urlService.List(&url.ListRequest{ - - }) - fmt.Println(rsp, err) - -} -``` ## Shorten Shorten a long URL @@ -85,3 +58,30 @@ func ResolveAshortUrlToAlongDestinationUrl() { } ``` +## List + +List all the shortened URLs + + +[https://m3o.com/url/api#List](https://m3o.com/url/api#List) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/url" +) + +// List all the shortened URLs +func ListYourShortenedUrls() { + urlService := url.NewUrlService(os.Getenv("M3O_API_TOKEN")) + rsp, err := urlService.List(&url.ListRequest{ + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/user/README.md b/examples/user/README.md index d6951fb..16e8bc9 100755 --- a/examples/user/README.md +++ b/examples/user/README.md @@ -4,12 +4,12 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/user/api](http Endpoints: -## SendMagicLink +## Update -Login using email only - Passwordless +Update the account username or email -[https://m3o.com/user/api#SendMagicLink](https://m3o.com/user/api#SendMagicLink) +[https://m3o.com/user/api#Update](https://m3o.com/user/api#Update) ```go package example @@ -21,18 +21,44 @@ import( "go.m3o.com/user" ) -// Login using email only - Passwordless -func SendAmagicLink() { +// Update the account username or email +func UpdateAnAccount() { 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, + rsp, err := userService.Update(&user.UpdateRequest{ + Email: "joe+2@example.com", +Id: "user-1", +Username: "joe", -Click here to access your account $micro_verification_link`, + }) + 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) @@ -93,116 +119,6 @@ func ReadAsessionByTheSessionId() { }) 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) - -} -``` -## 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) - } ``` ## Login @@ -236,12 +152,12 @@ Password: "Password1", } ``` -## ResetPassword +## SendMagicLink -Reset password with the code sent by the "SendPasswordResetEmail" endpoint. +Login using email only - Passwordless -[https://m3o.com/user/api#ResetPassword](https://m3o.com/user/api#ResetPassword) +[https://m3o.com/user/api#SendMagicLink](https://m3o.com/user/api#SendMagicLink) ```go package example @@ -253,14 +169,18 @@ import( "go.m3o.com/user" ) -// Reset password with the code sent by the "SendPasswordResetEmail" endpoint. -func ResetPassword() { +// Login using email only - Passwordless +func SendAmagicLink() { userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.ResetPassword(&user.ResetPasswordRequest{ - Code: "012345", -ConfirmPassword: "NewPassword1", + rsp, err := userService.SendMagicLink(&user.SendMagicLinkRequest{ + Address: "www.example.com", Email: "joe@example.com", -NewPassword: "NewPassword1", +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) @@ -327,6 +247,137 @@ 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) + +} +``` +## Read + +Read an account by id, username or email. Only one need to be specified. + + +[https://m3o.com/user/api#Read](https://m3o.com/user/api#Read) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Read an account by id, username or email. Only one need to be specified. +func ReadAnAccountById() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.Read(&user.ReadRequest{ + Id: "user-1", + + }) + fmt.Println(rsp, err) + +} +``` +## Read + +Read an account by id, username or email. Only one need to be specified. + + +[https://m3o.com/user/api#Read](https://m3o.com/user/api#Read) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Read an account by id, username or email. Only one need to be specified. +func ReadAccountByUsernameOrEmail() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.Read(&user.ReadRequest{ + Username: "joe", + + }) + fmt.Println(rsp, err) + +} +``` +## Read + +Read an account by id, username or email. Only one need to be specified. + + +[https://m3o.com/user/api#Read](https://m3o.com/user/api#Read) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Read an account by id, username or email. Only one need to be specified. +func ReadAccountByEmail() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.Read(&user.ReadRequest{ + Email: "joe@example.com", + + }) + fmt.Println(rsp, err) + } ``` ## SendPasswordResetEmail @@ -419,12 +470,12 @@ func DeleteUserAccount() { } ``` -## Update +## List -Update the account username or email +List all users. Returns a paged list of results -[https://m3o.com/user/api#Update](https://m3o.com/user/api#Update) +[https://m3o.com/user/api#List](https://m3o.com/user/api#List) ```go package example @@ -436,25 +487,27 @@ import( "go.m3o.com/user" ) -// Update the account username or email -func UpdateAnAccount() { +// List all users. Returns a paged list of results +func ListAllUsers() { userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.Update(&user.UpdateRequest{ - Email: "joe+2@example.com", -Id: "user-1", -Username: "joe", + rsp, err := userService.List(&user.ListRequest{ + Limit: 100, +Offset: 0, }) fmt.Println(rsp, err) } ``` -## Read +## VerifyToken -Read an account by id, username or email. Only one need to be specified. +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#Read](https://m3o.com/user/api#Read) +[https://m3o.com/user/api#VerifyToken](https://m3o.com/user/api#VerifyToken) ```go package example @@ -466,67 +519,14 @@ import( "go.m3o.com/user" ) -// Read an account by id, username or email. Only one need to be specified. -func ReadAnAccountById() { +// 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.Read(&user.ReadRequest{ - Id: "user-1", - - }) - fmt.Println(rsp, err) - -} -``` -## Read - -Read an account by id, username or email. Only one need to be specified. - - -[https://m3o.com/user/api#Read](https://m3o.com/user/api#Read) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/user" -) - -// Read an account by id, username or email. Only one need to be specified. -func ReadAccountByUsernameOrEmail() { - userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.Read(&user.ReadRequest{ - Username: "joe", - - }) - fmt.Println(rsp, err) - -} -``` -## Read - -Read an account by id, username or email. Only one need to be specified. - - -[https://m3o.com/user/api#Read](https://m3o.com/user/api#Read) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/user" -) - -// Read an account by id, username or email. Only one need to be specified. -func ReadAccountByEmail() { - userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.Read(&user.ReadRequest{ - Email: "joe@example.com", + rsp, err := userService.VerifyToken(&user.VerifyTokenRequest{ + Token: "EdsUiidouJJJLldjlloofUiorkojflsWWdld", }) fmt.Println(rsp, err) diff --git a/examples/weather/README.md b/examples/weather/README.md index 4fa715b..43c5660 100755 --- a/examples/weather/README.md +++ b/examples/weather/README.md @@ -4,34 +4,6 @@ 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 @@ -61,3 +33,31 @@ 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) + +} +```