diff --git a/avatar/avatar.go b/avatar/avatar.go index c79f199..cc67367 100755 --- a/avatar/avatar.go +++ b/avatar/avatar.go @@ -29,22 +29,21 @@ func (t *AvatarService) Generate(request *GenerateRequest) (*GenerateResponse, e } type GenerateRequest struct { - // encode format of avatar image, `png` or `jpeg`, default is `jpeg` + // encode format of avatar image: `png` or `jpeg`; default is `jpeg` Format string `json:"format"` - // avatar's gender, `male` or `female`, default is `male` + // avatar's gender: `male` or `female`; default is `male` Gender string `json:"gender"` - // if upload to m3o CDN, default is `false` - // if update = true, then it'll return the CDN url + // set to true to upload to the M3O CDN and receive the url Upload bool `json:"upload"` - // avatar's username, unique username will generates the unique avatar; - // if username == "", will generate a random avatar in every request - // if upload == true, username will be used as CDN filename rather than a random uuid string + // avatar's username, unique username will generate the unique avatar; + // if empty, every request generates a random avatar; + // if upload == true, username will be the CDN filename rather than a random uuid string Username string `json:"username"` } type GenerateResponse struct { - // base64encode string of the avatar image + // base64 encoded string of the avatar image Base64 string `json:"base64"` - // Micro's CDN url of the avatar image + // M3O's CDN url of the avatar image Url string `json:"url"` } diff --git a/examples/app/README.md b/examples/app/README.md index 99d6b0c..3c53fd6 100755 --- a/examples/app/README.md +++ b/examples/app/README.md @@ -4,92 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/app/api](https Endpoints: -## List - -List all the apps - - -[https://m3o.com/app/api#List](https://m3o.com/app/api#List) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/app" -) - -// List all the apps -func ListTheApps() { - appService := app.NewAppService(os.Getenv("M3O_API_TOKEN")) - rsp, err := appService.List(&app.ListRequest{ - - }) - fmt.Println(rsp, err) - -} -``` -## Run - -Run an app from source - - -[https://m3o.com/app/api#Run](https://m3o.com/app/api#Run) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/app" -) - -// Run an app from source -func RunAnApp() { - appService := app.NewAppService(os.Getenv("M3O_API_TOKEN")) - rsp, err := appService.Run(&app.RunRequest{ - Branch: "master", -Name: "helloworld", -Port: 8080, -Region: "europe-west1", -Repo: "github.com/asim/helloworld", - - }) - fmt.Println(rsp, err) - -} -``` -## 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 +144,89 @@ func ReserveAppName() { } ``` +## List + +List all the apps + + +[https://m3o.com/app/api#List](https://m3o.com/app/api#List) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/app" +) + +// List all the apps +func ListTheApps() { + appService := app.NewAppService(os.Getenv("M3O_API_TOKEN")) + rsp, err := appService.List(&app.ListRequest{ + + }) + fmt.Println(rsp, err) + +} +``` +## Run + +Run an app from source + + +[https://m3o.com/app/api#Run](https://m3o.com/app/api#Run) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/app" +) + +// Run an app from source +func RunAnApp() { + appService := app.NewAppService(os.Getenv("M3O_API_TOKEN")) + rsp, err := appService.Run(&app.RunRequest{ + Branch: "master", +Name: "helloworld", +Port: 8080, +Region: "europe-west1", +Repo: "github.com/asim/helloworld", + + }) + fmt.Println(rsp, err) + +} +``` +## 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/chat/README.md b/examples/chat/README.md index b83863b..47b72d7 100755 --- a/examples/chat/README.md +++ b/examples/chat/README.md @@ -4,6 +4,60 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/chat/api](http Endpoints: +## 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) + +} +``` ## Delete Delete a chat room @@ -58,12 +112,13 @@ func InviteAuser() { } ``` -## History +## Send -List the messages in a chat +Connect to a chat to receive a stream of messages +Send a message to a chat -[https://m3o.com/chat/api#History](https://m3o.com/chat/api#History) +[https://m3o.com/chat/api#Send](https://m3o.com/chat/api#Send) ```go package example @@ -75,10 +130,41 @@ import( "go.m3o.com/chat" ) -// List the messages in a chat -func GetChatHistory() { +// 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.History(&chat.HistoryRequest{ + rsp, err := chatService.Send(&chat.SendRequest{ + Client: "web", +Subject: "Random", +Text: "Hey whats up?", + + }) + fmt.Println(rsp, err) + +} +``` +## Leave + +Leave a chat room + + +[https://m3o.com/chat/api#Leave](https://m3o.com/chat/api#Leave) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/chat" +) + +// Leave a chat room +func LeaveAroom() { + chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN")) + rsp, err := chatService.Leave(&chat.LeaveRequest{ }) fmt.Println(rsp, err) @@ -139,92 +225,6 @@ func ListChatRooms() { }) 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) - -} -``` -## Leave - -Leave a chat room - - -[https://m3o.com/chat/api#Leave](https://m3o.com/chat/api#Leave) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/chat" -) - -// Leave a chat room -func LeaveAroom() { - chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN")) - rsp, err := chatService.Leave(&chat.LeaveRequest{ - - }) - fmt.Println(rsp, err) - -} -``` -## 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 diff --git a/examples/comments/README.md b/examples/comments/README.md index 6e8311b..fd28995 100755 --- a/examples/comments/README.md +++ b/examples/comments/README.md @@ -4,89 +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 - - -[https://m3o.com/comments/api#List](https://m3o.com/comments/api#List) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/comments" -) - -// List all the comments -func ListAllComments() { - commentsService := comments.NewCommentsService(os.Getenv("M3O_API_TOKEN")) - rsp, err := commentsService.List(&comments.ListRequest{ - - }) - fmt.Println(rsp, err) - -} -``` ## Update Update a comment @@ -188,3 +105,86 @@ 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) + +} +``` +## List + +List all the comments + + +[https://m3o.com/comments/api#List](https://m3o.com/comments/api#List) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/comments" +) + +// List all the comments +func ListAllComments() { + commentsService := comments.NewCommentsService(os.Getenv("M3O_API_TOKEN")) + rsp, err := commentsService.List(&comments.ListRequest{ + + }) + fmt.Println(rsp, err) + +} +``` 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/currency/README.md b/examples/currency/README.md index e112f11..f788d89 100755 --- a/examples/currency/README.md +++ b/examples/currency/README.md @@ -4,62 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/currency/api]( Endpoints: -## History - -Returns the historic rates for a currency on a given date - - -[https://m3o.com/currency/api#History](https://m3o.com/currency/api#History) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/currency" -) - -// Returns the historic rates for a currency on a given date -func HistoricRatesForAcurrency() { - currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN")) - rsp, err := currencyService.History(¤cy.HistoryRequest{ - Code: "USD", -Date: "2021-05-30", - - }) - fmt.Println(rsp, err) - -} -``` -## 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 @@ -147,3 +91,59 @@ To: "GBP", } ``` +## History + +Returns the historic rates for a currency on a given date + + +[https://m3o.com/currency/api#History](https://m3o.com/currency/api#History) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/currency" +) + +// Returns the historic rates for a currency on a given date +func HistoricRatesForAcurrency() { + currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN")) + rsp, err := currencyService.History(¤cy.HistoryRequest{ + Code: "USD", +Date: "2021-05-30", + + }) + fmt.Println(rsp, err) + +} +``` +## 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) + +} +``` diff --git a/examples/db/README.md b/examples/db/README.md index bfb734d..9e4706e 100755 --- a/examples/db/README.md +++ b/examples/db/README.md @@ -4,12 +4,12 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/db/api](https: Endpoints: -## RenameTable +## Read -Rename a table +Read data from a table. Lookup can be by ID or via querying any field in the record. -[https://m3o.com/db/api#RenameTable](https://m3o.com/db/api#RenameTable) +[https://m3o.com/db/api#Read](https://m3o.com/db/api#Read) ```go package example @@ -21,105 +21,16 @@ import( "go.m3o.com/db" ) -// Rename a table -func RenameTable() { +// Read data from a table. Lookup can be by ID or via querying any field in the record. +func ReadRecords() { dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) - rsp, err := dbService.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, -}, + rsp, err := dbService.Read(&db.ReadRequest{ + Query: "age == 43", Table: "example", }) fmt.Println(rsp, err) -} -``` -## Delete - -Delete a record in the database by id. - - -[https://m3o.com/db/api#Delete](https://m3o.com/db/api#Delete) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/db" -) - -// Delete a record in the database by id. -func DeleteArecord() { - dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) - rsp, err := dbService.Delete(&db.DeleteRequest{ - Id: "1", -Table: "example", - - }) - fmt.Println(rsp, err) - -} -``` -## Truncate - -Truncate the records in a table - - -[https://m3o.com/db/api#Truncate](https://m3o.com/db/api#Truncate) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/db" -) - -// Truncate the records in a table -func TruncateTable() { - dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) - rsp, err := dbService.Truncate(&db.TruncateRequest{ - Table: "example", - - }) - fmt.Println(rsp, err) - } ``` ## DropTable @@ -203,6 +114,35 @@ func ListTables() { }) fmt.Println(rsp, err) +} +``` +## RenameTable + +Rename a table + + +[https://m3o.com/db/api#RenameTable](https://m3o.com/db/api#RenameTable) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/db" +) + +// Rename a table +func RenameTable() { + dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) + rsp, err := dbService.RenameTable(&db.RenameTableRequest{ + From: "examples2", +To: "examples3", + + }) + fmt.Println(rsp, err) + } ``` ## Create @@ -227,10 +167,10 @@ func CreateArecord() { dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) rsp, err := dbService.Create(&db.CreateRequest{ Record: map[string]interface{}{ - "id": "1", - "name": "Jane", "age": 42, "isActive": true, + "id": "1", + "name": "Jane", }, Table: "example", @@ -239,12 +179,12 @@ Table: "example", } ``` -## Read +## Delete -Read data from a table. Lookup can be by ID or via querying any field in the record. +Delete a record in the database by id. -[https://m3o.com/db/api#Read](https://m3o.com/db/api#Read) +[https://m3o.com/db/api#Delete](https://m3o.com/db/api#Delete) ```go package example @@ -256,11 +196,71 @@ import( "go.m3o.com/db" ) -// Read data from a table. Lookup can be by ID or via querying any field in the record. -func ReadRecords() { +// Delete a record in the database by id. +func DeleteArecord() { dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) - rsp, err := dbService.Read(&db.ReadRequest{ - Query: "age == 43", + rsp, err := dbService.Delete(&db.DeleteRequest{ + Id: "1", +Table: "example", + + }) + fmt.Println(rsp, err) + +} +``` +## Truncate + +Truncate the records in a table + + +[https://m3o.com/db/api#Truncate](https://m3o.com/db/api#Truncate) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/db" +) + +// Truncate the records in a table +func TruncateTable() { + dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) + rsp, err := dbService.Truncate(&db.TruncateRequest{ + 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", }) diff --git a/examples/email/README.md b/examples/email/README.md index b04ca45..8e6afcf 100755 --- a/examples/email/README.md +++ b/examples/email/README.md @@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/email/api](htt Endpoints: -## Validate - -Validate an email address format - - -[https://m3o.com/email/api#Validate](https://m3o.com/email/api#Validate) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/email" -) - -// Validate an email address format -func ValidateEmail() { - emailService := email.NewEmailService(os.Getenv("M3O_API_TOKEN")) - rsp, err := emailService.Validate(&email.ValidateRequest{ - Address: "joe@example.com", - - }) - fmt.Println(rsp, err) - -} -``` ## Send Send an email by passing in from, to, subject, and a text or html body @@ -92,3 +64,31 @@ func ParseEmail() { } ``` +## Validate + +Validate an email address format + + +[https://m3o.com/email/api#Validate](https://m3o.com/email/api#Validate) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/email" +) + +// Validate an email address format +func ValidateEmail() { + emailService := email.NewEmailService(os.Getenv("M3O_API_TOKEN")) + rsp, err := emailService.Validate(&email.ValidateRequest{ + Address: "joe@example.com", + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/function/README.md b/examples/function/README.md index abc6ef7..8b6926f 100755 --- a/examples/function/README.md +++ b/examples/function/README.md @@ -4,6 +4,88 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/function/api]( Endpoints: +## 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) + +} +``` +## 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) + +} +``` +## 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 Call a function by name @@ -35,12 +117,12 @@ Request: map[string]interface{}{ } ``` -## List +## Describe -List all the deployed functions +Get the info for a deployed function -[https://m3o.com/function/api#List](https://m3o.com/function/api#List) +[https://m3o.com/function/api#Describe](https://m3o.com/function/api#Describe) ```go package example @@ -52,37 +134,10 @@ import( "go.m3o.com/function" ) -// List all the deployed functions -func ListFunctions() { +// Get the info for a deployed function +func DescribeFunctionStatus() { functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) - rsp, err := functionService.List(&function.ListRequest{ - - }) - 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{ + rsp, err := functionService.Describe(&function.DescribeRequest{ Name: "helloworld", }) @@ -116,6 +171,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 @@ -152,12 +235,12 @@ Subfolder: "examples/go-function", } ``` -## Update +## Delete -Update a function. Downloads the source, builds and redeploys +Delete a function by name -[https://m3o.com/function/api#Update](https://m3o.com/function/api#Update) +[https://m3o.com/function/api#Delete](https://m3o.com/function/api#Delete) ```go package example @@ -169,10 +252,10 @@ import( "go.m3o.com/function" ) -// Update a function. Downloads the source, builds and redeploys -func UpdateAfunction() { +// Delete a function by name +func DeleteAfunction() { functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) - rsp, err := functionService.Update(&function.UpdateRequest{ + rsp, err := functionService.Delete(&function.DeleteRequest{ Name: "helloworld", }) @@ -180,86 +263,3 @@ func UpdateAfunction() { } ``` -## 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) - -} -``` -## 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) - -} -``` diff --git a/examples/image/README.md b/examples/image/README.md index 6b5b4b5..a05edab 100755 --- a/examples/image/README.md +++ b/examples/image/README.md @@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/image/api](htt Endpoints: +## 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. @@ -228,31 +256,3 @@ Url: "somewebsite.com/cat.png", } ``` -## 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/mq/README.md b/examples/mq/README.md index 1582975..a0bfa01 100755 --- a/examples/mq/README.md +++ b/examples/mq/README.md @@ -4,39 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/mq/api](https: Endpoints: -## Publish - -Publish a message. Specify a topic to group messages for a specific topic. - - -[https://m3o.com/mq/api#Publish](https://m3o.com/mq/api#Publish) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/mq" -) - -// Publish a message. Specify a topic to group messages for a specific topic. -func PublishAmessage() { - mqService := mq.NewMqService(os.Getenv("M3O_API_TOKEN")) - rsp, err := mqService.Publish(&mq.PublishRequest{ - Message: map[string]interface{}{ - "id": "1", - "type": "signup", - "user": "john", -}, -Topic: "events", - - }) - fmt.Println(rsp, err) - -} -``` ## Subscribe Subscribe to messages for a given topic. @@ -78,3 +45,36 @@ func SubscribeToAtopic() { } } ``` +## Publish + +Publish a message. Specify a topic to group messages for a specific topic. + + +[https://m3o.com/mq/api#Publish](https://m3o.com/mq/api#Publish) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/mq" +) + +// Publish a message. Specify a topic to group messages for a specific topic. +func PublishAmessage() { + mqService := mq.NewMqService(os.Getenv("M3O_API_TOKEN")) + rsp, err := mqService.Publish(&mq.PublishRequest{ + Message: map[string]interface{}{ + "id": "1", + "type": "signup", + "user": "john", +}, +Topic: "events", + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/mq/publish/publishAMessage/main.go b/examples/mq/publish/publishAMessage/main.go index fe21c56..ad993e2 100755 --- a/examples/mq/publish/publishAMessage/main.go +++ b/examples/mq/publish/publishAMessage/main.go @@ -12,9 +12,9 @@ func main() { mqService := mq.NewMqService(os.Getenv("M3O_API_TOKEN")) rsp, err := mqService.Publish(&mq.PublishRequest{ Message: map[string]interface{}{ - "user": "john", "id": "1", "type": "signup", + "user": "john", }, Topic: "events", }) diff --git a/examples/nft/README.md b/examples/nft/README.md index 1c2809a..3f32ff7 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: +## Assets + +Return a list of assets + + +[https://m3o.com/nft/api#Assets](https://m3o.com/nft/api#Assets) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/nft" +) + +// Return a list of assets +func GetAlistOfAssets() { + nftService := nft.NewNftService(os.Getenv("M3O_API_TOKEN")) + rsp, err := nftService.Assets(&nft.AssetsRequest{ + Limit: 1, + + }) + fmt.Println(rsp, err) + +} +``` ## Create Create your own NFT (coming soon) @@ -116,31 +144,3 @@ func GetAsingleCollection() { } ``` -## Assets - -Return a list of assets - - -[https://m3o.com/nft/api#Assets](https://m3o.com/nft/api#Assets) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/nft" -) - -// Return a list of assets -func GetAlistOfAssets() { - nftService := nft.NewNftService(os.Getenv("M3O_API_TOKEN")) - rsp, err := nftService.Assets(&nft.AssetsRequest{ - Limit: 1, - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/notes/README.md b/examples/notes/README.md index 6d6064b..9e98ae9 100755 --- a/examples/notes/README.md +++ b/examples/notes/README.md @@ -4,6 +4,63 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/notes/api](htt Endpoints: +## Create + +Create a new note + + +[https://m3o.com/notes/api#Create](https://m3o.com/notes/api#Create) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/notes" +) + +// Create a new note +func CreateAnote() { + notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN")) + rsp, err := notesService.Create(¬es.CreateRequest{ + Text: "This is my note", +Title: "New Note", + + }) + fmt.Println(rsp, err) + +} +``` +## Read + +Read a note + + +[https://m3o.com/notes/api#Read](https://m3o.com/notes/api#Read) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/notes" +) + +// Read a note +func ReadAnote() { + notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN")) + rsp, err := notesService.Read(¬es.ReadRequest{ + Id: "63c0cdf8-2121-11ec-a881-0242e36f037a", + + }) + fmt.Println(rsp, err) + +} +``` ## List List all the notes @@ -132,60 +189,3 @@ func SubscribeToEvents() { } } ``` -## Create - -Create a new note - - -[https://m3o.com/notes/api#Create](https://m3o.com/notes/api#Create) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/notes" -) - -// Create a new note -func CreateAnote() { - notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN")) - rsp, err := notesService.Create(¬es.CreateRequest{ - Text: "This is my note", -Title: "New Note", - - }) - fmt.Println(rsp, err) - -} -``` -## Read - -Read a note - - -[https://m3o.com/notes/api#Read](https://m3o.com/notes/api#Read) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/notes" -) - -// Read a note -func ReadAnote() { - notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN")) - rsp, err := notesService.Read(¬es.ReadRequest{ - Id: "63c0cdf8-2121-11ec-a881-0242e36f037a", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/routing/README.md b/examples/routing/README.md index 513ed01..f133a39 100755 --- a/examples/routing/README.md +++ b/examples/routing/README.md @@ -4,41 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/routing/api](h Endpoints: -## Route - -Retrieve a route as a simple list of gps points along with total distance and estimated duration - - -[https://m3o.com/routing/api#Route](https://m3o.com/routing/api#Route) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/routing" -) - -// Retrieve a route as a simple list of gps points along with total distance and estimated duration -func GpsPointsForAroute() { - routingService := routing.NewRoutingService(os.Getenv("M3O_API_TOKEN")) - rsp, err := routingService.Route(&routing.RouteRequest{ - Destination: &routing.Point{ - Latitude: 52.529407, - Longitude: 13.397634, -}, -Origin: &routing.Point{ - Latitude: 52.517037, - Longitude: 13.38886, -}, - - }) - fmt.Println(rsp, err) - -} -``` ## Eta Get the eta for a route from origin to destination. The eta is an estimated time based on car routes @@ -109,3 +74,38 @@ Origin: &routing.Point{ } ``` +## Route + +Retrieve a route as a simple list of gps points along with total distance and estimated duration + + +[https://m3o.com/routing/api#Route](https://m3o.com/routing/api#Route) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/routing" +) + +// Retrieve a route as a simple list of gps points along with total distance and estimated duration +func GpsPointsForAroute() { + routingService := routing.NewRoutingService(os.Getenv("M3O_API_TOKEN")) + rsp, err := routingService.Route(&routing.RouteRequest{ + Destination: &routing.Point{ + Latitude: 52.529407, + Longitude: 13.397634, +}, +Origin: &routing.Point{ + Latitude: 52.517037, + Longitude: 13.38886, +}, + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/rss/README.md b/examples/rss/README.md index 5cda3e4..d95588d 100755 --- a/examples/rss/README.md +++ b/examples/rss/README.md @@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/rss/api](https Endpoints: +## Remove + +Remove an RSS feed by name + + +[https://m3o.com/rss/api#Remove](https://m3o.com/rss/api#Remove) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/rss" +) + +// Remove an RSS feed by name +func RemoveAfeed() { + rssService := rss.NewRssService(os.Getenv("M3O_API_TOKEN")) + rsp, err := rssService.Remove(&rss.RemoveRequest{ + Name: "bbc", + + }) + fmt.Println(rsp, err) + +} +``` ## Add Add a new RSS feed with a name, url, and category @@ -89,31 +117,3 @@ func ListRssFeeds() { } ``` -## Remove - -Remove an RSS feed by name - - -[https://m3o.com/rss/api#Remove](https://m3o.com/rss/api#Remove) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/rss" -) - -// Remove an RSS feed by name -func RemoveAfeed() { - rssService := rss.NewRssService(os.Getenv("M3O_API_TOKEN")) - rsp, err := rssService.Remove(&rss.RemoveRequest{ - Name: "bbc", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/search/README.md b/examples/search/README.md index fb59678..99681a2 100755 --- a/examples/search/README.md +++ b/examples/search/README.md @@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/search/api](ht Endpoints: +## DeleteIndex + +Delete an index by name + + +[https://m3o.com/search/api#DeleteIndex](https://m3o.com/search/api#DeleteIndex) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/search" +) + +// Delete an index by name +func DeleteAnIndex() { + searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN")) + rsp, err := searchService.DeleteIndex(&search.DeleteIndexRequest{ + Index: "customers", + + }) + fmt.Println(rsp, err) + +} +``` ## Index Index a record i.e. insert a document to search for. @@ -181,31 +209,3 @@ func CreateAnIndex() { } ``` -## DeleteIndex - -Delete an index by name - - -[https://m3o.com/search/api#DeleteIndex](https://m3o.com/search/api#DeleteIndex) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/search" -) - -// Delete an index by name -func DeleteAnIndex() { - searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN")) - rsp, err := searchService.DeleteIndex(&search.DeleteIndexRequest{ - Index: "customers", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/space/README.md b/examples/space/README.md index a3418ba..e0dac00 100755 --- a/examples/space/README.md +++ b/examples/space/README.md @@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/space/api](htt Endpoints: -## 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 @@ -232,3 +204,31 @@ func ListObjectsWithPrefix() { } ``` +## Head + +Retrieve meta information about an object + + +[https://m3o.com/space/api#Head](https://m3o.com/space/api#Head) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/space" +) + +// Retrieve meta information about an object +func HeadAnObject() { + spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN")) + rsp, err := spaceService.Head(&space.HeadRequest{ + Name: "images/file.jpg", + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/stock/README.md b/examples/stock/README.md index 2018b54..83cd80a 100755 --- a/examples/stock/README.md +++ b/examples/stock/README.md @@ -4,6 +4,35 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/stock/api](htt Endpoints: +## History + +Get the historic open-close for a given day + + +[https://m3o.com/stock/api#History](https://m3o.com/stock/api#History) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/stock" +) + +// Get the historic open-close for a given day +func GetHistoricData() { + stockService := stock.NewStockService(os.Getenv("M3O_API_TOKEN")) + rsp, err := stockService.History(&stock.HistoryRequest{ + Date: "2020-10-01", +Stock: "AAPL", + + }) + fmt.Println(rsp, err) + +} +``` ## OrderBook Get the historic order book and each trade by timestamp @@ -92,32 +121,3 @@ func GetAstockQuote() { } ``` -## History - -Get the historic open-close for a given day - - -[https://m3o.com/stock/api#History](https://m3o.com/stock/api#History) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/stock" -) - -// Get the historic open-close for a given day -func GetHistoricData() { - stockService := stock.NewStockService(os.Getenv("M3O_API_TOKEN")) - rsp, err := stockService.History(&stock.HistoryRequest{ - Date: "2020-10-01", -Stock: "AAPL", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/stream/README.md b/examples/stream/README.md index 11fa9f3..232026e 100755 --- a/examples/stream/README.md +++ b/examples/stream/README.md @@ -4,6 +4,37 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/stream/api](ht Endpoints: +## CreateChannel + +Create a channel with a given name and description. Channels are created automatically but +this allows you to specify a description that's persisted for the lifetime of the channel. + + +[https://m3o.com/stream/api#CreateChannel](https://m3o.com/stream/api#CreateChannel) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/stream" +) + +// Create a channel with a given name and description. Channels are created automatically but +// this allows you to specify a description that's persisted for the lifetime of the channel. +func CreateChannel() { + streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN")) + rsp, err := streamService.CreateChannel(&stream.CreateChannelRequest{ + Description: "The channel for all things", +Name: "general", + + }) + fmt.Println(rsp, err) + +} +``` ## SendMessage Send a message to the stream. @@ -88,34 +119,3 @@ func ListChannels() { } ``` -## CreateChannel - -Create a channel with a given name and description. Channels are created automatically but -this allows you to specify a description that's persisted for the lifetime of the channel. - - -[https://m3o.com/stream/api#CreateChannel](https://m3o.com/stream/api#CreateChannel) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/stream" -) - -// Create a channel with a given name and description. Channels are created automatically but -// this allows you to specify a description that's persisted for the lifetime of the channel. -func CreateChannel() { - streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN")) - rsp, err := streamService.CreateChannel(&stream.CreateChannelRequest{ - Description: "The channel for all things", -Name: "general", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/sunnah/README.md b/examples/sunnah/README.md index 6036ae5..fbe4416 100755 --- a/examples/sunnah/README.md +++ b/examples/sunnah/README.md @@ -4,35 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/sunnah/api](ht Endpoints: -## Chapters - -Get all the chapters of a given book within a collection. - - -[https://m3o.com/sunnah/api#Chapters](https://m3o.com/sunnah/api#Chapters) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/sunnah" -) - -// Get all the chapters of a given book within a collection. -func ListTheChaptersInAbook() { - sunnahService := sunnah.NewSunnahService(os.Getenv("M3O_API_TOKEN")) - rsp, err := sunnahService.Chapters(&sunnah.ChaptersRequest{ - Book: 1, -Collection: "bukhari", - - }) - fmt.Println(rsp, err) - -} -``` ## Hadiths Hadiths returns a list of hadiths and their corresponding text for a @@ -123,3 +94,32 @@ func GetTheBooksWithinAcollection() { } ``` +## Chapters + +Get all the chapters of a given book within a collection. + + +[https://m3o.com/sunnah/api#Chapters](https://m3o.com/sunnah/api#Chapters) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/sunnah" +) + +// Get all the chapters of a given book within a collection. +func ListTheChaptersInAbook() { + sunnahService := sunnah.NewSunnahService(os.Getenv("M3O_API_TOKEN")) + rsp, err := sunnahService.Chapters(&sunnah.ChaptersRequest{ + Book: 1, +Collection: "bukhari", + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/time/README.md b/examples/time/README.md index c0626b7..9aad631 100755 --- a/examples/time/README.md +++ b/examples/time/README.md @@ -4,6 +4,33 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/time/api](http Endpoints: +## Now + +Get the current time + + +[https://m3o.com/time/api#Now](https://m3o.com/time/api#Now) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/time" +) + +// Get the current time +func ReturnsCurrentTimeOptionallyWithLocation() { + timeService := time.NewTimeService(os.Getenv("M3O_API_TOKEN")) + rsp, err := timeService.Now(&time.NowRequest{ + + }) + fmt.Println(rsp, err) + +} +``` ## Zone Get the timezone info for a specific location @@ -32,30 +59,3 @@ func GetTheTimezoneInfoForAspecificLocation() { } ``` -## Now - -Get the current time - - -[https://m3o.com/time/api#Now](https://m3o.com/time/api#Now) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/time" -) - -// Get the current time -func ReturnsCurrentTimeOptionallyWithLocation() { - timeService := time.NewTimeService(os.Getenv("M3O_API_TOKEN")) - rsp, err := timeService.Now(&time.NowRequest{ - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/twitter/README.md b/examples/twitter/README.md index ec1dada..b65c6ac 100755 --- a/examples/twitter/README.md +++ b/examples/twitter/README.md @@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/twitter/api](h Endpoints: -## User - -Get a user's twitter profile - - -[https://m3o.com/twitter/api#User](https://m3o.com/twitter/api#User) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/twitter" -) - -// Get a user's twitter profile -func GetAusersTwitterProfile() { - twitterService := twitter.NewTwitterService(os.Getenv("M3O_API_TOKEN")) - rsp, err := twitterService.User(&twitter.UserRequest{ - Username: "crufter", - - }) - fmt.Println(rsp, err) - -} -``` ## Timeline Get the timeline for a given user @@ -116,3 +88,31 @@ func GetTheCurrentGlobalTrendingTopics() { } ``` +## User + +Get a user's twitter profile + + +[https://m3o.com/twitter/api#User](https://m3o.com/twitter/api#User) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/twitter" +) + +// Get a user's twitter profile +func GetAusersTwitterProfile() { + twitterService := twitter.NewTwitterService(os.Getenv("M3O_API_TOKEN")) + rsp, err := twitterService.User(&twitter.UserRequest{ + Username: "crufter", + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/user/README.md b/examples/user/README.md index 70c7186..ce38a51 100755 --- a/examples/user/README.md +++ b/examples/user/README.md @@ -86,34 +86,6 @@ func ReadAccountByEmail() { }) fmt.Println(rsp, err) -} -``` -## VerifyEmail - -Verify the email address of an account from a token sent in an email to the user. - - -[https://m3o.com/user/api#VerifyEmail](https://m3o.com/user/api#VerifyEmail) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/user" -) - -// Verify the email address of an account from a token sent in an email to the user. -func VerifyEmail() { - userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.VerifyEmail(&user.VerifyEmailRequest{ - Token: "012345", - - }) - fmt.Println(rsp, err) - } ``` ## Login @@ -145,41 +117,6 @@ Password: "Password1", }) fmt.Println(rsp, err) -} -``` -## SendMagicLink - -Login using email only - Passwordless - - -[https://m3o.com/user/api#SendMagicLink](https://m3o.com/user/api#SendMagicLink) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/user" -) - -// Login using email only - Passwordless -func SendAmagicLink() { - userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.SendMagicLink(&user.SendMagicLinkRequest{ - Address: "www.example.com", -Email: "joe@example.com", -Endpoint: "verifytoken", -FromName: "Awesome Dot Com", -Subject: "MagicLink to access your account", -TextContent: `Hi there, - -Click here to access your account $micro_verification_link`, - - }) - fmt.Println(rsp, err) - } ``` ## VerifyToken @@ -242,6 +179,35 @@ func LogAuserOut() { }) 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) + } ``` ## Create @@ -303,99 +269,6 @@ Username: "joe", }) fmt.Println(rsp, err) -} -``` -## UpdatePassword - -Update the account password - - -[https://m3o.com/user/api#UpdatePassword](https://m3o.com/user/api#UpdatePassword) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/user" -) - -// Update the account password -func UpdateTheAccountPassword() { - userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.UpdatePassword(&user.UpdatePasswordRequest{ - ConfirmPassword: "Password2", -NewPassword: "Password2", -OldPassword: "Password1", -UserId: "user-1", - - }) - fmt.Println(rsp, err) - -} -``` -## SendPasswordResetEmail - -Send an email with a verification code to reset password. -Call "ResetPassword" endpoint once user provides the code. - - -[https://m3o.com/user/api#SendPasswordResetEmail](https://m3o.com/user/api#SendPasswordResetEmail) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/user" -) - -// Send an email with a verification code to reset password. -// Call "ResetPassword" endpoint once user provides the code. -func SendPasswordResetEmail() { - userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.SendPasswordResetEmail(&user.SendPasswordResetEmailRequest{ - Email: "joe@example.com", -FromName: "Awesome Dot Com", -Subject: "Password reset", -TextContent: `Hi there, - click here to reset your password: myapp.com/reset/code?=$code`, - - }) - fmt.Println(rsp, err) - -} -``` -## 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) - } ``` ## SendVerificationEmail @@ -445,12 +318,13 @@ Please verify your email by clicking this link: $micro_verification_link`, } ``` -## ResetPassword +## SendPasswordResetEmail -Reset password with the code sent by the "SendPasswordResetEmail" endpoint. +Send an email with a verification code to reset password. +Call "ResetPassword" endpoint once user provides the code. -[https://m3o.com/user/api#ResetPassword](https://m3o.com/user/api#ResetPassword) +[https://m3o.com/user/api#SendPasswordResetEmail](https://m3o.com/user/api#SendPasswordResetEmail) ```go package example @@ -462,14 +336,75 @@ import( "go.m3o.com/user" ) -// Reset password with the code sent by the "SendPasswordResetEmail" endpoint. -func ResetPassword() { +// 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.ResetPassword(&user.ResetPasswordRequest{ - Code: "012345", -ConfirmPassword: "NewPassword1", -Email: "joe@example.com", -NewPassword: "NewPassword1", + 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) + +} +``` +## 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) + +} +``` +## 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) @@ -504,12 +439,12 @@ func DeleteUserAccount() { } ``` -## List +## SendMagicLink -List all users. Returns a paged list of results +Login using email only - Passwordless -[https://m3o.com/user/api#List](https://m3o.com/user/api#List) +[https://m3o.com/user/api#SendMagicLink](https://m3o.com/user/api#SendMagicLink) ```go package example @@ -521,12 +456,77 @@ import( "go.m3o.com/user" ) -// List all users. Returns a paged list of results -func ListAllUsers() { +// Login using email only - Passwordless +func SendAmagicLink() { userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.List(&user.ListRequest{ - Limit: 100, -Offset: 0, + rsp, err := userService.SendMagicLink(&user.SendMagicLinkRequest{ + Address: "www.example.com", +Email: "joe@example.com", +Endpoint: "verifytoken", +FromName: "Awesome Dot Com", +Subject: "MagicLink to access your account", +TextContent: `Hi there, + +Click here to access your account $micro_verification_link`, + + }) + fmt.Println(rsp, err) + +} +``` +## 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) + +} +``` +## 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/youtube/youtube.go b/youtube/youtube.go index 07f49c7..83a62cb 100755 --- a/youtube/youtube.go +++ b/youtube/youtube.go @@ -38,12 +38,12 @@ func (t *YoutubeService) Search(request *SearchRequest) (*SearchResponse, error) } type EmbedRequest struct { - // provide the youtube url e.g https://www.youtube.com/watch?v=GWRWZu7XsJ0 + // provide the youtube url Url string `json:"url"` } type EmbedResponse struct { - // the embeddable link e.g https://www.youtube.com/watch?v=GWRWZu7XsJ0 + // the embeddable link EmbedUrl string `json:"embed_url"` // the script code HtmlScript string `json:"html_script"` @@ -64,7 +64,7 @@ type SearchResponse struct { } type SearchResult struct { - // if live broadcast then indicates activity. + // if live broadcast then indicates activity: // none, upcoming, live, completed Broadcasting string `json:"broadcasting"` // the channel id @@ -75,7 +75,7 @@ type SearchResult struct { Description string `json:"description"` // id of the result Id string `json:"id"` - // kind of result; "video", "channel", "playlist" + // kind of result: "video", "channel", "playlist" Kind string `json:"kind"` // published at time PublishedAt string `json:"published_at"`