diff --git a/examples/app/README.md b/examples/app/README.md index 3c53fd6..9cfe535 100755 --- a/examples/app/README.md +++ b/examples/app/README.md @@ -4,6 +4,33 @@ 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 @@ -203,30 +230,3 @@ 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 359c982..b6e7759 100755 --- a/examples/cache/README.md +++ b/examples/cache/README.md @@ -4,6 +4,33 @@ 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. @@ -147,30 +174,3 @@ 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 060808e..9a16ca8 100755 --- a/examples/chat/README.md +++ b/examples/chat/README.md @@ -4,6 +4,38 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/chat/api](http Endpoints: +## 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 @@ -44,33 +76,6 @@ func JoinAroom() { } } ``` -## 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 @@ -96,6 +101,114 @@ func LeaveAroom() { }) 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 + +Invite a user to a chat room + + +[https://m3o.com/chat/api#Invite](https://m3o.com/chat/api#Invite) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/chat" +) + +// Invite a user to a chat room +func InviteAuser() { + chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN")) + rsp, err := chatService.Invite(&chat.InviteRequest{ + + }) + 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) + } ``` ## Create @@ -125,33 +238,6 @@ Name: "general", }) 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) - } ``` ## Delete @@ -181,89 +267,3 @@ func DeleteAchat() { } ``` -## 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) - -} -``` -## Invite - -Invite a user to a chat room - - -[https://m3o.com/chat/api#Invite](https://m3o.com/chat/api#Invite) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/chat" -) - -// Invite a user to a chat room -func InviteAuser() { - chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN")) - rsp, err := chatService.Invite(&chat.InviteRequest{ - - }) - 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) - -} -``` diff --git a/examples/comments/README.md b/examples/comments/README.md index bae93e5..6e8311b 100755 --- a/examples/comments/README.md +++ b/examples/comments/README.md @@ -4,47 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/comments/api]( Endpoints: -## Events - -Subscribe to comments events - - -[https://m3o.com/comments/api#Events](https://m3o.com/comments/api#Events) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/comments" -) - -// Subscribe to comments events -func SubscribeToEvents() { - commentsService := comments.NewCommentsService(os.Getenv("M3O_API_TOKEN")) - - stream, err := commentsService.Events(&comments.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 comment @@ -188,3 +147,44 @@ func DeleteAcomment() { } ``` +## Events + +Subscribe to comments events + + +[https://m3o.com/comments/api#Events](https://m3o.com/comments/api#Events) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/comments" +) + +// Subscribe to comments events +func SubscribeToEvents() { + commentsService := comments.NewCommentsService(os.Getenv("M3O_API_TOKEN")) + + stream, err := commentsService.Events(&comments.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) + } +} +``` diff --git a/examples/crypto/README.md b/examples/crypto/README.md index 8a2e169..d9bae9e 100755 --- a/examples/crypto/README.md +++ b/examples/crypto/README.md @@ -4,33 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/crypto/api](ht Endpoints: -## Symbols - -Returns the full list of supported symbols - - -[https://m3o.com/crypto/api#Symbols](https://m3o.com/crypto/api#Symbols) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/crypto" -) - -// Returns the full list of supported symbols -func GetListOfAllSupportedSymbols() { - cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN")) - rsp, err := cryptoService.Symbols(&crypto.SymbolsRequest{ - - }) - fmt.Println(rsp, err) - -} -``` ## News Get news related to a currency @@ -143,3 +116,30 @@ func GetPreviousClose() { } ``` +## Symbols + +Returns the full list of supported symbols + + +[https://m3o.com/crypto/api#Symbols](https://m3o.com/crypto/api#Symbols) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/crypto" +) + +// Returns the full list of supported symbols +func GetListOfAllSupportedSymbols() { + cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN")) + rsp, err := cryptoService.Symbols(&crypto.SymbolsRequest{ + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/currency/README.md b/examples/currency/README.md index 208ce2d..333170f 100755 --- a/examples/currency/README.md +++ b/examples/currency/README.md @@ -4,6 +4,61 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/currency/api]( Endpoints: +## Codes + +Codes returns the supported currency codes for the API + + +[https://m3o.com/currency/api#Codes](https://m3o.com/currency/api#Codes) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/currency" +) + +// Codes returns the supported currency codes for the API +func GetSupportedCodes() { + currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN")) + rsp, err := currencyService.Codes(¤cy.CodesRequest{ + + }) + fmt.Println(rsp, err) + +} +``` +## Rates + +Rates returns the currency rates for a given code e.g USD + + +[https://m3o.com/currency/api#Rates](https://m3o.com/currency/api#Rates) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/currency" +) + +// Rates returns the currency rates for a given code e.g USD +func GetRatesForUsd() { + currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN")) + rsp, err := currencyService.Rates(¤cy.RatesRequest{ + Code: "USD", + + }) + fmt.Println(rsp, err) + +} +``` ## Convert Convert returns the currency conversion rate between two pairs e.g USD/GBP @@ -92,58 +147,3 @@ Date: "2021-05-30", } ``` -## Codes - -Codes returns the supported currency codes for the API - - -[https://m3o.com/currency/api#Codes](https://m3o.com/currency/api#Codes) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/currency" -) - -// Codes returns the supported currency codes for the API -func GetSupportedCodes() { - currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN")) - rsp, err := currencyService.Codes(¤cy.CodesRequest{ - - }) - fmt.Println(rsp, err) - -} -``` -## Rates - -Rates returns the currency rates for a given code e.g USD - - -[https://m3o.com/currency/api#Rates](https://m3o.com/currency/api#Rates) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/currency" -) - -// Rates returns the currency rates for a given code e.g USD -func GetRatesForUsd() { - currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN")) - rsp, err := currencyService.Rates(¤cy.RatesRequest{ - Code: "USD", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/db/README.md b/examples/db/README.md index 017ffe9..8adfd3e 100755 --- a/examples/db/README.md +++ b/examples/db/README.md @@ -4,63 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/db/api](https: Endpoints: -## 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) - -} -``` -## 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. @@ -83,42 +26,10 @@ 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, - "isActive": true, -}, -Table: "example", - - }) - fmt.Println(rsp, err) - -} -``` -## Update - -Update a record in the database. Include an "id" in the record to update. - - -[https://m3o.com/db/api#Update](https://m3o.com/db/api#Update) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/db" -) - -// Update a record in the database. Include an "id" in the record to update. -func UpdateArecord() { - dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) - rsp, err := dbService.Update(&db.UpdateRequest{ - Record: map[string]interface{}{ - "id": "1", - "age": 43, }, Table: "example", @@ -208,6 +119,67 @@ func ListTables() { }) fmt.Println(rsp, err) +} +``` +## RenameTable + +Rename a table + + +[https://m3o.com/db/api#RenameTable](https://m3o.com/db/api#RenameTable) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/db" +) + +// Rename a table +func RenameTable() { + dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) + rsp, err := dbService.RenameTable(&db.RenameTableRequest{ + From: "examples2", +To: "examples3", + + }) + fmt.Println(rsp, err) + +} +``` +## Update + +Update a record in the database. Include an "id" in the record to update. + + +[https://m3o.com/db/api#Update](https://m3o.com/db/api#Update) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/db" +) + +// Update a record in the database. Include an "id" in the record to update. +func UpdateArecord() { + dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) + rsp, err := dbService.Update(&db.UpdateRequest{ + Record: map[string]interface{}{ + "id": "1", + "age": 43, +}, +Table: "example", + + }) + fmt.Println(rsp, err) + } ``` ## Read @@ -268,3 +240,31 @@ Table: "example", } ``` +## 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) + +} +``` diff --git a/examples/db/create/createARecord/main.go b/examples/db/create/createARecord/main.go index f258334..f7b3a81 100755 --- a/examples/db/create/createARecord/main.go +++ b/examples/db/create/createARecord/main.go @@ -12,10 +12,10 @@ func main() { dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) rsp, err := dbService.Create(&db.CreateRequest{ Record: map[string]interface{}{ - "id": "1", "name": "Jane", "age": 42, "isActive": true, + "id": "1", }, Table: "example", }) diff --git a/examples/emoji/README.md b/examples/emoji/README.md index e461cd8..dc735fb 100755 --- a/examples/emoji/README.md +++ b/examples/emoji/README.md @@ -4,36 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/emoji/api](htt Endpoints: -## Print - -Print text and renders the emojis with aliases e.g -let's grab a :beer: becomes let's grab a 🍺 - - -[https://m3o.com/emoji/api#Print](https://m3o.com/emoji/api#Print) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/emoji" -) - -// Print text and renders the emojis with aliases e.g -// let's grab a :beer: becomes let's grab a 🍺 -func PrintTextIncludingEmoji() { - emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN")) - rsp, err := emojiService.Print(&emoji.PrintRequest{ - Text: "let's grab a :beer:", - - }) - fmt.Println(rsp, err) - -} -``` ## Find Find an emoji by its alias e.g :beer: @@ -89,3 +59,33 @@ func GetFlagByCountryCode() { } ``` +## Print + +Print text and renders the emojis with aliases e.g +let's grab a :beer: becomes let's grab a 🍺 + + +[https://m3o.com/emoji/api#Print](https://m3o.com/emoji/api#Print) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/emoji" +) + +// Print text and renders the emojis with aliases e.g +// let's grab a :beer: becomes let's grab a 🍺 +func PrintTextIncludingEmoji() { + emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN")) + rsp, err := emojiService.Print(&emoji.PrintRequest{ + Text: "let's grab a :beer:", + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/event/README.md b/examples/event/README.md index 4b265ff..fc81ead 100755 --- a/examples/event/README.md +++ b/examples/event/README.md @@ -4,6 +4,39 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/event/api](htt Endpoints: +## Publish + +Publish a event to the event stream. + + +[https://m3o.com/event/api#Publish](https://m3o.com/event/api#Publish) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/event" +) + +// Publish a event to the event stream. +func PublishAnEvent() { + eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN")) + rsp, err := eventService.Publish(&event.PublishRequest{ + Message: map[string]interface{}{ + "type": "signup", + "user": "john", + "id": "1", +}, +Topic: "user", + + }) + fmt.Println(rsp, err) + +} +``` ## Consume Consume events from a given topic. @@ -73,36 +106,3 @@ func ReadEventsOnAtopic() { } ``` -## Publish - -Publish a event to the event stream. - - -[https://m3o.com/event/api#Publish](https://m3o.com/event/api#Publish) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/event" -) - -// Publish a event to the event stream. -func PublishAnEvent() { - eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN")) - rsp, err := eventService.Publish(&event.PublishRequest{ - Message: map[string]interface{}{ - "user": "john", - "id": "1", - "type": "signup", -}, -Topic: "user", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/event/publish/publishAnEvent/main.go b/examples/event/publish/publishAnEvent/main.go index 287af64..5c63360 100755 --- a/examples/event/publish/publishAnEvent/main.go +++ b/examples/event/publish/publishAnEvent/main.go @@ -12,9 +12,9 @@ func main() { eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN")) rsp, err := eventService.Publish(&event.PublishRequest{ Message: map[string]interface{}{ - "id": "1", "type": "signup", "user": "john", + "id": "1", }, Topic: "user", }) diff --git a/examples/file/README.md b/examples/file/README.md index a8b61c5..40962ee 100755 --- a/examples/file/README.md +++ b/examples/file/README.md @@ -4,6 +4,35 @@ 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 @@ -93,32 +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) - -} -``` diff --git a/examples/function/README.md b/examples/function/README.md index 30c9476..ad3bc14 100755 --- a/examples/function/README.md +++ b/examples/function/README.md @@ -4,6 +4,33 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/function/api]( Endpoints: +## 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) + +} +``` ## Proxy Return the backend url for proxying @@ -30,171 +57,6 @@ func ProxyUrl() { }) 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 - - -[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) - -} -``` -## 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) - -} -``` -## Describe - -Get the info for a deployed function - - -[https://m3o.com/function/api#Describe](https://m3o.com/function/api#Describe) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/function" -) - -// Get the info for a deployed function -func DescribeFunctionStatus() { - functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) - rsp, err := functionService.Describe(&function.DescribeRequest{ - Name: "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) - } ``` ## Deploy @@ -290,3 +152,141 @@ Request: map[string]interface{}{ } ``` +## 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) + +} +``` +## Describe + +Get the info for a deployed function + + +[https://m3o.com/function/api#Describe](https://m3o.com/function/api#Describe) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/function" +) + +// Get the info for a deployed function +func DescribeFunctionStatus() { + functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) + rsp, err := functionService.Describe(&function.DescribeRequest{ + Name: "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) + +} +``` +## 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) + +} +``` diff --git a/examples/image/README.md b/examples/image/README.md index f0985e4..6b5b4b5 100755 --- a/examples/image/README.md +++ b/examples/image/README.md @@ -4,104 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/image/api](htt Endpoints: -## Upload - -Upload an image by either sending a base64 encoded image to this endpoint or a URL. -To resize an image before uploading, see the Resize endpoint. -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. - - -[https://m3o.com/image/api#Delete](https://m3o.com/image/api#Delete) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/image" -) - -// Delete an image previously uploaded. -func DeleteAnUploadedImage() { - imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN")) - rsp, err := imageService.Delete(&image.DeleteRequest{ - Url: "https://cdn.m3ocontent.com/micro/images/micro/41e23b39-48dd-42b6-9738-79a313414bb8/cat.png", - - }) - fmt.Println(rsp, err) - -} -``` ## Resize Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters. @@ -256,3 +158,101 @@ 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) + +} +``` +## Delete + +Delete an image previously uploaded. + + +[https://m3o.com/image/api#Delete](https://m3o.com/image/api#Delete) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/image" +) + +// Delete an image previously uploaded. +func DeleteAnUploadedImage() { + imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN")) + rsp, err := imageService.Delete(&image.DeleteRequest{ + Url: "https://cdn.m3ocontent.com/micro/images/micro/41e23b39-48dd-42b6-9738-79a313414bb8/cat.png", + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/lists/README.md b/examples/lists/README.md index 7fe9884..da20dd4 100755 --- a/examples/lists/README.md +++ b/examples/lists/README.md @@ -4,6 +4,47 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/lists/api](htt Endpoints: +## Events + +Subscribe to lists events + + +[https://m3o.com/lists/api#Events](https://m3o.com/lists/api#Events) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/lists" +) + +// Subscribe to lists events +func SubscribeToEvents() { + listsService := lists.NewListsService(os.Getenv("M3O_API_TOKEN")) + + stream, err := listsService.Events(&lists.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 list @@ -144,44 +185,3 @@ func DeleteAlist() { } ``` -## Events - -Subscribe to lists events - - -[https://m3o.com/lists/api#Events](https://m3o.com/lists/api#Events) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/lists" -) - -// Subscribe to lists events -func SubscribeToEvents() { - listsService := lists.NewListsService(os.Getenv("M3O_API_TOKEN")) - - stream, err := listsService.Events(&lists.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) - } -} -``` diff --git a/examples/nft/README.md b/examples/nft/README.md index 3f32ff7..6f7c583 100755 --- a/examples/nft/README.md +++ b/examples/nft/README.md @@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/nft/api](https Endpoints: +## Collection + + + + +[https://m3o.com/nft/api#Collection](https://m3o.com/nft/api#Collection) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/nft" +) + +// +func GetAsingleCollection() { + nftService := nft.NewNftService(os.Getenv("M3O_API_TOKEN")) + rsp, err := nftService.Collection(&nft.CollectionRequest{ + Slug: "doodles-official", + + }) + fmt.Println(rsp, err) + +} +``` ## Assets Return a list of assets @@ -116,31 +144,3 @@ func GetAsingleAsset() { } ``` -## Collection - - - - -[https://m3o.com/nft/api#Collection](https://m3o.com/nft/api#Collection) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/nft" -) - -// -func GetAsingleCollection() { - nftService := nft.NewNftService(os.Getenv("M3O_API_TOKEN")) - rsp, err := nftService.Collection(&nft.CollectionRequest{ - Slug: "doodles-official", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/otp/README.md b/examples/otp/README.md index c585537..421d43d 100755 --- a/examples/otp/README.md +++ b/examples/otp/README.md @@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/otp/api](https Endpoints: -## Generate - -Generate an OTP (one time pass) code - - -[https://m3o.com/otp/api#Generate](https://m3o.com/otp/api#Generate) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/otp" -) - -// Generate an OTP (one time pass) code -func GenerateOtp() { - otpService := otp.NewOtpService(os.Getenv("M3O_API_TOKEN")) - rsp, err := otpService.Generate(&otp.GenerateRequest{ - Id: "asim@example.com", - - }) - fmt.Println(rsp, err) - -} -``` ## Validate Validate the OTP code @@ -61,3 +33,31 @@ Id: "asim@example.com", } ``` +## Generate + +Generate an OTP (one time pass) code + + +[https://m3o.com/otp/api#Generate](https://m3o.com/otp/api#Generate) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/otp" +) + +// Generate an OTP (one time pass) code +func GenerateOtp() { + otpService := otp.NewOtpService(os.Getenv("M3O_API_TOKEN")) + rsp, err := otpService.Generate(&otp.GenerateRequest{ + Id: "asim@example.com", + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/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 ee2ea3c..a29eef3 100755 --- a/examples/postcode/README.md +++ b/examples/postcode/README.md @@ -4,6 +4,33 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/postcode/api]( Endpoints: +## Random + +Return a random postcode and its related info + + +[https://m3o.com/postcode/api#Random](https://m3o.com/postcode/api#Random) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/postcode" +) + +// Return a random postcode and its related info +func ReturnArandomPostcodeAndItsInformation() { + postcodeService := postcode.NewPostcodeService(os.Getenv("M3O_API_TOKEN")) + rsp, err := postcodeService.Random(&postcode.RandomRequest{ + + }) + fmt.Println(rsp, err) + +} +``` ## Validate Validate a postcode. @@ -60,30 +87,3 @@ func LookupPostcode() { } ``` -## Random - -Return a random postcode and its related info - - -[https://m3o.com/postcode/api#Random](https://m3o.com/postcode/api#Random) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/postcode" -) - -// Return a random postcode and its related info -func ReturnArandomPostcodeAndItsInformation() { - postcodeService := postcode.NewPostcodeService(os.Getenv("M3O_API_TOKEN")) - rsp, err := postcodeService.Random(&postcode.RandomRequest{ - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/quran/README.md b/examples/quran/README.md index 7381cb5..5ce6584 100755 --- a/examples/quran/README.md +++ b/examples/quran/README.md @@ -4,34 +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) @@ -120,3 +92,31 @@ 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) + +} +``` diff --git a/examples/search/README.md b/examples/search/README.md index c731a03..fb59678 100755 --- a/examples/search/README.md +++ b/examples/search/README.md @@ -4,6 +4,39 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/search/api](ht Endpoints: +## Index + +Index a record i.e. insert a document to search for. + + +[https://m3o.com/search/api#Index](https://m3o.com/search/api#Index) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/search" +) + +// Index a record i.e. insert a document to search for. +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", +}, +Index: "customers", + + }) + fmt.Println(rsp, err) + +} +``` ## Search Search for records in a given in index @@ -176,36 +209,3 @@ func DeleteAnIndex() { } ``` -## Index - -Index a record i.e. insert a document to search for. - - -[https://m3o.com/search/api#Index](https://m3o.com/search/api#Index) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/search" -) - -// Index a record i.e. insert a document to search for. -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", -}, -Index: "customers", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/search/index/indexARecord/main.go b/examples/search/index/indexARecord/main.go index 8f47156..2a7b1d7 100755 --- a/examples/search/index/indexARecord/main.go +++ b/examples/search/index/indexARecord/main.go @@ -12,9 +12,9 @@ func main() { searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN")) rsp, err := searchService.Index(&search.IndexRequest{ Data: map[string]interface{}{ - "name": "John Doe", "age": 37, "starsign": "Leo", + "name": "John Doe", }, Index: "customers", }) diff --git a/examples/space/README.md b/examples/space/README.md index caa0bf5..d40b142 100755 --- a/examples/space/README.md +++ b/examples/space/README.md @@ -4,6 +4,118 @@ 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 + + +[https://m3o.com/space/api#Read](https://m3o.com/space/api#Read) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/space" +) + +// Read an object in space +func ReadAnObject() { + spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN")) + rsp, err := spaceService.Read(&space.ReadRequest{ + Name: "images/file.jpg", + + }) + fmt.Println(rsp, err) + +} +``` +## Download + +Download an object via a presigned url + + +[https://m3o.com/space/api#Download](https://m3o.com/space/api#Download) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/space" +) + +// Download an object via a presigned url +func DownloadAnObject() { + spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN")) + rsp, err := spaceService.Download(&space.DownloadRequest{ + Name: "images/file.jpg", + + }) + fmt.Println(rsp, err) + +} +``` ## Upload Upload a large object (> 10MB). Returns a time limited presigned URL to be used for uploading the object @@ -120,115 +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) - -} -``` -## Read - -Read an object in space - - -[https://m3o.com/space/api#Read](https://m3o.com/space/api#Read) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/space" -) - -// Read an object in space -func ReadAnObject() { - spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN")) - rsp, err := spaceService.Read(&space.ReadRequest{ - Name: "images/file.jpg", - - }) - fmt.Println(rsp, err) - -} -``` -## Download - -Download an object via a presigned url - - -[https://m3o.com/space/api#Download](https://m3o.com/space/api#Download) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/space" -) - -// Download an object via a presigned url -func DownloadAnObject() { - spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN")) - rsp, err := spaceService.Download(&space.DownloadRequest{ - Name: "images/file.jpg", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/stream/README.md b/examples/stream/README.md index 248440b..d35da4f 100755 --- a/examples/stream/README.md +++ b/examples/stream/README.md @@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/stream/api](ht Endpoints: -## ListMessages - -List messages for a given channel - - -[https://m3o.com/stream/api#ListMessages](https://m3o.com/stream/api#ListMessages) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/stream" -) - -// List messages for a given channel -func ListMessages() { - streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN")) - rsp, err := streamService.ListMessages(&stream.ListMessagesRequest{ - Channel: "general", - - }) - fmt.Println(rsp, err) - -} -``` ## ListChannels List all the active channels @@ -119,3 +91,31 @@ Text: "Hey checkout this tweet https://twitter.com/m3oservices/status/1455291054 } ``` +## ListMessages + +List messages for a given channel + + +[https://m3o.com/stream/api#ListMessages](https://m3o.com/stream/api#ListMessages) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/stream" +) + +// List messages for a given channel +func ListMessages() { + streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN")) + rsp, err := streamService.ListMessages(&stream.ListMessagesRequest{ + Channel: "general", + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/sunnah/README.md b/examples/sunnah/README.md index 68ccae1..d2d603b 100755 --- a/examples/sunnah/README.md +++ b/examples/sunnah/README.md @@ -4,6 +4,35 @@ 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 @@ -94,32 +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) - -} -``` diff --git a/examples/twitter/README.md b/examples/twitter/README.md index b65c6ac..19128ad 100755 --- a/examples/twitter/README.md +++ b/examples/twitter/README.md @@ -4,35 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/twitter/api](h Endpoints: -## Timeline - -Get the timeline for a given user - - -[https://m3o.com/twitter/api#Timeline](https://m3o.com/twitter/api#Timeline) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/twitter" -) - -// Get the timeline for a given user -func GetAtwitterTimeline() { - twitterService := twitter.NewTwitterService(os.Getenv("M3O_API_TOKEN")) - rsp, err := twitterService.Timeline(&twitter.TimelineRequest{ - Limit: 1, -Username: "m3oservices", - - }) - fmt.Println(rsp, err) - -} -``` ## Search Search for tweets with a simple query @@ -116,3 +87,32 @@ func GetAusersTwitterProfile() { } ``` +## Timeline + +Get the timeline for a given user + + +[https://m3o.com/twitter/api#Timeline](https://m3o.com/twitter/api#Timeline) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/twitter" +) + +// Get the timeline for a given user +func GetAtwitterTimeline() { + twitterService := twitter.NewTwitterService(os.Getenv("M3O_API_TOKEN")) + rsp, err := twitterService.Timeline(&twitter.TimelineRequest{ + Limit: 1, +Username: "m3oservices", + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/user/README.md b/examples/user/README.md index 14b5056..49d2c2e 100755 --- a/examples/user/README.md +++ b/examples/user/README.md @@ -4,12 +4,18 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/user/api](http Endpoints: -## Create +## SendVerificationEmail -Create a new user account. The email address and username for the account must be unique. +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#Create](https://m3o.com/user/api#Create) +[https://m3o.com/user/api#SendVerificationEmail](https://m3o.com/user/api#SendVerificationEmail) ```go package example @@ -21,162 +27,24 @@ import( "go.m3o.com/user" ) -// Create a new user account. The email address and username for the account must be unique. -func CreateAnAccount() { +// 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.Create(&user.CreateRequest{ + rsp, err := userService.SendVerificationEmail(&user.SendVerificationEmailRequest{ Email: "joe@example.com", -Id: "user-1", -Password: "Password1", -Username: "joe", +FailureRedirectUrl: "https://m3o.com/verification-failed", +FromName: "Awesome Dot Com", +RedirectUrl: "https://m3o.com", +Subject: "Email verification", +TextContent: `Hi there, - }) - 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) - -} -``` -## ResetPassword - -Reset password with the code sent by the "SendPasswordResetEmail" endpoint. - - -[https://m3o.com/user/api#ResetPassword](https://m3o.com/user/api#ResetPassword) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/user" -) - -// Reset password with the code sent by the "SendPasswordResetEmail" endpoint. -func ResetPassword() { - userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.ResetPassword(&user.ResetPasswordRequest{ - Code: "012345", -ConfirmPassword: "NewPassword1", -Email: "joe@example.com", -NewPassword: "NewPassword1", - - }) - fmt.Println(rsp, err) - -} -``` -## Logout - -Logout a user account - - -[https://m3o.com/user/api#Logout](https://m3o.com/user/api#Logout) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/user" -) - -// Logout a user account -func LogAuserOut() { - userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.Logout(&user.LogoutRequest{ - SessionId: "df91a612-5b24-4634-99ff-240220ab8f55", - - }) - fmt.Println(rsp, err) - -} -``` -## 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) - -} -``` -## Update - -Update the account username or email - - -[https://m3o.com/user/api#Update](https://m3o.com/user/api#Update) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/user" -) - -// Update the account username or email -func UpdateAnAccount() { - userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.Update(&user.UpdateRequest{ - Email: "joe+2@example.com", -Id: "user-1", -Username: "joe", +Please verify your email by clicking this link: $micro_verification_link`, }) fmt.Println(rsp, err) @@ -267,12 +135,13 @@ func ReadAccountByEmail() { } ``` -## Delete +## SendPasswordResetEmail -Delete an account by id +Send an email with a verification code to reset password. +Call "ResetPassword" endpoint once user provides the code. -[https://m3o.com/user/api#Delete](https://m3o.com/user/api#Delete) +[https://m3o.com/user/api#SendPasswordResetEmail](https://m3o.com/user/api#SendPasswordResetEmail) ```go package example @@ -284,24 +153,28 @@ import( "go.m3o.com/user" ) -// Delete an account by id -func DeleteUserAccount() { +// Send an email with a verification code to reset password. +// Call "ResetPassword" endpoint once user provides the code. +func SendPasswordResetEmail() { userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.Delete(&user.DeleteRequest{ - Id: "8b98acbe-0b6a-4d66-a414-5ffbf666786f", + rsp, err := userService.SendPasswordResetEmail(&user.SendPasswordResetEmailRequest{ + Email: "joe@example.com", +FromName: "Awesome Dot Com", +Subject: "Password reset", +TextContent: `Hi there, + click here to reset your password: myapp.com/reset/code?=$code`, }) fmt.Println(rsp, err) } ``` -## Login +## ResetPassword -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 +Reset password with the code sent by the "SendPasswordResetEmail" endpoint. -[https://m3o.com/user/api#Login](https://m3o.com/user/api#Login) +[https://m3o.com/user/api#ResetPassword](https://m3o.com/user/api#ResetPassword) ```go package example @@ -313,13 +186,42 @@ import( "go.m3o.com/user" ) -// Login using username or email. The response will return a new session for successful login, -// 401 in the case of login failure and 500 for any other error -func LogAuserIn() { +// Reset password with the code sent by the "SendPasswordResetEmail" endpoint. +func ResetPassword() { userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.Login(&user.LoginRequest{ - Email: "joe@example.com", -Password: "Password1", + rsp, err := userService.ResetPassword(&user.ResetPasswordRequest{ + Code: "012345", +ConfirmPassword: "NewPassword1", +Email: "joe@example.com", +NewPassword: "NewPassword1", + + }) + fmt.Println(rsp, err) + +} +``` +## Logout + +Logout a user account + + +[https://m3o.com/user/api#Logout](https://m3o.com/user/api#Logout) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Logout a user account +func LogAuserOut() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.Logout(&user.LogoutRequest{ + SessionId: "df91a612-5b24-4634-99ff-240220ab8f55", }) fmt.Println(rsp, err) @@ -355,18 +257,12 @@ Offset: 0, } ``` -## SendVerificationEmail +## Create -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' +Create a new user account. The email address and username for the account must be unique. -[https://m3o.com/user/api#SendVerificationEmail](https://m3o.com/user/api#SendVerificationEmail) +[https://m3o.com/user/api#Create](https://m3o.com/user/api#Create) ```go package example @@ -378,37 +274,26 @@ import( "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() { +// Create a new user account. The email address and username for the account must be unique. +func CreateAnAccount() { userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.SendVerificationEmail(&user.SendVerificationEmailRequest{ + rsp, err := userService.Create(&user.CreateRequest{ 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`, +Id: "user-1", +Password: "Password1", +Username: "joe", }) fmt.Println(rsp, err) } ``` -## SendPasswordResetEmail +## Update -Send an email with a verification code to reset password. -Call "ResetPassword" endpoint once user provides the code. +Update the account username or email -[https://m3o.com/user/api#SendPasswordResetEmail](https://m3o.com/user/api#SendPasswordResetEmail) +[https://m3o.com/user/api#Update](https://m3o.com/user/api#Update) ```go package example @@ -420,28 +305,26 @@ import( "go.m3o.com/user" ) -// Send an email with a verification code to reset password. -// Call "ResetPassword" endpoint once user provides the code. -func SendPasswordResetEmail() { +// Update the account username or email +func UpdateAnAccount() { userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.SendPasswordResetEmail(&user.SendPasswordResetEmailRequest{ - Email: "joe@example.com", -FromName: "Awesome Dot Com", -Subject: "Password reset", -TextContent: `Hi there, - click here to reset your password: myapp.com/reset/code?=$code`, + rsp, err := userService.Update(&user.UpdateRequest{ + Email: "joe+2@example.com", +Id: "user-1", +Username: "joe", }) fmt.Println(rsp, err) } ``` -## VerifyEmail +## Login -Verify the email address of an account from a token sent in an email to the 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 -[https://m3o.com/user/api#VerifyEmail](https://m3o.com/user/api#VerifyEmail) +[https://m3o.com/user/api#Login](https://m3o.com/user/api#Login) ```go package example @@ -453,11 +336,13 @@ import( "go.m3o.com/user" ) -// Verify the email address of an account from a token sent in an email to the user. -func VerifyEmail() { +// 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.VerifyEmail(&user.VerifyEmailRequest{ - Token: "012345", + rsp, err := userService.Login(&user.LoginRequest{ + Email: "joe@example.com", +Password: "Password1", }) fmt.Println(rsp, err) @@ -497,6 +382,65 @@ Click here to access your account $micro_verification_link`, }) 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) + +} +``` +## 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) + } ``` ## VerifyToken @@ -533,3 +477,59 @@ func VerifyAtoken() { } ``` +## VerifyEmail + +Verify the email address of an account from a token sent in an email to the user. + + +[https://m3o.com/user/api#VerifyEmail](https://m3o.com/user/api#VerifyEmail) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Verify the email address of an account from a token sent in an email to the user. +func VerifyEmail() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.VerifyEmail(&user.VerifyEmailRequest{ + Token: "012345", + + }) + fmt.Println(rsp, err) + +} +``` +## ReadSession + +Read a session by the session id. In the event it has expired or is not found and error is returned. + + +[https://m3o.com/user/api#ReadSession](https://m3o.com/user/api#ReadSession) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Read a session by the session id. In the event it has expired or is not found and error is returned. +func ReadAsessionByTheSessionId() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.ReadSession(&user.ReadSessionRequest{ + SessionId: "df91a612-5b24-4634-99ff-240220ab8f55", + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/url/url.go b/url/url.go index b57099f..75789fe 100755 --- a/url/url.go +++ b/url/url.go @@ -80,6 +80,8 @@ type URLPair struct { Created string `json:"created"` // destination url DestinationUrl string `json:"destinationURL"` + // The number of times the short URL has been resolved + HitCount int64 `json:"hit_count,string"` // shortened url ShortUrl string `json:"shortURL"` }