From 99dd48cf660814fe2dbcc9f135c7c48d8e6148e2 Mon Sep 17 00:00:00 2001 From: m3o-actions <> Date: Fri, 10 Dec 2021 15:30:19 +0000 Subject: [PATCH] Commit from m3o/m3o action --- examples/cache/README.md | 58 +- examples/crypto/README.md | 56 +- examples/currency/README.md | 58 +- examples/db/README.md | 76 +- examples/db/create/createARecord/main.go | 2 +- examples/emoji/README.md | 110 +-- examples/evchargers/README.md | 54 +- examples/event/README.md | 84 +-- examples/event/publish/publishAnEvent/main.go | 2 +- examples/file/README.md | 58 +- examples/location/README.md | 68 +- examples/postcode/README.md | 56 +- examples/quran/README.md | 56 +- examples/routing/README.md | 70 +- examples/rss/README.md | 110 +-- examples/space/README.md | 96 ++- examples/space/upload/uploadAnObject/main.go | 17 + examples/stock/README.md | 56 +- examples/stream/README.md | 110 +-- examples/user/README.md | 714 +++++++++--------- space/space.go | 19 + 21 files changed, 997 insertions(+), 933 deletions(-) create mode 100755 examples/space/upload/uploadAnObject/main.go diff --git a/examples/cache/README.md b/examples/cache/README.md index 44097c1..5229fee 100755 --- a/examples/cache/README.md +++ b/examples/cache/README.md @@ -4,35 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Cache/api](htt Endpoints: -## Set - -Set an item in the cache. Overwrites any existing value already set. - - -[https://m3o.com/cache/api#Set](https://m3o.com/cache/api#Set) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/cache" -) - -// Set an item in the cache. Overwrites any existing value already set. -func SetAvalue() { - cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN")) - rsp, err := cacheService.Set(&cache.SetRequest{ - Key: "foo", -Value: "bar", - - }) - fmt.Println(rsp, err) - -} -``` ## Get Get an item from the cache by key. If key is not found, an empty response is returned. @@ -147,3 +118,32 @@ Value: 2, } ``` +## Set + +Set an item in the cache. Overwrites any existing value already set. + + +[https://m3o.com/cache/api#Set](https://m3o.com/cache/api#Set) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/cache" +) + +// Set an item in the cache. Overwrites any existing value already set. +func SetAvalue() { + cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN")) + rsp, err := cacheService.Set(&cache.SetRequest{ + Key: "foo", +Value: "bar", + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/crypto/README.md b/examples/crypto/README.md index 40c1322..b836e92 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: +## News + +Get news related to a currency + + +[https://m3o.com/crypto/api#News](https://m3o.com/crypto/api#News) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/crypto" +) + +// Get news related to a currency +func GetCryptocurrencyNews() { + cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN")) + rsp, err := cryptoService.News(&crypto.NewsRequest{ + Symbol: "BTCUSD", + + }) + fmt.Println(rsp, err) + +} +``` ## Price Get the last price for a given crypto ticker @@ -88,31 +116,3 @@ func GetPreviousClose() { } ``` -## News - -Get news related to a currency - - -[https://m3o.com/crypto/api#News](https://m3o.com/crypto/api#News) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/crypto" -) - -// Get news related to a currency -func GetCryptocurrencyNews() { - cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN")) - rsp, err := cryptoService.News(&crypto.NewsRequest{ - Symbol: "BTCUSD", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/currency/README.md b/examples/currency/README.md index 773caf3..65a799d 100755 --- a/examples/currency/README.md +++ b/examples/currency/README.md @@ -4,35 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Currency/api]( Endpoints: -## History - -Returns the historic rates for a currency on a given date - - -[https://m3o.com/currency/api#History](https://m3o.com/currency/api#History) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/currency" -) - -// Returns the historic rates for a currency on a given date -func HistoricRatesForAcurrency() { - currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN")) - rsp, err := currencyService.History(¤cy.HistoryRequest{ - Code: "USD", -Date: "2021-05-30", - - }) - fmt.Println(rsp, err) - -} -``` ## Codes Codes returns the supported currency codes for the API @@ -147,3 +118,32 @@ To: "GBP", } ``` +## History + +Returns the historic rates for a currency on a given date + + +[https://m3o.com/currency/api#History](https://m3o.com/currency/api#History) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/currency" +) + +// Returns the historic rates for a currency on a given date +func HistoricRatesForAcurrency() { + currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN")) + rsp, err := currencyService.History(¤cy.HistoryRequest{ + Code: "USD", +Date: "2021-05-30", + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/db/README.md b/examples/db/README.md index 0dd76af..0adaf15 100755 --- a/examples/db/README.md +++ b/examples/db/README.md @@ -36,12 +36,12 @@ Table: "example", } ``` -## Read +## Delete -Read data from a table. Lookup can be by ID or via querying any field in the record. +Delete a record in the database by id. -[https://m3o.com/db/api#Read](https://m3o.com/db/api#Read) +[https://m3o.com/db/api#Delete](https://m3o.com/db/api#Delete) ```go package example @@ -53,11 +53,11 @@ import( "go.m3o.com/db" ) -// Read data from a table. Lookup can be by ID or via querying any field in the record. -func ReadRecords() { +// Delete a record in the database by id. +func DeleteArecord() { dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) - rsp, err := dbService.Read(&db.ReadRequest{ - Query: "age == 43", + rsp, err := dbService.Delete(&db.DeleteRequest{ + Id: "1", Table: "example", }) @@ -171,16 +171,45 @@ 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", + "age": 42, }, Table: "example", }) fmt.Println(rsp, err) +} +``` +## Read + +Read data from a table. Lookup can be by ID or via querying any field in the record. + + +[https://m3o.com/db/api#Read](https://m3o.com/db/api#Read) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/db" +) + +// Read data from a table. Lookup can be by ID or via querying any field in the record. +func ReadRecords() { + dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) + rsp, err := dbService.Read(&db.ReadRequest{ + Query: "age == 43", +Table: "example", + + }) + fmt.Println(rsp, err) + } ``` ## Truncate @@ -239,32 +268,3 @@ func DropTable() { } ``` -## Delete - -Delete a record in the database by id. - - -[https://m3o.com/db/api#Delete](https://m3o.com/db/api#Delete) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/db" -) - -// Delete a record in the database by id. -func DeleteArecord() { - dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) - rsp, err := dbService.Delete(&db.DeleteRequest{ - Id: "1", -Table: "example", - - }) - fmt.Println(rsp, err) - -} -``` 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/emoji/README.md b/examples/emoji/README.md index d2a4c7f..272d9a9 100755 --- a/examples/emoji/README.md +++ b/examples/emoji/README.md @@ -4,61 +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 - - -[https://m3o.com/emoji/api#Flag](https://m3o.com/emoji/api#Flag) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/emoji" -) - -// Get the flag for a country. Requires country code e.g GB for great britain -func GetFlagByCountryCode() { - emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN")) - rsp, err := emojiService.Flag(&emoji.FlagRequest{ - - }) - fmt.Println(rsp, err) - -} -``` ## Print Print text and renders the emojis with aliases e.g @@ -119,3 +64,58 @@ To: "+44782669123", } ``` +## 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 + + +[https://m3o.com/emoji/api#Flag](https://m3o.com/emoji/api#Flag) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/emoji" +) + +// Get the flag for a country. Requires country code e.g GB for great britain +func GetFlagByCountryCode() { + emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN")) + rsp, err := emojiService.Flag(&emoji.FlagRequest{ + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/evchargers/README.md b/examples/evchargers/README.md index 5aa9e11..335b9e3 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 a01a4f0..6e5247f 100755 --- a/examples/event/README.md +++ b/examples/event/README.md @@ -4,6 +4,47 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Event/api](htt Endpoints: +## Consume + +Consume events from a given topic. + + +[https://m3o.com/event/api#Consume](https://m3o.com/event/api#Consume) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/event" +) + +// Consume events from a given topic. +func ConsumeFromAtopic() { + eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN")) + + stream, err := eventService.Consume(&event.ConsumeRequest{ + Topic: "user", + + }) + if err != nil { + fmt.Println(err) + return + } + + for { + rsp, err := stream.Recv() + if err != nil { + fmt.Println(err) + return + } + + fmt.Println(rsp) + } +} +``` ## Read Read stored events @@ -54,9 +95,9 @@ func PublishAnEvent() { eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN")) rsp, err := eventService.Publish(&event.PublishRequest{ Message: map[string]interface{}{ - "id": "1", "type": "signup", "user": "john", + "id": "1", }, Topic: "user", @@ -65,44 +106,3 @@ Topic: "user", } ``` -## Consume - -Consume events from a given topic. - - -[https://m3o.com/event/api#Consume](https://m3o.com/event/api#Consume) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/event" -) - -// Consume events from a given topic. -func ConsumeFromAtopic() { - eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN")) - - stream, err := eventService.Consume(&event.ConsumeRequest{ - Topic: "user", - - }) - if err != nil { - fmt.Println(err) - return - } - - for { - rsp, err := stream.Recv() - if err != nil { - fmt.Println(err) - return - } - - fmt.Println(rsp) - } -} -``` diff --git a/examples/event/publish/publishAnEvent/main.go b/examples/event/publish/publishAnEvent/main.go index 5c63360..287af64 100755 --- a/examples/event/publish/publishAnEvent/main.go +++ b/examples/event/publish/publishAnEvent/main.go @@ -12,9 +12,9 @@ func main() { eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN")) rsp, err := eventService.Publish(&event.PublishRequest{ Message: map[string]interface{}{ + "id": "1", "type": "signup", "user": "john", - "id": "1", }, Topic: "user", }) diff --git a/examples/file/README.md b/examples/file/README.md index 058aedb..6b3ff5e 100755 --- a/examples/file/README.md +++ b/examples/file/README.md @@ -4,35 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/File/api](http Endpoints: -## Read - -Read a file by path - - -[https://m3o.com/file/api#Read](https://m3o.com/file/api#Read) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/file" -) - -// Read a file by path -func ReadFile() { - fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN")) - rsp, err := fileService.Read(&file.ReadRequest{ - Path: "/document/text-files/file.txt", -Project: "examples", - - }) - fmt.Println(rsp, err) - -} -``` ## Save Save a file @@ -122,3 +93,32 @@ Project: "examples", } ``` +## Read + +Read a file by path + + +[https://m3o.com/file/api#Read](https://m3o.com/file/api#Read) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/file" +) + +// Read a file by path +func ReadFile() { + fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN")) + rsp, err := fileService.Read(&file.ReadRequest{ + Path: "/document/text-files/file.txt", +Project: "examples", + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/location/README.md b/examples/location/README.md index 83046bb..08459be 100755 --- a/examples/location/README.md +++ b/examples/location/README.md @@ -4,6 +4,40 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Location/api]( Endpoints: +## Search + +Search for entities in a given radius + + +[https://m3o.com/location/api#Search](https://m3o.com/location/api#Search) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/location" +) + +// Search for entities in a given radius +func SearchForLocations() { + locationService := location.NewLocationService(os.Getenv("M3O_API_TOKEN")) + rsp, err := locationService.Search(&location.SearchRequest{ + Center: &location.Point{ + Latitude: 51.511061, + Longitude: -0.120022, + }, +NumEntities: 10, +Radius: 100, +Type: "bike", + + }) + fmt.Println(rsp, err) + +} +``` ## Save Save an entity's current position @@ -68,37 +102,3 @@ func GetLocationById() { } ``` -## Search - -Search for entities in a given radius - - -[https://m3o.com/location/api#Search](https://m3o.com/location/api#Search) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/location" -) - -// Search for entities in a given radius -func SearchForLocations() { - locationService := location.NewLocationService(os.Getenv("M3O_API_TOKEN")) - rsp, err := locationService.Search(&location.SearchRequest{ - Center: &location.Point{ - Latitude: 51.511061, - Longitude: -0.120022, - }, -NumEntities: 10, -Radius: 100, -Type: "bike", - - }) - 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/quran/README.md b/examples/quran/README.md index 5f43d60..03a059b 100755 --- a/examples/quran/README.md +++ b/examples/quran/README.md @@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Quran/api](htt Endpoints: -## Search - -Search the Quran for any form of query or questions - - -[https://m3o.com/quran/api#Search](https://m3o.com/quran/api#Search) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/quran" -) - -// Search the Quran for any form of query or questions -func SearchTheQuran() { - quranService := quran.NewQuranService(os.Getenv("M3O_API_TOKEN")) - rsp, err := quranService.Search(&quran.SearchRequest{ - Query: "messenger", - - }) - fmt.Println(rsp, err) - -} -``` ## Chapters List the Chapters (surahs) of the Quran @@ -120,3 +92,31 @@ func GetVersesOfAchapter() { } ``` +## Search + +Search the Quran for any form of query or questions + + +[https://m3o.com/quran/api#Search](https://m3o.com/quran/api#Search) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/quran" +) + +// Search the Quran for any form of query or questions +func SearchTheQuran() { + quranService := quran.NewQuranService(os.Getenv("M3O_API_TOKEN")) + rsp, err := quranService.Search(&quran.SearchRequest{ + Query: "messenger", + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/routing/README.md b/examples/routing/README.md index bd394b1..b7f4d07 100755 --- a/examples/routing/README.md +++ b/examples/routing/README.md @@ -4,6 +4,41 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Routing/api](h Endpoints: +## Route + +Retrieve a route as a simple list of gps points along with total distance and estimated duration + + +[https://m3o.com/routing/api#Route](https://m3o.com/routing/api#Route) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/routing" +) + +// Retrieve a route as a simple list of gps points along with total distance and estimated duration +func GpsPointsForAroute() { + routingService := routing.NewRoutingService(os.Getenv("M3O_API_TOKEN")) + rsp, err := routingService.Route(&routing.RouteRequest{ + Destination: &routing.Point{ + Latitude: 52.529407, + Longitude: 13.397634, +}, +Origin: &routing.Point{ + Latitude: 52.517037, + Longitude: 13.38886, +}, + + }) + fmt.Println(rsp, err) + +} +``` ## Eta Get the eta for a route from origin to destination. The eta is an estimated time based on car routes @@ -74,38 +109,3 @@ Origin: &routing.Point{ } ``` -## Route - -Retrieve a route as a simple list of gps points along with total distance and estimated duration - - -[https://m3o.com/routing/api#Route](https://m3o.com/routing/api#Route) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/routing" -) - -// Retrieve a route as a simple list of gps points along with total distance and estimated duration -func GpsPointsForAroute() { - routingService := routing.NewRoutingService(os.Getenv("M3O_API_TOKEN")) - rsp, err := routingService.Route(&routing.RouteRequest{ - Destination: &routing.Point{ - Latitude: 52.529407, - Longitude: 13.397634, -}, -Origin: &routing.Point{ - Latitude: 52.517037, - Longitude: 13.38886, -}, - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/rss/README.md b/examples/rss/README.md index 62d0224..bde5033 100755 --- a/examples/rss/README.md +++ b/examples/rss/README.md @@ -4,6 +4,61 @@ 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 @@ -62,58 +117,3 @@ 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/space/README.md b/examples/space/README.md index c370713..268302c 100755 --- a/examples/space/README.md +++ b/examples/space/README.md @@ -4,40 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Space/api](htt Endpoints: -## Update - -Update an object. If an object with this name does not exist, creates a new one. -You need to send the request as a multipart/form-data rather than the usual application/json -with each parameter as a form field. - - -[https://m3o.com/space/api#Update](https://m3o.com/space/api#Update) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/space" -) - -// Update an object. If an object with this name does not exist, creates a new one. -// You need to send the request as a multipart/form-data rather than the usual application/json -// with each parameter as a form field. -func UpdateAnObject() { - spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN")) - rsp, err := spaceService.Update(&space.UpdateRequest{ - Name: "images/file.jpg", -Object: "", -Visibility: "public", - - }) - fmt.Println(rsp, err) - -} -``` ## Delete Delete an object from space @@ -176,6 +142,34 @@ func DownloadAnObject() { }) fmt.Println(rsp, err) +} +``` +## Upload + +Upload a large object. Returns a time limited presigned URL to be used for uploading the object + + +[https://m3o.com/space/api#Upload](https://m3o.com/space/api#Upload) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/space" +) + +// Upload a large object. Returns a time limited presigned URL to be used for uploading the object +func UploadAnObject() { + spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN")) + rsp, err := spaceService.Upload(&space.UploadRequest{ + Name: "images/file.jpg", + + }) + fmt.Println(rsp, err) + } ``` ## Create @@ -212,3 +206,37 @@ Visibility: "public", } ``` +## Update + +Update an object. If an object with this name does not exist, creates a new one. +You need to send the request as a multipart/form-data rather than the usual application/json +with each parameter as a form field. + + +[https://m3o.com/space/api#Update](https://m3o.com/space/api#Update) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/space" +) + +// Update an object. If an object with this name does not exist, creates a new one. +// You need to send the request as a multipart/form-data rather than the usual application/json +// with each parameter as a form field. +func UpdateAnObject() { + spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN")) + rsp, err := spaceService.Update(&space.UpdateRequest{ + Name: "images/file.jpg", +Object: "", +Visibility: "public", + + }) + fmt.Println(rsp, err) + +} +``` diff --git a/examples/space/upload/uploadAnObject/main.go b/examples/space/upload/uploadAnObject/main.go new file mode 100755 index 0000000..09dfabf --- /dev/null +++ b/examples/space/upload/uploadAnObject/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/space" +) + +// Upload a large object. Returns a time limited presigned URL to be used for uploading the object +func main() { + spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN")) + rsp, err := spaceService.Upload(&space.UploadRequest{ + Name: "images/file.jpg", + }) + fmt.Println(rsp, err) +} diff --git a/examples/stock/README.md b/examples/stock/README.md index b627a34..3090684 100755 --- a/examples/stock/README.md +++ b/examples/stock/README.md @@ -4,34 +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 @@ -121,3 +93,31 @@ 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) + +} +``` diff --git a/examples/stream/README.md b/examples/stream/README.md index 08f1f1a..0fd96c4 100755 --- a/examples/stream/README.md +++ b/examples/stream/README.md @@ -4,6 +4,61 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Stream/api](ht Endpoints: +## ListMessages + +List messages for a given channel + + +[https://m3o.com/stream/api#ListMessages](https://m3o.com/stream/api#ListMessages) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/stream" +) + +// List messages for a given channel +func ListMessages() { + streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN")) + rsp, err := streamService.ListMessages(&stream.ListMessagesRequest{ + Channel: "general", + + }) + fmt.Println(rsp, err) + +} +``` +## ListChannels + +List all the active channels + + +[https://m3o.com/stream/api#ListChannels](https://m3o.com/stream/api#ListChannels) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/stream" +) + +// List all the active channels +func ListChannels() { + streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN")) + rsp, err := streamService.ListChannels(&stream.ListChannelsRequest{ + + }) + fmt.Println(rsp, err) + +} +``` ## CreateChannel Create a channel with a given name and description. Channels are created automatically but @@ -64,58 +119,3 @@ Text: "Hey checkout this tweet https://twitter.com/m3oservices/status/1455291054 } ``` -## ListMessages - -List messages for a given channel - - -[https://m3o.com/stream/api#ListMessages](https://m3o.com/stream/api#ListMessages) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/stream" -) - -// List messages for a given channel -func ListMessages() { - streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN")) - rsp, err := streamService.ListMessages(&stream.ListMessagesRequest{ - Channel: "general", - - }) - fmt.Println(rsp, err) - -} -``` -## ListChannels - -List all the active channels - - -[https://m3o.com/stream/api#ListChannels](https://m3o.com/stream/api#ListChannels) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/stream" -) - -// List all the active channels -func ListChannels() { - streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN")) - rsp, err := streamService.ListChannels(&stream.ListChannelsRequest{ - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/examples/user/README.md b/examples/user/README.md index 83911ff..2e7f833 100755 --- a/examples/user/README.md +++ b/examples/user/README.md @@ -4,6 +4,280 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/User/api](http Endpoints: +## 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) + +} +``` +## 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) + +} +``` +## List + +List all users. Returns a paged list of results + + +[https://m3o.com/user/api#List](https://m3o.com/user/api#List) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/user" +) + +// List all users. Returns a paged list of results +func ListAllUsers() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.List(&user.ListRequest{ + Limit: 100, +Offset: 0, + + }) + fmt.Println(rsp, err) + +} +``` +## 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) + +} +``` +## Logout + +Logout a user account + + +[https://m3o.com/user/api#Logout](https://m3o.com/user/api#Logout) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Logout a user account +func LogAuserOut() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.Logout(&user.LogoutRequest{ + SessionId: "df91a612-5b24-4634-99ff-240220ab8f55", + + }) + fmt.Println(rsp, err) + +} +``` +## ReadSession + +Read a session by the session id. In the event it has expired or is not found and error is returned. + + +[https://m3o.com/user/api#ReadSession](https://m3o.com/user/api#ReadSession) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Read a session by the session id. In the event it has expired or is not found and error is returned. +func ReadAsessionByTheSessionId() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.ReadSession(&user.ReadSessionRequest{ + SessionId: "df91a612-5b24-4634-99ff-240220ab8f55", + + }) + fmt.Println(rsp, err) + +} +``` +## Update + +Update the account username or email + + +[https://m3o.com/user/api#Update](https://m3o.com/user/api#Update) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Update the account username or email +func UpdateAnAccount() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.Update(&user.UpdateRequest{ + Email: "joe+2@example.com", +Id: "user-1", + + }) + 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) + +} +``` ## Read Read an account by id, username or email. Only one need to be specified. @@ -86,6 +360,53 @@ func ReadAccountByEmail() { }) 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{ + 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 @@ -119,12 +440,12 @@ NewPassword: "NewPassword1", } ``` -## Logout +## VerifyEmail -Logout a user account +Verify the email address of an account from a token sent in an email to the user. -[https://m3o.com/user/api#Logout](https://m3o.com/user/api#Logout) +[https://m3o.com/user/api#VerifyEmail](https://m3o.com/user/api#VerifyEmail) ```go package example @@ -136,11 +457,40 @@ import( "go.m3o.com/user" ) -// Logout a user account -func LogAuserOut() { +// 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.Logout(&user.LogoutRequest{ - SessionId: "df91a612-5b24-4634-99ff-240220ab8f55", + 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) @@ -195,353 +545,3 @@ Click here to access your account $micro_verification_link`, } } ``` -## 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) - -} -``` -## 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) - -} -``` -## 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) - -} -``` -## List - -List all users. Returns a paged list of results - - -[https://m3o.com/user/api#List](https://m3o.com/user/api#List) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/user" -) - -// List all users. Returns a paged list of results -func ListAllUsers() { - userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.List(&user.ListRequest{ - Limit: 100, -Offset: 0, - - }) - fmt.Println(rsp, err) - -} -``` -## VerifyToken - -Check whether the token attached to MagicLink is valid or not. -Ideally, you need to call this endpoint from your http request -handler that handles the endpoint which is specified in the -SendMagicLink request. - - -[https://m3o.com/user/api#VerifyToken](https://m3o.com/user/api#VerifyToken) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/user" -) - -// Check whether the token attached to MagicLink is valid or not. -// Ideally, you need to call this endpoint from your http request -// handler that handles the endpoint which is specified in the -// SendMagicLink request. -func VerifyAtoken() { - userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) - rsp, err := userService.VerifyToken(&user.VerifyTokenRequest{ - Token: "EdsUiidouJJJLldjlloofUiorkojflsWWdld", - - }) - fmt.Println(rsp, err) - -} -``` -## 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) - -} -``` -## 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) - -} -``` -## 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) - -} -``` -## 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{ - 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{ - Email: "joe@example.com", -Token: "012345", - - }) - fmt.Println(rsp, err) - -} -``` diff --git a/space/space.go b/space/space.go index c3e1586..865542c 100755 --- a/space/space.go +++ b/space/space.go @@ -76,6 +76,14 @@ func (t *SpaceService) Update(request *UpdateRequest) (*UpdateResponse, error) { } +// Upload a large object. Returns a time limited presigned URL to be used for uploading the object +func (t *SpaceService) Upload(request *UploadRequest) (*UploadResponse, error) { + + rsp := &UploadResponse{} + return rsp, t.client.Call("space", "Upload", request, rsp) + +} + type CreateRequest struct { // The name of the object. Use forward slash delimiter to implement a nested directory-like structure e.g. images/foo.jpg Name string `json:"name"` @@ -185,3 +193,14 @@ type UpdateResponse struct { // A public URL to access the object if visibility is "public" Url string `json:"url"` } + +type UploadRequest struct { + Name string `json:"name"` + // is this object public or private + Visibility string `json:"visibility"` +} + +type UploadResponse struct { + // a presigned url to be used for uploading + Url string `json:"url"` +}