From bcf8833d06cefb05129f41f0b65a68b4c2a7ae8e Mon Sep 17 00:00:00 2001 From: m3o-actions <> Date: Fri, 25 Feb 2022 12:46:02 +0000 Subject: [PATCH] Commit from m3o/m3o action --- examples/app/README.md | 54 +- examples/chat/README.md | 136 ++-- examples/contact/README.md | 168 ++--- examples/crypto/README.md | 56 +- examples/db/README.md | 88 +-- examples/db/create/createARecord/main.go | 2 +- examples/db/update/updateARecord/main.go | 2 +- examples/emoji/README.md | 56 +- examples/evchargers/README.md | 54 +- examples/event/README.md | 56 +- examples/file/README.md | 64 +- examples/function/README.md | 250 +++---- examples/geocoding/README.md | 58 +- examples/id/README.md | 54 +- examples/lists/README.md | 170 ++--- examples/mq/publish/publishAMessage/main.go | 2 +- examples/nft/README.md | 58 +- examples/ping/README.md | 56 +- examples/search/README.md | 176 ++--- examples/space/README.md | 168 ++--- examples/stock/README.md | 112 +-- examples/stream/README.md | 62 +- examples/url/README.md | 54 +- examples/user/README.md | 726 ++++++++++---------- 24 files changed, 1341 insertions(+), 1341 deletions(-) diff --git a/examples/app/README.md b/examples/app/README.md index 99d6b0c..67740e7 100755 --- a/examples/app/README.md +++ b/examples/app/README.md @@ -4,33 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/app/api](https Endpoints: -## 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 @@ -230,3 +203,30 @@ 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) + +} +``` diff --git a/examples/chat/README.md b/examples/chat/README.md index 67e8cb2..016282e 100755 --- a/examples/chat/README.md +++ b/examples/chat/README.md @@ -4,12 +4,12 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/chat/api](http Endpoints: -## Create +## List -Create a new chat room +List available chats -[https://m3o.com/chat/api#Create](https://m3o.com/chat/api#Create) +[https://m3o.com/chat/api#List](https://m3o.com/chat/api#List) ```go package example @@ -21,39 +21,10 @@ import( "go.m3o.com/chat" ) -// Create a new chat room -func CreateAnewChat() { +// List available chats +func ListChatRooms() { chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN")) - rsp, err := chatService.Create(&chat.CreateRequest{ - Description: "The general chat room", -Name: "general", - - }) - fmt.Println(rsp, err) - -} -``` -## Delete - -Delete a chat room - - -[https://m3o.com/chat/api#Delete](https://m3o.com/chat/api#Delete) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/chat" -) - -// Delete a chat room -func DeleteAchat() { - chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN")) - rsp, err := chatService.Delete(&chat.DeleteRequest{ + rsp, err := chatService.List(&chat.ListRequest{ }) fmt.Println(rsp, err) @@ -173,12 +144,12 @@ func KickAuserFromAroom() { } ``` -## List +## Leave -List available chats +Leave a chat room -[https://m3o.com/chat/api#List](https://m3o.com/chat/api#List) +[https://m3o.com/chat/api#Leave](https://m3o.com/chat/api#Leave) ```go package example @@ -190,10 +161,66 @@ import( "go.m3o.com/chat" ) -// List available chats -func ListChatRooms() { +// Leave a chat room +func LeaveAroom() { chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN")) - rsp, err := chatService.List(&chat.ListRequest{ + rsp, err := chatService.Leave(&chat.LeaveRequest{ + + }) + fmt.Println(rsp, err) + +} +``` +## Create + +Create a new chat room + + +[https://m3o.com/chat/api#Create](https://m3o.com/chat/api#Create) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/chat" +) + +// Create a new chat room +func CreateAnewChat() { + chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN")) + rsp, err := chatService.Create(&chat.CreateRequest{ + Description: "The general chat room", +Name: "general", + + }) + fmt.Println(rsp, err) + +} +``` +## Delete + +Delete a chat room + + +[https://m3o.com/chat/api#Delete](https://m3o.com/chat/api#Delete) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/chat" +) + +// Delete a chat room +func DeleteAchat() { + chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN")) + rsp, err := chatService.Delete(&chat.DeleteRequest{ }) fmt.Println(rsp, err) @@ -240,30 +267,3 @@ func JoinAroom() { } } ``` -## 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) - -} -``` diff --git a/examples/contact/README.md b/examples/contact/README.md index 9a41354..e2e01cc 100755 --- a/examples/contact/README.md +++ b/examples/contact/README.md @@ -4,90 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/contact/api](h Endpoints: -## Delete - -Delete a contact - - -[https://m3o.com/contact/api#Delete](https://m3o.com/contact/api#Delete) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/contact" -) - -// Delete a contact -func DeleteAcontact() { - contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN")) - rsp, err := contactService.Delete(&contact.DeleteRequest{ - Id: "42e48a3c-6221-11ec-96d2-acde48001122", - - }) - fmt.Println(rsp, err) - -} -``` -## List - -List contacts - - -[https://m3o.com/contact/api#List](https://m3o.com/contact/api#List) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/contact" -) - -// List contacts -func ListContactsWithDefaultOffsetAndLimitDefaultLimitIs20() { - contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN")) - rsp, err := contactService.List(&contact.ListRequest{ - - }) - fmt.Println(rsp, err) - -} -``` -## List - -List contacts - - -[https://m3o.com/contact/api#List](https://m3o.com/contact/api#List) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/contact" -) - -// List contacts -func ListContactsWithSpecificOffsetAndLimit() { - contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN")) - rsp, err := contactService.List(&contact.ListRequest{ - Limit: 1, -Offset: 1, - - }) - fmt.Println(rsp, err) - -} -``` ## Create Create a contact @@ -217,3 +133,87 @@ func GetAcontact() { } ``` +## Delete + +Delete a contact + + +[https://m3o.com/contact/api#Delete](https://m3o.com/contact/api#Delete) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/contact" +) + +// Delete a contact +func DeleteAcontact() { + contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN")) + rsp, err := contactService.Delete(&contact.DeleteRequest{ + Id: "42e48a3c-6221-11ec-96d2-acde48001122", + + }) + fmt.Println(rsp, err) + +} +``` +## List + +List contacts + + +[https://m3o.com/contact/api#List](https://m3o.com/contact/api#List) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/contact" +) + +// List contacts +func ListContactsWithDefaultOffsetAndLimitDefaultLimitIs20() { + contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN")) + rsp, err := contactService.List(&contact.ListRequest{ + + }) + fmt.Println(rsp, err) + +} +``` +## List + +List contacts + + +[https://m3o.com/contact/api#List](https://m3o.com/contact/api#List) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/contact" +) + +// List contacts +func ListContactsWithSpecificOffsetAndLimit() { + contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN")) + rsp, err := contactService.List(&contact.ListRequest{ + Limit: 1, +Offset: 1, + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/crypto/README.md b/examples/crypto/README.md index ceb1de4..6434fc3 100755 --- a/examples/crypto/README.md +++ b/examples/crypto/README.md @@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/crypto/api](ht Endpoints: +## Quote + +Get the last quote for a given crypto ticker + + +[https://m3o.com/crypto/api#Quote](https://m3o.com/crypto/api#Quote) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/crypto" +) + +// Get the last quote for a given crypto ticker +func GetAcryptocurrencyQuote() { + cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN")) + rsp, err := cryptoService.Quote(&crypto.QuoteRequest{ + Symbol: "BTCUSD", + + }) + fmt.Println(rsp, err) + +} +``` ## History Returns the history for the previous close @@ -88,31 +116,3 @@ func GetCryptocurrencyPrice() { } ``` -## Quote - -Get the last quote for a given crypto ticker - - -[https://m3o.com/crypto/api#Quote](https://m3o.com/crypto/api#Quote) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/crypto" -) - -// Get the last quote for a given crypto ticker -func GetAcryptocurrencyQuote() { - cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN")) - rsp, err := cryptoService.Quote(&crypto.QuoteRequest{ - Symbol: "BTCUSD", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/db/README.md b/examples/db/README.md index d0a6e18..6d06432 100755 --- a/examples/db/README.md +++ b/examples/db/README.md @@ -26,10 +26,10 @@ func CreateArecord() { dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) rsp, err := dbService.Create(&db.CreateRequest{ Record: map[string]interface{}{ - "name": "Jane", "age": 42, "isActive": true, "id": "1", + "name": "Jane", }, Table: "example", @@ -67,12 +67,12 @@ Table: "example", } ``` -## Delete +## Truncate -Delete a record in the database by id. +Truncate the records in a table -[https://m3o.com/db/api#Delete](https://m3o.com/db/api#Delete) +[https://m3o.com/db/api#Truncate](https://m3o.com/db/api#Truncate) ```go package example @@ -84,12 +84,39 @@ import( "go.m3o.com/db" ) -// Delete a record in the database by id. -func DeleteArecord() { +// Truncate the records in a table +func TruncateTable() { dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) - rsp, err := dbService.Delete(&db.DeleteRequest{ - Id: "1", -Table: "example", + rsp, err := dbService.Truncate(&db.TruncateRequest{ + Table: "example", + + }) + fmt.Println(rsp, err) + +} +``` +## DropTable + +Drop a table in the DB + + +[https://m3o.com/db/api#DropTable](https://m3o.com/db/api#DropTable) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/db" +) + +// Drop a table in the DB +func DropTable() { + dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) + rsp, err := dbService.DropTable(&db.DropTableRequest{ + Table: "example", }) fmt.Println(rsp, err) @@ -156,12 +183,12 @@ Table: "example", } ``` -## Truncate +## Delete -Truncate the records in a table +Delete a record in the database by id. -[https://m3o.com/db/api#Truncate](https://m3o.com/db/api#Truncate) +[https://m3o.com/db/api#Delete](https://m3o.com/db/api#Delete) ```go package example @@ -173,39 +200,12 @@ import( "go.m3o.com/db" ) -// Truncate the records in a table -func TruncateTable() { +// Delete a record in the database by id. +func DeleteArecord() { dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) - rsp, err := dbService.Truncate(&db.TruncateRequest{ - Table: "example", - - }) - fmt.Println(rsp, err) - -} -``` -## DropTable - -Drop a table in the DB - - -[https://m3o.com/db/api#DropTable](https://m3o.com/db/api#DropTable) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/db" -) - -// Drop a table in the DB -func DropTable() { - dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) - rsp, err := dbService.DropTable(&db.DropTableRequest{ - Table: "example", + rsp, err := dbService.Delete(&db.DeleteRequest{ + Id: "1", +Table: "example", }) fmt.Println(rsp, err) diff --git a/examples/db/create/createARecord/main.go b/examples/db/create/createARecord/main.go index 0e113b7..f258334 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{}{ - "isActive": true, "id": "1", "name": "Jane", "age": 42, + "isActive": true, }, Table: "example", }) diff --git a/examples/db/update/updateARecord/main.go b/examples/db/update/updateARecord/main.go index f14eea3..79984e8 100755 --- a/examples/db/update/updateARecord/main.go +++ b/examples/db/update/updateARecord/main.go @@ -12,8 +12,8 @@ func main() { dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) rsp, err := dbService.Update(&db.UpdateRequest{ Record: map[string]interface{}{ - "id": "1", "age": 43, + "id": "1", }, Table: "example", }) diff --git a/examples/emoji/README.md b/examples/emoji/README.md index dc735fb..9eb6bad 100755 --- a/examples/emoji/README.md +++ b/examples/emoji/README.md @@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/emoji/api](htt Endpoints: -## Find - -Find an emoji by its alias e.g :beer: - - -[https://m3o.com/emoji/api#Find](https://m3o.com/emoji/api#Find) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/emoji" -) - -// Find an emoji by its alias e.g :beer: -func FindEmoji() { - emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN")) - rsp, err := emojiService.Find(&emoji.FindRequest{ - Alias: ":beer:", - - }) - fmt.Println(rsp, err) - -} -``` ## Flag Get the flag for a country. Requires country code e.g GB for great britain @@ -89,3 +61,31 @@ func PrintTextIncludingEmoji() { } ``` +## Find + +Find an emoji by its alias e.g :beer: + + +[https://m3o.com/emoji/api#Find](https://m3o.com/emoji/api#Find) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/emoji" +) + +// Find an emoji by its alias e.g :beer: +func FindEmoji() { + emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN")) + rsp, err := emojiService.Find(&emoji.FindRequest{ + Alias: ":beer:", + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/evchargers/README.md b/examples/evchargers/README.md index 176565e..7e1c9b6 100755 --- a/examples/evchargers/README.md +++ b/examples/evchargers/README.md @@ -4,33 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/evchargers/api Endpoints: -## ReferenceData - -Retrieve reference data as used by this API and in conjunction with the Search endpoint - - -[https://m3o.com/evchargers/api#ReferenceData](https://m3o.com/evchargers/api#ReferenceData) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/evchargers" -) - -// Retrieve reference data as used by this API and in conjunction with the Search endpoint -func GetReferenceData() { - evchargersService := evchargers.NewEvchargersService(os.Getenv("M3O_API_TOKEN")) - rsp, err := evchargersService.ReferenceData(&evchargers.ReferenceDataRequest{ - - }) - fmt.Println(rsp, err) - -} -``` ## Search Search by giving a coordinate and a max distance, or bounding box and optional filters @@ -125,3 +98,30 @@ Location: &evchargers.Coordinates{ } ``` +## ReferenceData + +Retrieve reference data as used by this API and in conjunction with the Search endpoint + + +[https://m3o.com/evchargers/api#ReferenceData](https://m3o.com/evchargers/api#ReferenceData) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/evchargers" +) + +// Retrieve reference data as used by this API and in conjunction with the Search endpoint +func GetReferenceData() { + evchargersService := evchargers.NewEvchargersService(os.Getenv("M3O_API_TOKEN")) + rsp, err := evchargersService.ReferenceData(&evchargers.ReferenceDataRequest{ + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/event/README.md b/examples/event/README.md index 0a33d30..c8f6f43 100755 --- a/examples/event/README.md +++ b/examples/event/README.md @@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/event/api](htt Endpoints: -## Read - -Read stored events - - -[https://m3o.com/event/api#Read](https://m3o.com/event/api#Read) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/event" -) - -// Read stored events -func ReadEventsOnAtopic() { - eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN")) - rsp, err := eventService.Read(&event.ReadRequest{ - Topic: "user", - - }) - fmt.Println(rsp, err) - -} -``` ## Publish Publish a event to the event stream. @@ -106,3 +78,31 @@ func ConsumeFromAtopic() { } } ``` +## Read + +Read stored events + + +[https://m3o.com/event/api#Read](https://m3o.com/event/api#Read) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/event" +) + +// Read stored events +func ReadEventsOnAtopic() { + eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN")) + rsp, err := eventService.Read(&event.ReadRequest{ + Topic: "user", + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/file/README.md b/examples/file/README.md index 7435de8..bd236f7 100755 --- a/examples/file/README.md +++ b/examples/file/README.md @@ -4,6 +4,38 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/file/api](http Endpoints: +## Save + +Save a file + + +[https://m3o.com/file/api#Save](https://m3o.com/file/api#Save) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/file" +) + +// Save a file +func SaveFile() { + fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN")) + rsp, err := fileService.Save(&file.SaveRequest{ + File: &file.Record{ + Content: "file content example", + Path: "/document/text-files/file.txt", + Project: "examples", + }, + + }) + fmt.Println(rsp, err) + +} +``` ## List List files by their project and optionally a path. @@ -90,35 +122,3 @@ Project: "examples", } ``` -## Save - -Save a file - - -[https://m3o.com/file/api#Save](https://m3o.com/file/api#Save) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/file" -) - -// Save a file -func SaveFile() { - fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN")) - rsp, err := fileService.Save(&file.SaveRequest{ - File: &file.Record{ - Content: "file content example", - 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 5e91d93..b17d0ad 100755 --- a/examples/function/README.md +++ b/examples/function/README.md @@ -4,68 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/function/api]( Endpoints: -## 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 - -Deploy a group of functions - - -[https://m3o.com/function/api#Deploy](https://m3o.com/function/api#Deploy) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/function" -) - -// Deploy a group of functions -func DeployAfunction() { - functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) - rsp, err := functionService.Deploy(&function.DeployRequest{ - Branch: "main", -Entrypoint: "Helloworld", -Name: "helloworld", -Region: "europe-west1", -Repo: "https://github.com/m3o/m3o", -Runtime: "go116", -Subfolder: "examples/go-function", - - }) - fmt.Println(rsp, err) - -} -``` ## List List all the deployed functions @@ -91,62 +29,6 @@ func ListFunctions() { }) 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) - -} -``` -## 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 @@ -204,12 +86,12 @@ func ReserveAfunction() { } ``` -## Update +## Deploy -Update a function. Downloads the source, builds and redeploys +Deploy a group of functions -[https://m3o.com/function/api#Update](https://m3o.com/function/api#Update) +[https://m3o.com/function/api#Deploy](https://m3o.com/function/api#Deploy) ```go package example @@ -221,11 +103,17 @@ import( "go.m3o.com/function" ) -// Update a function. Downloads the source, builds and redeploys -func UpdateAfunction() { +// Deploy a group of functions +func DeployAfunction() { functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) - rsp, err := functionService.Update(&function.UpdateRequest{ - Name: "helloworld", + rsp, err := functionService.Deploy(&function.DeployRequest{ + Branch: "main", +Entrypoint: "Helloworld", +Name: "helloworld", +Region: "europe-west1", +Repo: "https://github.com/m3o/m3o", +Runtime: "go116", +Subfolder: "examples/go-function", }) fmt.Println(rsp, err) @@ -263,3 +151,115 @@ Request: map[string]interface{}{ } ``` +## 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) + +} +``` +## 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) + +} +``` +## Update + +Update a function. Downloads the source, builds and redeploys + + +[https://m3o.com/function/api#Update](https://m3o.com/function/api#Update) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/function" +) + +// Update a function. Downloads the source, builds and redeploys +func UpdateAfunction() { + functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) + rsp, err := functionService.Update(&function.UpdateRequest{ + Name: "helloworld", + + }) + fmt.Println(rsp, err) + +} +``` +## Delete + +Delete a function by name + + +[https://m3o.com/function/api#Delete](https://m3o.com/function/api#Delete) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/function" +) + +// Delete a function by name +func DeleteAfunction() { + functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) + rsp, err := functionService.Delete(&function.DeleteRequest{ + Name: "helloworld", + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/geocoding/README.md b/examples/geocoding/README.md index ffc18bb..b29fb43 100755 --- a/examples/geocoding/README.md +++ b/examples/geocoding/README.md @@ -4,6 +4,35 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/geocoding/api] Endpoints: +## Reverse + +Reverse lookup an address from gps coordinates + + +[https://m3o.com/geocoding/api#Reverse](https://m3o.com/geocoding/api#Reverse) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/geocoding" +) + +// Reverse lookup an address from gps coordinates +func ReverseGeocodeLocation() { + geocodingService := geocoding.NewGeocodingService(os.Getenv("M3O_API_TOKEN")) + rsp, err := geocodingService.Reverse(&geocoding.ReverseRequest{ + Latitude: 51.5123064, +Longitude: -0.1216235, + + }) + fmt.Println(rsp, err) + +} +``` ## Lookup Lookup returns a geocoded address including normalized address and gps coordinates. All fields are optional, provide more to get more accurate results @@ -35,32 +64,3 @@ Postcode: "wc2b", } ``` -## Reverse - -Reverse lookup an address from gps coordinates - - -[https://m3o.com/geocoding/api#Reverse](https://m3o.com/geocoding/api#Reverse) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/geocoding" -) - -// Reverse lookup an address from gps coordinates -func ReverseGeocodeLocation() { - geocodingService := geocoding.NewGeocodingService(os.Getenv("M3O_API_TOKEN")) - rsp, err := geocodingService.Reverse(&geocoding.ReverseRequest{ - Latitude: 51.5123064, -Longitude: -0.1216235, - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/id/README.md b/examples/id/README.md index eb26228..8013667 100755 --- a/examples/id/README.md +++ b/examples/id/README.md @@ -4,6 +4,33 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/id/api](https: Endpoints: +## Types + +List the types of IDs available. No query params needed. + + +[https://m3o.com/id/api#Types](https://m3o.com/id/api#Types) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/id" +) + +// List the types of IDs available. No query params needed. +func ListTheTypesOfIdsAvailable() { + idService := id.NewIdService(os.Getenv("M3O_API_TOKEN")) + rsp, err := idService.Types(&id.TypesRequest{ + + }) + fmt.Println(rsp, err) + +} +``` ## Generate Generate a unique ID. Defaults to uuid. @@ -116,30 +143,3 @@ func GenerateAbigflakeId() { } ``` -## Types - -List the types of IDs available. No query params needed. - - -[https://m3o.com/id/api#Types](https://m3o.com/id/api#Types) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/id" -) - -// List the types of IDs available. No query params needed. -func ListTheTypesOfIdsAvailable() { - idService := id.NewIdService(os.Getenv("M3O_API_TOKEN")) - rsp, err := idService.Types(&id.TypesRequest{ - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/lists/README.md b/examples/lists/README.md index da20dd4..4e35e62 100755 --- a/examples/lists/README.md +++ b/examples/lists/README.md @@ -4,6 +4,91 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/lists/api](htt Endpoints: +## List + +List all the lists + + +[https://m3o.com/lists/api#List](https://m3o.com/lists/api#List) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/lists" +) + +// List all the lists +func ListAllLists() { + listsService := lists.NewListsService(os.Getenv("M3O_API_TOKEN")) + rsp, err := listsService.List(&lists.ListRequest{ + + }) + fmt.Println(rsp, err) + +} +``` +## Update + +Update a list + + +[https://m3o.com/lists/api#Update](https://m3o.com/lists/api#Update) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/lists" +) + +// Update a list +func UpdateAlist() { + listsService := lists.NewListsService(os.Getenv("M3O_API_TOKEN")) + rsp, err := listsService.Update(&lists.UpdateRequest{ + List: &lists.List{ + Id: "63c0cdf8-2121-11ec-a881-0242e36f037a", + }, + + }) + fmt.Println(rsp, err) + +} +``` +## Delete + +Delete a list + + +[https://m3o.com/lists/api#Delete](https://m3o.com/lists/api#Delete) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/lists" +) + +// Delete a list +func DeleteAlist() { + listsService := lists.NewListsService(os.Getenv("M3O_API_TOKEN")) + rsp, err := listsService.Delete(&lists.DeleteRequest{ + Id: "63c0cdf8-2121-11ec-a881-0242e36f037a", + + }) + fmt.Println(rsp, err) + +} +``` ## Events Subscribe to lists events @@ -100,88 +185,3 @@ func ReadAlist() { } ``` -## List - -List all the lists - - -[https://m3o.com/lists/api#List](https://m3o.com/lists/api#List) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/lists" -) - -// List all the lists -func ListAllLists() { - listsService := lists.NewListsService(os.Getenv("M3O_API_TOKEN")) - rsp, err := listsService.List(&lists.ListRequest{ - - }) - fmt.Println(rsp, err) - -} -``` -## Update - -Update a list - - -[https://m3o.com/lists/api#Update](https://m3o.com/lists/api#Update) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/lists" -) - -// Update a list -func UpdateAlist() { - listsService := lists.NewListsService(os.Getenv("M3O_API_TOKEN")) - rsp, err := listsService.Update(&lists.UpdateRequest{ - List: &lists.List{ - Id: "63c0cdf8-2121-11ec-a881-0242e36f037a", - }, - - }) - fmt.Println(rsp, err) - -} -``` -## Delete - -Delete a list - - -[https://m3o.com/lists/api#Delete](https://m3o.com/lists/api#Delete) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/lists" -) - -// Delete a list -func DeleteAlist() { - listsService := lists.NewListsService(os.Getenv("M3O_API_TOKEN")) - rsp, err := listsService.Delete(&lists.DeleteRequest{ - Id: "63c0cdf8-2121-11ec-a881-0242e36f037a", - - }) - 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 9ae06b4..fd01a20 100755 --- a/examples/nft/README.md +++ b/examples/nft/README.md @@ -4,35 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/nft/api](https Endpoints: -## Create - -Create your own NFT (coming soon) - - -[https://m3o.com/nft/api#Create](https://m3o.com/nft/api#Create) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/nft" -) - -// Create your own NFT (coming soon) -func CreateAnNft() { - nftService := nft.NewNftService(os.Getenv("M3O_API_TOKEN")) - rsp, err := nftService.Create(&nft.CreateRequest{ - Description: "The epic monkey island character", -Name: "Guybrush Threepwood", - - }) - fmt.Println(rsp, err) - -} -``` ## Collections Get a list of collections @@ -89,3 +60,32 @@ func GetAlistOfAssets() { } ``` +## Create + +Create your own NFT (coming soon) + + +[https://m3o.com/nft/api#Create](https://m3o.com/nft/api#Create) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/nft" +) + +// Create your own NFT (coming soon) +func CreateAnNft() { + nftService := nft.NewNftService(os.Getenv("M3O_API_TOKEN")) + rsp, err := nftService.Create(&nft.CreateRequest{ + Description: "The epic monkey island character", +Name: "Guybrush Threepwood", + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/ping/README.md b/examples/ping/README.md index c07dd30..f7db414 100755 --- a/examples/ping/README.md +++ b/examples/ping/README.md @@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/ping/api](http Endpoints: +## Tcp + +Ping a TCP port is open + + +[https://m3o.com/ping/api#Tcp](https://m3o.com/ping/api#Tcp) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/ping" +) + +// Ping a TCP port is open +func DialAtcpAddress() { + pingService := ping.NewPingService(os.Getenv("M3O_API_TOKEN")) + rsp, err := pingService.Tcp(&ping.TcpRequest{ + Address: "google.com:80", + + }) + fmt.Println(rsp, err) + +} +``` ## Url Ping a HTTP URL @@ -60,31 +88,3 @@ func PingAnIp() { } ``` -## Tcp - -Ping a TCP port is open - - -[https://m3o.com/ping/api#Tcp](https://m3o.com/ping/api#Tcp) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/ping" -) - -// Ping a TCP port is open -func DialAtcpAddress() { - pingService := ping.NewPingService(os.Getenv("M3O_API_TOKEN")) - rsp, err := pingService.Tcp(&ping.TcpRequest{ - Address: "google.com:80", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/search/README.md b/examples/search/README.md index 451c712..f430826 100755 --- a/examples/search/README.md +++ b/examples/search/README.md @@ -4,6 +4,93 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/search/api](ht Endpoints: +## Search + +Search for records in a given in index + + +[https://m3o.com/search/api#Search](https://m3o.com/search/api#Search) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/search" +) + +// Search for records in a given in index +func SearchForArecord() { + searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN")) + rsp, err := searchService.Search(&search.SearchRequest{ + Index: "customers", +Query: "name == 'John'", + + }) + fmt.Println(rsp, err) + +} +``` +## Search + +Search for records in a given in index + + +[https://m3o.com/search/api#Search](https://m3o.com/search/api#Search) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/search" +) + +// Search for records in a given in index +func SearchOnMultipleFieldsand() { + searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN")) + rsp, err := searchService.Search(&search.SearchRequest{ + Index: "customers", +Query: "name == 'John' AND starsign == 'Leo'", + + }) + fmt.Println(rsp, err) + +} +``` +## Search + +Search for records in a given in index + + +[https://m3o.com/search/api#Search](https://m3o.com/search/api#Search) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/search" +) + +// Search for records in a given in index +func SearchOnMultipleFieldsor() { + searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN")) + rsp, err := searchService.Search(&search.SearchRequest{ + Index: "customers", +Query: "name == 'John' OR name == 'Jane'", + + }) + fmt.Println(rsp, err) + +} +``` ## Delete Delete a record given its ID @@ -111,9 +198,9 @@ func IndexArecord() { searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN")) rsp, err := searchService.Index(&search.IndexRequest{ Data: map[string]interface{}{ - "age": 37, "starsign": "Leo", "name": "John Doe", + "age": 37, }, Index: "customers", @@ -122,90 +209,3 @@ Index: "customers", } ``` -## Search - -Search for records in a given in index - - -[https://m3o.com/search/api#Search](https://m3o.com/search/api#Search) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/search" -) - -// Search for records in a given in index -func SearchForArecord() { - searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN")) - rsp, err := searchService.Search(&search.SearchRequest{ - Index: "customers", -Query: "name == 'John'", - - }) - fmt.Println(rsp, err) - -} -``` -## Search - -Search for records in a given in index - - -[https://m3o.com/search/api#Search](https://m3o.com/search/api#Search) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/search" -) - -// Search for records in a given in index -func SearchOnMultipleFieldsand() { - searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN")) - rsp, err := searchService.Search(&search.SearchRequest{ - Index: "customers", -Query: "name == 'John' AND starsign == 'Leo'", - - }) - fmt.Println(rsp, err) - -} -``` -## Search - -Search for records in a given in index - - -[https://m3o.com/search/api#Search](https://m3o.com/search/api#Search) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/search" -) - -// Search for records in a given in index -func SearchOnMultipleFieldsor() { - searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN")) - rsp, err := searchService.Search(&search.SearchRequest{ - Index: "customers", -Query: "name == 'John' OR name == 'Jane'", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/space/README.md b/examples/space/README.md index caa0bf5..a3418ba 100755 --- a/examples/space/README.md +++ b/examples/space/README.md @@ -4,6 +4,90 @@ 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 + + +[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 @@ -148,87 +232,3 @@ 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) - -} -``` -## 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/stock/README.md b/examples/stock/README.md index 0d497b8..83cd80a 100755 --- a/examples/stock/README.md +++ b/examples/stock/README.md @@ -4,62 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/stock/api](htt Endpoints: -## Price - -Get the last price for a given stock ticker - - -[https://m3o.com/stock/api#Price](https://m3o.com/stock/api#Price) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/stock" -) - -// Get the last price for a given stock ticker -func GetAstockPrice() { - stockService := stock.NewStockService(os.Getenv("M3O_API_TOKEN")) - rsp, err := stockService.Price(&stock.PriceRequest{ - Symbol: "AAPL", - - }) - fmt.Println(rsp, err) - -} -``` -## Quote - -Get the last quote for the stock - - -[https://m3o.com/stock/api#Quote](https://m3o.com/stock/api#Quote) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/stock" -) - -// Get the last quote for the stock -func GetAstockQuote() { - stockService := stock.NewStockService(os.Getenv("M3O_API_TOKEN")) - rsp, err := stockService.Quote(&stock.QuoteRequest{ - Symbol: "AAPL", - - }) - fmt.Println(rsp, err) - -} -``` ## History Get the historic open-close for a given day @@ -121,3 +65,59 @@ Stock: "AAPL", } ``` +## Price + +Get the last price for a given stock ticker + + +[https://m3o.com/stock/api#Price](https://m3o.com/stock/api#Price) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/stock" +) + +// Get the last price for a given stock ticker +func GetAstockPrice() { + stockService := stock.NewStockService(os.Getenv("M3O_API_TOKEN")) + rsp, err := stockService.Price(&stock.PriceRequest{ + Symbol: "AAPL", + + }) + fmt.Println(rsp, err) + +} +``` +## Quote + +Get the last quote for the stock + + +[https://m3o.com/stock/api#Quote](https://m3o.com/stock/api#Quote) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/stock" +) + +// Get the last quote for the stock +func GetAstockQuote() { + stockService := stock.NewStockService(os.Getenv("M3O_API_TOKEN")) + rsp, err := stockService.Quote(&stock.QuoteRequest{ + Symbol: "AAPL", + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/stream/README.md b/examples/stream/README.md index 232026e..11fa9f3 100755 --- a/examples/stream/README.md +++ b/examples/stream/README.md @@ -4,37 +4,6 @@ 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. @@ -119,3 +88,34 @@ 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/url/README.md b/examples/url/README.md index ec670c0..24bd71a 100755 --- a/examples/url/README.md +++ b/examples/url/README.md @@ -4,33 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/url/api](https Endpoints: -## List - -List all the shortened URLs - - -[https://m3o.com/url/api#List](https://m3o.com/url/api#List) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/url" -) - -// List all the shortened URLs -func ListYourShortenedUrls() { - urlService := url.NewUrlService(os.Getenv("M3O_API_TOKEN")) - rsp, err := urlService.List(&url.ListRequest{ - - }) - fmt.Println(rsp, err) - -} -``` ## Shorten Shorten a long URL @@ -85,3 +58,30 @@ func ResolveAshortUrlToAlongDestinationUrl() { } ``` +## List + +List all the shortened URLs + + +[https://m3o.com/url/api#List](https://m3o.com/url/api#List) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/url" +) + +// List all the shortened URLs +func ListYourShortenedUrls() { + urlService := url.NewUrlService(os.Getenv("M3O_API_TOKEN")) + rsp, err := urlService.List(&url.ListRequest{ + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/user/README.md b/examples/user/README.md index 7f1071c..37b4b16 100755 --- a/examples/user/README.md +++ b/examples/user/README.md @@ -33,360 +33,6 @@ Username: "joe", }) fmt.Println(rsp, err) -} -``` -## Update - -Update the account username or email - - -[https://m3o.com/user/api#Update](https://m3o.com/user/api#Update) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/user" -) - -// Update the account username or email -func UpdateAnAccount() { - userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.Update(&user.UpdateRequest{ - Email: "joe+2@example.com", -Id: "user-1", -Username: "joe", - - }) - fmt.Println(rsp, err) - -} -``` -## UpdatePassword - -Update the account password - - -[https://m3o.com/user/api#UpdatePassword](https://m3o.com/user/api#UpdatePassword) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/user" -) - -// Update the account password -func UpdateTheAccountPassword() { - userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.UpdatePassword(&user.UpdatePasswordRequest{ - ConfirmPassword: "Password2", -NewPassword: "Password2", -OldPassword: "Password1", -UserId: "user-1", - - }) - fmt.Println(rsp, err) - -} -``` -## 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) - -} -``` -## SendVerificationEmail - -Send a verification email to a user. -Email "from" will be 'noreply@email.m3ocontent.com'. -The verification link will be injected in the email -as a template variable, $micro_verification_link e.g -'Welcome to M3O! Use the link below to verify your email: $micro_verification_link' -The variable will be replaced with a url similar to: -'https://user.m3o.com/user/verify?token=a-verification-token&redirectUrl=your-redir-url' - - -[https://m3o.com/user/api#SendVerificationEmail](https://m3o.com/user/api#SendVerificationEmail) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/user" -) - -// Send a verification email to a user. -// Email "from" will be 'noreply@email.m3ocontent.com'. -// The verification link will be injected in the email -// as a template variable, $micro_verification_link e.g -// 'Welcome to M3O! Use the link below to verify your email: $micro_verification_link' -// The variable will be replaced with a url similar to: -// 'https://user.m3o.com/user/verify?token=a-verification-token&redirectUrl=your-redir-url' -func SendVerificationEmail() { - userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.SendVerificationEmail(&user.SendVerificationEmailRequest{ - Email: "joe@example.com", -FailureRedirectUrl: "https://m3o.com/verification-failed", -FromName: "Awesome Dot Com", -RedirectUrl: "https://m3o.com", -Subject: "Email verification", -TextContent: `Hi there, - -Please verify your email by clicking this link: $micro_verification_link`, - - }) - fmt.Println(rsp, err) - -} -``` -## VerifyEmail - -Verify the email address of an account from a token sent in an email to the user. - - -[https://m3o.com/user/api#VerifyEmail](https://m3o.com/user/api#VerifyEmail) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/user" -) - -// Verify the email address of an account from a token sent in an email to the user. -func VerifyEmail() { - userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.VerifyEmail(&user.VerifyEmailRequest{ - Token: "012345", - - }) - fmt.Println(rsp, err) - -} -``` -## 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) - -} -``` -## ResetPassword - -Reset password with the code sent by the "SendPasswordResetEmail" endpoint. - - -[https://m3o.com/user/api#ResetPassword](https://m3o.com/user/api#ResetPassword) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/user" -) - -// Reset password with the code sent by the "SendPasswordResetEmail" endpoint. -func ResetPassword() { - userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.ResetPassword(&user.ResetPasswordRequest{ - Code: "012345", -ConfirmPassword: "NewPassword1", -Email: "joe@example.com", -NewPassword: "NewPassword1", - - }) - fmt.Println(rsp, err) - -} -``` -## Delete - -Delete an account by id - - -[https://m3o.com/user/api#Delete](https://m3o.com/user/api#Delete) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/user" -) - -// Delete an account by id -func DeleteUserAccount() { - userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.Delete(&user.DeleteRequest{ - Id: "8b98acbe-0b6a-4d66-a414-5ffbf666786f", - - }) - fmt.Println(rsp, err) - -} -``` -## ReadSession - -Read a session by the session id. In the event it has expired or is not found and error is returned. - - -[https://m3o.com/user/api#ReadSession](https://m3o.com/user/api#ReadSession) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/user" -) - -// Read a session by the session id. In the event it has expired or is not found and error is returned. -func ReadAsessionByTheSessionId() { - userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.ReadSession(&user.ReadSessionRequest{ - SessionId: "df91a612-5b24-4634-99ff-240220ab8f55", - - }) - fmt.Println(rsp, err) - -} -``` -## SendMagicLink - -Login using email only - Passwordless - - -[https://m3o.com/user/api#SendMagicLink](https://m3o.com/user/api#SendMagicLink) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/user" -) - -// Login using email only - Passwordless -func SendAmagicLink() { - userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.SendMagicLink(&user.SendMagicLinkRequest{ - Address: "www.example.com", -Email: "joe@example.com", -Endpoint: "verifytoken", -FromName: "Awesome Dot Com", -Subject: "MagicLink to access your account", -TextContent: `Hi there, - -Click here to access your account $micro_verification_link`, - - }) - fmt.Println(rsp, err) - -} -``` -## VerifyToken - -Check whether the token attached to MagicLink is valid or not. -Ideally, you need to call this endpoint from your http request -handler that handles the endpoint which is specified in the -SendMagicLink request. - - -[https://m3o.com/user/api#VerifyToken](https://m3o.com/user/api#VerifyToken) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/user" -) - -// Check whether the token attached to MagicLink is valid or not. -// Ideally, you need to call this endpoint from your http request -// handler that handles the endpoint which is specified in the -// SendMagicLink request. -func VerifyAtoken() { - userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.VerifyToken(&user.VerifyTokenRequest{ - Token: "EdsUiidouJJJLldjlloofUiorkojflsWWdld", - - }) - fmt.Println(rsp, err) - } ``` ## Read @@ -473,13 +119,13 @@ func ReadAccountByEmail() { } ``` -## Login +## SendPasswordResetEmail -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 +Send an email with a verification code to reset password. +Call "ResetPassword" endpoint once user provides the code. -[https://m3o.com/user/api#Login](https://m3o.com/user/api#Login) +[https://m3o.com/user/api#SendPasswordResetEmail](https://m3o.com/user/api#SendPasswordResetEmail) ```go package example @@ -491,13 +137,241 @@ 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() { +// 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.Login(&user.LoginRequest{ + rsp, err := userService.SendPasswordResetEmail(&user.SendPasswordResetEmailRequest{ Email: "joe@example.com", -Password: "Password1", +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) + +} +``` +## Logout + +Logout a user account + + +[https://m3o.com/user/api#Logout](https://m3o.com/user/api#Logout) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Logout a user account +func LogAuserOut() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.Logout(&user.LogoutRequest{ + SessionId: "df91a612-5b24-4634-99ff-240220ab8f55", + + }) + fmt.Println(rsp, err) + +} +``` +## SendMagicLink + +Login using email only - Passwordless + + +[https://m3o.com/user/api#SendMagicLink](https://m3o.com/user/api#SendMagicLink) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Login using email only - Passwordless +func SendAmagicLink() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.SendMagicLink(&user.SendMagicLinkRequest{ + Address: "www.example.com", +Email: "joe@example.com", +Endpoint: "verifytoken", +FromName: "Awesome Dot Com", +Subject: "MagicLink to access your account", +TextContent: `Hi there, + +Click here to access your account $micro_verification_link`, + + }) + fmt.Println(rsp, err) + +} +``` +## SendVerificationEmail + +Send a verification email to a user. +Email "from" will be 'noreply@email.m3ocontent.com'. +The verification link will be injected in the email +as a template variable, $micro_verification_link e.g +'Welcome to M3O! Use the link below to verify your email: $micro_verification_link' +The variable will be replaced with a url similar to: +'https://user.m3o.com/user/verify?token=a-verification-token&redirectUrl=your-redir-url' + + +[https://m3o.com/user/api#SendVerificationEmail](https://m3o.com/user/api#SendVerificationEmail) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Send a verification email to a user. +// Email "from" will be 'noreply@email.m3ocontent.com'. +// The verification link will be injected in the email +// as a template variable, $micro_verification_link e.g +// 'Welcome to M3O! Use the link below to verify your email: $micro_verification_link' +// The variable will be replaced with a url similar to: +// 'https://user.m3o.com/user/verify?token=a-verification-token&redirectUrl=your-redir-url' +func SendVerificationEmail() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.SendVerificationEmail(&user.SendVerificationEmailRequest{ + Email: "joe@example.com", +FailureRedirectUrl: "https://m3o.com/verification-failed", +FromName: "Awesome Dot Com", +RedirectUrl: "https://m3o.com", +Subject: "Email verification", +TextContent: `Hi there, + +Please verify your email by clicking this link: $micro_verification_link`, + + }) + fmt.Println(rsp, err) + +} +``` +## 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) + +} +``` +## 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) + +} +``` +## 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) @@ -533,3 +407,129 @@ Offset: 0, } ``` +## Update + +Update the account username or email + + +[https://m3o.com/user/api#Update](https://m3o.com/user/api#Update) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Update the account username or email +func UpdateAnAccount() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.Update(&user.UpdateRequest{ + Email: "joe+2@example.com", +Id: "user-1", +Username: "joe", + + }) + fmt.Println(rsp, err) + +} +``` +## UpdatePassword + +Update the account password + + +[https://m3o.com/user/api#UpdatePassword](https://m3o.com/user/api#UpdatePassword) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Update the account password +func UpdateTheAccountPassword() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.UpdatePassword(&user.UpdatePasswordRequest{ + ConfirmPassword: "Password2", +NewPassword: "Password2", +OldPassword: "Password1", +UserId: "user-1", + + }) + fmt.Println(rsp, err) + +} +``` +## Login + +Login using username or email. The response will return a new session for successful login, +401 in the case of login failure and 500 for any other error + + +[https://m3o.com/user/api#Login](https://m3o.com/user/api#Login) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Login using username or email. The response will return a new session for successful login, +// 401 in the case of login failure and 500 for any other error +func LogAuserIn() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.Login(&user.LoginRequest{ + Email: "joe@example.com", +Password: "Password1", + + }) + fmt.Println(rsp, err) + +} +``` +## VerifyToken + +Check whether the token attached to MagicLink is valid or not. +Ideally, you need to call this endpoint from your http request +handler that handles the endpoint which is specified in the +SendMagicLink request. + + +[https://m3o.com/user/api#VerifyToken](https://m3o.com/user/api#VerifyToken) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Check whether the token attached to MagicLink is valid or not. +// Ideally, you need to call this endpoint from your http request +// handler that handles the endpoint which is specified in the +// SendMagicLink request. +func VerifyAtoken() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.VerifyToken(&user.VerifyTokenRequest{ + Token: "EdsUiidouJJJLldjlloofUiorkojflsWWdld", + + }) + fmt.Println(rsp, err) + +} +```