From 726d1ccef6520ade428b4b646948ed8ecc5007eb Mon Sep 17 00:00:00 2001 From: Janos Dobronszki Date: Tue, 14 Sep 2021 16:36:40 +0100 Subject: [PATCH 1/2] Add separate service clients (#5) --- service/address/address.go | 57 ++++++++ service/answer/answer.go | 37 +++++ service/cache/cache.go | 113 +++++++++++++++ service/crypto/crypto.go | 120 ++++++++++++++++ service/currency/currency.go | 103 ++++++++++++++ service/db/db.go | 117 ++++++++++++++++ service/email/email.go | 41 ++++++ service/emoji/emoji.go | 86 ++++++++++++ service/file/file.go | 107 ++++++++++++++ service/forex/forex.go | 85 ++++++++++++ service/geocoding/geocoding.go | 64 +++++++++ service/helloworld/helloworld.go | 47 +++++++ service/id/id.go | 48 +++++++ service/image/image.go | 115 +++++++++++++++ service/ip/ip.go | 47 +++++++ service/location/location.go | 78 +++++++++++ service/otp/otp.go | 55 ++++++++ service/postcode/postcode.go | 87 ++++++++++++ service/routing/routing.go | 129 +++++++++++++++++ service/rss/rss.go | 114 +++++++++++++++ service/sentiment/sentiment.go | 35 +++++ service/sms/sms.go | 39 ++++++ service/stock/stock.go | 132 ++++++++++++++++++ service/stream/stream.go | 51 +++++++ service/thumbnail/thumbnail.go | 35 +++++ service/time/time.go | 73 ++++++++++ service/url/url.go | 73 ++++++++++ service/user/user.go | 231 +++++++++++++++++++++++++++++++ service/weather/weather.go | 132 ++++++++++++++++++ 29 files changed, 2451 insertions(+) create mode 100755 service/address/address.go create mode 100755 service/answer/answer.go create mode 100755 service/cache/cache.go create mode 100755 service/crypto/crypto.go create mode 100755 service/currency/currency.go create mode 100755 service/db/db.go create mode 100755 service/email/email.go create mode 100755 service/emoji/emoji.go create mode 100755 service/file/file.go create mode 100755 service/forex/forex.go create mode 100755 service/geocoding/geocoding.go create mode 100755 service/helloworld/helloworld.go create mode 100755 service/id/id.go create mode 100755 service/image/image.go create mode 100755 service/ip/ip.go create mode 100755 service/location/location.go create mode 100755 service/otp/otp.go create mode 100755 service/postcode/postcode.go create mode 100755 service/routing/routing.go create mode 100755 service/rss/rss.go create mode 100755 service/sentiment/sentiment.go create mode 100755 service/sms/sms.go create mode 100755 service/stock/stock.go create mode 100755 service/stream/stream.go create mode 100755 service/thumbnail/thumbnail.go create mode 100755 service/time/time.go create mode 100755 service/url/url.go create mode 100755 service/user/user.go create mode 100755 service/weather/weather.go diff --git a/service/address/address.go b/service/address/address.go new file mode 100755 index 0000000..e775315 --- /dev/null +++ b/service/address/address.go @@ -0,0 +1,57 @@ +package address + +import ( + "github.com/m3o/m3o-go/client" +) + +func NewAddressService(token string) *AddressService { + return &AddressService{ + client: client.NewClient(&client.Options{ + Token: token, + }), + } +} + +type AddressService struct { + client *client.Client +} + +// 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 { + // UK postcode e.g SW1A 2AA + Postcode string `json:"postcode"` +} + +type LookupPostcodeResponse struct { + Addresses []Record `json:"addresses"` +} + +type Record struct { + // building name + BuildingName string `json:"buildingName"` + // the county + County string `json:"county"` + // line one of address + LineOne string `json:"lineOne"` + // line two of address + LineTwo string `json:"lineTwo"` + // dependent locality + Locality string `json:"locality"` + // organisation if present + Organisation string `json:"organisation"` + // the postcode + Postcode string `json:"postcode"` + // the premise + Premise string `json:"premise"` + // street name + Street string `json:"street"` + // the complete address + Summary string `json:"summary"` + // post town + Town string `json:"town"` +} diff --git a/service/answer/answer.go b/service/answer/answer.go new file mode 100755 index 0000000..881e67f --- /dev/null +++ b/service/answer/answer.go @@ -0,0 +1,37 @@ +package answer + +import ( + "github.com/m3o/m3o-go/client" +) + +func NewAnswerService(token string) *AnswerService { + return &AnswerService{ + client: client.NewClient(&client.Options{ + Token: token, + }), + } +} + +type AnswerService struct { + client *client.Client +} + +// 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 { + // the question to answer + Query string `json:"query"` +} + +type QuestionResponse struct { + // the answer to your question + Answer string `json:"answer"` + // any related image + Image string `json:"image"` + // a related url + Url string `json:"url"` +} diff --git a/service/cache/cache.go b/service/cache/cache.go new file mode 100755 index 0000000..63fea8e --- /dev/null +++ b/service/cache/cache.go @@ -0,0 +1,113 @@ +package cache + +import ( + "github.com/m3o/m3o-go/client" +) + +func NewCacheService(token string) *CacheService { + return &CacheService{ + client: client.NewClient(&client.Options{ + Token: token, + }), + } +} + +type CacheService struct { + client *client.Client +} + +// Decrement a value (if it's a number) +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 +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 +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) +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 { + // The key to decrement + Key string `json:"key"` + // The amount to decrement the value by + Value int64 `json:"value"` +} + +type DecrementResponse struct { + // The key decremented + Key string `json:"key"` + // The new value + Value int64 `json:"value"` +} + +type DeleteRequest struct { + // The key to delete + Key string `json:"key"` +} + +type DeleteResponse struct { + // Returns "ok" if successful + Status string `json:"status"` +} + +type GetRequest struct { + // The key to retrieve + Key string `json:"key"` +} + +type GetResponse struct { + // The key + Key string `json:"key"` + // Time to live in seconds + Ttl int64 `json:"ttl"` + // The value + Value string `json:"value"` +} + +type IncrementRequest struct { + // The key to increment + Key string `json:"key"` + // The amount to increment the value by + Value int64 `json:"value"` +} + +type IncrementResponse struct { + // The key incremented + Key string `json:"key"` + // The new value + Value int64 `json:"value"` +} + +type SetRequest struct { + // The key to update + Key string `json:"key"` + // Time to live in seconds + Ttl int64 `json:"ttl"` + // The value to set + Value string `json:"value"` +} + +type SetResponse struct { + // Returns "ok" if successful + Status string `json:"status"` +} diff --git a/service/crypto/crypto.go b/service/crypto/crypto.go new file mode 100755 index 0000000..ea85643 --- /dev/null +++ b/service/crypto/crypto.go @@ -0,0 +1,120 @@ +package crypto + +import ( + "github.com/m3o/m3o-go/client" +) + +func NewCryptoService(token string) *CryptoService { + return &CryptoService{ + client: client.NewClient(&client.Options{ + Token: token, + }), + } +} + +type CryptoService struct { + client *client.Client +} + +// 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 { + // the date published + Date string `json:"date"` + // its description + Description string `json:"description"` + // the source + Source string `json:"source"` + // title of the article + Title string `json:"title"` + // the source url + Url string `json:"url"` +} + +type HistoryRequest struct { + // the crypto symbol e.g BTCUSD + Symbol string `json:"symbol"` +} + +type HistoryResponse struct { + // the close price + Close float64 `json:"close"` + // the date + Date string `json:"date"` + // the peak price + High float64 `json:"high"` + // the low price + Low float64 `json:"low"` + // the open price + Open float64 `json:"open"` + // the crypto symbol + Symbol string `json:"symbol"` + // the volume + Volume float64 `json:"volume"` +} + +type NewsRequest struct { + // cryptocurrency ticker to request news for e.g BTC + Symbol string `json:"symbol"` +} + +type NewsResponse struct { + // list of articles + Articles []Article `json:"articles"` + // symbol requested for + Symbol string `json:"symbol"` +} + +type PriceRequest struct { + // the crypto symbol e.g BTCUSD + Symbol string `json:"symbol"` +} + +type PriceResponse struct { + // the last price + Price float64 `json:"price"` + // the crypto symbol e.g BTCUSD + Symbol string `json:"symbol"` +} + +type QuoteRequest struct { + // the crypto symbol e.g BTCUSD + Symbol string `json:"symbol"` +} + +type QuoteResponse struct { + // the asking price + AskPrice float64 `json:"askPrice"` + // the ask size + AskSize float64 `json:"askSize"` + // the bidding price + BidPrice float64 `json:"bidPrice"` + // the bid size + BidSize float64 `json:"bidSize"` + // the crypto symbol + Symbol string `json:"symbol"` + // the UTC timestamp of the quote + Timestamp string `json:"timestamp"` +} diff --git a/service/currency/currency.go b/service/currency/currency.go new file mode 100755 index 0000000..c3410b0 --- /dev/null +++ b/service/currency/currency.go @@ -0,0 +1,103 @@ +package currency + +import ( + "github.com/m3o/m3o-go/client" +) + +func NewCurrencyService(token string) *CurrencyService { + return &CurrencyService{ + client: client.NewClient(&client.Options{ + Token: token, + }), + } +} + +type CurrencyService struct { + client *client.Client +} + +// 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 { + // e.g United States Dollar + Currency string `json:"currency"` + // e.g USD + Name string `json:"name"` +} + +type CodesRequest struct { +} + +type CodesResponse struct { + Codes []Code `json:"codes"` +} + +type ConvertRequest struct { + // optional amount to convert e.g 10.0 + Amount float64 `json:"amount"` + // base code to convert from e.g USD + From string `json:"from"` + // target code to convert to e.g GBP + To string `json:"to"` +} + +type ConvertResponse struct { + // converted amount e.g 7.10 + Amount float64 `json:"amount"` + // the base code e.g USD + From string `json:"from"` + // conversion rate e.g 0.71 + Rate float64 `json:"rate"` + // the target code e.g GBP + To string `json:"to"` +} + +type HistoryRequest struct { + // currency code e.g USD + Code string `json:"code"` + // date formatted as YYYY-MM-DD + Date string `json:"date"` +} + +type HistoryResponse struct { + // The code of the request + Code string `json:"code"` + // The date requested + Date string `json:"date"` + // The rate for the day as code:rate + Rates map[string]float64 `json:"rates"` +} + +type RatesRequest struct { + // The currency code to get rates for e.g USD + Code string `json:"code"` +} + +type RatesResponse struct { + // The code requested e.g USD + Code string `json:"code"` + // The rates for the given code as key-value pairs code:rate + Rates map[string]float64 `json:"rates"` +} diff --git a/service/db/db.go b/service/db/db.go new file mode 100755 index 0000000..1cea496 --- /dev/null +++ b/service/db/db.go @@ -0,0 +1,117 @@ +package db + +import ( + "github.com/m3o/m3o-go/client" +) + +func NewDbService(token string) *DbService { + return &DbService{ + client: client.NewClient(&client.Options{ + Token: token, + }), + } +} + +type DbService struct { + client *client.Client +} + +// 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 CreateRequest struct { + // JSON encoded record or records (can be array or object) + Record map[string]interface{} `json:"record"` + // Optional table name. Defaults to 'default' + Table string `json:"table"` +} + +type CreateResponse struct { + // The id of the record (either specified or automatically created) + Id string `json:"id"` +} + +type DeleteRequest struct { + // id of the record + Id string `json:"id"` + // Optional table name. Defaults to 'default' + Table string `json:"table"` +} + +type DeleteResponse struct { +} + +type ReadRequest struct { + // Read by id. Equivalent to 'id == "your-id"' + Id string `json:"id"` + // Maximum number of records to return. Default limit is 25. + // Maximum limit is 1000. Anything higher will return an error. + Limit int32 `json:"limit"` + Offset int32 `json:"offset"` + // 'asc' (default), 'desc' + Order string `json:"order"` + // field name to order by + OrderBy string `json:"orderBy"` + // Examples: 'age >= 18', 'age >= 18 and verified == true' + // Comparison operators: '==', '!=', '<', '>', '<=', '>=' + // Logical operator: 'and' + // Dot access is supported, eg: 'user.age == 11' + // Accessing list elements is not supported yet. + Query string `json:"query"` + // Optional table name. Defaults to 'default' + Table string `json:"table"` +} + +type ReadResponse struct { + // JSON encoded records + Records []map[string]interface{} `json:"records"` +} + +type TruncateRequest struct { + // Optional table name. Defaults to 'default' + Table string `json:"table"` +} + +type TruncateResponse struct { + // The table truncated + Table string `json:"table"` +} + +type UpdateRequest struct { + // The id of the record. If not specified it is inferred from the 'id' field of the record + Id string `json:"id"` + // record, JSON object + Record map[string]interface{} `json:"record"` + // Optional table name. Defaults to 'default' + Table string `json:"table"` +} + +type UpdateResponse struct { +} diff --git a/service/email/email.go b/service/email/email.go new file mode 100755 index 0000000..8cc63d3 --- /dev/null +++ b/service/email/email.go @@ -0,0 +1,41 @@ +package email + +import ( + "github.com/m3o/m3o-go/client" +) + +func NewEmailService(token string) *EmailService { + return &EmailService{ + client: client.NewClient(&client.Options{ + Token: token, + }), + } +} + +type EmailService struct { + client *client.Client +} + +// 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 { + // the display name of the sender + From string `json:"from"` + // the html body + HtmlBody string `json:"htmlBody"` + // an optional reply to email address + ReplyTo string `json:"replyTo"` + // the email subject + Subject string `json:"subject"` + // the text body + TextBody string `json:"textBody"` + // the email address of the recipient + To string `json:"to"` +} + +type SendResponse struct { +} diff --git a/service/emoji/emoji.go b/service/emoji/emoji.go new file mode 100755 index 0000000..783c405 --- /dev/null +++ b/service/emoji/emoji.go @@ -0,0 +1,86 @@ +package emoji + +import ( + "github.com/m3o/m3o-go/client" +) + +func NewEmojiService(token string) *EmojiService { + return &EmojiService{ + client: client.NewClient(&client.Options{ + Token: token, + }), + } +} + +type EmojiService struct { + client *client.Client +} + +// 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 { + // the alias code e.g :beer: + Alias string `json:"alias"` +} + +type FindResponse struct { + // the unicode emoji 🍺 + Emoji string `json:"emoji"` +} + +type FlagRequest struct { + // country code e.g GB + Code string `json:"code"` +} + +type FlagResponse struct { + // the emoji flag + Flag string `json:"flag"` +} + +type PrintRequest struct { + // text including any alias e.g let's grab a :beer: + Text string `json:"text"` +} + +type PrintResponse struct { + // text with rendered emojis + Text string `json:"text"` +} + +type SendRequest struct { + // the name of the sender from e.g Alice + From string `json:"from"` + // message to send including emoji aliases + Message string `json:"message"` + // phone number to send to (including international dialing code) + To string `json:"to"` +} + +type SendResponse struct { + // whether or not it succeeded + Success bool `json:"success"` +} diff --git a/service/file/file.go b/service/file/file.go new file mode 100755 index 0000000..dbf8caf --- /dev/null +++ b/service/file/file.go @@ -0,0 +1,107 @@ +package file + +import ( + "github.com/m3o/m3o-go/client" +) + +func NewFileService(token string) *FileService { + return &FileService{ + client: client.NewClient(&client.Options{ + Token: token, + }), + } +} + +type FileService struct { + client *client.Client +} + +// 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 { + Files []Record `json:"files"` +} + +type BatchSaveResponse struct { +} + +type DeleteRequest struct { + // Path to the file + Path string `json:"path"` + // The project name + Project string `json:"project"` +} + +type DeleteResponse struct { +} + +type ListRequest struct { + // Defaults to '/', ie. lists all files in a project. + // Supply path to a folder if you want to list + // files inside that folder + // eg. '/docs' + Path string `json:"path"` + // Project, required for listing. + Project string `json:"project"` +} + +type ListResponse struct { + Files []Record `json:"files"` +} + +type ReadRequest struct { + // Path to the file + Path string `json:"path"` + // Project name + Project string `json:"project"` +} + +type ReadResponse struct { + // Returns the file + File *Record `json:"file"` +} + +type Record struct { + // File contents + Content string `json:"content"` + // Time the file was created e.g 2021-05-20T13:37:21Z + Created string `json:"created"` + // Any other associated metadata as a map of key-value pairs + Metadata map[string]string `json:"metadata"` + // Path to file or folder eg. '/documents/text-files/file.txt'. + Path string `json:"path"` + // A custom project to group files + // eg. file-of-mywebsite.com + Project string `json:"project"` + // Time the file was updated e.g 2021-05-20T13:37:21Z + Updated string `json:"updated"` +} + +type SaveRequest struct { + File *Record `json:"file"` +} + +type SaveResponse struct { +} diff --git a/service/forex/forex.go b/service/forex/forex.go new file mode 100755 index 0000000..d4f2fe5 --- /dev/null +++ b/service/forex/forex.go @@ -0,0 +1,85 @@ +package forex + +import ( + "github.com/m3o/m3o-go/client" +) + +func NewForexService(token string) *ForexService { + return &ForexService{ + client: client.NewClient(&client.Options{ + Token: token, + }), + } +} + +type ForexService struct { + client *client.Client +} + +// 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 { + // the forex symbol e.g GBPUSD + Symbol string `json:"symbol"` +} + +type HistoryResponse struct { + // the close price + Close float64 `json:"close"` + // the date + Date string `json:"date"` + // the peak price + High float64 `json:"high"` + // the low price + Low float64 `json:"low"` + // the open price + Open float64 `json:"open"` + // the forex symbol + Symbol string `json:"symbol"` + // the volume + Volume float64 `json:"volume"` +} + +type PriceRequest struct { + // forex symbol e.g GBPUSD + Symbol string `json:"symbol"` +} + +type PriceResponse struct { + // the last price + Price float64 `json:"price"` + // the forex symbol e.g GBPUSD + Symbol string `json:"symbol"` +} + +type QuoteRequest struct { + // the forex symbol e.g GBPUSD + Symbol string `json:"symbol"` +} + +type QuoteResponse struct { + // the asking price + AskPrice float64 `json:"askPrice"` + // the bidding price + BidPrice float64 `json:"bidPrice"` + // the forex symbol + Symbol string `json:"symbol"` + // the UTC timestamp of the quote + Timestamp string `json:"timestamp"` +} diff --git a/service/geocoding/geocoding.go b/service/geocoding/geocoding.go new file mode 100755 index 0000000..d569b7f --- /dev/null +++ b/service/geocoding/geocoding.go @@ -0,0 +1,64 @@ +package geocoding + +import ( + "github.com/m3o/m3o-go/client" +) + +func NewGeocodingService(token string) *GeocodingService { + return &GeocodingService{ + client: client.NewClient(&client.Options{ + Token: token, + }), + } +} + +type GeocodingService struct { + client *client.Client +} + +// 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 { + City string `json:"city"` + Country string `json:"country"` + LineOne string `json:"lineOne"` + LineTwo string `json:"lineTwo"` + Postcode string `json:"postcode"` +} + +type Location struct { + Latitude float64 `json:"latitude"` + Longitude float64 `json:"longitude"` +} + +type LookupRequest struct { + Address string `json:"address"` + City string `json:"city"` + Country string `json:"country"` + Postcode string `json:"postcode"` +} + +type LookupResponse struct { + Address *Address `json:"address"` + Location *Location `json:"location"` +} + +type ReverseRequest struct { + Latitude float64 `json:"latitude"` + Longitude float64 `json:"longitude"` +} + +type ReverseResponse struct { + Address *Address `json:"address"` + Location *Location `json:"location"` +} diff --git a/service/helloworld/helloworld.go b/service/helloworld/helloworld.go new file mode 100755 index 0000000..0777b7e --- /dev/null +++ b/service/helloworld/helloworld.go @@ -0,0 +1,47 @@ +package helloworld + +import ( + "github.com/m3o/m3o-go/client" +) + +func NewHelloworldService(token string) *HelloworldService { + return &HelloworldService{ + client: client.NewClient(&client.Options{ + Token: token, + }), + } +} + +type HelloworldService struct { + client *client.Client +} + +// 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) +} + +type CallRequest struct { + Name string `json:"name"` +} + +type CallResponse struct { + Message string `json:"message"` +} + +type StreamRequest struct { + // the number of messages to send back + Messages int64 `json:"messages"` + Name string `json:"name"` +} + +type StreamResponse struct { + Message string `json:"message"` +} diff --git a/service/id/id.go b/service/id/id.go new file mode 100755 index 0000000..f3d5638 --- /dev/null +++ b/service/id/id.go @@ -0,0 +1,48 @@ +package id + +import ( + "github.com/m3o/m3o-go/client" +) + +func NewIdService(token string) *IdService { + return &IdService{ + client: client.NewClient(&client.Options{ + Token: token, + }), + } +} + +type IdService struct { + client *client.Client +} + +// 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 { + // type of id e.g uuid, shortid, snowflake (64 bit), bigflake (128 bit) + Type string `json:"type"` +} + +type GenerateResponse struct { + // the unique id generated + Id string `json:"id"` + // the type of id generated + Type string `json:"type"` +} + +type TypesRequest struct { +} + +type TypesResponse struct { + Types []string `json:"types"` +} diff --git a/service/image/image.go b/service/image/image.go new file mode 100755 index 0000000..37bf373 --- /dev/null +++ b/service/image/image.go @@ -0,0 +1,115 @@ +package image + +import ( + "github.com/m3o/m3o-go/client" +) + +func NewImageService(token string) *ImageService { + return &ImageService{ + client: client.NewClient(&client.Options{ + Token: token, + }), + } +} + +type ImageService struct { + client *client.Client +} + +// 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 { + // base64 encoded image to resize, + // ie. "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==" + Base64 string `json:"base64"` + // output name of the image including extension, ie. "cat.png" + Name string `json:"name"` + // make output a URL and not a base64 response + OutputUrl bool `json:"outputUrl"` + // url of the image to resize + Url string `json:"url"` +} + +type ConvertResponse struct { + Base64 string `json:"base64"` + Url string `json:"url"` +} + +type CropOptions struct { + // Crop anchor point: "top", "top left", "top right", + // "left", "center", "right" + // "bottom left", "bottom", "bottom right". + // Optional. Defaults to center. + Anchor string `json:"anchor"` + // height to crop to + Height int32 `json:"height"` + // width to crop to + Width int32 `json:"width"` +} + +type Point struct { + X int32 `json:"x"` + Y int32 `json:"y"` +} + +type Rectangle struct { + Max *Point `json:"max"` + Min *Point `json:"min"` +} + +type ResizeRequest struct { + // base64 encoded image to resize, + // ie. "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==" + Base64 string `json:"base64"` + // optional crop options + // if provided, after resize, the image + // will be cropped + CropOptions *CropOptions `json:"cropOptions"` + Height int64 `json:"height"` + // output name of the image including extension, ie. "cat.png" + Name string `json:"name"` + // make output a URL and not a base64 response + OutputUrl bool `json:"outputUrl"` + // url of the image to resize + Url string `json:"url"` + Width int64 `json:"width"` +} + +type ResizeResponse struct { + Base64 string `json:"base64"` + Url string `json:"url"` +} + +type UploadRequest struct { + // Base64 encoded image to upload, + // ie. "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==" + Base64 string `json:"base64"` + // Output name of the image including extension, ie. "cat.png" + Name string `json:"name"` + // URL of the image to upload + Url string `json:"url"` +} + +type UploadResponse struct { + Url string `json:"url"` +} diff --git a/service/ip/ip.go b/service/ip/ip.go new file mode 100755 index 0000000..3d81955 --- /dev/null +++ b/service/ip/ip.go @@ -0,0 +1,47 @@ +package ip + +import ( + "github.com/m3o/m3o-go/client" +) + +func NewIpService(token string) *IpService { + return &IpService{ + client: client.NewClient(&client.Options{ + Token: token, + }), + } +} + +type IpService struct { + client *client.Client +} + +// 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 { + // IP to lookup + Ip string `json:"ip"` +} + +type LookupResponse struct { + // Autonomous system number + Asn int32 `json:"asn"` + // Name of the city + City string `json:"city"` + // Name of the continent + Continent string `json:"continent"` + // Name of the country + Country string `json:"country"` + // IP of the query + Ip string `json:"ip"` + // Latitude e.g 52.523219 + Latitude float64 `json:"latitude"` + // Longitude e.g 13.428555 + Longitude float64 `json:"longitude"` + // Timezone e.g Europe/Rome + Timezone string `json:"timezone"` +} diff --git a/service/location/location.go b/service/location/location.go new file mode 100755 index 0000000..5c477f9 --- /dev/null +++ b/service/location/location.go @@ -0,0 +1,78 @@ +package location + +import ( + "github.com/m3o/m3o-go/client" +) + +func NewLocationService(token string) *LocationService { + return &LocationService{ + client: client.NewClient(&client.Options{ + Token: token, + }), + } +} + +type LocationService struct { + client *client.Client +} + +// 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 { + Id string `json:"id"` + Location *Point `json:"location"` + Type string `json:"type"` +} + +type Point struct { + Latitude float64 `json:"latitude"` + Longitude float64 `json:"longitude"` + Timestamp int64 `json:"timestamp"` +} + +type ReadRequest struct { + // the entity id + Id string `json:"id"` +} + +type ReadResponse struct { + Entity *Entity `json:"entity"` +} + +type SaveRequest struct { + Entity *Entity `json:"entity"` +} + +type SaveResponse struct { +} + +type SearchRequest struct { + // Central position to search from + Center *Point `json:"center"` + // Maximum number of entities to return + NumEntities int64 `json:"numEntities"` + // radius in meters + Radius float64 `json:"radius"` + // type of entities to filter + Type string `json:"type"` +} + +type SearchResponse struct { + Entities []Entity `json:"entities"` +} diff --git a/service/otp/otp.go b/service/otp/otp.go new file mode 100755 index 0000000..17764cd --- /dev/null +++ b/service/otp/otp.go @@ -0,0 +1,55 @@ +package otp + +import ( + "github.com/m3o/m3o-go/client" +) + +func NewOtpService(token string) *OtpService { + return &OtpService{ + client: client.NewClient(&client.Options{ + Token: token, + }), + } +} + +type OtpService struct { + client *client.Client +} + +// 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 { + // expiration in seconds (default: 60) + Expiry int64 `json:"expiry"` + // unique id, email or user to generate an OTP for + Id string `json:"id"` + // number of characters (default: 6) + Size int64 `json:"size"` +} + +type GenerateResponse struct { + // one time pass code + Code string `json:"code"` +} + +type ValidateRequest struct { + // one time pass code to validate + Code string `json:"code"` + // unique id, email or user for which the code was generated + Id string `json:"id"` +} + +type ValidateResponse struct { + // returns true if the code is valid for the ID + Success bool `json:"success"` +} diff --git a/service/postcode/postcode.go b/service/postcode/postcode.go new file mode 100755 index 0000000..818f64b --- /dev/null +++ b/service/postcode/postcode.go @@ -0,0 +1,87 @@ +package postcode + +import ( + "github.com/m3o/m3o-go/client" +) + +func NewPostcodeService(token string) *PostcodeService { + return &PostcodeService{ + client: client.NewClient(&client.Options{ + Token: token, + }), + } +} + +type PostcodeService struct { + client *client.Client +} + +// 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 { + // UK postcode e.g SW1A 2AA + Postcode string `json:"postcode"` +} + +type LookupResponse struct { + // country e.g United Kingdom + Country string `json:"country"` + // e.g Westminster + District string `json:"district"` + // e.g 51.50354 + Latitude float64 `json:"latitude"` + // e.g -0.127695 + Longitude float64 `json:"longitude"` + // UK postcode e.g SW1A 2AA + Postcode string `json:"postcode"` + // related region e.g London + Region string `json:"region"` + // e.g St James's + Ward string `json:"ward"` +} + +type RandomRequest struct { +} + +type RandomResponse struct { + // country e.g United Kingdom + Country string `json:"country"` + // e.g Westminster + District string `json:"district"` + // e.g 51.50354 + Latitude float64 `json:"latitude"` + // e.g -0.127695 + Longitude float64 `json:"longitude"` + // UK postcode e.g SW1A 2AA + Postcode string `json:"postcode"` + // related region e.g London + Region string `json:"region"` + // e.g St James's + Ward string `json:"ward"` +} + +type ValidateRequest struct { + // UK postcode e.g SW1A 2AA + Postcode string `json:"postcode"` +} + +type ValidateResponse struct { + // Is the postcode valid (true) or not (false) + Valid bool `json:"valid"` +} diff --git a/service/routing/routing.go b/service/routing/routing.go new file mode 100755 index 0000000..4ac2d5b --- /dev/null +++ b/service/routing/routing.go @@ -0,0 +1,129 @@ +package routing + +import ( + "github.com/m3o/m3o-go/client" +) + +func NewRoutingService(token string) *RoutingService { + return &RoutingService{ + client: client.NewClient(&client.Options{ + Token: token, + }), + } +} + +type RoutingService struct { + client *client.Client +} + +// 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 { + // distance to travel in meters + Distance float64 `json:"distance"` + // duration to travel in seconds + Duration float64 `json:"duration"` + // human readable instruction + Instruction string `json:"instruction"` + // intersections on route + Intersections []Intersection `json:"intersections"` + // maneuver to take + Maneuver *Maneuver `json:"maneuver"` + // street name or location + Name string `json:"name"` + // alternative reference + Reference string `json:"reference"` +} + +type DirectionsRequest struct { + // The destination of the journey + Destination *Point `json:"destination"` + // The staring point for the journey + Origin *Point `json:"origin"` +} + +type DirectionsResponse struct { + // Turn by turn directions + Directions []Direction `json:"directions"` + // Estimated distance of the route in meters + Distance float64 `json:"distance"` + // Estimated duration of the route in seconds + Duration float64 `json:"duration"` + // The waypoints on the route + Waypoints []Waypoint `json:"waypoints"` +} + +type EtaRequest struct { + // The end point for the eta calculation + Destination *Point `json:"destination"` + // The starting point for the eta calculation + Origin *Point `json:"origin"` + // speed in kilometers + Speed float64 `json:"speed"` + // type of transport. Only "car" is supported currently. + Type string `json:"type"` +} + +type EtaResponse struct { + // eta in seconds + Duration float64 `json:"duration"` +} + +type Intersection struct { + Bearings []float64 `json:"bearings"` + Location *Point `json:"location"` +} + +type Maneuver struct { + Action string `json:"action"` + BearingAfter float64 `json:"bearingAfter"` + BearingBefore float64 `json:"bearingBefore"` + Direction string `json:"direction"` + Location *Point `json:"location"` +} + +type Point struct { + // Lat e.g 52.523219 + Latitude float64 `json:"latitude"` + // Long e.g 13.428555 + Longitude float64 `json:"longitude"` +} + +type RouteRequest struct { + // Point of destination for the trip + Destination *Point `json:"destination"` + // Point of origin for the trip + Origin *Point `json:"origin"` +} + +type RouteResponse struct { + // estimated distance in meters + Distance float64 `json:"distance"` + // estimated duration in seconds + Duration float64 `json:"duration"` + // waypoints on the route + Waypoints []Waypoint `json:"waypoints"` +} + +type Waypoint struct { + // gps point coordinates + Location *Point `json:"location"` + // street name or related reference + Name string `json:"name"` +} diff --git a/service/rss/rss.go b/service/rss/rss.go new file mode 100755 index 0000000..04acf3d --- /dev/null +++ b/service/rss/rss.go @@ -0,0 +1,114 @@ +package rss + +import ( + "github.com/m3o/m3o-go/client" +) + +func NewRssService(token string) *RssService { + return &RssService{ + client: client.NewClient(&client.Options{ + Token: token, + }), + } +} + +type RssService struct { + client *client.Client +} + +// 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 { + // category to add e.g news + Category string `json:"category"` + // rss feed name + // eg. a16z + Name string `json:"name"` + // rss feed url + // eg. http://a16z.com/feed/ + Url string `json:"url"` +} + +type AddResponse struct { +} + +type Entry struct { + // article content + Content string `json:"content"` + // data of the entry + Date string `json:"date"` + // the rss feed where it came from + Feed string `json:"feed"` + // unique id of the entry + Id string `json:"id"` + // rss feed url of the entry + Link string `json:"link"` + // article summary + Summary string `json:"summary"` + // title of the entry + Title string `json:"title"` +} + +type Feed struct { + // category of the feed e.g news + Category string `json:"category"` + // unique id + Id string `json:"id"` + // rss feed name + // eg. a16z + Name string `json:"name"` + // rss feed url + // eg. http://a16z.com/feed/ + Url string `json:"url"` +} + +type FeedRequest struct { + // limit entries returned + Limit int64 `json:"limit"` + // rss feed name + Name string `json:"name"` + // offset entries + Offset int64 `json:"offset"` +} + +type FeedResponse struct { + Entries []Entry `json:"entries"` +} + +type ListRequest struct { +} + +type ListResponse struct { + Feeds []Feed `json:"feeds"` +} + +type RemoveRequest struct { + // rss feed name + // eg. a16z + Name string `json:"name"` +} + +type RemoveResponse struct { +} diff --git a/service/sentiment/sentiment.go b/service/sentiment/sentiment.go new file mode 100755 index 0000000..f53278f --- /dev/null +++ b/service/sentiment/sentiment.go @@ -0,0 +1,35 @@ +package sentiment + +import ( + "github.com/m3o/m3o-go/client" +) + +func NewSentimentService(token string) *SentimentService { + return &SentimentService{ + client: client.NewClient(&client.Options{ + Token: token, + }), + } +} + +type SentimentService struct { + client *client.Client +} + +// 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 { + // The language. Defaults to english. + Lang string `json:"lang"` + // The text to analyze + Text string `json:"text"` +} + +type AnalyzeResponse struct { + // The score of the text {positive is 1, negative is 0} + Score float64 `json:"score"` +} diff --git a/service/sms/sms.go b/service/sms/sms.go new file mode 100755 index 0000000..8ae4f5f --- /dev/null +++ b/service/sms/sms.go @@ -0,0 +1,39 @@ +package sms + +import ( + "github.com/m3o/m3o-go/client" +) + +func NewSmsService(token string) *SmsService { + return &SmsService{ + client: client.NewClient(&client.Options{ + Token: token, + }), + } +} + +type SmsService struct { + client *client.Client +} + +// 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 { + // who is the message from? The message will be suffixed with "Sent from " + From string `json:"from"` + // the main body of the message to send + Message string `json:"message"` + // the destination phone number including the international dialling code (e.g. +44) + To string `json:"to"` +} + +type SendResponse struct { + // any additional info + Info string `json:"info"` + // will return "ok" if successful + Status string `json:"status"` +} diff --git a/service/stock/stock.go b/service/stock/stock.go new file mode 100755 index 0000000..002ddf5 --- /dev/null +++ b/service/stock/stock.go @@ -0,0 +1,132 @@ +package stock + +import ( + "github.com/m3o/m3o-go/client" +) + +func NewStockService(token string) *StockService { + return &StockService{ + client: client.NewClient(&client.Options{ + Token: token, + }), + } +} + +type StockService struct { + client *client.Client +} + +// 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 { + // date to retrieve as YYYY-MM-DD + Date string `json:"date"` + // the stock symbol e.g AAPL + Stock string `json:"stock"` +} + +type HistoryResponse struct { + // the close price + Close float64 `json:"close"` + // the date + Date string `json:"date"` + // the peak price + High float64 `json:"high"` + // the low price + Low float64 `json:"low"` + // the open price + Open float64 `json:"open"` + // the stock symbol + Symbol string `json:"symbol"` + // the volume + Volume int32 `json:"volume"` +} + +type Order struct { + // the asking price + AskPrice float64 `json:"askPrice"` + // the ask size + AskSize int32 `json:"askSize"` + // the bidding price + BidPrice float64 `json:"bidPrice"` + // the bid size + BidSize int32 `json:"bidSize"` + // the UTC timestamp of the quote + Timestamp string `json:"timestamp"` +} + +type OrderBookRequest struct { + // the date in format YYYY-MM-dd + Date string `json:"date"` + // optional RFC3339Nano end time e.g 2006-01-02T15:04:05.999999999Z07:00 + End string `json:"end"` + // limit number of prices + Limit int32 `json:"limit"` + // optional RFC3339Nano start time e.g 2006-01-02T15:04:05.999999999Z07:00 + Start string `json:"start"` + // stock to retrieve e.g AAPL + Stock string `json:"stock"` +} + +type OrderBookResponse struct { + // date of the request + Date string `json:"date"` + // list of orders + Orders []Order `json:"orders"` + // the stock symbol + Symbol string `json:"symbol"` +} + +type PriceRequest struct { + // stock symbol e.g AAPL + Symbol string `json:"symbol"` +} + +type PriceResponse struct { + // the last price + Price float64 `json:"price"` + // the stock symbol e.g AAPL + Symbol string `json:"symbol"` +} + +type QuoteRequest struct { + // the stock symbol e.g AAPL + Symbol string `json:"symbol"` +} + +type QuoteResponse struct { + // the asking price + AskPrice float64 `json:"askPrice"` + // the ask size + AskSize int32 `json:"askSize"` + // the bidding price + BidPrice float64 `json:"bidPrice"` + // the bid size + BidSize int32 `json:"bidSize"` + // the stock symbol + Symbol string `json:"symbol"` + // the UTC timestamp of the quote + Timestamp string `json:"timestamp"` +} diff --git a/service/stream/stream.go b/service/stream/stream.go new file mode 100755 index 0000000..6467965 --- /dev/null +++ b/service/stream/stream.go @@ -0,0 +1,51 @@ +package stream + +import ( + "github.com/m3o/m3o-go/client" +) + +func NewStreamService(token string) *StreamService { + return &StreamService{ + client: client.NewClient(&client.Options{ + Token: token, + }), + } +} + +type StreamService struct { + client *client.Client +} + +// Publish a message to the stream. Specify a topic to group messages for a specific topic. +func (t *StreamService) Publish(request *PublishRequest) (*PublishResponse, error) { + rsp := &PublishResponse{} + return rsp, t.client.Call("stream", "Publish", request, rsp) +} + +// Subscribe to messages for a given topic. +func (t *StreamService) Subscribe(request *SubscribeRequest) (*SubscribeResponse, error) { + rsp := &SubscribeResponse{} + return rsp, t.client.Call("stream", "Subscribe", request, rsp) +} + +type PublishRequest struct { + // The json message to publish + Message map[string]interface{} `json:"message"` + // The topic to publish to + Topic string `json:"topic"` +} + +type PublishResponse struct { +} + +type SubscribeRequest struct { + // The topic to subscribe to + Topic string `json:"topic"` +} + +type SubscribeResponse struct { + // The next json message on the topic + Message map[string]interface{} `json:"message"` + // The topic subscribed to + Topic string `json:"topic"` +} diff --git a/service/thumbnail/thumbnail.go b/service/thumbnail/thumbnail.go new file mode 100755 index 0000000..cb33147 --- /dev/null +++ b/service/thumbnail/thumbnail.go @@ -0,0 +1,35 @@ +package thumbnail + +import ( + "github.com/m3o/m3o-go/client" +) + +func NewThumbnailService(token string) *ThumbnailService { + return &ThumbnailService{ + client: client.NewClient(&client.Options{ + Token: token, + }), + } +} + +type ThumbnailService struct { + client *client.Client +} + +// 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 { + // height of the browser window, optional + Height int32 `json:"height"` + Url string `json:"url"` + // width of the browser window. optional + Width int32 `json:"width"` +} + +type ScreenshotResponse struct { + ImageUrl string `json:"imageUrl"` +} diff --git a/service/time/time.go b/service/time/time.go new file mode 100755 index 0000000..cbda864 --- /dev/null +++ b/service/time/time.go @@ -0,0 +1,73 @@ +package time + +import ( + "github.com/m3o/m3o-go/client" +) + +func NewTimeService(token string) *TimeService { + return &TimeService{ + client: client.NewClient(&client.Options{ + Token: token, + }), + } +} + +type TimeService struct { + client *client.Client +} + +// 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 { + // optional location, otherwise returns UTC + Location string `json:"location"` +} + +type NowResponse struct { + // the current time as HH:MM:SS + Localtime string `json:"localtime"` + // the location as Europe/London + Location string `json:"location"` + // timestamp as 2006-01-02T15:04:05.999999999Z07:00 + Timestamp string `json:"timestamp"` + // the timezone as BST + Timezone string `json:"timezone"` + // the unix timestamp + Unix int64 `json:"unix"` +} + +type ZoneRequest struct { + // location to lookup e.g postcode, city, ip address + Location string `json:"location"` +} + +type ZoneResponse struct { + // the abbreviated code e.g BST + Abbreviation string `json:"abbreviation"` + // country of the timezone + Country string `json:"country"` + // is daylight savings + Dst bool `json:"dst"` + // e.g 51.42 + Latitude float64 `json:"latitude"` + // the local time + Localtime string `json:"localtime"` + // location requested + Location string `json:"location"` + // e.g -0.37 + Longitude float64 `json:"longitude"` + // region of timezone + Region string `json:"region"` + // the timezone e.g Europe/London + Timezone string `json:"timezone"` +} diff --git a/service/url/url.go b/service/url/url.go new file mode 100755 index 0000000..75fb17e --- /dev/null +++ b/service/url/url.go @@ -0,0 +1,73 @@ +package url + +import ( + "github.com/m3o/m3o-go/client" +) + +func NewUrlService(token string) *UrlService { + return &UrlService{ + client: client.NewClient(&client.Options{ + Token: token, + }), + } +} + +type UrlService struct { + client *client.Client +} + +// 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 { + // filter by short URL, optional + ShortUrl string `json:"shortUrl"` +} + +type ListResponse struct { + UrlPairs *URLPair `json:"urlPairs"` +} + +type ProxyRequest struct { + // short url ID, without the domain, eg. if your short URL is + // `m3o.one/u/someshorturlid` then pass in `someshorturlid` + ShortUrl string `json:"shortUrl"` +} + +type ProxyResponse struct { + DestinationUrl string `json:"destinationUrl"` +} + +type ShortenRequest struct { + DestinationUrl string `json:"destinationUrl"` +} + +type ShortenResponse struct { + ShortUrl string `json:"shortUrl"` +} + +type URLPair struct { + Created int64 `json:"created"` + DestinationUrl string `json:"destinationUrl"` + // HitCount keeps track many times the short URL has been resolved. + // Hitcount only gets saved to disk (database) after every 10th hit, so + // its not intended to be 100% accurate, more like an almost correct estimate. + HitCount int64 `json:"hitCount"` + Owner string `json:"owner"` + ShortUrl string `json:"shortUrl"` +} diff --git a/service/user/user.go b/service/user/user.go new file mode 100755 index 0000000..fcd01fa --- /dev/null +++ b/service/user/user.go @@ -0,0 +1,231 @@ +package user + +import ( + "github.com/m3o/m3o-go/client" +) + +func NewUserService(token string) *UserService { + return &UserService{ + client: client.NewClient(&client.Options{ + Token: token, + }), + } +} + +type UserService struct { + client *client.Client +} + +// 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 +// 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&rediretUrl=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 { + // unix timestamp + Created int64 `json:"created"` + // an email address + Email string `json:"email"` + // unique account id + Id string `json:"id"` + // Store any custom data you want about your users in this fields. + Profile map[string]string `json:"profile"` + // unix timestamp + Updated int64 `json:"updated"` + // alphanumeric username + Username string `json:"username"` + VerificationDate int64 `json:"verificationDate"` + Verified bool `json:"verified"` +} + +type CreateRequest struct { + // the email address + Email string `json:"email"` + // optional account id + Id string `json:"id"` + // the user password + Password string `json:"password"` + // optional user profile as map + Profile map[string]string `json:"profile"` + // the username + Username string `json:"username"` +} + +type CreateResponse struct { + Account *Account `json:"account"` +} + +type DeleteRequest struct { + // the account id + Id string `json:"id"` +} + +type DeleteResponse struct { +} + +type LoginRequest struct { + // The email address of the user + Email string `json:"email"` + // The password of the user + Password string `json:"password"` + // The username of the user + Username string `json:"username"` +} + +type LoginResponse struct { + // The session of the logged in user + Session *Session `json:"session"` +} + +type LogoutRequest struct { + SessionId string `json:"sessionId"` +} + +type LogoutResponse struct { +} + +type ReadRequest struct { + // the account email + Email string `json:"email"` + // the account id + Id string `json:"id"` + // the account username + Username string `json:"username"` +} + +type ReadResponse struct { + Account *Account `json:"account"` +} + +type ReadSessionRequest struct { + // The unique session id + SessionId string `json:"sessionId"` +} + +type ReadSessionResponse struct { + Session *Session `json:"session"` +} + +type SendVerificationEmailRequest struct { + Email string `json:"email"` + FailureRedirectUrl string `json:"failureRedirectUrl"` + // Display name of the sender for the email. Note: the email address will still be 'support@m3o.com' + FromName string `json:"fromName"` + RedirectUrl string `json:"redirectUrl"` + Subject string `json:"subject"` + // Text content of the email. Don't forget to include the string '$micro_verification_link' which will be replaced by the real verification link + // HTML emails are not available currently. + TextContent string `json:"textContent"` +} + +type SendVerificationEmailResponse struct { +} + +type Session struct { + // unix timestamp + Created int64 `json:"created"` + // unix timestamp + Expires int64 `json:"expires"` + // the session id + Id string `json:"id"` + // the associated user id + UserId string `json:"userId"` +} + +type UpdatePasswordRequest struct { + // confirm new password + ConfirmPassword string `json:"confirmPassword"` + // the new password + NewPassword string `json:"newPassword"` + // the old password + OldPassword string `json:"oldPassword"` + // the account id + UserId string `json:"userId"` +} + +type UpdatePasswordResponse struct { +} + +type UpdateRequest struct { + // the new email address + Email string `json:"email"` + // the account id + Id string `json:"id"` + // the user profile as map + Profile map[string]string `json:"profile"` + // the new username + Username string `json:"username"` +} + +type UpdateResponse struct { +} + +type VerifyEmailRequest struct { + // The token from the verification email + Token string `json:"token"` +} + +type VerifyEmailResponse struct { +} diff --git a/service/weather/weather.go b/service/weather/weather.go new file mode 100755 index 0000000..578297a --- /dev/null +++ b/service/weather/weather.go @@ -0,0 +1,132 @@ +package weather + +import ( + "github.com/m3o/m3o-go/client" +) + +func NewWeatherService(token string) *WeatherService { + return &WeatherService{ + client: client.NewClient(&client.Options{ + Token: token, + }), + } +} + +type WeatherService struct { + client *client.Client +} + +// 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 { + // the average temp in celsius + AvgTempC float64 `json:"avgTempC"` + // the average temp in fahrenheit + AvgTempF float64 `json:"avgTempF"` + // chance of rain (percentage) + ChanceOfRain int32 `json:"chanceOfRain"` + // forecast condition + Condition string `json:"condition"` + // date of the forecast + Date string `json:"date"` + // the URL of forecast condition icon. Simply prefix with either http or https to use it + IconUrl string `json:"iconUrl"` + // max temp in celsius + MaxTempC float64 `json:"maxTempC"` + // max temp in fahrenheit + MaxTempF float64 `json:"maxTempF"` + // minimum temp in celsius + MinTempC float64 `json:"minTempC"` + // minimum temp in fahrenheit + MinTempF float64 `json:"minTempF"` + // time of sunrise + Sunrise string `json:"sunrise"` + // time of sunset + Sunset string `json:"sunset"` + // will it rain + WillItRain bool `json:"willItRain"` +} + +type ForecastRequest struct { + // number of days. default 1, max 10 + Days int32 `json:"days"` + // location of the forecase + Location string `json:"location"` +} + +type ForecastResponse struct { + // country of the request + Country string `json:"country"` + // forecast for the next number of days + Forecast []Forecast `json:"forecast"` + // e.g 37.55 + Latitude float64 `json:"latitude"` + // the local time + LocalTime string `json:"localTime"` + // location of the request + Location string `json:"location"` + // e.g -77.46 + Longitude float64 `json:"longitude"` + // region related to the location + Region string `json:"region"` + // timezone of the location + Timezone string `json:"timezone"` +} + +type NowRequest struct { + // location to get weather e.g postcode, city + Location string `json:"location"` +} + +type NowResponse struct { + // cloud cover percentage + Cloud int32 `json:"cloud"` + // the weather condition + Condition string `json:"condition"` + // country of the request + Country string `json:"country"` + // whether its daytime + Daytime bool `json:"daytime"` + // feels like in celsius + FeelsLikeC float64 `json:"feelsLikeC"` + // feels like in fahrenheit + FeelsLikeF float64 `json:"feelsLikeF"` + // the humidity percentage + Humidity int32 `json:"humidity"` + // the URL of the related icon. Simply prefix with either http or https to use it + IconUrl string `json:"iconUrl"` + // e.g 37.55 + Latitude float64 `json:"latitude"` + // the local time + LocalTime string `json:"localTime"` + // location of the request + Location string `json:"location"` + // e.g -77.46 + Longitude float64 `json:"longitude"` + // region related to the location + Region string `json:"region"` + // temperature in celsius + TempC float64 `json:"tempC"` + // temperature in fahrenheit + TempF float64 `json:"tempF"` + // timezone of the location + Timezone string `json:"timezone"` + // wind degree + WindDegree int32 `json:"windDegree"` + // wind direction + WindDirection string `json:"windDirection"` + // wind in kph + WindKph float64 `json:"windKph"` + // wind in mph + WindMph float64 `json:"windMph"` +} From a4f018a78d79128ce05c6702fb67a8c08897c4b8 Mon Sep 17 00:00:00 2001 From: Janos Dobronszki Date: Wed, 15 Sep 2021 12:36:33 +0100 Subject: [PATCH 2/2] Remove type safe clients --- service/address/address.go | 57 -------- service/answer/answer.go | 37 ----- service/cache/cache.go | 113 --------------- service/crypto/crypto.go | 120 ---------------- service/currency/currency.go | 103 -------------- service/db/db.go | 117 ---------------- service/email/email.go | 41 ------ service/emoji/emoji.go | 86 ------------ service/file/file.go | 107 -------------- service/forex/forex.go | 85 ------------ service/geocoding/geocoding.go | 64 --------- service/helloworld/helloworld.go | 47 ------- service/id/id.go | 48 ------- service/image/image.go | 115 --------------- service/ip/ip.go | 47 ------- service/location/location.go | 78 ----------- service/otp/otp.go | 55 -------- service/postcode/postcode.go | 87 ------------ service/routing/routing.go | 129 ----------------- service/rss/rss.go | 114 --------------- service/sentiment/sentiment.go | 35 ----- service/sms/sms.go | 39 ------ service/stock/stock.go | 132 ------------------ service/stream/stream.go | 51 ------- service/thumbnail/thumbnail.go | 35 ----- service/time/time.go | 73 ---------- service/url/url.go | 73 ---------- service/user/user.go | 231 ------------------------------- service/weather/weather.go | 132 ------------------ 29 files changed, 2451 deletions(-) delete mode 100755 service/address/address.go delete mode 100755 service/answer/answer.go delete mode 100755 service/cache/cache.go delete mode 100755 service/crypto/crypto.go delete mode 100755 service/currency/currency.go delete mode 100755 service/db/db.go delete mode 100755 service/email/email.go delete mode 100755 service/emoji/emoji.go delete mode 100755 service/file/file.go delete mode 100755 service/forex/forex.go delete mode 100755 service/geocoding/geocoding.go delete mode 100755 service/helloworld/helloworld.go delete mode 100755 service/id/id.go delete mode 100755 service/image/image.go delete mode 100755 service/ip/ip.go delete mode 100755 service/location/location.go delete mode 100755 service/otp/otp.go delete mode 100755 service/postcode/postcode.go delete mode 100755 service/routing/routing.go delete mode 100755 service/rss/rss.go delete mode 100755 service/sentiment/sentiment.go delete mode 100755 service/sms/sms.go delete mode 100755 service/stock/stock.go delete mode 100755 service/stream/stream.go delete mode 100755 service/thumbnail/thumbnail.go delete mode 100755 service/time/time.go delete mode 100755 service/url/url.go delete mode 100755 service/user/user.go delete mode 100755 service/weather/weather.go diff --git a/service/address/address.go b/service/address/address.go deleted file mode 100755 index e775315..0000000 --- a/service/address/address.go +++ /dev/null @@ -1,57 +0,0 @@ -package address - -import ( - "github.com/m3o/m3o-go/client" -) - -func NewAddressService(token string) *AddressService { - return &AddressService{ - client: client.NewClient(&client.Options{ - Token: token, - }), - } -} - -type AddressService struct { - client *client.Client -} - -// 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 { - // UK postcode e.g SW1A 2AA - Postcode string `json:"postcode"` -} - -type LookupPostcodeResponse struct { - Addresses []Record `json:"addresses"` -} - -type Record struct { - // building name - BuildingName string `json:"buildingName"` - // the county - County string `json:"county"` - // line one of address - LineOne string `json:"lineOne"` - // line two of address - LineTwo string `json:"lineTwo"` - // dependent locality - Locality string `json:"locality"` - // organisation if present - Organisation string `json:"organisation"` - // the postcode - Postcode string `json:"postcode"` - // the premise - Premise string `json:"premise"` - // street name - Street string `json:"street"` - // the complete address - Summary string `json:"summary"` - // post town - Town string `json:"town"` -} diff --git a/service/answer/answer.go b/service/answer/answer.go deleted file mode 100755 index 881e67f..0000000 --- a/service/answer/answer.go +++ /dev/null @@ -1,37 +0,0 @@ -package answer - -import ( - "github.com/m3o/m3o-go/client" -) - -func NewAnswerService(token string) *AnswerService { - return &AnswerService{ - client: client.NewClient(&client.Options{ - Token: token, - }), - } -} - -type AnswerService struct { - client *client.Client -} - -// 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 { - // the question to answer - Query string `json:"query"` -} - -type QuestionResponse struct { - // the answer to your question - Answer string `json:"answer"` - // any related image - Image string `json:"image"` - // a related url - Url string `json:"url"` -} diff --git a/service/cache/cache.go b/service/cache/cache.go deleted file mode 100755 index 63fea8e..0000000 --- a/service/cache/cache.go +++ /dev/null @@ -1,113 +0,0 @@ -package cache - -import ( - "github.com/m3o/m3o-go/client" -) - -func NewCacheService(token string) *CacheService { - return &CacheService{ - client: client.NewClient(&client.Options{ - Token: token, - }), - } -} - -type CacheService struct { - client *client.Client -} - -// Decrement a value (if it's a number) -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 -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 -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) -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 { - // The key to decrement - Key string `json:"key"` - // The amount to decrement the value by - Value int64 `json:"value"` -} - -type DecrementResponse struct { - // The key decremented - Key string `json:"key"` - // The new value - Value int64 `json:"value"` -} - -type DeleteRequest struct { - // The key to delete - Key string `json:"key"` -} - -type DeleteResponse struct { - // Returns "ok" if successful - Status string `json:"status"` -} - -type GetRequest struct { - // The key to retrieve - Key string `json:"key"` -} - -type GetResponse struct { - // The key - Key string `json:"key"` - // Time to live in seconds - Ttl int64 `json:"ttl"` - // The value - Value string `json:"value"` -} - -type IncrementRequest struct { - // The key to increment - Key string `json:"key"` - // The amount to increment the value by - Value int64 `json:"value"` -} - -type IncrementResponse struct { - // The key incremented - Key string `json:"key"` - // The new value - Value int64 `json:"value"` -} - -type SetRequest struct { - // The key to update - Key string `json:"key"` - // Time to live in seconds - Ttl int64 `json:"ttl"` - // The value to set - Value string `json:"value"` -} - -type SetResponse struct { - // Returns "ok" if successful - Status string `json:"status"` -} diff --git a/service/crypto/crypto.go b/service/crypto/crypto.go deleted file mode 100755 index ea85643..0000000 --- a/service/crypto/crypto.go +++ /dev/null @@ -1,120 +0,0 @@ -package crypto - -import ( - "github.com/m3o/m3o-go/client" -) - -func NewCryptoService(token string) *CryptoService { - return &CryptoService{ - client: client.NewClient(&client.Options{ - Token: token, - }), - } -} - -type CryptoService struct { - client *client.Client -} - -// 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 { - // the date published - Date string `json:"date"` - // its description - Description string `json:"description"` - // the source - Source string `json:"source"` - // title of the article - Title string `json:"title"` - // the source url - Url string `json:"url"` -} - -type HistoryRequest struct { - // the crypto symbol e.g BTCUSD - Symbol string `json:"symbol"` -} - -type HistoryResponse struct { - // the close price - Close float64 `json:"close"` - // the date - Date string `json:"date"` - // the peak price - High float64 `json:"high"` - // the low price - Low float64 `json:"low"` - // the open price - Open float64 `json:"open"` - // the crypto symbol - Symbol string `json:"symbol"` - // the volume - Volume float64 `json:"volume"` -} - -type NewsRequest struct { - // cryptocurrency ticker to request news for e.g BTC - Symbol string `json:"symbol"` -} - -type NewsResponse struct { - // list of articles - Articles []Article `json:"articles"` - // symbol requested for - Symbol string `json:"symbol"` -} - -type PriceRequest struct { - // the crypto symbol e.g BTCUSD - Symbol string `json:"symbol"` -} - -type PriceResponse struct { - // the last price - Price float64 `json:"price"` - // the crypto symbol e.g BTCUSD - Symbol string `json:"symbol"` -} - -type QuoteRequest struct { - // the crypto symbol e.g BTCUSD - Symbol string `json:"symbol"` -} - -type QuoteResponse struct { - // the asking price - AskPrice float64 `json:"askPrice"` - // the ask size - AskSize float64 `json:"askSize"` - // the bidding price - BidPrice float64 `json:"bidPrice"` - // the bid size - BidSize float64 `json:"bidSize"` - // the crypto symbol - Symbol string `json:"symbol"` - // the UTC timestamp of the quote - Timestamp string `json:"timestamp"` -} diff --git a/service/currency/currency.go b/service/currency/currency.go deleted file mode 100755 index c3410b0..0000000 --- a/service/currency/currency.go +++ /dev/null @@ -1,103 +0,0 @@ -package currency - -import ( - "github.com/m3o/m3o-go/client" -) - -func NewCurrencyService(token string) *CurrencyService { - return &CurrencyService{ - client: client.NewClient(&client.Options{ - Token: token, - }), - } -} - -type CurrencyService struct { - client *client.Client -} - -// 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 { - // e.g United States Dollar - Currency string `json:"currency"` - // e.g USD - Name string `json:"name"` -} - -type CodesRequest struct { -} - -type CodesResponse struct { - Codes []Code `json:"codes"` -} - -type ConvertRequest struct { - // optional amount to convert e.g 10.0 - Amount float64 `json:"amount"` - // base code to convert from e.g USD - From string `json:"from"` - // target code to convert to e.g GBP - To string `json:"to"` -} - -type ConvertResponse struct { - // converted amount e.g 7.10 - Amount float64 `json:"amount"` - // the base code e.g USD - From string `json:"from"` - // conversion rate e.g 0.71 - Rate float64 `json:"rate"` - // the target code e.g GBP - To string `json:"to"` -} - -type HistoryRequest struct { - // currency code e.g USD - Code string `json:"code"` - // date formatted as YYYY-MM-DD - Date string `json:"date"` -} - -type HistoryResponse struct { - // The code of the request - Code string `json:"code"` - // The date requested - Date string `json:"date"` - // The rate for the day as code:rate - Rates map[string]float64 `json:"rates"` -} - -type RatesRequest struct { - // The currency code to get rates for e.g USD - Code string `json:"code"` -} - -type RatesResponse struct { - // The code requested e.g USD - Code string `json:"code"` - // The rates for the given code as key-value pairs code:rate - Rates map[string]float64 `json:"rates"` -} diff --git a/service/db/db.go b/service/db/db.go deleted file mode 100755 index 1cea496..0000000 --- a/service/db/db.go +++ /dev/null @@ -1,117 +0,0 @@ -package db - -import ( - "github.com/m3o/m3o-go/client" -) - -func NewDbService(token string) *DbService { - return &DbService{ - client: client.NewClient(&client.Options{ - Token: token, - }), - } -} - -type DbService struct { - client *client.Client -} - -// 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 CreateRequest struct { - // JSON encoded record or records (can be array or object) - Record map[string]interface{} `json:"record"` - // Optional table name. Defaults to 'default' - Table string `json:"table"` -} - -type CreateResponse struct { - // The id of the record (either specified or automatically created) - Id string `json:"id"` -} - -type DeleteRequest struct { - // id of the record - Id string `json:"id"` - // Optional table name. Defaults to 'default' - Table string `json:"table"` -} - -type DeleteResponse struct { -} - -type ReadRequest struct { - // Read by id. Equivalent to 'id == "your-id"' - Id string `json:"id"` - // Maximum number of records to return. Default limit is 25. - // Maximum limit is 1000. Anything higher will return an error. - Limit int32 `json:"limit"` - Offset int32 `json:"offset"` - // 'asc' (default), 'desc' - Order string `json:"order"` - // field name to order by - OrderBy string `json:"orderBy"` - // Examples: 'age >= 18', 'age >= 18 and verified == true' - // Comparison operators: '==', '!=', '<', '>', '<=', '>=' - // Logical operator: 'and' - // Dot access is supported, eg: 'user.age == 11' - // Accessing list elements is not supported yet. - Query string `json:"query"` - // Optional table name. Defaults to 'default' - Table string `json:"table"` -} - -type ReadResponse struct { - // JSON encoded records - Records []map[string]interface{} `json:"records"` -} - -type TruncateRequest struct { - // Optional table name. Defaults to 'default' - Table string `json:"table"` -} - -type TruncateResponse struct { - // The table truncated - Table string `json:"table"` -} - -type UpdateRequest struct { - // The id of the record. If not specified it is inferred from the 'id' field of the record - Id string `json:"id"` - // record, JSON object - Record map[string]interface{} `json:"record"` - // Optional table name. Defaults to 'default' - Table string `json:"table"` -} - -type UpdateResponse struct { -} diff --git a/service/email/email.go b/service/email/email.go deleted file mode 100755 index 8cc63d3..0000000 --- a/service/email/email.go +++ /dev/null @@ -1,41 +0,0 @@ -package email - -import ( - "github.com/m3o/m3o-go/client" -) - -func NewEmailService(token string) *EmailService { - return &EmailService{ - client: client.NewClient(&client.Options{ - Token: token, - }), - } -} - -type EmailService struct { - client *client.Client -} - -// 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 { - // the display name of the sender - From string `json:"from"` - // the html body - HtmlBody string `json:"htmlBody"` - // an optional reply to email address - ReplyTo string `json:"replyTo"` - // the email subject - Subject string `json:"subject"` - // the text body - TextBody string `json:"textBody"` - // the email address of the recipient - To string `json:"to"` -} - -type SendResponse struct { -} diff --git a/service/emoji/emoji.go b/service/emoji/emoji.go deleted file mode 100755 index 783c405..0000000 --- a/service/emoji/emoji.go +++ /dev/null @@ -1,86 +0,0 @@ -package emoji - -import ( - "github.com/m3o/m3o-go/client" -) - -func NewEmojiService(token string) *EmojiService { - return &EmojiService{ - client: client.NewClient(&client.Options{ - Token: token, - }), - } -} - -type EmojiService struct { - client *client.Client -} - -// 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 { - // the alias code e.g :beer: - Alias string `json:"alias"` -} - -type FindResponse struct { - // the unicode emoji 🍺 - Emoji string `json:"emoji"` -} - -type FlagRequest struct { - // country code e.g GB - Code string `json:"code"` -} - -type FlagResponse struct { - // the emoji flag - Flag string `json:"flag"` -} - -type PrintRequest struct { - // text including any alias e.g let's grab a :beer: - Text string `json:"text"` -} - -type PrintResponse struct { - // text with rendered emojis - Text string `json:"text"` -} - -type SendRequest struct { - // the name of the sender from e.g Alice - From string `json:"from"` - // message to send including emoji aliases - Message string `json:"message"` - // phone number to send to (including international dialing code) - To string `json:"to"` -} - -type SendResponse struct { - // whether or not it succeeded - Success bool `json:"success"` -} diff --git a/service/file/file.go b/service/file/file.go deleted file mode 100755 index dbf8caf..0000000 --- a/service/file/file.go +++ /dev/null @@ -1,107 +0,0 @@ -package file - -import ( - "github.com/m3o/m3o-go/client" -) - -func NewFileService(token string) *FileService { - return &FileService{ - client: client.NewClient(&client.Options{ - Token: token, - }), - } -} - -type FileService struct { - client *client.Client -} - -// 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 { - Files []Record `json:"files"` -} - -type BatchSaveResponse struct { -} - -type DeleteRequest struct { - // Path to the file - Path string `json:"path"` - // The project name - Project string `json:"project"` -} - -type DeleteResponse struct { -} - -type ListRequest struct { - // Defaults to '/', ie. lists all files in a project. - // Supply path to a folder if you want to list - // files inside that folder - // eg. '/docs' - Path string `json:"path"` - // Project, required for listing. - Project string `json:"project"` -} - -type ListResponse struct { - Files []Record `json:"files"` -} - -type ReadRequest struct { - // Path to the file - Path string `json:"path"` - // Project name - Project string `json:"project"` -} - -type ReadResponse struct { - // Returns the file - File *Record `json:"file"` -} - -type Record struct { - // File contents - Content string `json:"content"` - // Time the file was created e.g 2021-05-20T13:37:21Z - Created string `json:"created"` - // Any other associated metadata as a map of key-value pairs - Metadata map[string]string `json:"metadata"` - // Path to file or folder eg. '/documents/text-files/file.txt'. - Path string `json:"path"` - // A custom project to group files - // eg. file-of-mywebsite.com - Project string `json:"project"` - // Time the file was updated e.g 2021-05-20T13:37:21Z - Updated string `json:"updated"` -} - -type SaveRequest struct { - File *Record `json:"file"` -} - -type SaveResponse struct { -} diff --git a/service/forex/forex.go b/service/forex/forex.go deleted file mode 100755 index d4f2fe5..0000000 --- a/service/forex/forex.go +++ /dev/null @@ -1,85 +0,0 @@ -package forex - -import ( - "github.com/m3o/m3o-go/client" -) - -func NewForexService(token string) *ForexService { - return &ForexService{ - client: client.NewClient(&client.Options{ - Token: token, - }), - } -} - -type ForexService struct { - client *client.Client -} - -// 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 { - // the forex symbol e.g GBPUSD - Symbol string `json:"symbol"` -} - -type HistoryResponse struct { - // the close price - Close float64 `json:"close"` - // the date - Date string `json:"date"` - // the peak price - High float64 `json:"high"` - // the low price - Low float64 `json:"low"` - // the open price - Open float64 `json:"open"` - // the forex symbol - Symbol string `json:"symbol"` - // the volume - Volume float64 `json:"volume"` -} - -type PriceRequest struct { - // forex symbol e.g GBPUSD - Symbol string `json:"symbol"` -} - -type PriceResponse struct { - // the last price - Price float64 `json:"price"` - // the forex symbol e.g GBPUSD - Symbol string `json:"symbol"` -} - -type QuoteRequest struct { - // the forex symbol e.g GBPUSD - Symbol string `json:"symbol"` -} - -type QuoteResponse struct { - // the asking price - AskPrice float64 `json:"askPrice"` - // the bidding price - BidPrice float64 `json:"bidPrice"` - // the forex symbol - Symbol string `json:"symbol"` - // the UTC timestamp of the quote - Timestamp string `json:"timestamp"` -} diff --git a/service/geocoding/geocoding.go b/service/geocoding/geocoding.go deleted file mode 100755 index d569b7f..0000000 --- a/service/geocoding/geocoding.go +++ /dev/null @@ -1,64 +0,0 @@ -package geocoding - -import ( - "github.com/m3o/m3o-go/client" -) - -func NewGeocodingService(token string) *GeocodingService { - return &GeocodingService{ - client: client.NewClient(&client.Options{ - Token: token, - }), - } -} - -type GeocodingService struct { - client *client.Client -} - -// 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 { - City string `json:"city"` - Country string `json:"country"` - LineOne string `json:"lineOne"` - LineTwo string `json:"lineTwo"` - Postcode string `json:"postcode"` -} - -type Location struct { - Latitude float64 `json:"latitude"` - Longitude float64 `json:"longitude"` -} - -type LookupRequest struct { - Address string `json:"address"` - City string `json:"city"` - Country string `json:"country"` - Postcode string `json:"postcode"` -} - -type LookupResponse struct { - Address *Address `json:"address"` - Location *Location `json:"location"` -} - -type ReverseRequest struct { - Latitude float64 `json:"latitude"` - Longitude float64 `json:"longitude"` -} - -type ReverseResponse struct { - Address *Address `json:"address"` - Location *Location `json:"location"` -} diff --git a/service/helloworld/helloworld.go b/service/helloworld/helloworld.go deleted file mode 100755 index 0777b7e..0000000 --- a/service/helloworld/helloworld.go +++ /dev/null @@ -1,47 +0,0 @@ -package helloworld - -import ( - "github.com/m3o/m3o-go/client" -) - -func NewHelloworldService(token string) *HelloworldService { - return &HelloworldService{ - client: client.NewClient(&client.Options{ - Token: token, - }), - } -} - -type HelloworldService struct { - client *client.Client -} - -// 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) -} - -type CallRequest struct { - Name string `json:"name"` -} - -type CallResponse struct { - Message string `json:"message"` -} - -type StreamRequest struct { - // the number of messages to send back - Messages int64 `json:"messages"` - Name string `json:"name"` -} - -type StreamResponse struct { - Message string `json:"message"` -} diff --git a/service/id/id.go b/service/id/id.go deleted file mode 100755 index f3d5638..0000000 --- a/service/id/id.go +++ /dev/null @@ -1,48 +0,0 @@ -package id - -import ( - "github.com/m3o/m3o-go/client" -) - -func NewIdService(token string) *IdService { - return &IdService{ - client: client.NewClient(&client.Options{ - Token: token, - }), - } -} - -type IdService struct { - client *client.Client -} - -// 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 { - // type of id e.g uuid, shortid, snowflake (64 bit), bigflake (128 bit) - Type string `json:"type"` -} - -type GenerateResponse struct { - // the unique id generated - Id string `json:"id"` - // the type of id generated - Type string `json:"type"` -} - -type TypesRequest struct { -} - -type TypesResponse struct { - Types []string `json:"types"` -} diff --git a/service/image/image.go b/service/image/image.go deleted file mode 100755 index 37bf373..0000000 --- a/service/image/image.go +++ /dev/null @@ -1,115 +0,0 @@ -package image - -import ( - "github.com/m3o/m3o-go/client" -) - -func NewImageService(token string) *ImageService { - return &ImageService{ - client: client.NewClient(&client.Options{ - Token: token, - }), - } -} - -type ImageService struct { - client *client.Client -} - -// 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 { - // base64 encoded image to resize, - // ie. "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==" - Base64 string `json:"base64"` - // output name of the image including extension, ie. "cat.png" - Name string `json:"name"` - // make output a URL and not a base64 response - OutputUrl bool `json:"outputUrl"` - // url of the image to resize - Url string `json:"url"` -} - -type ConvertResponse struct { - Base64 string `json:"base64"` - Url string `json:"url"` -} - -type CropOptions struct { - // Crop anchor point: "top", "top left", "top right", - // "left", "center", "right" - // "bottom left", "bottom", "bottom right". - // Optional. Defaults to center. - Anchor string `json:"anchor"` - // height to crop to - Height int32 `json:"height"` - // width to crop to - Width int32 `json:"width"` -} - -type Point struct { - X int32 `json:"x"` - Y int32 `json:"y"` -} - -type Rectangle struct { - Max *Point `json:"max"` - Min *Point `json:"min"` -} - -type ResizeRequest struct { - // base64 encoded image to resize, - // ie. "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==" - Base64 string `json:"base64"` - // optional crop options - // if provided, after resize, the image - // will be cropped - CropOptions *CropOptions `json:"cropOptions"` - Height int64 `json:"height"` - // output name of the image including extension, ie. "cat.png" - Name string `json:"name"` - // make output a URL and not a base64 response - OutputUrl bool `json:"outputUrl"` - // url of the image to resize - Url string `json:"url"` - Width int64 `json:"width"` -} - -type ResizeResponse struct { - Base64 string `json:"base64"` - Url string `json:"url"` -} - -type UploadRequest struct { - // Base64 encoded image to upload, - // ie. "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==" - Base64 string `json:"base64"` - // Output name of the image including extension, ie. "cat.png" - Name string `json:"name"` - // URL of the image to upload - Url string `json:"url"` -} - -type UploadResponse struct { - Url string `json:"url"` -} diff --git a/service/ip/ip.go b/service/ip/ip.go deleted file mode 100755 index 3d81955..0000000 --- a/service/ip/ip.go +++ /dev/null @@ -1,47 +0,0 @@ -package ip - -import ( - "github.com/m3o/m3o-go/client" -) - -func NewIpService(token string) *IpService { - return &IpService{ - client: client.NewClient(&client.Options{ - Token: token, - }), - } -} - -type IpService struct { - client *client.Client -} - -// 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 { - // IP to lookup - Ip string `json:"ip"` -} - -type LookupResponse struct { - // Autonomous system number - Asn int32 `json:"asn"` - // Name of the city - City string `json:"city"` - // Name of the continent - Continent string `json:"continent"` - // Name of the country - Country string `json:"country"` - // IP of the query - Ip string `json:"ip"` - // Latitude e.g 52.523219 - Latitude float64 `json:"latitude"` - // Longitude e.g 13.428555 - Longitude float64 `json:"longitude"` - // Timezone e.g Europe/Rome - Timezone string `json:"timezone"` -} diff --git a/service/location/location.go b/service/location/location.go deleted file mode 100755 index 5c477f9..0000000 --- a/service/location/location.go +++ /dev/null @@ -1,78 +0,0 @@ -package location - -import ( - "github.com/m3o/m3o-go/client" -) - -func NewLocationService(token string) *LocationService { - return &LocationService{ - client: client.NewClient(&client.Options{ - Token: token, - }), - } -} - -type LocationService struct { - client *client.Client -} - -// 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 { - Id string `json:"id"` - Location *Point `json:"location"` - Type string `json:"type"` -} - -type Point struct { - Latitude float64 `json:"latitude"` - Longitude float64 `json:"longitude"` - Timestamp int64 `json:"timestamp"` -} - -type ReadRequest struct { - // the entity id - Id string `json:"id"` -} - -type ReadResponse struct { - Entity *Entity `json:"entity"` -} - -type SaveRequest struct { - Entity *Entity `json:"entity"` -} - -type SaveResponse struct { -} - -type SearchRequest struct { - // Central position to search from - Center *Point `json:"center"` - // Maximum number of entities to return - NumEntities int64 `json:"numEntities"` - // radius in meters - Radius float64 `json:"radius"` - // type of entities to filter - Type string `json:"type"` -} - -type SearchResponse struct { - Entities []Entity `json:"entities"` -} diff --git a/service/otp/otp.go b/service/otp/otp.go deleted file mode 100755 index 17764cd..0000000 --- a/service/otp/otp.go +++ /dev/null @@ -1,55 +0,0 @@ -package otp - -import ( - "github.com/m3o/m3o-go/client" -) - -func NewOtpService(token string) *OtpService { - return &OtpService{ - client: client.NewClient(&client.Options{ - Token: token, - }), - } -} - -type OtpService struct { - client *client.Client -} - -// 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 { - // expiration in seconds (default: 60) - Expiry int64 `json:"expiry"` - // unique id, email or user to generate an OTP for - Id string `json:"id"` - // number of characters (default: 6) - Size int64 `json:"size"` -} - -type GenerateResponse struct { - // one time pass code - Code string `json:"code"` -} - -type ValidateRequest struct { - // one time pass code to validate - Code string `json:"code"` - // unique id, email or user for which the code was generated - Id string `json:"id"` -} - -type ValidateResponse struct { - // returns true if the code is valid for the ID - Success bool `json:"success"` -} diff --git a/service/postcode/postcode.go b/service/postcode/postcode.go deleted file mode 100755 index 818f64b..0000000 --- a/service/postcode/postcode.go +++ /dev/null @@ -1,87 +0,0 @@ -package postcode - -import ( - "github.com/m3o/m3o-go/client" -) - -func NewPostcodeService(token string) *PostcodeService { - return &PostcodeService{ - client: client.NewClient(&client.Options{ - Token: token, - }), - } -} - -type PostcodeService struct { - client *client.Client -} - -// 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 { - // UK postcode e.g SW1A 2AA - Postcode string `json:"postcode"` -} - -type LookupResponse struct { - // country e.g United Kingdom - Country string `json:"country"` - // e.g Westminster - District string `json:"district"` - // e.g 51.50354 - Latitude float64 `json:"latitude"` - // e.g -0.127695 - Longitude float64 `json:"longitude"` - // UK postcode e.g SW1A 2AA - Postcode string `json:"postcode"` - // related region e.g London - Region string `json:"region"` - // e.g St James's - Ward string `json:"ward"` -} - -type RandomRequest struct { -} - -type RandomResponse struct { - // country e.g United Kingdom - Country string `json:"country"` - // e.g Westminster - District string `json:"district"` - // e.g 51.50354 - Latitude float64 `json:"latitude"` - // e.g -0.127695 - Longitude float64 `json:"longitude"` - // UK postcode e.g SW1A 2AA - Postcode string `json:"postcode"` - // related region e.g London - Region string `json:"region"` - // e.g St James's - Ward string `json:"ward"` -} - -type ValidateRequest struct { - // UK postcode e.g SW1A 2AA - Postcode string `json:"postcode"` -} - -type ValidateResponse struct { - // Is the postcode valid (true) or not (false) - Valid bool `json:"valid"` -} diff --git a/service/routing/routing.go b/service/routing/routing.go deleted file mode 100755 index 4ac2d5b..0000000 --- a/service/routing/routing.go +++ /dev/null @@ -1,129 +0,0 @@ -package routing - -import ( - "github.com/m3o/m3o-go/client" -) - -func NewRoutingService(token string) *RoutingService { - return &RoutingService{ - client: client.NewClient(&client.Options{ - Token: token, - }), - } -} - -type RoutingService struct { - client *client.Client -} - -// 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 { - // distance to travel in meters - Distance float64 `json:"distance"` - // duration to travel in seconds - Duration float64 `json:"duration"` - // human readable instruction - Instruction string `json:"instruction"` - // intersections on route - Intersections []Intersection `json:"intersections"` - // maneuver to take - Maneuver *Maneuver `json:"maneuver"` - // street name or location - Name string `json:"name"` - // alternative reference - Reference string `json:"reference"` -} - -type DirectionsRequest struct { - // The destination of the journey - Destination *Point `json:"destination"` - // The staring point for the journey - Origin *Point `json:"origin"` -} - -type DirectionsResponse struct { - // Turn by turn directions - Directions []Direction `json:"directions"` - // Estimated distance of the route in meters - Distance float64 `json:"distance"` - // Estimated duration of the route in seconds - Duration float64 `json:"duration"` - // The waypoints on the route - Waypoints []Waypoint `json:"waypoints"` -} - -type EtaRequest struct { - // The end point for the eta calculation - Destination *Point `json:"destination"` - // The starting point for the eta calculation - Origin *Point `json:"origin"` - // speed in kilometers - Speed float64 `json:"speed"` - // type of transport. Only "car" is supported currently. - Type string `json:"type"` -} - -type EtaResponse struct { - // eta in seconds - Duration float64 `json:"duration"` -} - -type Intersection struct { - Bearings []float64 `json:"bearings"` - Location *Point `json:"location"` -} - -type Maneuver struct { - Action string `json:"action"` - BearingAfter float64 `json:"bearingAfter"` - BearingBefore float64 `json:"bearingBefore"` - Direction string `json:"direction"` - Location *Point `json:"location"` -} - -type Point struct { - // Lat e.g 52.523219 - Latitude float64 `json:"latitude"` - // Long e.g 13.428555 - Longitude float64 `json:"longitude"` -} - -type RouteRequest struct { - // Point of destination for the trip - Destination *Point `json:"destination"` - // Point of origin for the trip - Origin *Point `json:"origin"` -} - -type RouteResponse struct { - // estimated distance in meters - Distance float64 `json:"distance"` - // estimated duration in seconds - Duration float64 `json:"duration"` - // waypoints on the route - Waypoints []Waypoint `json:"waypoints"` -} - -type Waypoint struct { - // gps point coordinates - Location *Point `json:"location"` - // street name or related reference - Name string `json:"name"` -} diff --git a/service/rss/rss.go b/service/rss/rss.go deleted file mode 100755 index 04acf3d..0000000 --- a/service/rss/rss.go +++ /dev/null @@ -1,114 +0,0 @@ -package rss - -import ( - "github.com/m3o/m3o-go/client" -) - -func NewRssService(token string) *RssService { - return &RssService{ - client: client.NewClient(&client.Options{ - Token: token, - }), - } -} - -type RssService struct { - client *client.Client -} - -// 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 { - // category to add e.g news - Category string `json:"category"` - // rss feed name - // eg. a16z - Name string `json:"name"` - // rss feed url - // eg. http://a16z.com/feed/ - Url string `json:"url"` -} - -type AddResponse struct { -} - -type Entry struct { - // article content - Content string `json:"content"` - // data of the entry - Date string `json:"date"` - // the rss feed where it came from - Feed string `json:"feed"` - // unique id of the entry - Id string `json:"id"` - // rss feed url of the entry - Link string `json:"link"` - // article summary - Summary string `json:"summary"` - // title of the entry - Title string `json:"title"` -} - -type Feed struct { - // category of the feed e.g news - Category string `json:"category"` - // unique id - Id string `json:"id"` - // rss feed name - // eg. a16z - Name string `json:"name"` - // rss feed url - // eg. http://a16z.com/feed/ - Url string `json:"url"` -} - -type FeedRequest struct { - // limit entries returned - Limit int64 `json:"limit"` - // rss feed name - Name string `json:"name"` - // offset entries - Offset int64 `json:"offset"` -} - -type FeedResponse struct { - Entries []Entry `json:"entries"` -} - -type ListRequest struct { -} - -type ListResponse struct { - Feeds []Feed `json:"feeds"` -} - -type RemoveRequest struct { - // rss feed name - // eg. a16z - Name string `json:"name"` -} - -type RemoveResponse struct { -} diff --git a/service/sentiment/sentiment.go b/service/sentiment/sentiment.go deleted file mode 100755 index f53278f..0000000 --- a/service/sentiment/sentiment.go +++ /dev/null @@ -1,35 +0,0 @@ -package sentiment - -import ( - "github.com/m3o/m3o-go/client" -) - -func NewSentimentService(token string) *SentimentService { - return &SentimentService{ - client: client.NewClient(&client.Options{ - Token: token, - }), - } -} - -type SentimentService struct { - client *client.Client -} - -// 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 { - // The language. Defaults to english. - Lang string `json:"lang"` - // The text to analyze - Text string `json:"text"` -} - -type AnalyzeResponse struct { - // The score of the text {positive is 1, negative is 0} - Score float64 `json:"score"` -} diff --git a/service/sms/sms.go b/service/sms/sms.go deleted file mode 100755 index 8ae4f5f..0000000 --- a/service/sms/sms.go +++ /dev/null @@ -1,39 +0,0 @@ -package sms - -import ( - "github.com/m3o/m3o-go/client" -) - -func NewSmsService(token string) *SmsService { - return &SmsService{ - client: client.NewClient(&client.Options{ - Token: token, - }), - } -} - -type SmsService struct { - client *client.Client -} - -// 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 { - // who is the message from? The message will be suffixed with "Sent from " - From string `json:"from"` - // the main body of the message to send - Message string `json:"message"` - // the destination phone number including the international dialling code (e.g. +44) - To string `json:"to"` -} - -type SendResponse struct { - // any additional info - Info string `json:"info"` - // will return "ok" if successful - Status string `json:"status"` -} diff --git a/service/stock/stock.go b/service/stock/stock.go deleted file mode 100755 index 002ddf5..0000000 --- a/service/stock/stock.go +++ /dev/null @@ -1,132 +0,0 @@ -package stock - -import ( - "github.com/m3o/m3o-go/client" -) - -func NewStockService(token string) *StockService { - return &StockService{ - client: client.NewClient(&client.Options{ - Token: token, - }), - } -} - -type StockService struct { - client *client.Client -} - -// 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 { - // date to retrieve as YYYY-MM-DD - Date string `json:"date"` - // the stock symbol e.g AAPL - Stock string `json:"stock"` -} - -type HistoryResponse struct { - // the close price - Close float64 `json:"close"` - // the date - Date string `json:"date"` - // the peak price - High float64 `json:"high"` - // the low price - Low float64 `json:"low"` - // the open price - Open float64 `json:"open"` - // the stock symbol - Symbol string `json:"symbol"` - // the volume - Volume int32 `json:"volume"` -} - -type Order struct { - // the asking price - AskPrice float64 `json:"askPrice"` - // the ask size - AskSize int32 `json:"askSize"` - // the bidding price - BidPrice float64 `json:"bidPrice"` - // the bid size - BidSize int32 `json:"bidSize"` - // the UTC timestamp of the quote - Timestamp string `json:"timestamp"` -} - -type OrderBookRequest struct { - // the date in format YYYY-MM-dd - Date string `json:"date"` - // optional RFC3339Nano end time e.g 2006-01-02T15:04:05.999999999Z07:00 - End string `json:"end"` - // limit number of prices - Limit int32 `json:"limit"` - // optional RFC3339Nano start time e.g 2006-01-02T15:04:05.999999999Z07:00 - Start string `json:"start"` - // stock to retrieve e.g AAPL - Stock string `json:"stock"` -} - -type OrderBookResponse struct { - // date of the request - Date string `json:"date"` - // list of orders - Orders []Order `json:"orders"` - // the stock symbol - Symbol string `json:"symbol"` -} - -type PriceRequest struct { - // stock symbol e.g AAPL - Symbol string `json:"symbol"` -} - -type PriceResponse struct { - // the last price - Price float64 `json:"price"` - // the stock symbol e.g AAPL - Symbol string `json:"symbol"` -} - -type QuoteRequest struct { - // the stock symbol e.g AAPL - Symbol string `json:"symbol"` -} - -type QuoteResponse struct { - // the asking price - AskPrice float64 `json:"askPrice"` - // the ask size - AskSize int32 `json:"askSize"` - // the bidding price - BidPrice float64 `json:"bidPrice"` - // the bid size - BidSize int32 `json:"bidSize"` - // the stock symbol - Symbol string `json:"symbol"` - // the UTC timestamp of the quote - Timestamp string `json:"timestamp"` -} diff --git a/service/stream/stream.go b/service/stream/stream.go deleted file mode 100755 index 6467965..0000000 --- a/service/stream/stream.go +++ /dev/null @@ -1,51 +0,0 @@ -package stream - -import ( - "github.com/m3o/m3o-go/client" -) - -func NewStreamService(token string) *StreamService { - return &StreamService{ - client: client.NewClient(&client.Options{ - Token: token, - }), - } -} - -type StreamService struct { - client *client.Client -} - -// Publish a message to the stream. Specify a topic to group messages for a specific topic. -func (t *StreamService) Publish(request *PublishRequest) (*PublishResponse, error) { - rsp := &PublishResponse{} - return rsp, t.client.Call("stream", "Publish", request, rsp) -} - -// Subscribe to messages for a given topic. -func (t *StreamService) Subscribe(request *SubscribeRequest) (*SubscribeResponse, error) { - rsp := &SubscribeResponse{} - return rsp, t.client.Call("stream", "Subscribe", request, rsp) -} - -type PublishRequest struct { - // The json message to publish - Message map[string]interface{} `json:"message"` - // The topic to publish to - Topic string `json:"topic"` -} - -type PublishResponse struct { -} - -type SubscribeRequest struct { - // The topic to subscribe to - Topic string `json:"topic"` -} - -type SubscribeResponse struct { - // The next json message on the topic - Message map[string]interface{} `json:"message"` - // The topic subscribed to - Topic string `json:"topic"` -} diff --git a/service/thumbnail/thumbnail.go b/service/thumbnail/thumbnail.go deleted file mode 100755 index cb33147..0000000 --- a/service/thumbnail/thumbnail.go +++ /dev/null @@ -1,35 +0,0 @@ -package thumbnail - -import ( - "github.com/m3o/m3o-go/client" -) - -func NewThumbnailService(token string) *ThumbnailService { - return &ThumbnailService{ - client: client.NewClient(&client.Options{ - Token: token, - }), - } -} - -type ThumbnailService struct { - client *client.Client -} - -// 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 { - // height of the browser window, optional - Height int32 `json:"height"` - Url string `json:"url"` - // width of the browser window. optional - Width int32 `json:"width"` -} - -type ScreenshotResponse struct { - ImageUrl string `json:"imageUrl"` -} diff --git a/service/time/time.go b/service/time/time.go deleted file mode 100755 index cbda864..0000000 --- a/service/time/time.go +++ /dev/null @@ -1,73 +0,0 @@ -package time - -import ( - "github.com/m3o/m3o-go/client" -) - -func NewTimeService(token string) *TimeService { - return &TimeService{ - client: client.NewClient(&client.Options{ - Token: token, - }), - } -} - -type TimeService struct { - client *client.Client -} - -// 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 { - // optional location, otherwise returns UTC - Location string `json:"location"` -} - -type NowResponse struct { - // the current time as HH:MM:SS - Localtime string `json:"localtime"` - // the location as Europe/London - Location string `json:"location"` - // timestamp as 2006-01-02T15:04:05.999999999Z07:00 - Timestamp string `json:"timestamp"` - // the timezone as BST - Timezone string `json:"timezone"` - // the unix timestamp - Unix int64 `json:"unix"` -} - -type ZoneRequest struct { - // location to lookup e.g postcode, city, ip address - Location string `json:"location"` -} - -type ZoneResponse struct { - // the abbreviated code e.g BST - Abbreviation string `json:"abbreviation"` - // country of the timezone - Country string `json:"country"` - // is daylight savings - Dst bool `json:"dst"` - // e.g 51.42 - Latitude float64 `json:"latitude"` - // the local time - Localtime string `json:"localtime"` - // location requested - Location string `json:"location"` - // e.g -0.37 - Longitude float64 `json:"longitude"` - // region of timezone - Region string `json:"region"` - // the timezone e.g Europe/London - Timezone string `json:"timezone"` -} diff --git a/service/url/url.go b/service/url/url.go deleted file mode 100755 index 75fb17e..0000000 --- a/service/url/url.go +++ /dev/null @@ -1,73 +0,0 @@ -package url - -import ( - "github.com/m3o/m3o-go/client" -) - -func NewUrlService(token string) *UrlService { - return &UrlService{ - client: client.NewClient(&client.Options{ - Token: token, - }), - } -} - -type UrlService struct { - client *client.Client -} - -// 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 { - // filter by short URL, optional - ShortUrl string `json:"shortUrl"` -} - -type ListResponse struct { - UrlPairs *URLPair `json:"urlPairs"` -} - -type ProxyRequest struct { - // short url ID, without the domain, eg. if your short URL is - // `m3o.one/u/someshorturlid` then pass in `someshorturlid` - ShortUrl string `json:"shortUrl"` -} - -type ProxyResponse struct { - DestinationUrl string `json:"destinationUrl"` -} - -type ShortenRequest struct { - DestinationUrl string `json:"destinationUrl"` -} - -type ShortenResponse struct { - ShortUrl string `json:"shortUrl"` -} - -type URLPair struct { - Created int64 `json:"created"` - DestinationUrl string `json:"destinationUrl"` - // HitCount keeps track many times the short URL has been resolved. - // Hitcount only gets saved to disk (database) after every 10th hit, so - // its not intended to be 100% accurate, more like an almost correct estimate. - HitCount int64 `json:"hitCount"` - Owner string `json:"owner"` - ShortUrl string `json:"shortUrl"` -} diff --git a/service/user/user.go b/service/user/user.go deleted file mode 100755 index fcd01fa..0000000 --- a/service/user/user.go +++ /dev/null @@ -1,231 +0,0 @@ -package user - -import ( - "github.com/m3o/m3o-go/client" -) - -func NewUserService(token string) *UserService { - return &UserService{ - client: client.NewClient(&client.Options{ - Token: token, - }), - } -} - -type UserService struct { - client *client.Client -} - -// 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 -// 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&rediretUrl=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 { - // unix timestamp - Created int64 `json:"created"` - // an email address - Email string `json:"email"` - // unique account id - Id string `json:"id"` - // Store any custom data you want about your users in this fields. - Profile map[string]string `json:"profile"` - // unix timestamp - Updated int64 `json:"updated"` - // alphanumeric username - Username string `json:"username"` - VerificationDate int64 `json:"verificationDate"` - Verified bool `json:"verified"` -} - -type CreateRequest struct { - // the email address - Email string `json:"email"` - // optional account id - Id string `json:"id"` - // the user password - Password string `json:"password"` - // optional user profile as map - Profile map[string]string `json:"profile"` - // the username - Username string `json:"username"` -} - -type CreateResponse struct { - Account *Account `json:"account"` -} - -type DeleteRequest struct { - // the account id - Id string `json:"id"` -} - -type DeleteResponse struct { -} - -type LoginRequest struct { - // The email address of the user - Email string `json:"email"` - // The password of the user - Password string `json:"password"` - // The username of the user - Username string `json:"username"` -} - -type LoginResponse struct { - // The session of the logged in user - Session *Session `json:"session"` -} - -type LogoutRequest struct { - SessionId string `json:"sessionId"` -} - -type LogoutResponse struct { -} - -type ReadRequest struct { - // the account email - Email string `json:"email"` - // the account id - Id string `json:"id"` - // the account username - Username string `json:"username"` -} - -type ReadResponse struct { - Account *Account `json:"account"` -} - -type ReadSessionRequest struct { - // The unique session id - SessionId string `json:"sessionId"` -} - -type ReadSessionResponse struct { - Session *Session `json:"session"` -} - -type SendVerificationEmailRequest struct { - Email string `json:"email"` - FailureRedirectUrl string `json:"failureRedirectUrl"` - // Display name of the sender for the email. Note: the email address will still be 'support@m3o.com' - FromName string `json:"fromName"` - RedirectUrl string `json:"redirectUrl"` - Subject string `json:"subject"` - // Text content of the email. Don't forget to include the string '$micro_verification_link' which will be replaced by the real verification link - // HTML emails are not available currently. - TextContent string `json:"textContent"` -} - -type SendVerificationEmailResponse struct { -} - -type Session struct { - // unix timestamp - Created int64 `json:"created"` - // unix timestamp - Expires int64 `json:"expires"` - // the session id - Id string `json:"id"` - // the associated user id - UserId string `json:"userId"` -} - -type UpdatePasswordRequest struct { - // confirm new password - ConfirmPassword string `json:"confirmPassword"` - // the new password - NewPassword string `json:"newPassword"` - // the old password - OldPassword string `json:"oldPassword"` - // the account id - UserId string `json:"userId"` -} - -type UpdatePasswordResponse struct { -} - -type UpdateRequest struct { - // the new email address - Email string `json:"email"` - // the account id - Id string `json:"id"` - // the user profile as map - Profile map[string]string `json:"profile"` - // the new username - Username string `json:"username"` -} - -type UpdateResponse struct { -} - -type VerifyEmailRequest struct { - // The token from the verification email - Token string `json:"token"` -} - -type VerifyEmailResponse struct { -} diff --git a/service/weather/weather.go b/service/weather/weather.go deleted file mode 100755 index 578297a..0000000 --- a/service/weather/weather.go +++ /dev/null @@ -1,132 +0,0 @@ -package weather - -import ( - "github.com/m3o/m3o-go/client" -) - -func NewWeatherService(token string) *WeatherService { - return &WeatherService{ - client: client.NewClient(&client.Options{ - Token: token, - }), - } -} - -type WeatherService struct { - client *client.Client -} - -// 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 { - // the average temp in celsius - AvgTempC float64 `json:"avgTempC"` - // the average temp in fahrenheit - AvgTempF float64 `json:"avgTempF"` - // chance of rain (percentage) - ChanceOfRain int32 `json:"chanceOfRain"` - // forecast condition - Condition string `json:"condition"` - // date of the forecast - Date string `json:"date"` - // the URL of forecast condition icon. Simply prefix with either http or https to use it - IconUrl string `json:"iconUrl"` - // max temp in celsius - MaxTempC float64 `json:"maxTempC"` - // max temp in fahrenheit - MaxTempF float64 `json:"maxTempF"` - // minimum temp in celsius - MinTempC float64 `json:"minTempC"` - // minimum temp in fahrenheit - MinTempF float64 `json:"minTempF"` - // time of sunrise - Sunrise string `json:"sunrise"` - // time of sunset - Sunset string `json:"sunset"` - // will it rain - WillItRain bool `json:"willItRain"` -} - -type ForecastRequest struct { - // number of days. default 1, max 10 - Days int32 `json:"days"` - // location of the forecase - Location string `json:"location"` -} - -type ForecastResponse struct { - // country of the request - Country string `json:"country"` - // forecast for the next number of days - Forecast []Forecast `json:"forecast"` - // e.g 37.55 - Latitude float64 `json:"latitude"` - // the local time - LocalTime string `json:"localTime"` - // location of the request - Location string `json:"location"` - // e.g -77.46 - Longitude float64 `json:"longitude"` - // region related to the location - Region string `json:"region"` - // timezone of the location - Timezone string `json:"timezone"` -} - -type NowRequest struct { - // location to get weather e.g postcode, city - Location string `json:"location"` -} - -type NowResponse struct { - // cloud cover percentage - Cloud int32 `json:"cloud"` - // the weather condition - Condition string `json:"condition"` - // country of the request - Country string `json:"country"` - // whether its daytime - Daytime bool `json:"daytime"` - // feels like in celsius - FeelsLikeC float64 `json:"feelsLikeC"` - // feels like in fahrenheit - FeelsLikeF float64 `json:"feelsLikeF"` - // the humidity percentage - Humidity int32 `json:"humidity"` - // the URL of the related icon. Simply prefix with either http or https to use it - IconUrl string `json:"iconUrl"` - // e.g 37.55 - Latitude float64 `json:"latitude"` - // the local time - LocalTime string `json:"localTime"` - // location of the request - Location string `json:"location"` - // e.g -77.46 - Longitude float64 `json:"longitude"` - // region related to the location - Region string `json:"region"` - // temperature in celsius - TempC float64 `json:"tempC"` - // temperature in fahrenheit - TempF float64 `json:"tempF"` - // timezone of the location - Timezone string `json:"timezone"` - // wind degree - WindDegree int32 `json:"windDegree"` - // wind direction - WindDirection string `json:"windDirection"` - // wind in kph - WindKph float64 `json:"windKph"` - // wind in mph - WindMph float64 `json:"windMph"` -}