diff --git a/address/address.go b/address/address.go index 40e4b01..46b7c14 100755 --- a/address/address.go +++ b/address/address.go @@ -18,8 +18,10 @@ type AddressService struct { // Lookup a list of UK addresses by postcode func (t *AddressService) LookupPostcode(request *LookupPostcodeRequest) (*LookupPostcodeResponse, error) { + rsp := &LookupPostcodeResponse{} return rsp, t.client.Call("address", "LookupPostcode", request, rsp) + } type LookupPostcodeRequest struct { diff --git a/answer/answer.go b/answer/answer.go index 9c7a53c..a16eb45 100755 --- a/answer/answer.go +++ b/answer/answer.go @@ -18,8 +18,10 @@ type AnswerService struct { // Ask a question and receive an instant answer func (t *AnswerService) Question(request *QuestionRequest) (*QuestionResponse, error) { + rsp := &QuestionResponse{} return rsp, t.client.Call("answer", "Question", request, rsp) + } type QuestionRequest struct { diff --git a/cache/cache.go b/cache/cache.go index a87ed73..0af1dd0 100755 --- a/cache/cache.go +++ b/cache/cache.go @@ -18,32 +18,42 @@ type CacheService struct { // Decrement a value (if it's a number). If key not found it is equivalent to set. func (t *CacheService) Decrement(request *DecrementRequest) (*DecrementResponse, error) { + rsp := &DecrementResponse{} return rsp, t.client.Call("cache", "Decrement", request, rsp) + } // Delete a value from the cache. If key not found a success response is returned. func (t *CacheService) Delete(request *DeleteRequest) (*DeleteResponse, error) { + rsp := &DeleteResponse{} return rsp, t.client.Call("cache", "Delete", request, rsp) + } // Get an item from the cache by key. If key is not found, an empty response is returned. func (t *CacheService) Get(request *GetRequest) (*GetResponse, error) { + rsp := &GetResponse{} return rsp, t.client.Call("cache", "Get", request, rsp) + } // Increment a value (if it's a number). If key not found it is equivalent to set. func (t *CacheService) Increment(request *IncrementRequest) (*IncrementResponse, error) { + rsp := &IncrementResponse{} return rsp, t.client.Call("cache", "Increment", request, rsp) + } // Set an item in the cache. Overwrites any existing value already set. func (t *CacheService) Set(request *SetRequest) (*SetResponse, error) { + rsp := &SetResponse{} return rsp, t.client.Call("cache", "Set", request, rsp) + } type DecrementRequest struct { diff --git a/crypto/crypto.go b/crypto/crypto.go index cc82cea..b5f04c9 100755 --- a/crypto/crypto.go +++ b/crypto/crypto.go @@ -18,26 +18,34 @@ type CryptoService struct { // Returns the history for the previous close func (t *CryptoService) History(request *HistoryRequest) (*HistoryResponse, error) { + rsp := &HistoryResponse{} return rsp, t.client.Call("crypto", "History", request, rsp) + } // Get news related to a currency func (t *CryptoService) News(request *NewsRequest) (*NewsResponse, error) { + rsp := &NewsResponse{} return rsp, t.client.Call("crypto", "News", request, rsp) + } // Get the last price for a given crypto ticker func (t *CryptoService) Price(request *PriceRequest) (*PriceResponse, error) { + rsp := &PriceResponse{} return rsp, t.client.Call("crypto", "Price", request, rsp) + } // Get the last quote for a given crypto ticker func (t *CryptoService) Quote(request *QuoteRequest) (*QuoteResponse, error) { + rsp := &QuoteResponse{} return rsp, t.client.Call("crypto", "Quote", request, rsp) + } type Article struct { diff --git a/currency/currency.go b/currency/currency.go index db4fea5..60e47e6 100755 --- a/currency/currency.go +++ b/currency/currency.go @@ -18,26 +18,34 @@ type CurrencyService struct { // Codes returns the supported currency codes for the API func (t *CurrencyService) Codes(request *CodesRequest) (*CodesResponse, error) { + rsp := &CodesResponse{} return rsp, t.client.Call("currency", "Codes", request, rsp) + } // Convert returns the currency conversion rate between two pairs e.g USD/GBP func (t *CurrencyService) Convert(request *ConvertRequest) (*ConvertResponse, error) { + rsp := &ConvertResponse{} return rsp, t.client.Call("currency", "Convert", request, rsp) + } // Returns the historic rates for a currency on a given date func (t *CurrencyService) History(request *HistoryRequest) (*HistoryResponse, error) { + rsp := &HistoryResponse{} return rsp, t.client.Call("currency", "History", request, rsp) + } // Rates returns the currency rates for a given code e.g USD func (t *CurrencyService) Rates(request *RatesRequest) (*RatesResponse, error) { + rsp := &RatesResponse{} return rsp, t.client.Call("currency", "Rates", request, rsp) + } type Code struct { diff --git a/db/db.go b/db/db.go index 7c6d9d7..11e419b 100755 --- a/db/db.go +++ b/db/db.go @@ -18,38 +18,50 @@ type DbService struct { // Count records in a table func (t *DbService) Count(request *CountRequest) (*CountResponse, error) { + rsp := &CountResponse{} return rsp, t.client.Call("db", "Count", request, rsp) + } // Create a record in the database. Optionally include an "id" field otherwise it's set automatically. func (t *DbService) Create(request *CreateRequest) (*CreateResponse, error) { + rsp := &CreateResponse{} return rsp, t.client.Call("db", "Create", request, rsp) + } // Delete a record in the database by id. func (t *DbService) Delete(request *DeleteRequest) (*DeleteResponse, error) { + rsp := &DeleteResponse{} return rsp, t.client.Call("db", "Delete", request, rsp) + } // Read data from a table. Lookup can be by ID or via querying any field in the record. func (t *DbService) Read(request *ReadRequest) (*ReadResponse, error) { + rsp := &ReadResponse{} return rsp, t.client.Call("db", "Read", request, rsp) + } // Truncate the records in a table func (t *DbService) Truncate(request *TruncateRequest) (*TruncateResponse, error) { + rsp := &TruncateResponse{} return rsp, t.client.Call("db", "Truncate", request, rsp) + } // Update a record in the database. Include an "id" in the record to update. func (t *DbService) Update(request *UpdateRequest) (*UpdateResponse, error) { + rsp := &UpdateResponse{} return rsp, t.client.Call("db", "Update", request, rsp) + } type CountRequest struct { diff --git a/email/email.go b/email/email.go index ee60657..4e49468 100755 --- a/email/email.go +++ b/email/email.go @@ -18,8 +18,10 @@ type EmailService struct { // Send an email by passing in from, to, subject, and a text or html body func (t *EmailService) Send(request *SendRequest) (*SendResponse, error) { + rsp := &SendResponse{} return rsp, t.client.Call("email", "Send", request, rsp) + } type SendRequest struct { diff --git a/emoji/emoji.go b/emoji/emoji.go index 78d64c0..c30fa16 100755 --- a/emoji/emoji.go +++ b/emoji/emoji.go @@ -18,27 +18,35 @@ type EmojiService struct { // Find an emoji by its alias e.g :beer: func (t *EmojiService) Find(request *FindRequest) (*FindResponse, error) { + rsp := &FindResponse{} return rsp, t.client.Call("emoji", "Find", request, rsp) + } // Get the flag for a country. Requires country code e.g GB for great britain func (t *EmojiService) Flag(request *FlagRequest) (*FlagResponse, error) { + rsp := &FlagResponse{} return rsp, t.client.Call("emoji", "Flag", request, rsp) + } // Print text and renders the emojis with aliases e.g // let's grab a :beer: becomes let's grab a 🍺 func (t *EmojiService) Print(request *PrintRequest) (*PrintResponse, error) { + rsp := &PrintResponse{} return rsp, t.client.Call("emoji", "Print", request, rsp) + } // Send an emoji to anyone via SMS. Messages are sent in the form ' Sent from ' func (t *EmojiService) Send(request *SendRequest) (*SendResponse, error) { + rsp := &SendResponse{} return rsp, t.client.Call("emoji", "Send", request, rsp) + } type FindRequest struct { diff --git a/evchargers/evchargers.go b/evchargers/evchargers.go index dbe4d1c..f16fe9b 100755 --- a/evchargers/evchargers.go +++ b/evchargers/evchargers.go @@ -18,14 +18,18 @@ type EvchargersService struct { // Retrieve reference data as used by this API and in conjunction with the Search endpoint func (t *EvchargersService) ReferenceData(request *ReferenceDataRequest) (*ReferenceDataResponse, error) { + rsp := &ReferenceDataResponse{} return rsp, t.client.Call("evchargers", "ReferenceData", request, rsp) + } // Search by giving a coordinate and a max distance, or bounding box and optional filters func (t *EvchargersService) Search(request *SearchRequest) (*SearchResponse, error) { + rsp := &SearchResponse{} return rsp, t.client.Call("evchargers", "Search", request, rsp) + } type Address struct { diff --git a/event/event.go b/event/event.go index 829c7fe..ab23a99 100755 --- a/event/event.go +++ b/event/event.go @@ -17,21 +17,43 @@ type EventService struct { } // Consume events from a given topic. -func (t *EventService) Consume(request *ConsumeRequest) (*ConsumeResponse, error) { - rsp := &ConsumeResponse{} - return rsp, t.client.Call("event", "Consume", request, rsp) +func (t *EventService) Consume(request *ConsumeRequest) (*ConsumeResponseStream, error) { + stream, err := t.client.Stream("event", "Consume", request) + if err != nil { + return nil, err + } + return &ConsumeResponseStream{ + stream: stream, + }, nil + +} + +type ConsumeResponseStream struct { + stream *client.Stream +} + +func (t *ConsumeResponseStream) Recv() (*ConsumeResponse, error) { + var rsp ConsumeResponse + if err := t.stream.Recv(&rsp); err != nil { + return nil, err + } + return &rsp, nil } // Publish a event to the event stream. func (t *EventService) Publish(request *PublishRequest) (*PublishResponse, error) { + rsp := &PublishResponse{} return rsp, t.client.Call("event", "Publish", request, rsp) + } // Read stored events func (t *EventService) Read(request *ReadRequest) (*ReadResponse, error) { + rsp := &ReadResponse{} return rsp, t.client.Call("event", "Read", request, rsp) + } type ConsumeRequest struct { diff --git a/examples/address/lookupPostcode/lookupPostcode/main.go b/examples/address/lookupPostcode/lookupPostcode/main.go index f1e2135..2bbb521 100755 --- a/examples/address/lookupPostcode/lookupPostcode/main.go +++ b/examples/address/lookupPostcode/lookupPostcode/main.go @@ -14,4 +14,5 @@ func main() { Postcode: "SW1A 2AA", }) fmt.Println(rsp, err) + } diff --git a/examples/answer/question/askAQuestion/main.go b/examples/answer/question/askAQuestion/main.go index 48f6322..1a19218 100755 --- a/examples/answer/question/askAQuestion/main.go +++ b/examples/answer/question/askAQuestion/main.go @@ -14,4 +14,5 @@ func main() { Query: "microsoft", }) fmt.Println(rsp, err) + } diff --git a/examples/cache/decrement/decrementAValue/main.go b/examples/cache/decrement/decrementAValue/main.go index 83dbaf5..ed3d078 100755 --- a/examples/cache/decrement/decrementAValue/main.go +++ b/examples/cache/decrement/decrementAValue/main.go @@ -7,7 +7,7 @@ import ( "go.m3o.com/cache" ) -// Decrement a value (if it's a number) +// Decrement a value (if it's a number). If key not found it is equivalent to set. func main() { cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN")) rsp, err := cacheService.Decrement(&cache.DecrementRequest{ @@ -15,4 +15,5 @@ func main() { Value: 2, }) fmt.Println(rsp, err) + } diff --git a/examples/cache/delete/deleteAValue/main.go b/examples/cache/delete/deleteAValue/main.go index 285fa47..b5aff23 100755 --- a/examples/cache/delete/deleteAValue/main.go +++ b/examples/cache/delete/deleteAValue/main.go @@ -7,11 +7,12 @@ import ( "go.m3o.com/cache" ) -// Delete a value from the cache +// Delete a value from the cache. If key not found a success response is returned. func main() { cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN")) rsp, err := cacheService.Delete(&cache.DeleteRequest{ Key: "foo", }) fmt.Println(rsp, err) + } diff --git a/examples/cache/get/getAValue/main.go b/examples/cache/get/getAValue/main.go index 652187e..9f99299 100755 --- a/examples/cache/get/getAValue/main.go +++ b/examples/cache/get/getAValue/main.go @@ -7,11 +7,12 @@ import ( "go.m3o.com/cache" ) -// Get an item from the cache by key +// Get an item from the cache by key. If key is not found, an empty response is returned. func main() { cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN")) rsp, err := cacheService.Get(&cache.GetRequest{ Key: "foo", }) fmt.Println(rsp, err) + } diff --git a/examples/cache/increment/incrementAValue/main.go b/examples/cache/increment/incrementAValue/main.go index f2e1c95..c7852f4 100755 --- a/examples/cache/increment/incrementAValue/main.go +++ b/examples/cache/increment/incrementAValue/main.go @@ -7,7 +7,7 @@ import ( "go.m3o.com/cache" ) -// Increment a value (if it's a number) +// Increment a value (if it's a number). If key not found it is equivalent to set. func main() { cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN")) rsp, err := cacheService.Increment(&cache.IncrementRequest{ @@ -15,4 +15,5 @@ func main() { Value: 2, }) fmt.Println(rsp, err) + } diff --git a/examples/cache/set/setAValue/main.go b/examples/cache/set/setAValue/main.go index de832c1..d589106 100755 --- a/examples/cache/set/setAValue/main.go +++ b/examples/cache/set/setAValue/main.go @@ -15,4 +15,5 @@ func main() { Value: "bar", }) fmt.Println(rsp, err) + } diff --git a/examples/crypto/history/getPreviousClose/main.go b/examples/crypto/history/getPreviousClose/main.go index 3edca22..ae800f9 100755 --- a/examples/crypto/history/getPreviousClose/main.go +++ b/examples/crypto/history/getPreviousClose/main.go @@ -14,4 +14,5 @@ func main() { Symbol: "BTCUSD", }) fmt.Println(rsp, err) + } diff --git a/examples/crypto/news/getCryptocurrencyNews/main.go b/examples/crypto/news/getCryptocurrencyNews/main.go index af5412c..8976ac6 100755 --- a/examples/crypto/news/getCryptocurrencyNews/main.go +++ b/examples/crypto/news/getCryptocurrencyNews/main.go @@ -14,4 +14,5 @@ func main() { Symbol: "BTCUSD", }) fmt.Println(rsp, err) + } diff --git a/examples/crypto/price/getCryptocurrencyPrice/main.go b/examples/crypto/price/getCryptocurrencyPrice/main.go index 4bba4fe..1dea531 100755 --- a/examples/crypto/price/getCryptocurrencyPrice/main.go +++ b/examples/crypto/price/getCryptocurrencyPrice/main.go @@ -14,4 +14,5 @@ func main() { Symbol: "BTCUSD", }) fmt.Println(rsp, err) + } diff --git a/examples/crypto/quote/getACryptocurrencyQuote/main.go b/examples/crypto/quote/getACryptocurrencyQuote/main.go index 464fce7..4714abc 100755 --- a/examples/crypto/quote/getACryptocurrencyQuote/main.go +++ b/examples/crypto/quote/getACryptocurrencyQuote/main.go @@ -14,4 +14,5 @@ func main() { Symbol: "BTCUSD", }) fmt.Println(rsp, err) + } diff --git a/examples/currency/codes/getSupportedCodes/main.go b/examples/currency/codes/getSupportedCodes/main.go index 17d658e..1e9f1d2 100755 --- a/examples/currency/codes/getSupportedCodes/main.go +++ b/examples/currency/codes/getSupportedCodes/main.go @@ -12,4 +12,5 @@ func main() { currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN")) rsp, err := currencyService.Codes(¤cy.CodesRequest{}) fmt.Println(rsp, err) + } diff --git a/examples/currency/convert/convert10UsdToGbp/main.go b/examples/currency/convert/convert10UsdToGbp/main.go index 75aa7b5..c7f2227 100755 --- a/examples/currency/convert/convert10UsdToGbp/main.go +++ b/examples/currency/convert/convert10UsdToGbp/main.go @@ -16,4 +16,5 @@ func main() { To: "GBP", }) fmt.Println(rsp, err) + } diff --git a/examples/currency/convert/convertUsdToGbp/main.go b/examples/currency/convert/convertUsdToGbp/main.go index 2a87d8d..4ad634a 100755 --- a/examples/currency/convert/convertUsdToGbp/main.go +++ b/examples/currency/convert/convertUsdToGbp/main.go @@ -15,4 +15,5 @@ func main() { To: "GBP", }) fmt.Println(rsp, err) + } diff --git a/examples/currency/history/historicRatesForACurrency/main.go b/examples/currency/history/historicRatesForACurrency/main.go index 1a6de42..6643c7a 100755 --- a/examples/currency/history/historicRatesForACurrency/main.go +++ b/examples/currency/history/historicRatesForACurrency/main.go @@ -15,4 +15,5 @@ func main() { Date: "2021-05-30", }) fmt.Println(rsp, err) + } diff --git a/examples/currency/rates/getRatesForUsd/main.go b/examples/currency/rates/getRatesForUsd/main.go index 5d86627..b2d1bb3 100755 --- a/examples/currency/rates/getRatesForUsd/main.go +++ b/examples/currency/rates/getRatesForUsd/main.go @@ -14,4 +14,5 @@ func main() { Code: "USD", }) fmt.Println(rsp, err) + } diff --git a/examples/db/README.md b/examples/db/README.md index af4b3d8..1d5449e 100755 --- a/examples/db/README.md +++ b/examples/db/README.md @@ -4,88 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Db/api](https: Endpoints: -## 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: "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) -} -``` ## Create Create a record in the database. Optionally include an "id" field otherwise it's set automatically. @@ -178,3 +96,85 @@ Table: "users", fmt.Println(rsp, err) } ``` +## Delete + +Delete a record in the database by id. + + +[https://m3o.com/db/api#Delete](https://m3o.com/db/api#Delete) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/db" +) + +// Delete a record in the database by id. +func DeleteArecord() { + dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) + rsp, err := dbService.Delete(&db.DeleteRequest{ + Id: "1", +Table: "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) +} +``` diff --git a/examples/db/count/countEntriesInATable/main.go b/examples/db/count/countEntriesInATable/main.go index 26500a0..86e77ee 100755 --- a/examples/db/count/countEntriesInATable/main.go +++ b/examples/db/count/countEntriesInATable/main.go @@ -14,4 +14,5 @@ func main() { Table: "users", }) fmt.Println(rsp, err) + } diff --git a/examples/db/create/createARecord/main.go b/examples/db/create/createARecord/main.go index 1e242cc..886de82 100755 --- a/examples/db/create/createARecord/main.go +++ b/examples/db/create/createARecord/main.go @@ -12,12 +12,13 @@ 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", }) fmt.Println(rsp, err) + } diff --git a/examples/db/delete/deleteARecord/main.go b/examples/db/delete/deleteARecord/main.go index a3a9513..6e04605 100755 --- a/examples/db/delete/deleteARecord/main.go +++ b/examples/db/delete/deleteARecord/main.go @@ -15,4 +15,5 @@ func main() { Table: "users", }) fmt.Println(rsp, err) + } diff --git a/examples/db/read/readRecords/main.go b/examples/db/read/readRecords/main.go index 2329dcb..cb5e82c 100755 --- a/examples/db/read/readRecords/main.go +++ b/examples/db/read/readRecords/main.go @@ -15,4 +15,5 @@ func main() { Table: "users", }) fmt.Println(rsp, err) + } diff --git a/examples/db/truncate/truncateTable/main.go b/examples/db/truncate/truncateTable/main.go index d2e9af8..9acd837 100755 --- a/examples/db/truncate/truncateTable/main.go +++ b/examples/db/truncate/truncateTable/main.go @@ -14,4 +14,5 @@ func main() { Table: "users", }) fmt.Println(rsp, err) + } diff --git a/examples/db/update/updateARecord/main.go b/examples/db/update/updateARecord/main.go index b226b80..37b63dd 100755 --- a/examples/db/update/updateARecord/main.go +++ b/examples/db/update/updateARecord/main.go @@ -18,4 +18,5 @@ func main() { Table: "users", }) fmt.Println(rsp, err) + } diff --git a/examples/email/send/sendEmail/main.go b/examples/email/send/sendEmail/main.go index 51a86b4..48a6d31 100755 --- a/examples/email/send/sendEmail/main.go +++ b/examples/email/send/sendEmail/main.go @@ -18,4 +18,5 @@ func main() { Please verify your email by clicking this link: $micro_verification_link`, }) fmt.Println(rsp, err) + } diff --git a/examples/emoji/find/findEmoji/main.go b/examples/emoji/find/findEmoji/main.go index 941278e..4e3557e 100755 --- a/examples/emoji/find/findEmoji/main.go +++ b/examples/emoji/find/findEmoji/main.go @@ -14,4 +14,5 @@ func main() { Alias: ":beer:", }) fmt.Println(rsp, err) + } diff --git a/examples/emoji/flag/getFlagByCountryCode/main.go b/examples/emoji/flag/getFlagByCountryCode/main.go index d8d302e..e9955b0 100755 --- a/examples/emoji/flag/getFlagByCountryCode/main.go +++ b/examples/emoji/flag/getFlagByCountryCode/main.go @@ -12,4 +12,5 @@ func main() { emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN")) rsp, err := emojiService.Flag(&emoji.FlagRequest{}) fmt.Println(rsp, err) + } diff --git a/examples/emoji/print/printTextIncludingEmoji/main.go b/examples/emoji/print/printTextIncludingEmoji/main.go index ed604d7..c88e66f 100755 --- a/examples/emoji/print/printTextIncludingEmoji/main.go +++ b/examples/emoji/print/printTextIncludingEmoji/main.go @@ -15,4 +15,5 @@ func main() { Text: "let's grab a :beer:", }) fmt.Println(rsp, err) + } diff --git a/examples/emoji/send/sendATextContainingAnEmojiToAnyoneViaSms/main.go b/examples/emoji/send/sendATextContainingAnEmojiToAnyoneViaSms/main.go index 459dde3..74b84e7 100755 --- a/examples/emoji/send/sendATextContainingAnEmojiToAnyoneViaSms/main.go +++ b/examples/emoji/send/sendATextContainingAnEmojiToAnyoneViaSms/main.go @@ -16,4 +16,5 @@ func main() { To: "+44782669123", }) fmt.Println(rsp, err) + } diff --git a/examples/evchargers/referenceData/getReferenceData/main.go b/examples/evchargers/referenceData/getReferenceData/main.go index 5860273..ff34397 100755 --- a/examples/evchargers/referenceData/getReferenceData/main.go +++ b/examples/evchargers/referenceData/getReferenceData/main.go @@ -12,4 +12,5 @@ func main() { evchargersService := evchargers.NewEvchargersService(os.Getenv("M3O_API_TOKEN")) rsp, err := evchargersService.ReferenceData(&evchargers.ReferenceDataRequest{}) fmt.Println(rsp, err) + } diff --git a/examples/evchargers/search/searchByBoundingBox/main.go b/examples/evchargers/search/searchByBoundingBox/main.go index ec4095f..f6ba190 100755 --- a/examples/evchargers/search/searchByBoundingBox/main.go +++ b/examples/evchargers/search/searchByBoundingBox/main.go @@ -14,4 +14,5 @@ func main() { Box: &evchargers.BoundingBox{}, }) fmt.Println(rsp, err) + } diff --git a/examples/evchargers/search/searchByLocation/main.go b/examples/evchargers/search/searchByLocation/main.go index 1bcc6eb..9ec143e 100755 --- a/examples/evchargers/search/searchByLocation/main.go +++ b/examples/evchargers/search/searchByLocation/main.go @@ -18,4 +18,5 @@ func main() { }, }) fmt.Println(rsp, err) + } diff --git a/examples/evchargers/search/searchWithFiltersFastChargersOnly/main.go b/examples/evchargers/search/searchWithFiltersFastChargersOnly/main.go index b35f129..7dd30d5 100755 --- a/examples/evchargers/search/searchWithFiltersFastChargersOnly/main.go +++ b/examples/evchargers/search/searchWithFiltersFastChargersOnly/main.go @@ -19,4 +19,5 @@ func main() { }, }) fmt.Println(rsp, err) + } diff --git a/examples/event/README.md b/examples/event/README.md index 38d6199..c41e12c 100755 --- a/examples/event/README.md +++ b/examples/event/README.md @@ -4,6 +4,33 @@ 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. @@ -63,30 +90,3 @@ func ConsumeFromAtopic() { fmt.Println(rsp, err) } ``` -## 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/event/consume/consumeFromATopic/main.go b/examples/event/consume/consumeFromATopic/main.go index b45abf4..35a0ab7 100755 --- a/examples/event/consume/consumeFromATopic/main.go +++ b/examples/event/consume/consumeFromATopic/main.go @@ -10,8 +10,22 @@ import ( // Consume events from a given topic. func main() { eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN")) - rsp, err := eventService.Consume(&event.ConsumeRequest{ + + stream, err := eventService.Consume(&event.ConsumeRequest{ Topic: "user", }) - fmt.Println(rsp, err) + 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 287af64..49e4e18 100755 --- a/examples/event/publish/publishAnEvent/main.go +++ b/examples/event/publish/publishAnEvent/main.go @@ -19,4 +19,5 @@ func main() { Topic: "user", }) fmt.Println(rsp, err) + } diff --git a/examples/event/read/readEventsOnATopic/main.go b/examples/event/read/readEventsOnATopic/main.go index 3d0e67a..831db83 100755 --- a/examples/event/read/readEventsOnATopic/main.go +++ b/examples/event/read/readEventsOnATopic/main.go @@ -14,4 +14,5 @@ func main() { Topic: "user", }) fmt.Println(rsp, err) + } diff --git a/examples/file/delete/deleteFile/main.go b/examples/file/delete/deleteFile/main.go index 841ed3b..90ef85a 100755 --- a/examples/file/delete/deleteFile/main.go +++ b/examples/file/delete/deleteFile/main.go @@ -15,4 +15,5 @@ func main() { Project: "examples", }) fmt.Println(rsp, err) + } diff --git a/examples/file/list/listFiles/main.go b/examples/file/list/listFiles/main.go index cbc502c..fd56a41 100755 --- a/examples/file/list/listFiles/main.go +++ b/examples/file/list/listFiles/main.go @@ -14,4 +14,5 @@ func main() { Project: "examples", }) fmt.Println(rsp, err) + } diff --git a/examples/file/read/readFile/main.go b/examples/file/read/readFile/main.go index a64f84c..9a5dce4 100755 --- a/examples/file/read/readFile/main.go +++ b/examples/file/read/readFile/main.go @@ -15,4 +15,5 @@ func main() { Project: "examples", }) fmt.Println(rsp, err) + } diff --git a/examples/file/save/saveFile/main.go b/examples/file/save/saveFile/main.go index 178b924..16ba9bd 100755 --- a/examples/file/save/saveFile/main.go +++ b/examples/file/save/saveFile/main.go @@ -18,4 +18,5 @@ func main() { }, }) fmt.Println(rsp, err) + } diff --git a/examples/forex/history/getPreviousClose/main.go b/examples/forex/history/getPreviousClose/main.go index 63da6aa..d50b774 100755 --- a/examples/forex/history/getPreviousClose/main.go +++ b/examples/forex/history/getPreviousClose/main.go @@ -14,4 +14,5 @@ func main() { Symbol: "GBPUSD", }) fmt.Println(rsp, err) + } diff --git a/examples/forex/price/getAnFxPrice/main.go b/examples/forex/price/getAnFxPrice/main.go index 291f0ae..a0de2fa 100755 --- a/examples/forex/price/getAnFxPrice/main.go +++ b/examples/forex/price/getAnFxPrice/main.go @@ -14,4 +14,5 @@ func main() { Symbol: "GBPUSD", }) fmt.Println(rsp, err) + } diff --git a/examples/forex/quote/getAFxQuote/main.go b/examples/forex/quote/getAFxQuote/main.go index 3dc6e99..1a1430c 100755 --- a/examples/forex/quote/getAFxQuote/main.go +++ b/examples/forex/quote/getAFxQuote/main.go @@ -14,4 +14,5 @@ func main() { Symbol: "GBPUSD", }) fmt.Println(rsp, err) + } diff --git a/examples/function/call/callAFunction/main.go b/examples/function/call/callAFunction/main.go index a39a95e..fc0f17f 100755 --- a/examples/function/call/callAFunction/main.go +++ b/examples/function/call/callAFunction/main.go @@ -15,4 +15,5 @@ func main() { Request: map[string]interface{}{}, }) fmt.Println(rsp, err) + } diff --git a/examples/function/delete/deleteAFunction/main.go b/examples/function/delete/deleteAFunction/main.go index 30b37fd..0af6663 100755 --- a/examples/function/delete/deleteAFunction/main.go +++ b/examples/function/delete/deleteAFunction/main.go @@ -15,4 +15,5 @@ func main() { Project: "tests", }) fmt.Println(rsp, err) + } diff --git a/examples/function/deploy/deployAFunction/main.go b/examples/function/deploy/deployAFunction/main.go index 4ee23e4..a48fd60 100755 --- a/examples/function/deploy/deployAFunction/main.go +++ b/examples/function/deploy/deployAFunction/main.go @@ -18,4 +18,5 @@ func main() { Runtime: "nodejs14", }) fmt.Println(rsp, err) + } diff --git a/examples/function/describe/describeFunctionStatus/main.go b/examples/function/describe/describeFunctionStatus/main.go index 0e2df81..651e53a 100755 --- a/examples/function/describe/describeFunctionStatus/main.go +++ b/examples/function/describe/describeFunctionStatus/main.go @@ -15,4 +15,5 @@ func main() { Project: "tests", }) fmt.Println(rsp, err) + } diff --git a/examples/function/list/listFunctions/main.go b/examples/function/list/listFunctions/main.go index 109cd6a..38aeb6e 100755 --- a/examples/function/list/listFunctions/main.go +++ b/examples/function/list/listFunctions/main.go @@ -12,4 +12,5 @@ func main() { functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) rsp, err := functionService.List(&function.ListRequest{}) fmt.Println(rsp, err) + } diff --git a/examples/geocoding/lookup/geocodeAnAddress/main.go b/examples/geocoding/lookup/geocodeAnAddress/main.go index eeb3ae9..c3e1ebc 100755 --- a/examples/geocoding/lookup/geocodeAnAddress/main.go +++ b/examples/geocoding/lookup/geocodeAnAddress/main.go @@ -17,4 +17,5 @@ func main() { Postcode: "wc2b", }) fmt.Println(rsp, err) + } diff --git a/examples/geocoding/reverse/reverseGeocodeLocation/main.go b/examples/geocoding/reverse/reverseGeocodeLocation/main.go index 1285f0e..efffb69 100755 --- a/examples/geocoding/reverse/reverseGeocodeLocation/main.go +++ b/examples/geocoding/reverse/reverseGeocodeLocation/main.go @@ -15,4 +15,5 @@ func main() { Longitude: -0.1216235, }) fmt.Println(rsp, err) + } diff --git a/examples/gifs/search/search/main.go b/examples/gifs/search/search/main.go index 60535bb..672867c 100755 --- a/examples/gifs/search/search/main.go +++ b/examples/gifs/search/search/main.go @@ -15,4 +15,5 @@ func main() { Query: "dogs", }) fmt.Println(rsp, err) + } diff --git a/examples/google/search/searchForVideos/main.go b/examples/google/search/searchForVideos/main.go index f305ce8..9497c56 100755 --- a/examples/google/search/searchForVideos/main.go +++ b/examples/google/search/searchForVideos/main.go @@ -14,4 +14,5 @@ func main() { Query: "how to make donuts", }) fmt.Println(rsp, err) + } diff --git a/examples/helloworld/call/callTheHelloworldService/main.go b/examples/helloworld/call/callTheHelloworldService/main.go index 886f101..f79fa5e 100755 --- a/examples/helloworld/call/callTheHelloworldService/main.go +++ b/examples/helloworld/call/callTheHelloworldService/main.go @@ -14,4 +14,5 @@ func main() { Name: "John", }) fmt.Println(rsp, err) + } diff --git a/examples/helloworld/stream/streamsAreCurrentlyTemporarilyNotSupportedInClients/main.go b/examples/helloworld/stream/streamsAreCurrentlyTemporarilyNotSupportedInClients/main.go index a81aaa5..7894d67 100755 --- a/examples/helloworld/stream/streamsAreCurrentlyTemporarilyNotSupportedInClients/main.go +++ b/examples/helloworld/stream/streamsAreCurrentlyTemporarilyNotSupportedInClients/main.go @@ -10,8 +10,22 @@ import ( // Stream returns a stream of "Hello $name" responses func main() { helloworldService := helloworld.NewHelloworldService(os.Getenv("M3O_API_TOKEN")) - rsp, err := helloworldService.Stream(&helloworld.StreamRequest{ + + stream, err := helloworldService.Stream(&helloworld.StreamRequest{ Name: "not supported", }) - fmt.Println(rsp, err) + 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/holidays/countries/listCountries/main.go b/examples/holidays/countries/listCountries/main.go index 3dc2dc6..676b6db 100755 --- a/examples/holidays/countries/listCountries/main.go +++ b/examples/holidays/countries/listCountries/main.go @@ -12,4 +12,5 @@ func main() { holidaysService := holidays.NewHolidaysService(os.Getenv("M3O_API_TOKEN")) rsp, err := holidaysService.Countries(&holidays.CountriesRequest{}) fmt.Println(rsp, err) + } diff --git a/examples/holidays/list/getHolidays/main.go b/examples/holidays/list/getHolidays/main.go index 1391a60..f40051c 100755 --- a/examples/holidays/list/getHolidays/main.go +++ b/examples/holidays/list/getHolidays/main.go @@ -14,4 +14,5 @@ func main() { Year: 2022, }) fmt.Println(rsp, err) + } diff --git a/examples/id/generate/generateABigflakeId/main.go b/examples/id/generate/generateABigflakeId/main.go index 8d8bc5f..e62e3e8 100755 --- a/examples/id/generate/generateABigflakeId/main.go +++ b/examples/id/generate/generateABigflakeId/main.go @@ -14,4 +14,5 @@ func main() { Type: "bigflake", }) fmt.Println(rsp, err) + } diff --git a/examples/id/generate/generateAShortId/main.go b/examples/id/generate/generateAShortId/main.go index c68843e..37a638e 100755 --- a/examples/id/generate/generateAShortId/main.go +++ b/examples/id/generate/generateAShortId/main.go @@ -14,4 +14,5 @@ func main() { Type: "shortid", }) fmt.Println(rsp, err) + } diff --git a/examples/id/generate/generateASnowflakeId/main.go b/examples/id/generate/generateASnowflakeId/main.go index 4194e0c..df5d120 100755 --- a/examples/id/generate/generateASnowflakeId/main.go +++ b/examples/id/generate/generateASnowflakeId/main.go @@ -14,4 +14,5 @@ func main() { Type: "snowflake", }) fmt.Println(rsp, err) + } diff --git a/examples/id/generate/generateAUniqueId/main.go b/examples/id/generate/generateAUniqueId/main.go index 934d6c4..596586c 100755 --- a/examples/id/generate/generateAUniqueId/main.go +++ b/examples/id/generate/generateAUniqueId/main.go @@ -14,4 +14,5 @@ func main() { Type: "uuid", }) fmt.Println(rsp, err) + } diff --git a/examples/id/types/listTheTypesOfIdsAvailable/main.go b/examples/id/types/listTheTypesOfIdsAvailable/main.go index ce5f77e..10709b0 100755 --- a/examples/id/types/listTheTypesOfIdsAvailable/main.go +++ b/examples/id/types/listTheTypesOfIdsAvailable/main.go @@ -12,4 +12,5 @@ func main() { idService := id.NewIdService(os.Getenv("M3O_API_TOKEN")) rsp, err := idService.Types(&id.TypesRequest{}) fmt.Println(rsp, err) + } diff --git a/examples/image/README.md b/examples/image/README.md index 1d58d10..e590a10 100755 --- a/examples/image/README.md +++ b/examples/image/README.md @@ -4,6 +4,66 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Image/api](htt Endpoints: +## Upload + +Upload an image by either sending a base64 encoded image to this endpoint or a URL. +To resize an image before uploading, see the Resize endpoint. + + +[https://m3o.com/image/api#Upload](https://m3o.com/image/api#Upload) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/image" +) + +// Upload an image by either sending a base64 encoded image to this endpoint or a URL. +// To resize an image before uploading, see the Resize endpoint. +func UploadAbase64imageToMicrosCdn() { + imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN")) + rsp, err := imageService.Upload(&image.UploadRequest{ + Base64: "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAx0lEQVR4nOzaMaoDMQyE4ZHj+x82vVdhwQoTkzKQEcwP5r0ihT7sbjUTeAJ4HCegXQJYfOYefOyjDuBiz3yjwJBoCIl6QZOeUjTC1Ix1IxEJXF9+0KWsf2bD4bn37OO/c/wuQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9Sa/NG94Tf3j4WBdaxudMEkn4IM2rZBA0wBrvo7aOcpj2emXvLeVt0IGm0GVXUj91mvAAAA//+V2CZl+4AKXwAAAABJRU5ErkJggg==", +Name: "cat.jpeg", + + }) + fmt.Println(rsp, err) +} +``` +## Upload + +Upload an image by either sending a base64 encoded image to this endpoint or a URL. +To resize an image before uploading, see the Resize endpoint. + + +[https://m3o.com/image/api#Upload](https://m3o.com/image/api#Upload) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/image" +) + +// Upload an image by either sending a base64 encoded image to this endpoint or a URL. +// To resize an image before uploading, see the Resize endpoint. +func UploadAnImageFromAurlToMicrosCdn() { + imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN")) + rsp, err := imageService.Upload(&image.UploadRequest{ + Name: "cat.jpeg", +Url: "somewebsite.com/cat.png", + + }) + fmt.Println(rsp, err) +} +``` ## Resize Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters. @@ -138,63 +198,3 @@ Url: "somewebsite.com/cat.png", fmt.Println(rsp, err) } ``` -## Upload - -Upload an image by either sending a base64 encoded image to this endpoint or a URL. -To resize an image before uploading, see the Resize endpoint. - - -[https://m3o.com/image/api#Upload](https://m3o.com/image/api#Upload) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/image" -) - -// Upload an image by either sending a base64 encoded image to this endpoint or a URL. -// To resize an image before uploading, see the Resize endpoint. -func UploadAbase64imageToMicrosCdn() { - imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN")) - rsp, err := imageService.Upload(&image.UploadRequest{ - Base64: "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAx0lEQVR4nOzaMaoDMQyE4ZHj+x82vVdhwQoTkzKQEcwP5r0ihT7sbjUTeAJ4HCegXQJYfOYefOyjDuBiz3yjwJBoCIl6QZOeUjTC1Ix1IxEJXF9+0KWsf2bD4bn37OO/c/wuQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9Sa/NG94Tf3j4WBdaxudMEkn4IM2rZBA0wBrvo7aOcpj2emXvLeVt0IGm0GVXUj91mvAAAA//+V2CZl+4AKXwAAAABJRU5ErkJggg==", -Name: "cat.jpeg", - - }) - fmt.Println(rsp, err) -} -``` -## Upload - -Upload an image by either sending a base64 encoded image to this endpoint or a URL. -To resize an image before uploading, see the Resize endpoint. - - -[https://m3o.com/image/api#Upload](https://m3o.com/image/api#Upload) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/image" -) - -// Upload an image by either sending a base64 encoded image to this endpoint or a URL. -// To resize an image before uploading, see the Resize endpoint. -func UploadAnImageFromAurlToMicrosCdn() { - imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN")) - rsp, err := imageService.Upload(&image.UploadRequest{ - Name: "cat.jpeg", -Url: "somewebsite.com/cat.png", - - }) - fmt.Println(rsp, err) -} -``` diff --git a/examples/image/convert/convertAPngImageToAJpegTakenFromAUrlAndSavedToAUrlOnMicrosCdn/main.go b/examples/image/convert/convertAPngImageToAJpegTakenFromAUrlAndSavedToAUrlOnMicrosCdn/main.go index f700a86..816262f 100755 --- a/examples/image/convert/convertAPngImageToAJpegTakenFromAUrlAndSavedToAUrlOnMicrosCdn/main.go +++ b/examples/image/convert/convertAPngImageToAJpegTakenFromAUrlAndSavedToAUrlOnMicrosCdn/main.go @@ -16,4 +16,5 @@ func main() { Url: "somewebsite.com/cat.png", }) fmt.Println(rsp, err) + } diff --git a/examples/image/resize/base64ToBase64Image/main.go b/examples/image/resize/base64ToBase64Image/main.go index 1a236e1..9fb465c 100755 --- a/examples/image/resize/base64ToBase64Image/main.go +++ b/examples/image/resize/base64ToBase64Image/main.go @@ -18,4 +18,5 @@ func main() { Width: 100, }) fmt.Println(rsp, err) + } diff --git a/examples/image/resize/base64ToBase64ImageWithCropping/main.go b/examples/image/resize/base64ToBase64ImageWithCropping/main.go index 4448207..85e9d01 100755 --- a/examples/image/resize/base64ToBase64ImageWithCropping/main.go +++ b/examples/image/resize/base64ToBase64ImageWithCropping/main.go @@ -22,4 +22,5 @@ func main() { Width: 100, }) fmt.Println(rsp, err) + } diff --git a/examples/image/resize/base64ToHostedImage/main.go b/examples/image/resize/base64ToHostedImage/main.go index ed31ece..940c8bf 100755 --- a/examples/image/resize/base64ToHostedImage/main.go +++ b/examples/image/resize/base64ToHostedImage/main.go @@ -19,4 +19,5 @@ func main() { Width: 100, }) fmt.Println(rsp, err) + } diff --git a/examples/image/upload/uploadABase64ImageToMicrosCdn/main.go b/examples/image/upload/uploadABase64ImageToMicrosCdn/main.go index 646899d..def8836 100755 --- a/examples/image/upload/uploadABase64ImageToMicrosCdn/main.go +++ b/examples/image/upload/uploadABase64ImageToMicrosCdn/main.go @@ -16,4 +16,5 @@ func main() { Name: "cat.jpeg", }) fmt.Println(rsp, err) + } diff --git a/examples/image/upload/uploadAnImageFromAUrlToMicrosCdn/main.go b/examples/image/upload/uploadAnImageFromAUrlToMicrosCdn/main.go index 11b51fb..2ab1a25 100755 --- a/examples/image/upload/uploadAnImageFromAUrlToMicrosCdn/main.go +++ b/examples/image/upload/uploadAnImageFromAUrlToMicrosCdn/main.go @@ -16,4 +16,5 @@ func main() { Url: "somewebsite.com/cat.png", }) fmt.Println(rsp, err) + } diff --git a/examples/ip/lookup/lookupIpInfo/main.go b/examples/ip/lookup/lookupIpInfo/main.go index 75269c6..d586e3c 100755 --- a/examples/ip/lookup/lookupIpInfo/main.go +++ b/examples/ip/lookup/lookupIpInfo/main.go @@ -14,4 +14,5 @@ func main() { Ip: "93.148.214.31", }) fmt.Println(rsp, err) + } diff --git a/examples/location/README.md b/examples/location/README.md index 4db841c..828fe78 100755 --- a/examples/location/README.md +++ b/examples/location/README.md @@ -4,6 +4,41 @@ 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 @@ -64,38 +99,3 @@ Type: "bike", fmt.Println(rsp, err) } ``` -## 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/location/read/getLocationById/main.go b/examples/location/read/getLocationById/main.go index bbc21cd..627f3a1 100755 --- a/examples/location/read/getLocationById/main.go +++ b/examples/location/read/getLocationById/main.go @@ -14,4 +14,5 @@ func main() { Id: "1", }) fmt.Println(rsp, err) + } diff --git a/examples/location/save/saveAnEntity/main.go b/examples/location/save/saveAnEntity/main.go index dc9ff51..3f42638 100755 --- a/examples/location/save/saveAnEntity/main.go +++ b/examples/location/save/saveAnEntity/main.go @@ -22,4 +22,5 @@ func main() { }, }) fmt.Println(rsp, err) + } diff --git a/examples/location/search/searchForLocations/main.go b/examples/location/search/searchForLocations/main.go index a0aec8b..1d143e9 100755 --- a/examples/location/search/searchForLocations/main.go +++ b/examples/location/search/searchForLocations/main.go @@ -20,4 +20,5 @@ func main() { Type: "bike", }) fmt.Println(rsp, err) + } diff --git a/examples/mq/publish/publishAMessage/main.go b/examples/mq/publish/publishAMessage/main.go index ad993e2..d5d14f2 100755 --- a/examples/mq/publish/publishAMessage/main.go +++ b/examples/mq/publish/publishAMessage/main.go @@ -19,4 +19,5 @@ func main() { Topic: "events", }) fmt.Println(rsp, err) + } diff --git a/examples/mq/subscribe/subscribeToATopic/main.go b/examples/mq/subscribe/subscribeToATopic/main.go index 111aea8..0144ae4 100755 --- a/examples/mq/subscribe/subscribeToATopic/main.go +++ b/examples/mq/subscribe/subscribeToATopic/main.go @@ -10,8 +10,22 @@ import ( // Subscribe to messages for a given topic. func main() { mqService := mq.NewMqService(os.Getenv("M3O_API_TOKEN")) - rsp, err := mqService.Subscribe(&mq.SubscribeRequest{ + + stream, err := mqService.Subscribe(&mq.SubscribeRequest{ Topic: "events", }) - fmt.Println(rsp, err) + 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/notes/README.md b/examples/notes/README.md index ee3f1a7..bf9f0b9 100755 --- a/examples/notes/README.md +++ b/examples/notes/README.md @@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Notes/api](htt Endpoints: +## Create + +Create a new note + + +[https://m3o.com/notes/api#Create](https://m3o.com/notes/api#Create) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/notes" +) + +// Create a new note +func CreateAnote() { + notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN")) + rsp, err := notesService.Create(¬es.CreateRequest{ + Text: "This is my note", +Title: "New Note", + + }) + fmt.Println(rsp, err) +} +``` ## Read Read a note @@ -142,31 +170,3 @@ func SubscribeToEvents() { fmt.Println(rsp, err) } ``` -## Create - -Create a new note - - -[https://m3o.com/notes/api#Create](https://m3o.com/notes/api#Create) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/notes" -) - -// Create a new note -func CreateAnote() { - notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN")) - rsp, err := notesService.Create(¬es.CreateRequest{ - Text: "This is my note", -Title: "New Note", - - }) - fmt.Println(rsp, err) -} -``` diff --git a/examples/otp/generate/generateOtp/main.go b/examples/otp/generate/generateOtp/main.go index 4085622..a90d729 100755 --- a/examples/otp/generate/generateOtp/main.go +++ b/examples/otp/generate/generateOtp/main.go @@ -14,4 +14,5 @@ func main() { Id: "asim@example.com", }) fmt.Println(rsp, err) + } diff --git a/examples/otp/validate/validateOtp/main.go b/examples/otp/validate/validateOtp/main.go index 4b27d65..89e63c6 100755 --- a/examples/otp/validate/validateOtp/main.go +++ b/examples/otp/validate/validateOtp/main.go @@ -15,4 +15,5 @@ func main() { Id: "asim@example.com", }) fmt.Println(rsp, err) + } diff --git a/examples/postcode/lookup/lookupPostcode/main.go b/examples/postcode/lookup/lookupPostcode/main.go index 5903e45..0b641be 100755 --- a/examples/postcode/lookup/lookupPostcode/main.go +++ b/examples/postcode/lookup/lookupPostcode/main.go @@ -14,4 +14,5 @@ func main() { Postcode: "SW1A 2AA", }) fmt.Println(rsp, err) + } diff --git a/examples/postcode/random/returnARandomPostcodeAndItsInformation/main.go b/examples/postcode/random/returnARandomPostcodeAndItsInformation/main.go index a150b95..dc40bc2 100755 --- a/examples/postcode/random/returnARandomPostcodeAndItsInformation/main.go +++ b/examples/postcode/random/returnARandomPostcodeAndItsInformation/main.go @@ -12,4 +12,5 @@ func main() { postcodeService := postcode.NewPostcodeService(os.Getenv("M3O_API_TOKEN")) rsp, err := postcodeService.Random(&postcode.RandomRequest{}) fmt.Println(rsp, err) + } diff --git a/examples/postcode/validate/returnARandomPostcodeAndItsInformation/main.go b/examples/postcode/validate/returnARandomPostcodeAndItsInformation/main.go index 55f04f0..17ccbc0 100755 --- a/examples/postcode/validate/returnARandomPostcodeAndItsInformation/main.go +++ b/examples/postcode/validate/returnARandomPostcodeAndItsInformation/main.go @@ -14,4 +14,5 @@ func main() { Postcode: "SW1A 2AA", }) fmt.Println(rsp, err) + } diff --git a/examples/prayer/times/prayerTimes/main.go b/examples/prayer/times/prayerTimes/main.go index 9b127c5..35d5810 100755 --- a/examples/prayer/times/prayerTimes/main.go +++ b/examples/prayer/times/prayerTimes/main.go @@ -14,4 +14,5 @@ func main() { Location: "london", }) fmt.Println(rsp, err) + } diff --git a/examples/qr/generate/generateAQrCode/main.go b/examples/qr/generate/generateAQrCode/main.go index 21fd932..2490887 100755 --- a/examples/qr/generate/generateAQrCode/main.go +++ b/examples/qr/generate/generateAQrCode/main.go @@ -15,4 +15,5 @@ func main() { Text: "https://m3o.com/qr", }) fmt.Println(rsp, err) + } diff --git a/examples/quran/chapters/listChapters/main.go b/examples/quran/chapters/listChapters/main.go index 6b70221..364aacf 100755 --- a/examples/quran/chapters/listChapters/main.go +++ b/examples/quran/chapters/listChapters/main.go @@ -14,4 +14,5 @@ func main() { Language: "en", }) fmt.Println(rsp, err) + } diff --git a/examples/quran/search/searchTheQuran/main.go b/examples/quran/search/searchTheQuran/main.go index 55ff062..ed635a1 100755 --- a/examples/quran/search/searchTheQuran/main.go +++ b/examples/quran/search/searchTheQuran/main.go @@ -14,4 +14,5 @@ func main() { Query: "messenger", }) fmt.Println(rsp, err) + } diff --git a/examples/quran/summary/getChapterSummary/main.go b/examples/quran/summary/getChapterSummary/main.go index 6dca3fa..39c7fc0 100755 --- a/examples/quran/summary/getChapterSummary/main.go +++ b/examples/quran/summary/getChapterSummary/main.go @@ -14,4 +14,5 @@ func main() { Chapter: 1, }) fmt.Println(rsp, err) + } diff --git a/examples/quran/verses/getVersesOfAChapter/main.go b/examples/quran/verses/getVersesOfAChapter/main.go index 5ea0718..ebcfc01 100755 --- a/examples/quran/verses/getVersesOfAChapter/main.go +++ b/examples/quran/verses/getVersesOfAChapter/main.go @@ -16,4 +16,5 @@ func main() { Chapter: 1, }) fmt.Println(rsp, err) + } diff --git a/examples/routing/README.md b/examples/routing/README.md index 1f0e61c..8f4968f 100755 --- a/examples/routing/README.md +++ b/examples/routing/README.md @@ -4,6 +4,40 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Routing/api](h Endpoints: +## Eta + +Get the eta for a route from origin to destination. The eta is an estimated time based on car routes + + +[https://m3o.com/routing/api#Eta](https://m3o.com/routing/api#Eta) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/routing" +) + +// Get the eta for a route from origin to destination. The eta is an estimated time based on car routes +func EtaFromPointAtoPointB() { + routingService := routing.NewRoutingService(os.Getenv("M3O_API_TOKEN")) + rsp, err := routingService.Eta(&routing.EtaRequest{ + Destination: &routing.Point{ + Latitude: 52.529407, + Longitude: 13.397634, +}, +Origin: &routing.Point{ + Latitude: 52.517037, + Longitude: 13.38886, +}, + + }) + fmt.Println(rsp, err) +} +``` ## Directions Turn by turn directions from a start point to an end point including maneuvers and bearings @@ -72,37 +106,3 @@ Origin: &routing.Point{ 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 - - -[https://m3o.com/routing/api#Eta](https://m3o.com/routing/api#Eta) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/routing" -) - -// Get the eta for a route from origin to destination. The eta is an estimated time based on car routes -func EtaFromPointAtoPointB() { - routingService := routing.NewRoutingService(os.Getenv("M3O_API_TOKEN")) - rsp, err := routingService.Eta(&routing.EtaRequest{ - 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/routing/directions/turnByTurnDirections/main.go b/examples/routing/directions/turnByTurnDirections/main.go index e9526af..c62178f 100755 --- a/examples/routing/directions/turnByTurnDirections/main.go +++ b/examples/routing/directions/turnByTurnDirections/main.go @@ -21,4 +21,5 @@ func main() { }, }) fmt.Println(rsp, err) + } diff --git a/examples/routing/eta/etaFromPointAToPointB/main.go b/examples/routing/eta/etaFromPointAToPointB/main.go index 10ac617..ade9e0e 100755 --- a/examples/routing/eta/etaFromPointAToPointB/main.go +++ b/examples/routing/eta/etaFromPointAToPointB/main.go @@ -21,4 +21,5 @@ func main() { }, }) fmt.Println(rsp, err) + } diff --git a/examples/routing/route/gpsPointsForARoute/main.go b/examples/routing/route/gpsPointsForARoute/main.go index 0970236..99b900a 100755 --- a/examples/routing/route/gpsPointsForARoute/main.go +++ b/examples/routing/route/gpsPointsForARoute/main.go @@ -21,4 +21,5 @@ func main() { }, }) fmt.Println(rsp, err) + } diff --git a/examples/rss/add/addANewFeed/main.go b/examples/rss/add/addANewFeed/main.go index 87191ea..64df6c1 100755 --- a/examples/rss/add/addANewFeed/main.go +++ b/examples/rss/add/addANewFeed/main.go @@ -16,4 +16,5 @@ func main() { Url: "http://feeds.bbci.co.uk/news/rss.xml", }) fmt.Println(rsp, err) + } diff --git a/examples/rss/feed/readAFeed/main.go b/examples/rss/feed/readAFeed/main.go index 4c9a358..6c1b3d7 100755 --- a/examples/rss/feed/readAFeed/main.go +++ b/examples/rss/feed/readAFeed/main.go @@ -14,4 +14,5 @@ func main() { Name: "bbc", }) fmt.Println(rsp, err) + } diff --git a/examples/rss/list/listRssFeeds/main.go b/examples/rss/list/listRssFeeds/main.go index 853a946..0383c11 100755 --- a/examples/rss/list/listRssFeeds/main.go +++ b/examples/rss/list/listRssFeeds/main.go @@ -12,4 +12,5 @@ func main() { rssService := rss.NewRssService(os.Getenv("M3O_API_TOKEN")) rsp, err := rssService.List(&rss.ListRequest{}) fmt.Println(rsp, err) + } diff --git a/examples/rss/remove/removeAFeed/main.go b/examples/rss/remove/removeAFeed/main.go index 594472e..51b0d38 100755 --- a/examples/rss/remove/removeAFeed/main.go +++ b/examples/rss/remove/removeAFeed/main.go @@ -14,4 +14,5 @@ func main() { Name: "bbc", }) fmt.Println(rsp, err) + } diff --git a/examples/sentiment/analyze/analyzeAPieceOfText/main.go b/examples/sentiment/analyze/analyzeAPieceOfText/main.go index a7446d9..a7887f5 100755 --- a/examples/sentiment/analyze/analyzeAPieceOfText/main.go +++ b/examples/sentiment/analyze/analyzeAPieceOfText/main.go @@ -14,4 +14,5 @@ func main() { Text: "this is amazing", }) fmt.Println(rsp, err) + } diff --git a/examples/sms/send/sendSms/main.go b/examples/sms/send/sendSms/main.go index edda18c..188c0f0 100755 --- a/examples/sms/send/sendSms/main.go +++ b/examples/sms/send/sendSms/main.go @@ -16,4 +16,5 @@ func main() { To: "+447681129", }) fmt.Println(rsp, err) + } diff --git a/examples/stock/README.md b/examples/stock/README.md index 264b273..9dda59f 100755 --- a/examples/stock/README.md +++ b/examples/stock/README.md @@ -4,33 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Stock/api](htt Endpoints: -## 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 @@ -117,3 +90,30 @@ func GetAstockPrice() { 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/stock/history/getHistoricData/main.go b/examples/stock/history/getHistoricData/main.go index 5898d67..e4bf2cb 100755 --- a/examples/stock/history/getHistoricData/main.go +++ b/examples/stock/history/getHistoricData/main.go @@ -15,4 +15,5 @@ func main() { Stock: "AAPL", }) fmt.Println(rsp, err) + } diff --git a/examples/stock/orderBook/orderBookHistory/main.go b/examples/stock/orderBook/orderBookHistory/main.go index 4e14b0d..db305f6 100755 --- a/examples/stock/orderBook/orderBookHistory/main.go +++ b/examples/stock/orderBook/orderBookHistory/main.go @@ -18,4 +18,5 @@ func main() { Stock: "AAPL", }) fmt.Println(rsp, err) + } diff --git a/examples/stock/price/getAStockPrice/main.go b/examples/stock/price/getAStockPrice/main.go index ea3dcba..0559928 100755 --- a/examples/stock/price/getAStockPrice/main.go +++ b/examples/stock/price/getAStockPrice/main.go @@ -14,4 +14,5 @@ func main() { Symbol: "AAPL", }) fmt.Println(rsp, err) + } diff --git a/examples/stock/quote/getAStockQuote/main.go b/examples/stock/quote/getAStockQuote/main.go index 2702907..e191381 100755 --- a/examples/stock/quote/getAStockQuote/main.go +++ b/examples/stock/quote/getAStockQuote/main.go @@ -14,4 +14,5 @@ func main() { Symbol: "AAPL", }) fmt.Println(rsp, err) + } diff --git a/examples/stream/README.md b/examples/stream/README.md index 23477f0..a03c3d5 100755 --- a/examples/stream/README.md +++ b/examples/stream/README.md @@ -6,7 +6,7 @@ Endpoints: ## SendMessage -SendMessage a message to the stream. +Send a message to the stream. [https://m3o.com/stream/api#SendMessage](https://m3o.com/stream/api#SendMessage) @@ -21,8 +21,8 @@ import( "go.m3o.com/stream" ) -// SendMessage a message to the stream. -func SendAmessage() { +// Send a message to the stream. +func SendMessage() { streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN")) rsp, err := streamService.SendMessage(&stream.SendMessageRequest{ Channel: "general", diff --git a/examples/stream/listChannels/listChannels/main.go b/examples/stream/listChannels/listChannels/main.go new file mode 100755 index 0000000..05b1adc --- /dev/null +++ b/examples/stream/listChannels/listChannels/main.go @@ -0,0 +1,16 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/stream" +) + +// List all the active channels +func main() { + streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN")) + rsp, err := streamService.ListChannels(&stream.ListChannelsRequest{}) + fmt.Println(rsp, err) + +} diff --git a/examples/stream/listMessages/listMessages/main.go b/examples/stream/listMessages/listMessages/main.go new file mode 100755 index 0000000..3ae50f2 --- /dev/null +++ b/examples/stream/listMessages/listMessages/main.go @@ -0,0 +1,18 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/stream" +) + +// List messages for a given channel +func main() { + streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN")) + rsp, err := streamService.ListMessages(&stream.ListMessagesRequest{ + Channel: "general", + }) + fmt.Println(rsp, err) + +} diff --git a/examples/stream/sendMessage/sendMessage/main.go b/examples/stream/sendMessage/sendMessage/main.go new file mode 100755 index 0000000..967c037 --- /dev/null +++ b/examples/stream/sendMessage/sendMessage/main.go @@ -0,0 +1,19 @@ +package main + +import ( + "fmt" + "os" + + "go.m3o.com/stream" +) + +// Send a message to the stream. +func main() { + streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN")) + rsp, err := streamService.SendMessage(&stream.SendMessageRequest{ + Channel: "general", + Text: "Hey checkout this tweet https://twitter.com/m3oservices/status/1455291054295498752", + }) + fmt.Println(rsp, err) + +} diff --git a/examples/sunnah/README.md b/examples/sunnah/README.md index e450b78..8f2aa8f 100755 --- a/examples/sunnah/README.md +++ b/examples/sunnah/README.md @@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Sunnah/api](ht Endpoints: -## Collections - -Get a list of available collections. A collection is -a compilation of hadiths collected and written by an author. - - -[https://m3o.com/sunnah/api#Collections](https://m3o.com/sunnah/api#Collections) - -```go -package example - -import( - "fmt" - "os" - - "go.m3o.com/sunnah" -) - -// Get a list of available collections. A collection is -// a compilation of hadiths collected and written by an author. -func ListAvailableCollections() { - sunnahService := sunnah.NewSunnahService(os.Getenv("M3O_API_TOKEN")) - rsp, err := sunnahService.Collections(&sunnah.CollectionsRequest{ - - }) - fmt.Println(rsp, err) -} -``` ## Books Get a list of books from within a collection. A book can contain many chapters @@ -119,3 +91,31 @@ Collection: "bukhari", fmt.Println(rsp, err) } ``` +## Collections + +Get a list of available collections. A collection is +a compilation of hadiths collected and written by an author. + + +[https://m3o.com/sunnah/api#Collections](https://m3o.com/sunnah/api#Collections) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/sunnah" +) + +// Get a list of available collections. A collection is +// a compilation of hadiths collected and written by an author. +func ListAvailableCollections() { + sunnahService := sunnah.NewSunnahService(os.Getenv("M3O_API_TOKEN")) + rsp, err := sunnahService.Collections(&sunnah.CollectionsRequest{ + + }) + fmt.Println(rsp, err) +} +``` diff --git a/examples/sunnah/books/getTheBooksWithinACollection/main.go b/examples/sunnah/books/getTheBooksWithinACollection/main.go index 397bd23..8df4a5c 100755 --- a/examples/sunnah/books/getTheBooksWithinACollection/main.go +++ b/examples/sunnah/books/getTheBooksWithinACollection/main.go @@ -15,4 +15,5 @@ func main() { Collection: "bukhari", }) fmt.Println(rsp, err) + } diff --git a/examples/sunnah/chapters/listTheChaptersInABook/main.go b/examples/sunnah/chapters/listTheChaptersInABook/main.go index d38375c..ea670a7 100755 --- a/examples/sunnah/chapters/listTheChaptersInABook/main.go +++ b/examples/sunnah/chapters/listTheChaptersInABook/main.go @@ -15,4 +15,5 @@ func main() { Collection: "bukhari", }) fmt.Println(rsp, err) + } diff --git a/examples/sunnah/collections/listAvailableCollections/main.go b/examples/sunnah/collections/listAvailableCollections/main.go index d97caa8..403d502 100755 --- a/examples/sunnah/collections/listAvailableCollections/main.go +++ b/examples/sunnah/collections/listAvailableCollections/main.go @@ -13,4 +13,5 @@ func main() { sunnahService := sunnah.NewSunnahService(os.Getenv("M3O_API_TOKEN")) rsp, err := sunnahService.Collections(&sunnah.CollectionsRequest{}) fmt.Println(rsp, err) + } diff --git a/examples/sunnah/hadiths/listTheHadithsInABook/main.go b/examples/sunnah/hadiths/listTheHadithsInABook/main.go index 897ffc5..e7f4ed0 100755 --- a/examples/sunnah/hadiths/listTheHadithsInABook/main.go +++ b/examples/sunnah/hadiths/listTheHadithsInABook/main.go @@ -16,4 +16,5 @@ func main() { Collection: "bukhari", }) fmt.Println(rsp, err) + } diff --git a/examples/thumbnail/screenshot/takeScreenshotOfAUrl/main.go b/examples/thumbnail/screenshot/takeScreenshotOfAUrl/main.go index 6109aba..655bdb8 100755 --- a/examples/thumbnail/screenshot/takeScreenshotOfAUrl/main.go +++ b/examples/thumbnail/screenshot/takeScreenshotOfAUrl/main.go @@ -16,4 +16,5 @@ func main() { Width: 600, }) fmt.Println(rsp, err) + } diff --git a/examples/time/now/returnsCurrentTimeOptionallyWithLocation/main.go b/examples/time/now/returnsCurrentTimeOptionallyWithLocation/main.go index 5770dc1..baee4d9 100755 --- a/examples/time/now/returnsCurrentTimeOptionallyWithLocation/main.go +++ b/examples/time/now/returnsCurrentTimeOptionallyWithLocation/main.go @@ -12,4 +12,5 @@ func main() { timeService := time.NewTimeService(os.Getenv("M3O_API_TOKEN")) rsp, err := timeService.Now(&time.NowRequest{}) fmt.Println(rsp, err) + } diff --git a/examples/time/zone/getTheTimezoneInfoForASpecificLocation/main.go b/examples/time/zone/getTheTimezoneInfoForASpecificLocation/main.go index 9a2a98f..eaa1678 100755 --- a/examples/time/zone/getTheTimezoneInfoForASpecificLocation/main.go +++ b/examples/time/zone/getTheTimezoneInfoForASpecificLocation/main.go @@ -14,4 +14,5 @@ func main() { Location: "London", }) fmt.Println(rsp, err) + } diff --git a/examples/twitter/search/searchForTweets/main.go b/examples/twitter/search/searchForTweets/main.go index ad8aa8d..82455c3 100755 --- a/examples/twitter/search/searchForTweets/main.go +++ b/examples/twitter/search/searchForTweets/main.go @@ -14,4 +14,5 @@ func main() { Query: "cats", }) fmt.Println(rsp, err) + } diff --git a/examples/twitter/timeline/getATwitterTimeline/main.go b/examples/twitter/timeline/getATwitterTimeline/main.go index c1be363..92297d8 100755 --- a/examples/twitter/timeline/getATwitterTimeline/main.go +++ b/examples/twitter/timeline/getATwitterTimeline/main.go @@ -15,4 +15,5 @@ func main() { Username: "m3oservices", }) fmt.Println(rsp, err) + } diff --git a/examples/twitter/trends/getTheCurrentGlobalTrendingTopics/main.go b/examples/twitter/trends/getTheCurrentGlobalTrendingTopics/main.go index eacab68..2be453a 100755 --- a/examples/twitter/trends/getTheCurrentGlobalTrendingTopics/main.go +++ b/examples/twitter/trends/getTheCurrentGlobalTrendingTopics/main.go @@ -12,4 +12,5 @@ func main() { twitterService := twitter.NewTwitterService(os.Getenv("M3O_API_TOKEN")) rsp, err := twitterService.Trends(&twitter.TrendsRequest{}) fmt.Println(rsp, err) + } diff --git a/examples/twitter/user/getAUsersTwitterProfile/main.go b/examples/twitter/user/getAUsersTwitterProfile/main.go index 7fb502e..f31cbcc 100755 --- a/examples/twitter/user/getAUsersTwitterProfile/main.go +++ b/examples/twitter/user/getAUsersTwitterProfile/main.go @@ -14,4 +14,5 @@ func main() { Username: "crufter", }) fmt.Println(rsp, err) + } diff --git a/examples/url/list/listYourShortenedUrls/main.go b/examples/url/list/listYourShortenedUrls/main.go index 51656af..ac507e3 100755 --- a/examples/url/list/listYourShortenedUrls/main.go +++ b/examples/url/list/listYourShortenedUrls/main.go @@ -12,4 +12,5 @@ func main() { urlService := url.NewUrlService(os.Getenv("M3O_API_TOKEN")) rsp, err := urlService.List(&url.ListRequest{}) fmt.Println(rsp, err) + } diff --git a/examples/url/proxy/resolveAShortUrlToALongDestinationUrl/main.go b/examples/url/proxy/resolveAShortUrlToALongDestinationUrl/main.go index 91414c4..03637b7 100755 --- a/examples/url/proxy/resolveAShortUrlToALongDestinationUrl/main.go +++ b/examples/url/proxy/resolveAShortUrlToALongDestinationUrl/main.go @@ -12,4 +12,5 @@ func main() { urlService := url.NewUrlService(os.Getenv("M3O_API_TOKEN")) rsp, err := urlService.Proxy(&url.ProxyRequest{}) fmt.Println(rsp, err) + } diff --git a/examples/url/shorten/shortenALongUrl/main.go b/examples/url/shorten/shortenALongUrl/main.go index fcec9c6..25029f3 100755 --- a/examples/url/shorten/shortenALongUrl/main.go +++ b/examples/url/shorten/shortenALongUrl/main.go @@ -12,4 +12,5 @@ func main() { urlService := url.NewUrlService(os.Getenv("M3O_API_TOKEN")) rsp, err := urlService.Shorten(&url.ShortenRequest{}) fmt.Println(rsp, err) + } diff --git a/examples/user/README.md b/examples/user/README.md index 6a1add8..51a2a0d 100755 --- a/examples/user/README.md +++ b/examples/user/README.md @@ -4,36 +4,6 @@ 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: "usrid-1", -Password: "mySecretPass123", -Username: "usrname-1", - - }) - fmt.Println(rsp, err) -} -``` ## Update Update the account username or email @@ -62,138 +32,6 @@ Id: "usrid-1", fmt.Println(rsp, err) } ``` -## SendVerificationEmail - -Send a verification email -to the user being signed up. Email from will be from 'support@m3o.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 'support@m3o.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{ - Token: "t2323t232t", - - }) - 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: "mySecretPass123", - - }) - 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: "myEvenMoreSecretPass123", -NewPassword: "myEvenMoreSecretPass123", -OldPassword: "mySecretPass123", - - }) - fmt.Println(rsp, err) -} -``` ## Read Read an account by id, username or email. Only one need to be specified. @@ -275,12 +113,18 @@ func ReadAccountByEmail() { fmt.Println(rsp, err) } ``` -## Delete +## SendVerificationEmail -Delete an account by id +Send a verification email +to the user being signed up. Email from will be from 'support@m3o.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#Delete](https://m3o.com/user/api#Delete) +[https://m3o.com/user/api#SendVerificationEmail](https://m3o.com/user/api#SendVerificationEmail) ```go package example @@ -292,11 +136,24 @@ import( "go.m3o.com/user" ) -// Delete an account by id -func DeleteUserAccount() { +// Send a verification email +// to the user being signed up. Email from will be from 'support@m3o.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.Delete(&user.DeleteRequest{ - Id: "fdf34f34f34-f34f34-f43f43f34-f4f34f", + 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) @@ -356,3 +213,146 @@ 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: "usrid-1", +Password: "mySecretPass123", +Username: "usrname-1", + + }) + fmt.Println(rsp, err) +} +``` +## VerifyEmail + +Verify the email address of an account from a token sent in an email to the user. + + +[https://m3o.com/user/api#VerifyEmail](https://m3o.com/user/api#VerifyEmail) + +```go +package example + +import( + "fmt" + "os" + + "go.m3o.com/user" +) + +// Verify the email address of an account from a token sent in an email to the user. +func VerifyEmail() { + userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) + rsp, err := userService.VerifyEmail(&user.VerifyEmailRequest{ + Token: "t2323t232t", + + }) + 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: "fdf34f34f34-f34f34-f43f43f34-f4f34f", + + }) + 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: "mySecretPass123", + + }) + 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: "myEvenMoreSecretPass123", +NewPassword: "myEvenMoreSecretPass123", +OldPassword: "mySecretPass123", + + }) + fmt.Println(rsp, err) +} +``` diff --git a/examples/user/create/createAnAccount/main.go b/examples/user/create/createAnAccount/main.go index 8668db4..3931f44 100755 --- a/examples/user/create/createAnAccount/main.go +++ b/examples/user/create/createAnAccount/main.go @@ -17,4 +17,5 @@ func main() { Username: "usrname-1", }) fmt.Println(rsp, err) + } diff --git a/examples/user/delete/deleteUserAccount/main.go b/examples/user/delete/deleteUserAccount/main.go index ee1196e..fe76b12 100755 --- a/examples/user/delete/deleteUserAccount/main.go +++ b/examples/user/delete/deleteUserAccount/main.go @@ -14,4 +14,5 @@ func main() { Id: "fdf34f34f34-f34f34-f43f43f34-f4f34f", }) fmt.Println(rsp, err) + } diff --git a/examples/user/login/logAUserIn/main.go b/examples/user/login/logAUserIn/main.go index 8c8f5c1..7db8042 100755 --- a/examples/user/login/logAUserIn/main.go +++ b/examples/user/login/logAUserIn/main.go @@ -16,4 +16,5 @@ func main() { Password: "mySecretPass123", }) fmt.Println(rsp, err) + } diff --git a/examples/user/logout/logAUserOut/main.go b/examples/user/logout/logAUserOut/main.go index 548573d..4dc105d 100755 --- a/examples/user/logout/logAUserOut/main.go +++ b/examples/user/logout/logAUserOut/main.go @@ -14,4 +14,5 @@ func main() { SessionId: "sds34s34s34-s34s34-s43s43s34-s4s34s", }) fmt.Println(rsp, err) + } diff --git a/examples/user/read/readAccountByEmail/main.go b/examples/user/read/readAccountByEmail/main.go index f5b9f0a..4f1b825 100755 --- a/examples/user/read/readAccountByEmail/main.go +++ b/examples/user/read/readAccountByEmail/main.go @@ -14,4 +14,5 @@ func main() { Email: "joe@example.com", }) fmt.Println(rsp, err) + } diff --git a/examples/user/read/readAccountByUsernameOrEmail/main.go b/examples/user/read/readAccountByUsernameOrEmail/main.go index 7258bc7..780eb74 100755 --- a/examples/user/read/readAccountByUsernameOrEmail/main.go +++ b/examples/user/read/readAccountByUsernameOrEmail/main.go @@ -14,4 +14,5 @@ func main() { Username: "usrname-1", }) fmt.Println(rsp, err) + } diff --git a/examples/user/read/readAnAccountById/main.go b/examples/user/read/readAnAccountById/main.go index fc3d1d9..2c75ff7 100755 --- a/examples/user/read/readAnAccountById/main.go +++ b/examples/user/read/readAnAccountById/main.go @@ -14,4 +14,5 @@ func main() { Id: "usrid-1", }) fmt.Println(rsp, err) + } diff --git a/examples/user/readSession/readASessionByTheSessionId/main.go b/examples/user/readSession/readASessionByTheSessionId/main.go index 83811ae..dd48244 100755 --- a/examples/user/readSession/readASessionByTheSessionId/main.go +++ b/examples/user/readSession/readASessionByTheSessionId/main.go @@ -14,4 +14,5 @@ func main() { SessionId: "sds34s34s34-s34s34-s43s43s34-s4s34s", }) fmt.Println(rsp, err) + } diff --git a/examples/user/sendVerificationEmail/sendVerificationEmail/main.go b/examples/user/sendVerificationEmail/sendVerificationEmail/main.go index 0623336..e4e92d2 100755 --- a/examples/user/sendVerificationEmail/sendVerificationEmail/main.go +++ b/examples/user/sendVerificationEmail/sendVerificationEmail/main.go @@ -27,4 +27,5 @@ func main() { Please verify your email by clicking this link: $micro_verification_link`, }) fmt.Println(rsp, err) + } diff --git a/examples/user/update/updateAnAccount/main.go b/examples/user/update/updateAnAccount/main.go index be24112..68e350d 100755 --- a/examples/user/update/updateAnAccount/main.go +++ b/examples/user/update/updateAnAccount/main.go @@ -15,4 +15,5 @@ func main() { Id: "usrid-1", }) fmt.Println(rsp, err) + } diff --git a/examples/user/updatePassword/updateTheAccountPassword/main.go b/examples/user/updatePassword/updateTheAccountPassword/main.go index 94e6496..dd260d2 100755 --- a/examples/user/updatePassword/updateTheAccountPassword/main.go +++ b/examples/user/updatePassword/updateTheAccountPassword/main.go @@ -16,4 +16,5 @@ func main() { OldPassword: "mySecretPass123", }) fmt.Println(rsp, err) + } diff --git a/examples/user/verifyEmail/verifyEmail/main.go b/examples/user/verifyEmail/verifyEmail/main.go index a0099de..3a35cc8 100755 --- a/examples/user/verifyEmail/verifyEmail/main.go +++ b/examples/user/verifyEmail/verifyEmail/main.go @@ -14,4 +14,5 @@ func main() { Token: "t2323t232t", }) fmt.Println(rsp, err) + } diff --git a/examples/vehicle/lookup/lookupVehicle/main.go b/examples/vehicle/lookup/lookupVehicle/main.go index f5e2383..4e93eee 100755 --- a/examples/vehicle/lookup/lookupVehicle/main.go +++ b/examples/vehicle/lookup/lookupVehicle/main.go @@ -14,4 +14,5 @@ func main() { Registration: "LC60OTA", }) fmt.Println(rsp, err) + } diff --git a/examples/weather/forecast/forecastWeather/main.go b/examples/weather/forecast/forecastWeather/main.go index d8d2841..9753116 100755 --- a/examples/weather/forecast/forecastWeather/main.go +++ b/examples/weather/forecast/forecastWeather/main.go @@ -15,4 +15,5 @@ func main() { Location: "London", }) fmt.Println(rsp, err) + } diff --git a/examples/weather/now/getCurrentWeather/main.go b/examples/weather/now/getCurrentWeather/main.go index 7c9ca4e..4bd8fd0 100755 --- a/examples/weather/now/getCurrentWeather/main.go +++ b/examples/weather/now/getCurrentWeather/main.go @@ -14,4 +14,5 @@ func main() { Location: "london", }) fmt.Println(rsp, err) + } diff --git a/examples/youtube/search/searchForVideos/main.go b/examples/youtube/search/searchForVideos/main.go index af5292e..1694902 100755 --- a/examples/youtube/search/searchForVideos/main.go +++ b/examples/youtube/search/searchForVideos/main.go @@ -14,4 +14,5 @@ func main() { Query: "donuts", }) fmt.Println(rsp, err) + } diff --git a/file/file.go b/file/file.go index c0da688..2004285 100755 --- a/file/file.go +++ b/file/file.go @@ -18,26 +18,34 @@ type FileService struct { // Delete a file by project name/path func (t *FileService) Delete(request *DeleteRequest) (*DeleteResponse, error) { + rsp := &DeleteResponse{} return rsp, t.client.Call("file", "Delete", request, rsp) + } // List files by their project and optionally a path. func (t *FileService) List(request *ListRequest) (*ListResponse, error) { + rsp := &ListResponse{} return rsp, t.client.Call("file", "List", request, rsp) + } // Read a file by path func (t *FileService) Read(request *ReadRequest) (*ReadResponse, error) { + rsp := &ReadResponse{} return rsp, t.client.Call("file", "Read", request, rsp) + } // Save a file func (t *FileService) Save(request *SaveRequest) (*SaveResponse, error) { + rsp := &SaveResponse{} return rsp, t.client.Call("file", "Save", request, rsp) + } type BatchSaveRequest struct { diff --git a/forex/forex.go b/forex/forex.go index 8fcb80e..5d0bc90 100755 --- a/forex/forex.go +++ b/forex/forex.go @@ -18,20 +18,26 @@ type ForexService struct { // Returns the data for the previous close func (t *ForexService) History(request *HistoryRequest) (*HistoryResponse, error) { + rsp := &HistoryResponse{} return rsp, t.client.Call("forex", "History", request, rsp) + } // Get the latest price for a given forex ticker func (t *ForexService) Price(request *PriceRequest) (*PriceResponse, error) { + rsp := &PriceResponse{} return rsp, t.client.Call("forex", "Price", request, rsp) + } // Get the latest quote for the forex func (t *ForexService) Quote(request *QuoteRequest) (*QuoteResponse, error) { + rsp := &QuoteResponse{} return rsp, t.client.Call("forex", "Quote", request, rsp) + } type HistoryRequest struct { diff --git a/function/function.go b/function/function.go index 502e64f..b15ed4d 100755 --- a/function/function.go +++ b/function/function.go @@ -18,32 +18,42 @@ type FunctionService struct { // Call a function by name func (t *FunctionService) Call(request *CallRequest) (*CallResponse, error) { + rsp := &CallResponse{} return rsp, t.client.Call("function", "Call", request, rsp) + } // Delete a function by name func (t *FunctionService) Delete(request *DeleteRequest) (*DeleteResponse, error) { + rsp := &DeleteResponse{} return rsp, t.client.Call("function", "Delete", request, rsp) + } // Deploy a group of functions func (t *FunctionService) Deploy(request *DeployRequest) (*DeployResponse, error) { + rsp := &DeployResponse{} return rsp, t.client.Call("function", "Deploy", request, rsp) + } // Get the info for a deployed function func (t *FunctionService) Describe(request *DescribeRequest) (*DescribeResponse, error) { + rsp := &DescribeResponse{} return rsp, t.client.Call("function", "Describe", request, rsp) + } // List all the deployed functions func (t *FunctionService) List(request *ListRequest) (*ListResponse, error) { + rsp := &ListResponse{} return rsp, t.client.Call("function", "List", request, rsp) + } type CallRequest struct { diff --git a/geocoding/geocoding.go b/geocoding/geocoding.go index a01a173..391007a 100755 --- a/geocoding/geocoding.go +++ b/geocoding/geocoding.go @@ -18,14 +18,18 @@ type GeocodingService struct { // Lookup returns a geocoded address including normalized address and gps coordinates. All fields are optional, provide more to get more accurate results func (t *GeocodingService) Lookup(request *LookupRequest) (*LookupResponse, error) { + rsp := &LookupResponse{} return rsp, t.client.Call("geocoding", "Lookup", request, rsp) + } // Reverse lookup an address from gps coordinates func (t *GeocodingService) Reverse(request *ReverseRequest) (*ReverseResponse, error) { + rsp := &ReverseResponse{} return rsp, t.client.Call("geocoding", "Reverse", request, rsp) + } type Address struct { diff --git a/gifs/gifs.go b/gifs/gifs.go index c761446..8858823 100755 --- a/gifs/gifs.go +++ b/gifs/gifs.go @@ -18,8 +18,10 @@ type GifsService struct { // Search for a GIF func (t *GifsService) Search(request *SearchRequest) (*SearchResponse, error) { + rsp := &SearchResponse{} return rsp, t.client.Call("gifs", "Search", request, rsp) + } type Gif struct { diff --git a/google/google.go b/google/google.go index 985462f..9bf8a04 100755 --- a/google/google.go +++ b/google/google.go @@ -18,8 +18,10 @@ type GoogleService struct { // Search for videos on Google func (t *GoogleService) Search(request *SearchRequest) (*SearchResponse, error) { + rsp := &SearchResponse{} return rsp, t.client.Call("google", "Search", request, rsp) + } type SearchRequest struct { diff --git a/helloworld/helloworld.go b/helloworld/helloworld.go index e7bcf38..7d7555a 100755 --- a/helloworld/helloworld.go +++ b/helloworld/helloworld.go @@ -18,14 +18,34 @@ type HelloworldService struct { // Call returns a personalised "Hello $name" response func (t *HelloworldService) Call(request *CallRequest) (*CallResponse, error) { + rsp := &CallResponse{} return rsp, t.client.Call("helloworld", "Call", request, rsp) + } // Stream returns a stream of "Hello $name" responses -func (t *HelloworldService) Stream(request *StreamRequest) (*StreamResponse, error) { - rsp := &StreamResponse{} - return rsp, t.client.Call("helloworld", "Stream", request, rsp) +func (t *HelloworldService) Stream(request *StreamRequest) (*StreamResponseStream, error) { + stream, err := t.client.Stream("helloworld", "Stream", request) + if err != nil { + return nil, err + } + return &StreamResponseStream{ + stream: stream, + }, nil + +} + +type StreamResponseStream struct { + stream *client.Stream +} + +func (t *StreamResponseStream) Recv() (*StreamResponse, error) { + var rsp StreamResponse + if err := t.stream.Recv(&rsp); err != nil { + return nil, err + } + return &rsp, nil } type CallRequest struct { diff --git a/holidays/holidays.go b/holidays/holidays.go index 71b1058..2d2807c 100755 --- a/holidays/holidays.go +++ b/holidays/holidays.go @@ -18,14 +18,18 @@ type HolidaysService struct { // Get the list of countries that are supported by this API func (t *HolidaysService) Countries(request *CountriesRequest) (*CountriesResponse, error) { + rsp := &CountriesResponse{} return rsp, t.client.Call("holidays", "Countries", request, rsp) + } // List the holiday dates for a given country and year func (t *HolidaysService) List(request *ListRequest) (*ListResponse, error) { + rsp := &ListResponse{} return rsp, t.client.Call("holidays", "List", request, rsp) + } type CountriesRequest struct { diff --git a/id/id.go b/id/id.go index d26ea72..277ae63 100755 --- a/id/id.go +++ b/id/id.go @@ -18,14 +18,18 @@ type IdService struct { // Generate a unique ID. Defaults to uuid. func (t *IdService) Generate(request *GenerateRequest) (*GenerateResponse, error) { + rsp := &GenerateResponse{} return rsp, t.client.Call("id", "Generate", request, rsp) + } // List the types of IDs available. No query params needed. func (t *IdService) Types(request *TypesRequest) (*TypesResponse, error) { + rsp := &TypesResponse{} return rsp, t.client.Call("id", "Types", request, rsp) + } type GenerateRequest struct { diff --git a/image/image.go b/image/image.go index 70800b1..dd23fcf 100755 --- a/image/image.go +++ b/image/image.go @@ -19,23 +19,29 @@ type ImageService struct { // Convert an image from one format (jpeg, png etc.) to an other either on the fly (from base64 to base64), // or by uploading the conversion result. func (t *ImageService) Convert(request *ConvertRequest) (*ConvertResponse, error) { + rsp := &ConvertResponse{} return rsp, t.client.Call("image", "Convert", request, rsp) + } // Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters. // If one of width or height is 0, the image aspect ratio is preserved. // Optional cropping. func (t *ImageService) Resize(request *ResizeRequest) (*ResizeResponse, error) { + rsp := &ResizeResponse{} return rsp, t.client.Call("image", "Resize", request, rsp) + } // Upload an image by either sending a base64 encoded image to this endpoint or a URL. // To resize an image before uploading, see the Resize endpoint. func (t *ImageService) Upload(request *UploadRequest) (*UploadResponse, error) { + rsp := &UploadResponse{} return rsp, t.client.Call("image", "Upload", request, rsp) + } type ConvertRequest struct { diff --git a/ip/ip.go b/ip/ip.go index 8213744..b772332 100755 --- a/ip/ip.go +++ b/ip/ip.go @@ -18,8 +18,10 @@ type IpService struct { // Lookup the geolocation information for an IP address func (t *IpService) Lookup(request *LookupRequest) (*LookupResponse, error) { + rsp := &LookupResponse{} return rsp, t.client.Call("ip", "Lookup", request, rsp) + } type LookupRequest struct { diff --git a/location/location.go b/location/location.go index 2817790..b1dd33f 100755 --- a/location/location.go +++ b/location/location.go @@ -18,20 +18,26 @@ type LocationService struct { // Read an entity by its ID func (t *LocationService) Read(request *ReadRequest) (*ReadResponse, error) { + rsp := &ReadResponse{} return rsp, t.client.Call("location", "Read", request, rsp) + } // Save an entity's current position func (t *LocationService) Save(request *SaveRequest) (*SaveResponse, error) { + rsp := &SaveResponse{} return rsp, t.client.Call("location", "Save", request, rsp) + } // Search for entities in a given radius func (t *LocationService) Search(request *SearchRequest) (*SearchResponse, error) { + rsp := &SearchResponse{} return rsp, t.client.Call("location", "Search", request, rsp) + } type Entity struct { diff --git a/mq/mq.go b/mq/mq.go index 8272b3e..8b666cc 100755 --- a/mq/mq.go +++ b/mq/mq.go @@ -18,14 +18,34 @@ type MqService struct { // Publish a message. Specify a topic to group messages for a specific topic. func (t *MqService) Publish(request *PublishRequest) (*PublishResponse, error) { + rsp := &PublishResponse{} return rsp, t.client.Call("mq", "Publish", request, rsp) + } // Subscribe to messages for a given topic. -func (t *MqService) Subscribe(request *SubscribeRequest) (*SubscribeResponse, error) { - rsp := &SubscribeResponse{} - return rsp, t.client.Call("mq", "Subscribe", request, rsp) +func (t *MqService) Subscribe(request *SubscribeRequest) (*SubscribeResponseStream, error) { + stream, err := t.client.Stream("mq", "Subscribe", request) + if err != nil { + return nil, err + } + return &SubscribeResponseStream{ + stream: stream, + }, nil + +} + +type SubscribeResponseStream struct { + stream *client.Stream +} + +func (t *SubscribeResponseStream) Recv() (*SubscribeResponse, error) { + var rsp SubscribeResponse + if err := t.stream.Recv(&rsp); err != nil { + return nil, err + } + return &rsp, nil } type PublishRequest struct { diff --git a/notes/notes.go b/notes/notes.go index c036e07..5e2e157 100755 --- a/notes/notes.go +++ b/notes/notes.go @@ -18,38 +18,66 @@ type NotesService struct { // Create a new note func (t *NotesService) Create(request *CreateRequest) (*CreateResponse, error) { + rsp := &CreateResponse{} return rsp, t.client.Call("notes", "Create", request, rsp) + } // Delete a note func (t *NotesService) Delete(request *DeleteRequest) (*DeleteResponse, error) { + rsp := &DeleteResponse{} return rsp, t.client.Call("notes", "Delete", request, rsp) + } // Subscribe to notes events -func (t *NotesService) Events(request *EventsRequest) (*EventsResponse, error) { - rsp := &EventsResponse{} - return rsp, t.client.Call("notes", "Events", request, rsp) +func (t *NotesService) Events(request *EventsRequest) (*EventsResponseStream, error) { + stream, err := t.client.Stream("notes", "Events", request) + if err != nil { + return nil, err + } + return &EventsResponseStream{ + stream: stream, + }, nil + +} + +type EventsResponseStream struct { + stream *client.Stream +} + +func (t *EventsResponseStream) Recv() (*EventsResponse, error) { + var rsp EventsResponse + if err := t.stream.Recv(&rsp); err != nil { + return nil, err + } + return &rsp, nil } // List all the notes func (t *NotesService) List(request *ListRequest) (*ListResponse, error) { + rsp := &ListResponse{} return rsp, t.client.Call("notes", "List", request, rsp) + } // Read a note func (t *NotesService) Read(request *ReadRequest) (*ReadResponse, error) { + rsp := &ReadResponse{} return rsp, t.client.Call("notes", "Read", request, rsp) + } // Update a note func (t *NotesService) Update(request *UpdateRequest) (*UpdateResponse, error) { + rsp := &UpdateResponse{} return rsp, t.client.Call("notes", "Update", request, rsp) + } type CreateRequest struct { diff --git a/otp/otp.go b/otp/otp.go index 109b379..94ca7fd 100755 --- a/otp/otp.go +++ b/otp/otp.go @@ -18,14 +18,18 @@ type OtpService struct { // Generate an OTP (one time pass) code func (t *OtpService) Generate(request *GenerateRequest) (*GenerateResponse, error) { + rsp := &GenerateResponse{} return rsp, t.client.Call("otp", "Generate", request, rsp) + } // Validate the OTP code func (t *OtpService) Validate(request *ValidateRequest) (*ValidateResponse, error) { + rsp := &ValidateResponse{} return rsp, t.client.Call("otp", "Validate", request, rsp) + } type GenerateRequest struct { diff --git a/postcode/postcode.go b/postcode/postcode.go index 4419b85..44b195d 100755 --- a/postcode/postcode.go +++ b/postcode/postcode.go @@ -18,20 +18,26 @@ type PostcodeService struct { // Lookup a postcode to retrieve the related region, county, etc func (t *PostcodeService) Lookup(request *LookupRequest) (*LookupResponse, error) { + rsp := &LookupResponse{} return rsp, t.client.Call("postcode", "Lookup", request, rsp) + } // Return a random postcode and its related info func (t *PostcodeService) Random(request *RandomRequest) (*RandomResponse, error) { + rsp := &RandomResponse{} return rsp, t.client.Call("postcode", "Random", request, rsp) + } // Validate a postcode. func (t *PostcodeService) Validate(request *ValidateRequest) (*ValidateResponse, error) { + rsp := &ValidateResponse{} return rsp, t.client.Call("postcode", "Validate", request, rsp) + } type LookupRequest struct { diff --git a/prayer/prayer.go b/prayer/prayer.go index 9a3eba6..10aec04 100755 --- a/prayer/prayer.go +++ b/prayer/prayer.go @@ -18,8 +18,10 @@ type PrayerService struct { // Get the prayer (salah) times for a location on a given date func (t *PrayerService) Times(request *TimesRequest) (*TimesResponse, error) { + rsp := &TimesResponse{} return rsp, t.client.Call("prayer", "Times", request, rsp) + } type PrayerTime struct { diff --git a/qr/qr.go b/qr/qr.go index 17db08b..96d3d12 100755 --- a/qr/qr.go +++ b/qr/qr.go @@ -18,8 +18,10 @@ type QrService struct { // Generate a QR code with a specific text and size func (t *QrService) Generate(request *GenerateRequest) (*GenerateResponse, error) { + rsp := &GenerateResponse{} return rsp, t.client.Call("qr", "Generate", request, rsp) + } type GenerateRequest struct { diff --git a/quran/quran.go b/quran/quran.go index cac5927..1c9243c 100755 --- a/quran/quran.go +++ b/quran/quran.go @@ -18,28 +18,36 @@ type QuranService struct { // List the Chapters (surahs) of the Quran func (t *QuranService) Chapters(request *ChaptersRequest) (*ChaptersResponse, error) { + rsp := &ChaptersResponse{} return rsp, t.client.Call("quran", "Chapters", request, rsp) + } // Search the Quran for any form of query or questions func (t *QuranService) Search(request *SearchRequest) (*SearchResponse, error) { + rsp := &SearchResponse{} return rsp, t.client.Call("quran", "Search", request, rsp) + } // Get a summary for a given chapter (surah) func (t *QuranService) Summary(request *SummaryRequest) (*SummaryResponse, error) { + rsp := &SummaryResponse{} return rsp, t.client.Call("quran", "Summary", request, rsp) + } // Lookup the verses (ayahs) for a chapter including // translation, interpretation and breakdown by individual // words. func (t *QuranService) Verses(request *VersesRequest) (*VersesResponse, error) { + rsp := &VersesResponse{} return rsp, t.client.Call("quran", "Verses", request, rsp) + } type Chapter struct { diff --git a/routing/routing.go b/routing/routing.go index 43471ff..cfc0749 100755 --- a/routing/routing.go +++ b/routing/routing.go @@ -18,20 +18,26 @@ type RoutingService struct { // Turn by turn directions from a start point to an end point including maneuvers and bearings func (t *RoutingService) Directions(request *DirectionsRequest) (*DirectionsResponse, error) { + rsp := &DirectionsResponse{} return rsp, t.client.Call("routing", "Directions", request, rsp) + } // Get the eta for a route from origin to destination. The eta is an estimated time based on car routes func (t *RoutingService) Eta(request *EtaRequest) (*EtaResponse, error) { + rsp := &EtaResponse{} return rsp, t.client.Call("routing", "Eta", request, rsp) + } // Retrieve a route as a simple list of gps points along with total distance and estimated duration func (t *RoutingService) Route(request *RouteRequest) (*RouteResponse, error) { + rsp := &RouteResponse{} return rsp, t.client.Call("routing", "Route", request, rsp) + } type Direction struct { diff --git a/rss/rss.go b/rss/rss.go index 1e3f0b4..dc97aa1 100755 --- a/rss/rss.go +++ b/rss/rss.go @@ -18,26 +18,34 @@ type RssService struct { // Add a new RSS feed with a name, url, and category func (t *RssService) Add(request *AddRequest) (*AddResponse, error) { + rsp := &AddResponse{} return rsp, t.client.Call("rss", "Add", request, rsp) + } // Get an RSS feed by name. If no name is given, all feeds are returned. Default limit is 25 entries. func (t *RssService) Feed(request *FeedRequest) (*FeedResponse, error) { + rsp := &FeedResponse{} return rsp, t.client.Call("rss", "Feed", request, rsp) + } // List the saved RSS fields func (t *RssService) List(request *ListRequest) (*ListResponse, error) { + rsp := &ListResponse{} return rsp, t.client.Call("rss", "List", request, rsp) + } // Remove an RSS feed by name func (t *RssService) Remove(request *RemoveRequest) (*RemoveResponse, error) { + rsp := &RemoveResponse{} return rsp, t.client.Call("rss", "Remove", request, rsp) + } type AddRequest struct { diff --git a/sentiment/sentiment.go b/sentiment/sentiment.go index c7ed2e3..a531489 100755 --- a/sentiment/sentiment.go +++ b/sentiment/sentiment.go @@ -18,8 +18,10 @@ type SentimentService struct { // Analyze and score a piece of text func (t *SentimentService) Analyze(request *AnalyzeRequest) (*AnalyzeResponse, error) { + rsp := &AnalyzeResponse{} return rsp, t.client.Call("sentiment", "Analyze", request, rsp) + } type AnalyzeRequest struct { diff --git a/sms/sms.go b/sms/sms.go index c947bd4..d4dc8f8 100755 --- a/sms/sms.go +++ b/sms/sms.go @@ -18,8 +18,10 @@ type SmsService struct { // Send an SMS. func (t *SmsService) Send(request *SendRequest) (*SendResponse, error) { + rsp := &SendResponse{} return rsp, t.client.Call("sms", "Send", request, rsp) + } type SendRequest struct { diff --git a/stock/stock.go b/stock/stock.go index 4bb6fa8..5715ddc 100755 --- a/stock/stock.go +++ b/stock/stock.go @@ -18,26 +18,34 @@ type StockService struct { // Get the historic open-close for a given day func (t *StockService) History(request *HistoryRequest) (*HistoryResponse, error) { + rsp := &HistoryResponse{} return rsp, t.client.Call("stock", "History", request, rsp) + } // Get the historic order book and each trade by timestamp func (t *StockService) OrderBook(request *OrderBookRequest) (*OrderBookResponse, error) { + rsp := &OrderBookResponse{} return rsp, t.client.Call("stock", "OrderBook", request, rsp) + } // Get the last price for a given stock ticker func (t *StockService) Price(request *PriceRequest) (*PriceResponse, error) { + rsp := &PriceResponse{} return rsp, t.client.Call("stock", "Price", request, rsp) + } // Get the last quote for the stock func (t *StockService) Quote(request *QuoteRequest) (*QuoteResponse, error) { + rsp := &QuoteResponse{} return rsp, t.client.Call("stock", "Quote", request, rsp) + } type HistoryRequest struct { diff --git a/stream/stream.go b/stream/stream.go index f4e88fc..67df4de 100755 --- a/stream/stream.go +++ b/stream/stream.go @@ -18,20 +18,26 @@ type StreamService struct { // List all the active channels func (t *StreamService) ListChannels(request *ListChannelsRequest) (*ListChannelsResponse, error) { + rsp := &ListChannelsResponse{} return rsp, t.client.Call("stream", "ListChannels", request, rsp) + } // List messages for a given channel func (t *StreamService) ListMessages(request *ListMessagesRequest) (*ListMessagesResponse, error) { + rsp := &ListMessagesResponse{} return rsp, t.client.Call("stream", "ListMessages", request, rsp) + } -// SendMessage a message to the stream. +// Send a message to the stream. func (t *StreamService) SendMessage(request *SendMessageRequest) (*SendMessageResponse, error) { + rsp := &SendMessageResponse{} return rsp, t.client.Call("stream", "SendMessage", request, rsp) + } type Channel struct { diff --git a/sunnah/sunnah.go b/sunnah/sunnah.go index a7276b0..5f44169 100755 --- a/sunnah/sunnah.go +++ b/sunnah/sunnah.go @@ -19,28 +19,36 @@ type SunnahService struct { // Get a list of books from within a collection. A book can contain many chapters // each with its own hadiths. func (t *SunnahService) Books(request *BooksRequest) (*BooksResponse, error) { + rsp := &BooksResponse{} return rsp, t.client.Call("sunnah", "Books", request, rsp) + } // Get all the chapters of a given book within a collection. func (t *SunnahService) Chapters(request *ChaptersRequest) (*ChaptersResponse, error) { + rsp := &ChaptersResponse{} return rsp, t.client.Call("sunnah", "Chapters", request, rsp) + } // Get a list of available collections. A collection is // a compilation of hadiths collected and written by an author. func (t *SunnahService) Collections(request *CollectionsRequest) (*CollectionsResponse, error) { + rsp := &CollectionsResponse{} return rsp, t.client.Call("sunnah", "Collections", request, rsp) + } // Hadiths returns a list of hadiths and their corresponding text for a // given book within a collection. func (t *SunnahService) Hadiths(request *HadithsRequest) (*HadithsResponse, error) { + rsp := &HadithsResponse{} return rsp, t.client.Call("sunnah", "Hadiths", request, rsp) + } type Book struct { diff --git a/thumbnail/thumbnail.go b/thumbnail/thumbnail.go index 968aa87..baba605 100755 --- a/thumbnail/thumbnail.go +++ b/thumbnail/thumbnail.go @@ -18,8 +18,10 @@ type ThumbnailService struct { // Create a thumbnail screenshot by passing in a url, height and width func (t *ThumbnailService) Screenshot(request *ScreenshotRequest) (*ScreenshotResponse, error) { + rsp := &ScreenshotResponse{} return rsp, t.client.Call("thumbnail", "Screenshot", request, rsp) + } type ScreenshotRequest struct { diff --git a/time/time.go b/time/time.go index db652c3..c84445d 100755 --- a/time/time.go +++ b/time/time.go @@ -18,14 +18,18 @@ type TimeService struct { // Get the current time func (t *TimeService) Now(request *NowRequest) (*NowResponse, error) { + rsp := &NowResponse{} return rsp, t.client.Call("time", "Now", request, rsp) + } // Get the timezone info for a specific location func (t *TimeService) Zone(request *ZoneRequest) (*ZoneResponse, error) { + rsp := &ZoneResponse{} return rsp, t.client.Call("time", "Zone", request, rsp) + } type NowRequest struct { diff --git a/twitter/twitter.go b/twitter/twitter.go index 1a94e3d..fb5e26c 100755 --- a/twitter/twitter.go +++ b/twitter/twitter.go @@ -18,26 +18,34 @@ type TwitterService struct { // Search for tweets with a simple query func (t *TwitterService) Search(request *SearchRequest) (*SearchResponse, error) { + rsp := &SearchResponse{} return rsp, t.client.Call("twitter", "Search", request, rsp) + } // Get the timeline for a given user func (t *TwitterService) Timeline(request *TimelineRequest) (*TimelineResponse, error) { + rsp := &TimelineResponse{} return rsp, t.client.Call("twitter", "Timeline", request, rsp) + } // Get the current global trending topics func (t *TwitterService) Trends(request *TrendsRequest) (*TrendsResponse, error) { + rsp := &TrendsResponse{} return rsp, t.client.Call("twitter", "Trends", request, rsp) + } // Get a user's twitter profile func (t *TwitterService) User(request *UserRequest) (*UserResponse, error) { + rsp := &UserResponse{} return rsp, t.client.Call("twitter", "User", request, rsp) + } type Profile struct { diff --git a/url/url.go b/url/url.go index 12bb178..7fbd714 100755 --- a/url/url.go +++ b/url/url.go @@ -18,20 +18,26 @@ type UrlService struct { // List information on all the shortened URLs that you have created func (t *UrlService) List(request *ListRequest) (*ListResponse, error) { + rsp := &ListResponse{} return rsp, t.client.Call("url", "List", request, rsp) + } // Proxy returns the destination URL of a short URL. func (t *UrlService) Proxy(request *ProxyRequest) (*ProxyResponse, error) { + rsp := &ProxyResponse{} return rsp, t.client.Call("url", "Proxy", request, rsp) + } // Shortens a destination URL and returns a full short URL. func (t *UrlService) Shorten(request *ShortenRequest) (*ShortenResponse, error) { + rsp := &ShortenResponse{} return rsp, t.client.Call("url", "Shorten", request, rsp) + } type ListRequest struct { diff --git a/user/user.go b/user/user.go index 6a4ce49..0281fce 100755 --- a/user/user.go +++ b/user/user.go @@ -18,39 +18,51 @@ type UserService struct { // Create a new user account. The email address and username for the account must be unique. func (t *UserService) Create(request *CreateRequest) (*CreateResponse, error) { + rsp := &CreateResponse{} return rsp, t.client.Call("user", "Create", request, rsp) + } // Delete an account by id func (t *UserService) Delete(request *DeleteRequest) (*DeleteResponse, error) { + rsp := &DeleteResponse{} return rsp, t.client.Call("user", "Delete", request, rsp) + } // 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 (t *UserService) Login(request *LoginRequest) (*LoginResponse, error) { + rsp := &LoginResponse{} return rsp, t.client.Call("user", "Login", request, rsp) + } // Logout a user account func (t *UserService) Logout(request *LogoutRequest) (*LogoutResponse, error) { + rsp := &LogoutResponse{} return rsp, t.client.Call("user", "Logout", request, rsp) + } // Read an account by id, username or email. Only one need to be specified. func (t *UserService) Read(request *ReadRequest) (*ReadResponse, error) { + rsp := &ReadResponse{} return rsp, t.client.Call("user", "Read", request, rsp) + } // Read a session by the session id. In the event it has expired or is not found and error is returned. func (t *UserService) ReadSession(request *ReadSessionRequest) (*ReadSessionResponse, error) { + rsp := &ReadSessionResponse{} return rsp, t.client.Call("user", "ReadSession", request, rsp) + } // Send a verification email @@ -61,26 +73,34 @@ func (t *UserService) ReadSession(request *ReadSessionRequest) (*ReadSessionResp // 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 (t *UserService) SendVerificationEmail(request *SendVerificationEmailRequest) (*SendVerificationEmailResponse, error) { + rsp := &SendVerificationEmailResponse{} return rsp, t.client.Call("user", "SendVerificationEmail", request, rsp) + } // Update the account password func (t *UserService) UpdatePassword(request *UpdatePasswordRequest) (*UpdatePasswordResponse, error) { + rsp := &UpdatePasswordResponse{} return rsp, t.client.Call("user", "UpdatePassword", request, rsp) + } // Update the account username or email func (t *UserService) Update(request *UpdateRequest) (*UpdateResponse, error) { + rsp := &UpdateResponse{} return rsp, t.client.Call("user", "Update", request, rsp) + } // Verify the email address of an account from a token sent in an email to the user. func (t *UserService) VerifyEmail(request *VerifyEmailRequest) (*VerifyEmailResponse, error) { + rsp := &VerifyEmailResponse{} return rsp, t.client.Call("user", "VerifyEmail", request, rsp) + } type Account struct { diff --git a/vehicle/vehicle.go b/vehicle/vehicle.go index 6e05260..3f908c5 100755 --- a/vehicle/vehicle.go +++ b/vehicle/vehicle.go @@ -18,8 +18,10 @@ type VehicleService struct { // Lookup a UK vehicle by it's registration number func (t *VehicleService) Lookup(request *LookupRequest) (*LookupResponse, error) { + rsp := &LookupResponse{} return rsp, t.client.Call("vehicle", "Lookup", request, rsp) + } type LookupRequest struct { diff --git a/weather/weather.go b/weather/weather.go index 1704993..c970bda 100755 --- a/weather/weather.go +++ b/weather/weather.go @@ -18,14 +18,18 @@ type WeatherService struct { // Get the weather forecast for the next 1-10 days func (t *WeatherService) Forecast(request *ForecastRequest) (*ForecastResponse, error) { + rsp := &ForecastResponse{} return rsp, t.client.Call("weather", "Forecast", request, rsp) + } // Get the current weather report for a location by postcode, city, zip code, ip address func (t *WeatherService) Now(request *NowRequest) (*NowResponse, error) { + rsp := &NowResponse{} return rsp, t.client.Call("weather", "Now", request, rsp) + } type Forecast struct { diff --git a/youtube/youtube.go b/youtube/youtube.go index b2cec9a..453e874 100755 --- a/youtube/youtube.go +++ b/youtube/youtube.go @@ -18,8 +18,10 @@ type YoutubeService struct { // Search for videos on YouTube func (t *YoutubeService) Search(request *SearchRequest) (*SearchResponse, error) { + rsp := &SearchResponse{} return rsp, t.client.Call("youtube", "Search", request, rsp) + } type SearchRequest struct {