diff --git a/examples/cache/README.md b/examples/cache/README.md index 03c0009..8d61626 100755 --- a/examples/cache/README.md +++ b/examples/cache/README.md @@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Cache/api](htt Endpoints: -## Delete - -Delete a value from the cache. If key not found a success response is returned. - - -[https://m3o.com/cache/api#Delete](https://m3o.com/cache/api#Delete) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/cache" -) - -// Delete a value from the cache. If key not found a success response is returned. -func DeleteAvalue() { - cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN")) - rsp, err := cacheService.Delete(&cache.DeleteRequest{ - Key: "foo", - - }) - fmt.Println(rsp, err) - -} -``` ## Increment Increment a value (if it's a number). If key not found it is equivalent to set. @@ -147,3 +119,31 @@ func GetAvalue() { } ``` +## Delete + +Delete a value from the cache. If key not found a success response is returned. + + +[https://m3o.com/cache/api#Delete](https://m3o.com/cache/api#Delete) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/cache" +) + +// Delete a value from the cache. If key not found a success response is returned. +func DeleteAvalue() { + cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN")) + rsp, err := cacheService.Delete(&cache.DeleteRequest{ + Key: "foo", + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/db/README.md b/examples/db/README.md index 748d685..9cc0d69 100755 --- a/examples/db/README.md +++ b/examples/db/README.md @@ -4,124 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Db/api](https: Endpoints: -## Create - -Create a record in the database. Optionally include an "id" field otherwise it's set automatically. - - -[https://m3o.com/db/api#Create](https://m3o.com/db/api#Create) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/db" -) - -// Create a record in the database. Optionally include an "id" field otherwise it's set automatically. -func CreateArecord() { - dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) - rsp, err := dbService.Create(&db.CreateRequest{ - Record: map[string]interface{}{ - "id": "1", - "name": "Jane", - "age": 42, - "isActive": true, -}, -Table: "users", - - }) - 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: "users", - - }) - 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: "users", - - }) - fmt.Println(rsp, err) - -} -``` -## Count - -Count records in a table - - -[https://m3o.com/db/api#Count](https://m3o.com/db/api#Count) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/db" -) - -// Count records in a table -func CountEntriesInAtable() { - dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) - rsp, err := dbService.Count(&db.CountRequest{ - Table: "users", - - }) - fmt.Println(rsp, err) - -} -``` ## RenameTable Rename a table @@ -149,38 +31,6 @@ To: "events_backup", }) 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: "users", - - }) - fmt.Println(rsp, err) - } ``` ## Read @@ -239,6 +89,62 @@ Table: "users", }) 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: "users", + + }) + fmt.Println(rsp, err) + +} +``` +## Count + +Count records in a table + + +[https://m3o.com/db/api#Count](https://m3o.com/db/api#Count) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/db" +) + +// Count records in a table +func CountEntriesInAtable() { + dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) + rsp, err := dbService.Count(&db.CountRequest{ + Table: "users", + + }) + fmt.Println(rsp, err) + } ``` ## ListTables @@ -268,3 +174,97 @@ func ListTables() { } ``` +## Create + +Create a record in the database. Optionally include an "id" field otherwise it's set automatically. + + +[https://m3o.com/db/api#Create](https://m3o.com/db/api#Create) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/db" +) + +// Create a record in the database. Optionally include an "id" field otherwise it's set automatically. +func CreateArecord() { + dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) + rsp, err := dbService.Create(&db.CreateRequest{ + Record: map[string]interface{}{ + "id": "1", + "name": "Jane", + "age": 42, + "isActive": true, +}, +Table: "users", + + }) + 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: "users", + + }) + 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: "users", + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/db/create/createARecord/main.go b/examples/db/create/createARecord/main.go index 81f6b1b..886de82 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: "users", }) diff --git a/examples/emoji/README.md b/examples/emoji/README.md index d2a4c7f..f4b291f 100755 --- a/examples/emoji/README.md +++ b/examples/emoji/README.md @@ -4,6 +4,36 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Emoji/api](htt Endpoints: +## Send + +Send an emoji to anyone via SMS. Messages are sent in the form ' Sent from ' + + +[https://m3o.com/emoji/api#Send](https://m3o.com/emoji/api#Send) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/emoji" +) + +// Send an emoji to anyone via SMS. Messages are sent in the form ' Sent from ' +func SendAtextContainingAnEmojiToAnyoneViaSms() { + emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN")) + rsp, err := emojiService.Send(&emoji.SendRequest{ + From: "Alice", +Message: "let's grab a :beer:", +To: "+44782669123", + + }) + fmt.Println(rsp, err) + +} +``` ## Find Find an emoji by its alias e.g :beer: @@ -89,33 +119,3 @@ func PrintTextIncludingEmoji() { } ``` -## Send - -Send an emoji to anyone via SMS. Messages are sent in the form ' Sent from ' - - -[https://m3o.com/emoji/api#Send](https://m3o.com/emoji/api#Send) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/emoji" -) - -// Send an emoji to anyone via SMS. Messages are sent in the form ' Sent from ' -func SendAtextContainingAnEmojiToAnyoneViaSms() { - emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN")) - rsp, err := emojiService.Send(&emoji.SendRequest{ - From: "Alice", -Message: "let's grab a :beer:", -To: "+44782669123", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/evchargers/README.md b/examples/evchargers/README.md index 335b9e3..5aa9e11 100755 --- a/examples/evchargers/README.md +++ b/examples/evchargers/README.md @@ -4,6 +4,33 @@ 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 @@ -98,30 +125,3 @@ 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/forex/README.md b/examples/forex/README.md index 0a103c1..076f73a 100755 --- a/examples/forex/README.md +++ b/examples/forex/README.md @@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Forex/api](htt Endpoints: +## Price + +Get the latest price for a given forex ticker + + +[https://m3o.com/forex/api#Price](https://m3o.com/forex/api#Price) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/forex" +) + +// Get the latest price for a given forex ticker +func GetAnFxPrice() { + forexService := forex.NewForexService(os.Getenv("M3O_API_TOKEN")) + rsp, err := forexService.Price(&forex.PriceRequest{ + Symbol: "GBPUSD", + + }) + fmt.Println(rsp, err) + +} +``` ## Quote Get the latest quote for the forex @@ -60,31 +88,3 @@ func GetPreviousClose() { } ``` -## Price - -Get the latest price for a given forex ticker - - -[https://m3o.com/forex/api#Price](https://m3o.com/forex/api#Price) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/forex" -) - -// Get the latest price for a given forex ticker -func GetAnFxPrice() { - forexService := forex.NewForexService(os.Getenv("M3O_API_TOKEN")) - rsp, err := forexService.Price(&forex.PriceRequest{ - Symbol: "GBPUSD", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/function/README.md b/examples/function/README.md index 0889d21..deadd9a 100755 --- a/examples/function/README.md +++ b/examples/function/README.md @@ -4,6 +4,64 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Function/api]( Endpoints: +## 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: "my-first-func", +Project: "tests", + + }) + 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: "my-first-func", +Project: "tests", + + }) + fmt.Println(rsp, err) + +} +``` ## Deploy Deploy a group of functions @@ -93,61 +151,3 @@ func ListFunctions() { } ``` -## 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: "my-first-func", -Project: "tests", - - }) - 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: "my-first-func", -Project: "tests", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/holidays/README.md b/examples/holidays/README.md index c0b9f00..22e8fcd 100755 --- a/examples/holidays/README.md +++ b/examples/holidays/README.md @@ -4,33 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Holidays/api]( Endpoints: -## Countries - -Get the list of countries that are supported by this API - - -[https://m3o.com/holidays/api#Countries](https://m3o.com/holidays/api#Countries) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/holidays" -) - -// Get the list of countries that are supported by this API -func ListCountries() { - holidaysService := holidays.NewHolidaysService(os.Getenv("M3O_API_TOKEN")) - rsp, err := holidaysService.Countries(&holidays.CountriesRequest{ - - }) - fmt.Println(rsp, err) - -} -``` ## List List the holiday dates for a given country and year @@ -59,3 +32,30 @@ func GetHolidays() { } ``` +## Countries + +Get the list of countries that are supported by this API + + +[https://m3o.com/holidays/api#Countries](https://m3o.com/holidays/api#Countries) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/holidays" +) + +// Get the list of countries that are supported by this API +func ListCountries() { + holidaysService := holidays.NewHolidaysService(os.Getenv("M3O_API_TOKEN")) + rsp, err := holidaysService.Countries(&holidays.CountriesRequest{ + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/location/README.md b/examples/location/README.md index 83046bb..9d51b7a 100755 --- a/examples/location/README.md +++ b/examples/location/README.md @@ -4,42 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Location/api]( Endpoints: -## Save - -Save an entity's current position - - -[https://m3o.com/location/api#Save](https://m3o.com/location/api#Save) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/location" -) - -// Save an entity's current position -func SaveAnEntity() { - locationService := location.NewLocationService(os.Getenv("M3O_API_TOKEN")) - rsp, err := locationService.Save(&location.SaveRequest{ - Entity: &location.Entity{ - Id: "1", - Location: &location.Point{ - Latitude: 51.511061, - Longitude: -0.120022, - Timestamp: 1622802761, -}, - Type: "bike", -}, - - }) - fmt.Println(rsp, err) - -} -``` ## Read Read an entity by its ID @@ -102,3 +66,39 @@ Type: "bike", } ``` +## Save + +Save an entity's current position + + +[https://m3o.com/location/api#Save](https://m3o.com/location/api#Save) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/location" +) + +// Save an entity's current position +func SaveAnEntity() { + locationService := location.NewLocationService(os.Getenv("M3O_API_TOKEN")) + rsp, err := locationService.Save(&location.SaveRequest{ + Entity: &location.Entity{ + Id: "1", + Location: &location.Point{ + Latitude: 51.511061, + Longitude: -0.120022, + Timestamp: 1622802761, +}, + Type: "bike", +}, + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/mq/README.md b/examples/mq/README.md index 10f108b..8153f1c 100755 --- a/examples/mq/README.md +++ b/examples/mq/README.md @@ -26,9 +26,9 @@ func PublishAmessage() { mqService := mq.NewMqService(os.Getenv("M3O_API_TOKEN")) rsp, err := mqService.Publish(&mq.PublishRequest{ Message: map[string]interface{}{ - "id": "1", "type": "signup", "user": "john", + "id": "1", }, Topic: "events", diff --git a/examples/nft/README.md b/examples/nft/README.md new file mode 100755 index 0000000..885d934 --- /dev/null +++ b/examples/nft/README.md @@ -0,0 +1,34 @@ +# Nft + +An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Nft/api](https://m3o.com/Nft/api). + +Endpoints: + +## Vote + +Vote to have the NFT api launched faster! + + +[https://m3o.com/nft/api#Vote](https://m3o.com/nft/api#Vote) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/nft" +) + +// Vote to have the NFT api launched faster! +func VoteForTheApi() { + nftService := nft.NewNftService(os.Getenv("M3O_API_TOKEN")) + rsp, err := nftService.Vote(&nft.VoteRequest{ + Message: "Launch it!", + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/nft/vote/voteForTheApi/main.go b/examples/nft/vote/voteForTheApi/main.go new file mode 100755 index 0000000..ecb89b9 --- /dev/null +++ b/examples/nft/vote/voteForTheApi/main.go @@ -0,0 +1,18 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/nft" +) + +// Vote to have the NFT api launched faster! +func main() { + nftService := nft.NewNftService(os.Getenv("M3O_API_TOKEN")) + rsp, err := nftService.Vote(&nft.VoteRequest{ + Message: "Launch it!", + }) + fmt.Println(rsp, err) + +} diff --git a/examples/postcode/README.md b/examples/postcode/README.md index cccb09a..0ce5559 100755 --- a/examples/postcode/README.md +++ b/examples/postcode/README.md @@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Postcode/api]( Endpoints: +## Validate + +Validate a postcode. + + +[https://m3o.com/postcode/api#Validate](https://m3o.com/postcode/api#Validate) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/postcode" +) + +// Validate a postcode. +func ReturnArandomPostcodeAndItsInformation() { + postcodeService := postcode.NewPostcodeService(os.Getenv("M3O_API_TOKEN")) + rsp, err := postcodeService.Validate(&postcode.ValidateRequest{ + Postcode: "SW1A 2AA", + + }) + fmt.Println(rsp, err) + +} +``` ## Lookup Lookup a postcode to retrieve the related region, county, etc @@ -59,31 +87,3 @@ func ReturnArandomPostcodeAndItsInformation() { } ``` -## Validate - -Validate a postcode. - - -[https://m3o.com/postcode/api#Validate](https://m3o.com/postcode/api#Validate) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/postcode" -) - -// Validate a postcode. -func ReturnArandomPostcodeAndItsInformation() { - postcodeService := postcode.NewPostcodeService(os.Getenv("M3O_API_TOKEN")) - rsp, err := postcodeService.Validate(&postcode.ValidateRequest{ - Postcode: "SW1A 2AA", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/rss/README.md b/examples/rss/README.md index bde5033..62d0224 100755 --- a/examples/rss/README.md +++ b/examples/rss/README.md @@ -4,61 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Rss/api](https Endpoints: -## List - -List the saved RSS fields - - -[https://m3o.com/rss/api#List](https://m3o.com/rss/api#List) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/rss" -) - -// List the saved RSS fields -func ListRssFeeds() { - rssService := rss.NewRssService(os.Getenv("M3O_API_TOKEN")) - rsp, err := rssService.List(&rss.ListRequest{ - - }) - fmt.Println(rsp, err) - -} -``` -## 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 @@ -117,3 +62,58 @@ func ReadAfeed() { } ``` +## List + +List the saved RSS fields + + +[https://m3o.com/rss/api#List](https://m3o.com/rss/api#List) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/rss" +) + +// List the saved RSS fields +func ListRssFeeds() { + rssService := rss.NewRssService(os.Getenv("M3O_API_TOKEN")) + rsp, err := rssService.List(&rss.ListRequest{ + + }) + fmt.Println(rsp, err) + +} +``` +## 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/stock/README.md b/examples/stock/README.md index b627a34..4983276 100755 --- a/examples/stock/README.md +++ b/examples/stock/README.md @@ -4,6 +4,38 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Stock/api](htt Endpoints: +## OrderBook + +Get the historic order book and each trade by timestamp + + +[https://m3o.com/stock/api#OrderBook](https://m3o.com/stock/api#OrderBook) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/stock" +) + +// Get the historic order book and each trade by timestamp +func OrderBookHistory() { + stockService := stock.NewStockService(os.Getenv("M3O_API_TOKEN")) + rsp, err := stockService.OrderBook(&stock.OrderBookRequest{ + Date: "2020-10-01", +End: "2020-10-01T11:00:00Z", +Limit: 3, +Start: "2020-10-01T10:00:00Z", +Stock: "AAPL", + + }) + fmt.Println(rsp, err) + +} +``` ## Price Get the last price for a given stock ticker @@ -89,35 +121,3 @@ Stock: "AAPL", } ``` -## OrderBook - -Get the historic order book and each trade by timestamp - - -[https://m3o.com/stock/api#OrderBook](https://m3o.com/stock/api#OrderBook) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/stock" -) - -// Get the historic order book and each trade by timestamp -func OrderBookHistory() { - stockService := stock.NewStockService(os.Getenv("M3O_API_TOKEN")) - rsp, err := stockService.OrderBook(&stock.OrderBookRequest{ - Date: "2020-10-01", -End: "2020-10-01T11:00:00Z", -Limit: 3, -Start: "2020-10-01T10:00:00Z", -Stock: "AAPL", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/twitter/README.md b/examples/twitter/README.md index fd92920..f11d086 100755 --- a/examples/twitter/README.md +++ b/examples/twitter/README.md @@ -4,6 +4,33 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Twitter/api](h Endpoints: +## Trends + +Get the current global trending topics + + +[https://m3o.com/twitter/api#Trends](https://m3o.com/twitter/api#Trends) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/twitter" +) + +// Get the current global trending topics +func GetTheCurrentGlobalTrendingTopics() { + twitterService := twitter.NewTwitterService(os.Getenv("M3O_API_TOKEN")) + rsp, err := twitterService.Trends(&twitter.TrendsRequest{ + + }) + fmt.Println(rsp, err) + +} +``` ## User Get a user's twitter profile @@ -89,30 +116,3 @@ func SearchForTweets() { } ``` -## Trends - -Get the current global trending topics - - -[https://m3o.com/twitter/api#Trends](https://m3o.com/twitter/api#Trends) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/twitter" -) - -// Get the current global trending topics -func GetTheCurrentGlobalTrendingTopics() { - twitterService := twitter.NewTwitterService(os.Getenv("M3O_API_TOKEN")) - rsp, err := twitterService.Trends(&twitter.TrendsRequest{ - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/user/README.md b/examples/user/README.md index 49bf547..0ca498e 100755 --- a/examples/user/README.md +++ b/examples/user/README.md @@ -4,12 +4,12 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/User/api](http Endpoints: -## UpdatePassword +## Create -Update the account password +Create a new user account. The email address and username for the account must be unique. -[https://m3o.com/user/api#UpdatePassword](https://m3o.com/user/api#UpdatePassword) +[https://m3o.com/user/api#Create](https://m3o.com/user/api#Create) ```go package example @@ -21,72 +21,26 @@ import( "go.m3o.com/user" ) -// Update the account password -func UpdateTheAccountPassword() { +// Create a new user account. The email address and username for the account must be unique. +func CreateAnAccount() { userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.UpdatePassword(&user.UpdatePasswordRequest{ - ConfirmPassword: "Password2", -NewPassword: "Password2", -OldPassword: "Password1", - - }) - fmt.Println(rsp, err) - -} -``` -## SendVerificationEmail - -Send a verification email -to the user being signed up. Email from will be from 'noreply@email.m3ocontent.com', -but you can provide the title and contents. -The verification link will be injected in to the email as a template variable, $micro_verification_link. -Example: 'Hi there, welcome onboard! Use the link below to verify your email: $micro_verification_link' -The variable will be replaced with an actual url that will look similar to this: -'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 the user being signed up. Email from will be from 'noreply@email.m3ocontent.com', -// but you can provide the title and contents. -// The verification link will be injected in to the email as a template variable, $micro_verification_link. -// Example: 'Hi there, welcome onboard! Use the link below to verify your email: $micro_verification_link' -// The variable will be replaced with an actual url that will look similar to this: -// '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{ + rsp, err := userService.Create(&user.CreateRequest{ Email: "joe@example.com", -FailureRedirectUrl: "https://m3o.com/verification-failed", -FromName: "Awesome Dot Com", -RedirectUrl: "https://m3o.com", -Subject: "Email verification", -TextContent: `Hi there, - -Please verify your email by clicking this link: $micro_verification_link`, +Id: "user-1", +Password: "Password1", +Username: "joe", }) fmt.Println(rsp, err) } ``` -## ResetPassword +## Update -Reset password with the code sent by the "SendPasswordResetEmail" endoint. +Update the account username or email -[https://m3o.com/user/api#ResetPassword](https://m3o.com/user/api#ResetPassword) +[https://m3o.com/user/api#Update](https://m3o.com/user/api#Update) ```go package example @@ -98,14 +52,103 @@ import( "go.m3o.com/user" ) -// Reset password with the code sent by the "SendPasswordResetEmail" endoint. -func ResetPassword() { +// Update the account username or email +func UpdateAnAccount() { 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.Update(&user.UpdateRequest{ + Email: "joe+2@example.com", +Id: "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) + +} +``` +## 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{ + Email: "joe@example.com", +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) @@ -169,151 +212,6 @@ func ReadAsessionByTheSessionId() { }) fmt.Println(rsp, err) -} -``` -## Create - -Create a new user account. The email address and username for the account must be unique. - - -[https://m3o.com/user/api#Create](https://m3o.com/user/api#Create) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/user" -) - -// Create a new user account. The email address and username for the account must be unique. -func CreateAnAccount() { - userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.Create(&user.CreateRequest{ - Email: "joe@example.com", -Id: "user-1", -Password: "Password1", -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", - - }) - 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{ - Email: "joe@example.com", -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) - -} -``` -## 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) - } ``` ## List @@ -343,6 +241,36 @@ Offset: 0, }) 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", + + }) + fmt.Println(rsp, err) + } ``` ## Read @@ -429,13 +357,18 @@ func ReadAccountByEmail() { } ``` -## SendPasswordResetEmail +## SendVerificationEmail -Send an email with a verification code to reset password. -Call "ResetPassword" endpoint once user provides the code. +Send a verification email +to the user being signed up. Email from will be from 'noreply@email.m3ocontent.com', +but you can provide the title and contents. +The verification link will be injected in to the email as a template variable, $micro_verification_link. +Example: 'Hi there, welcome onboard! Use the link below to verify your email: $micro_verification_link' +The variable will be replaced with an actual url that will look similar to this: +'https://user.m3o.com/user/verify?token=a-verification-token&redirectUrl=your-redir-url' -[https://m3o.com/user/api#SendPasswordResetEmail](https://m3o.com/user/api#SendPasswordResetEmail) +[https://m3o.com/user/api#SendVerificationEmail](https://m3o.com/user/api#SendVerificationEmail) ```go package example @@ -447,16 +380,83 @@ import( "go.m3o.com/user" ) -// Send an email with a verification code to reset password. -// Call "ResetPassword" endpoint once user provides the code. -func SendPasswordResetEmail() { +// Send a verification email +// to the user being signed up. Email from will be from 'noreply@email.m3ocontent.com', +// but you can provide the title and contents. +// The verification link will be injected in to the email as a template variable, $micro_verification_link. +// Example: 'Hi there, welcome onboard! Use the link below to verify your email: $micro_verification_link' +// The variable will be replaced with an actual url that will look similar to this: +// '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.SendPasswordResetEmail(&user.SendPasswordResetEmailRequest{ + rsp, err := userService.SendVerificationEmail(&user.SendVerificationEmailRequest{ Email: "joe@example.com", +FailureRedirectUrl: "https://m3o.com/verification-failed", FromName: "Awesome Dot Com", -Subject: "Password reset", +RedirectUrl: "https://m3o.com", +Subject: "Email verification", TextContent: `Hi there, - click here to reset your password: myapp.com/reset/code?=$code`, + +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" endoint. + + +[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" endoint. +func ResetPassword() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.ResetPassword(&user.ResetPasswordRequest{ + Code: "012345", +ConfirmPassword: "NewPassword1", +Email: "joe@example.com", +NewPassword: "NewPassword1", + + }) + fmt.Println(rsp, err) + +} +``` +## Logout + +Logout a user account + + +[https://m3o.com/user/api#Logout](https://m3o.com/user/api#Logout) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Logout a user account +func LogAuserOut() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.Logout(&user.LogoutRequest{ + SessionId: "df91a612-5b24-4634-99ff-240220ab8f55", }) fmt.Println(rsp, err) diff --git a/m3o.go b/m3o.go index 5f19863..011c15b 100755 --- a/m3o.go +++ b/m3o.go @@ -26,6 +26,7 @@ import ( "go.m3o.com/location" "go.m3o.com/mq" "go.m3o.com/news" + "go.m3o.com/nft" "go.m3o.com/notes" "go.m3o.com/otp" "go.m3o.com/postcode" @@ -79,6 +80,7 @@ func NewClient(token string) *Client { LocationService: location.NewLocationService(token), MqService: mq.NewMqService(token), NewsService: news.NewNewsService(token), + NftService: nft.NewNftService(token), NotesService: notes.NewNotesService(token), OtpService: otp.NewOtpService(token), PostcodeService: postcode.NewPostcodeService(token), @@ -132,6 +134,7 @@ type Client struct { LocationService *location.LocationService MqService *mq.MqService NewsService *news.NewsService + NftService *nft.NftService NotesService *notes.NotesService OtpService *otp.OtpService PostcodeService *postcode.PostcodeService diff --git a/nft/nft.go b/nft/nft.go new file mode 100755 index 0000000..cbfd109 --- /dev/null +++ b/nft/nft.go @@ -0,0 +1,35 @@ +package nft + +import ( + "go.m3o.com/client" +) + +func NewNftService(token string) *NftService { + return &NftService{ + client: client.NewClient(&client.Options{ + Token: token, + }), + } +} + +type NftService struct { + client *client.Client +} + +// Vote to have the NFT api launched faster! +func (t *NftService) Vote(request *VoteRequest) (*VoteResponse, error) { + + rsp := &VoteResponse{} + return rsp, t.client.Call("nft", "Vote", request, rsp) + +} + +type VoteRequest struct { + // optional message + Message string `json:"message"` +} + +type VoteResponse struct { + // response message + Message string `json:"message"` +}