diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 2e6ab06..277e024 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,7 +1,5 @@ name: Publish APIs & Clients -on: - push: - branches: [master] +on: [push] jobs: docs: @@ -57,6 +55,7 @@ jobs: - name: Generate openapi spec and publish the api working-directory: services + if: github.ref == 'refs/heads/master' run: | go run cmd/publisher/main.go . env: @@ -66,33 +65,22 @@ jobs: env: NPM_TOKEN: ${{ secrets.NPM_TOKEN }} run: | + pwd cd cmd/clients; go install; cd ../..; clients . + + - uses: EndBug/add-and-commit@v7 + with: + cwd: './services' + + - name: npm install + working-directory: services + if: github.ref == 'refs/heads/master' + run: | + git status cd clients/ts; npm install npm run build - - # publish to github first under micro/services - # .npmrc has settings for it - - uses: JS-DevTools/npm-publish@v1 - #if: github.ref == 'refs/heads/master' - with: - access: public - package: services/clients/ts/package.json - token: ${{ secrets.NPM_TOKEN }} - - # publish to npm m3o/services - - name: Change npm settings - working-directory: services - run: | - rm clients/ts/.npmrc - sed -i 's/micro/m3o/g' clients/ts/package.json - - - uses: JS-DevTools/npm-publish@v1 - #if: github.ref == 'refs/heads/master' - with: - access: public - package: services/clients/ts/package.json - token: ${{ secrets.NPM_SITE_TOKEN }} + npm publish --access public diff --git a/.gitignore b/.gitignore index 75f2e54..8b5e099 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ api-*.json redoc-static.html !docs node_modules +postman.json +.npmrc diff --git a/clients/go/address/address.go b/clients/go/address/address.go new file mode 100755 index 0000000..e775315 --- /dev/null +++ b/clients/go/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/clients/go/answer/answer.go b/clients/go/answer/answer.go new file mode 100755 index 0000000..881e67f --- /dev/null +++ b/clients/go/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/clients/go/cache/cache.go b/clients/go/cache/cache.go new file mode 100755 index 0000000..63fea8e --- /dev/null +++ b/clients/go/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/clients/go/crypto/crypto.go b/clients/go/crypto/crypto.go new file mode 100755 index 0000000..ea85643 --- /dev/null +++ b/clients/go/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/clients/go/currency/currency.go b/clients/go/currency/currency.go new file mode 100755 index 0000000..c3410b0 --- /dev/null +++ b/clients/go/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/clients/go/db/db.go b/clients/go/db/db.go new file mode 100755 index 0000000..1cea496 --- /dev/null +++ b/clients/go/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/clients/go/email/email.go b/clients/go/email/email.go new file mode 100755 index 0000000..8cc63d3 --- /dev/null +++ b/clients/go/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/clients/go/emoji/emoji.go b/clients/go/emoji/emoji.go new file mode 100755 index 0000000..783c405 --- /dev/null +++ b/clients/go/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/clients/go/file/file.go b/clients/go/file/file.go new file mode 100755 index 0000000..dbf8caf --- /dev/null +++ b/clients/go/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/clients/go/forex/forex.go b/clients/go/forex/forex.go new file mode 100755 index 0000000..d4f2fe5 --- /dev/null +++ b/clients/go/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/clients/go/geocoding/geocoding.go b/clients/go/geocoding/geocoding.go new file mode 100755 index 0000000..d569b7f --- /dev/null +++ b/clients/go/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/clients/go/helloworld/helloworld.go b/clients/go/helloworld/helloworld.go new file mode 100755 index 0000000..0777b7e --- /dev/null +++ b/clients/go/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/clients/go/id/id.go b/clients/go/id/id.go new file mode 100755 index 0000000..f3d5638 --- /dev/null +++ b/clients/go/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/clients/go/image/image.go b/clients/go/image/image.go new file mode 100755 index 0000000..37bf373 --- /dev/null +++ b/clients/go/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/clients/go/ip/ip.go b/clients/go/ip/ip.go new file mode 100755 index 0000000..3d81955 --- /dev/null +++ b/clients/go/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/clients/go/location/location.go b/clients/go/location/location.go new file mode 100755 index 0000000..5c477f9 --- /dev/null +++ b/clients/go/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/clients/go/m3o.go b/clients/go/m3o.go new file mode 100755 index 0000000..f1be388 --- /dev/null +++ b/clients/go/m3o.go @@ -0,0 +1,106 @@ +package m3o + +import ( + "github.com/micro/services/clients/go/address" + "github.com/micro/services/clients/go/answer" + "github.com/micro/services/clients/go/cache" + "github.com/micro/services/clients/go/crypto" + "github.com/micro/services/clients/go/currency" + "github.com/micro/services/clients/go/db" + "github.com/micro/services/clients/go/email" + "github.com/micro/services/clients/go/emoji" + "github.com/micro/services/clients/go/file" + "github.com/micro/services/clients/go/forex" + "github.com/micro/services/clients/go/geocoding" + "github.com/micro/services/clients/go/helloworld" + "github.com/micro/services/clients/go/id" + "github.com/micro/services/clients/go/image" + "github.com/micro/services/clients/go/ip" + "github.com/micro/services/clients/go/location" + "github.com/micro/services/clients/go/otp" + "github.com/micro/services/clients/go/postcode" + "github.com/micro/services/clients/go/quran" + "github.com/micro/services/clients/go/routing" + "github.com/micro/services/clients/go/rss" + "github.com/micro/services/clients/go/sentiment" + "github.com/micro/services/clients/go/sms" + "github.com/micro/services/clients/go/stock" + "github.com/micro/services/clients/go/stream" + "github.com/micro/services/clients/go/thumbnail" + "github.com/micro/services/clients/go/time" + "github.com/micro/services/clients/go/url" + "github.com/micro/services/clients/go/user" + "github.com/micro/services/clients/go/weather" +) + +func NewClient(token string) *Client { + return &Client{ + token: token, + + AddressService: address.NewAddressService(token), + AnswerService: answer.NewAnswerService(token), + CacheService: cache.NewCacheService(token), + CryptoService: crypto.NewCryptoService(token), + CurrencyService: currency.NewCurrencyService(token), + DbService: db.NewDbService(token), + EmailService: email.NewEmailService(token), + EmojiService: emoji.NewEmojiService(token), + FileService: file.NewFileService(token), + ForexService: forex.NewForexService(token), + GeocodingService: geocoding.NewGeocodingService(token), + HelloworldService: helloworld.NewHelloworldService(token), + IdService: id.NewIdService(token), + ImageService: image.NewImageService(token), + IpService: ip.NewIpService(token), + LocationService: location.NewLocationService(token), + OtpService: otp.NewOtpService(token), + PostcodeService: postcode.NewPostcodeService(token), + QuranService: quran.NewQuranService(token), + RoutingService: routing.NewRoutingService(token), + RssService: rss.NewRssService(token), + SentimentService: sentiment.NewSentimentService(token), + SmsService: sms.NewSmsService(token), + StockService: stock.NewStockService(token), + StreamService: stream.NewStreamService(token), + ThumbnailService: thumbnail.NewThumbnailService(token), + TimeService: time.NewTimeService(token), + UrlService: url.NewUrlService(token), + UserService: user.NewUserService(token), + WeatherService: weather.NewWeatherService(token), + } +} + +type Client struct { + token string + + AddressService *address.AddressService + AnswerService *answer.AnswerService + CacheService *cache.CacheService + CryptoService *crypto.CryptoService + CurrencyService *currency.CurrencyService + DbService *db.DbService + EmailService *email.EmailService + EmojiService *emoji.EmojiService + FileService *file.FileService + ForexService *forex.ForexService + GeocodingService *geocoding.GeocodingService + HelloworldService *helloworld.HelloworldService + IdService *id.IdService + ImageService *image.ImageService + IpService *ip.IpService + LocationService *location.LocationService + OtpService *otp.OtpService + PostcodeService *postcode.PostcodeService + QuranService *quran.QuranService + RoutingService *routing.RoutingService + RssService *rss.RssService + SentimentService *sentiment.SentimentService + SmsService *sms.SmsService + StockService *stock.StockService + StreamService *stream.StreamService + ThumbnailService *thumbnail.ThumbnailService + TimeService *time.TimeService + UrlService *url.UrlService + UserService *user.UserService + WeatherService *weather.WeatherService +} diff --git a/clients/go/otp/otp.go b/clients/go/otp/otp.go new file mode 100755 index 0000000..17764cd --- /dev/null +++ b/clients/go/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/clients/go/postcode/postcode.go b/clients/go/postcode/postcode.go new file mode 100755 index 0000000..818f64b --- /dev/null +++ b/clients/go/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/clients/go/quran/quran.go b/clients/go/quran/quran.go new file mode 100755 index 0000000..fbe5f5b --- /dev/null +++ b/clients/go/quran/quran.go @@ -0,0 +1,216 @@ +package quran + +import ( + "github.com/m3o/m3o-go/client" +) + +func NewQuranService(token string) *QuranService { + return &QuranService{ + client: client.NewClient(&client.Options{ + Token: token, + }), + } +} + +type QuranService struct { + client *client.Client +} + +// List the Chapters (surahs) of the Quran +func (t *QuranService) Chapters(request *ChaptersRequest) (*ChaptersResponse, error) { + rsp := &ChaptersResponse{} + return rsp, t.client.Call("quran", "Chapters", request, rsp) +} + +// Search the Quran for any form of query or questions +func (t *QuranService) Search(request *SearchRequest) (*SearchResponse, error) { + rsp := &SearchResponse{} + return rsp, t.client.Call("quran", "Search", request, rsp) +} + +// Get a summary for a given chapter (surah) +func (t *QuranService) Summary(request *SummaryRequest) (*SummaryResponse, error) { + rsp := &SummaryResponse{} + return rsp, t.client.Call("quran", "Summary", request, rsp) +} + +// Lookup the verses (ayahs) for a chapter +func (t *QuranService) Verses(request *VersesRequest) (*VersesResponse, error) { + rsp := &VersesResponse{} + return rsp, t.client.Call("quran", "Verses", request, rsp) +} + +type Chapter struct { + // The arabic name of the chapter + ArabicName string `json:"arabicName"` + // The complex name of the chapter + ComplexName string `json:"complexName"` + // The id of the chapter as a number e.g 1 + Id int32 `json:"id"` + // The simple name of the chapter + Name string `json:"name"` + // The pages from and to e.g 1, 1 + Pages []int32 `json:"pages"` + // Should the chapter start with bismillah + PrefixBismillah bool `json:"prefixBismillah"` + // The order in which it was revealed + RevelationOrder int32 `json:"revelationOrder"` + // The place of revelation + RevelationPlace string `json:"revelationPlace"` + // The translated name + TranslatedName string `json:"translatedName"` + // The number of verses in the chapter + Verses int32 `json:"verses"` +} + +type ChaptersRequest struct { + // Specify the language e.g en + Language string `json:"language"` +} + +type ChaptersResponse struct { + Chapters []Chapter `json:"chapters"` +} + +type Interpretation struct { + // The unique id of the interpretation + Id int32 `json:"id"` + // The source of the interpretation + Source string `json:"source"` + // The translated text + Text string `json:"text"` +} + +type Result struct { + // The associated arabic text + Text string `json:"text"` + // The related translations to the text + Translations []Translation `json:"translations"` + // The unique verse id across the Quran + VerseId int32 `json:"verseId"` + // The verse key e.g 1:1 + VerseKey string `json:"verseKey"` +} + +type SearchRequest struct { + // The language for translation + Language string `json:"language"` + // The number of results to return + Limit int32 `json:"limit"` + // The pagination number + Page int32 `json:"page"` + // The query to ask + Query string `json:"query"` +} + +type SearchResponse struct { + // The current page + Page int32 `json:"page"` + // The question asked + Query string `json:"query"` + // The results for the query + Results []Result `json:"results"` + // The total pages + TotalPages int32 `json:"totalPages"` + // The total results returned + TotalResults int32 `json:"totalResults"` +} + +type SummaryRequest struct { + // The chapter id e.g 1 + Chapter int32 `json:"chapter"` + // Specify the language e.g en + Language string `json:"language"` +} + +type SummaryResponse struct { + // The chapter id + Chapter int32 `json:"chapter"` + // The source of the summary + Source string `json:"source"` + // The short summary for the chapter + Summary string `json:"summary"` + // The full description for the chapter + Text string `json:"text"` +} + +type Translation struct { + // The unique id of the translation + Id int32 `json:"id"` + // The source of the translation + Source string `json:"source"` + // The translated text + Text string `json:"text"` +} + +type Verse struct { + // The unique id of the verse in the whole book + Id int32 `json:"id"` + // The interpretations of the verse + Interpretations []Translation `json:"interpretations"` + // The key of this verse (chapter:verse) e.g 1:1 + Key string `json:"key"` + // The verse number in this chapter + Number int32 `json:"number"` + // The page of the Quran this verse is on + Page int32 `json:"page"` + // The arabic text for this verse + Text string `json:"text"` + // The basic translation of the verse + TranslatedText string `json:"translatedText"` + // The alternative translations for the verse + Translations []Translation `json:"translations"` + // The phonetic transliteration from arabic + Transliteration string `json:"transliteration"` + // The individual words within the verse (Ayah) + Words []Word `json:"words"` +} + +type VersesRequest struct { + // The chapter id to retrieve + Chapter int32 `json:"chapter"` + // Return the interpretation (tafsir) + Interpret bool `json:"interpret"` + // The language of translation + Language string `json:"language"` + // The verses per page + Limit int32 `json:"limit"` + // The page number to request + Page int32 `json:"page"` + // Return alternate translations + Translate bool `json:"translate"` + // Return the individual words with the verses + Words bool `json:"words"` +} + +type VersesResponse struct { + // The chapter requested + Chapter int32 `json:"chapter"` + // The page requested + Page int32 `json:"page"` + // The total pages + TotalPages int32 `json:"totalPages"` + // The verses on the page + Verses []Verse `json:"verses"` +} + +type Word struct { + // The character type e.g word, end + CharType string `json:"charType"` + // The QCF v2 font code + Code string `json:"code"` + // The id of the word within the verse + Id int32 `json:"id"` + // The line number + Line int32 `json:"line"` + // The page number + Page int32 `json:"page"` + // The position of the word + Position int32 `json:"position"` + // The arabic text for this word + Text string `json:"text"` + // The translated text + Translation string `json:"translation"` + // The transliteration text + Transliteration string `json:"transliteration"` +} diff --git a/clients/go/routing/routing.go b/clients/go/routing/routing.go new file mode 100755 index 0000000..4ac2d5b --- /dev/null +++ b/clients/go/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/clients/go/rss/rss.go b/clients/go/rss/rss.go new file mode 100755 index 0000000..04acf3d --- /dev/null +++ b/clients/go/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/clients/go/sentiment/sentiment.go b/clients/go/sentiment/sentiment.go new file mode 100755 index 0000000..f53278f --- /dev/null +++ b/clients/go/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/clients/go/sms/sms.go b/clients/go/sms/sms.go new file mode 100755 index 0000000..8ae4f5f --- /dev/null +++ b/clients/go/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/clients/go/stock/stock.go b/clients/go/stock/stock.go new file mode 100755 index 0000000..002ddf5 --- /dev/null +++ b/clients/go/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/clients/go/stream/stream.go b/clients/go/stream/stream.go new file mode 100755 index 0000000..6467965 --- /dev/null +++ b/clients/go/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/clients/go/thumbnail/thumbnail.go b/clients/go/thumbnail/thumbnail.go new file mode 100755 index 0000000..cb33147 --- /dev/null +++ b/clients/go/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/clients/go/time/time.go b/clients/go/time/time.go new file mode 100755 index 0000000..cbda864 --- /dev/null +++ b/clients/go/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/clients/go/url/url.go b/clients/go/url/url.go new file mode 100755 index 0000000..75fb17e --- /dev/null +++ b/clients/go/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/clients/go/user/user.go b/clients/go/user/user.go new file mode 100755 index 0000000..fcd01fa --- /dev/null +++ b/clients/go/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/clients/go/weather/weather.go b/clients/go/weather/weather.go new file mode 100755 index 0000000..578297a --- /dev/null +++ b/clients/go/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"` +} diff --git a/clients/ts/.gitignore b/clients/ts/.gitignore new file mode 100644 index 0000000..1521c8b --- /dev/null +++ b/clients/ts/.gitignore @@ -0,0 +1 @@ +dist diff --git a/clients/ts/address/index.ts b/clients/ts/address/index.ts new file mode 100755 index 0000000..51ab8cf --- /dev/null +++ b/clients/ts/address/index.ts @@ -0,0 +1,53 @@ +import * as m3o from "@m3o/m3o-node"; + +export class AddressService { + private client: m3o.Client; + + constructor(token: string) { + this.client = new m3o.Client({ token: token }); + } + // Lookup a list of UK addresses by postcode + lookupPostcode( + request: LookupPostcodeRequest + ): Promise { + return this.client.call( + "address", + "LookupPostcode", + request + ) as Promise; + } +} + +export interface LookupPostcodeRequest { + // UK postcode e.g SW1A 2AA + postcode?: string; +} + +export interface LookupPostcodeResponse { + addresses?: Record[]; +} + +export interface Record { + // building name + buildingName?: string; + // the county + county?: string; + // line one of address + lineOne?: string; + // line two of address + lineTwo?: string; + // dependent locality + locality?: string; + // organisation if present + organisation?: string; + // the postcode + postcode?: string; + // the premise + premise?: string; + // street name + street?: string; + // the complete address + summary?: string; + // post town + town?: string; +} diff --git a/clients/ts/answer/index.ts b/clients/ts/answer/index.ts new file mode 100755 index 0000000..a03c452 --- /dev/null +++ b/clients/ts/answer/index.ts @@ -0,0 +1,31 @@ +import * as m3o from "@m3o/m3o-node"; + +export class AnswerService { + private client: m3o.Client; + + constructor(token: string) { + this.client = new m3o.Client({ token: token }); + } + // Ask a question and receive an instant answer + question(request: QuestionRequest): Promise { + return this.client.call( + "answer", + "Question", + request + ) as Promise; + } +} + +export interface QuestionRequest { + // the question to answer + query?: string; +} + +export interface QuestionResponse { + // the answer to your question + answer?: string; + // any related image + image?: string; + // a related url + url?: string; +} diff --git a/clients/ts/cache/index.ts b/clients/ts/cache/index.ts new file mode 100755 index 0000000..8f43b48 --- /dev/null +++ b/clients/ts/cache/index.ts @@ -0,0 +1,107 @@ +import * as m3o from "@m3o/m3o-node"; + +export class CacheService { + private client: m3o.Client; + + constructor(token: string) { + this.client = new m3o.Client({ token: token }); + } + // Decrement a value (if it's a number) + decrement(request: DecrementRequest): Promise { + return this.client.call( + "cache", + "Decrement", + request + ) as Promise; + } + // Delete a value from the cache + delete(request: DeleteRequest): Promise { + return this.client.call( + "cache", + "Delete", + request + ) as Promise; + } + // Get an item from the cache by key + get(request: GetRequest): Promise { + return this.client.call("cache", "Get", request) as Promise; + } + // Increment a value (if it's a number) + increment(request: IncrementRequest): Promise { + return this.client.call( + "cache", + "Increment", + request + ) as Promise; + } + // Set an item in the cache. Overwrites any existing value already set. + set(request: SetRequest): Promise { + return this.client.call("cache", "Set", request) as Promise; + } +} + +export interface DecrementRequest { + // The key to decrement + key?: string; + // The amount to decrement the value by + value?: number; +} + +export interface DecrementResponse { + // The key decremented + key?: string; + // The new value + value?: number; +} + +export interface DeleteRequest { + // The key to delete + key?: string; +} + +export interface DeleteResponse { + // Returns "ok" if successful + status?: string; +} + +export interface GetRequest { + // The key to retrieve + key?: string; +} + +export interface GetResponse { + // The key + key?: string; + // Time to live in seconds + ttl?: number; + // The value + value?: string; +} + +export interface IncrementRequest { + // The key to increment + key?: string; + // The amount to increment the value by + value?: number; +} + +export interface IncrementResponse { + // The key incremented + key?: string; + // The new value + value?: number; +} + +export interface SetRequest { + // The key to update + key?: string; + // Time to live in seconds + ttl?: number; + // The value to set + value?: string; +} + +export interface SetResponse { + // Returns "ok" if successful + status?: string; +} diff --git a/clients/ts/crypto/index.ts b/clients/ts/crypto/index.ts new file mode 100755 index 0000000..c173f65 --- /dev/null +++ b/clients/ts/crypto/index.ts @@ -0,0 +1,116 @@ +import * as m3o from "@m3o/m3o-node"; + +export class CryptoService { + private client: m3o.Client; + + constructor(token: string) { + this.client = new m3o.Client({ token: token }); + } + // Returns the history for the previous close + history(request: HistoryRequest): Promise { + return this.client.call( + "crypto", + "History", + request + ) as Promise; + } + // Get news related to a currency + news(request: NewsRequest): Promise { + return this.client.call("crypto", "News", request) as Promise; + } + // Get the last price for a given crypto ticker + price(request: PriceRequest): Promise { + return this.client.call( + "crypto", + "Price", + request + ) as Promise; + } + // Get the last quote for a given crypto ticker + quote(request: QuoteRequest): Promise { + return this.client.call( + "crypto", + "Quote", + request + ) as Promise; + } +} + +export interface Article { + // the date published + date?: string; + // its description + description?: string; + // the source + source?: string; + // title of the article + title?: string; + // the source url + url?: string; +} + +export interface HistoryRequest { + // the crypto symbol e.g BTCUSD + symbol?: string; +} + +export interface HistoryResponse { + // the close price + close?: number; + // the date + date?: string; + // the peak price + high?: number; + // the low price + low?: number; + // the open price + open?: number; + // the crypto symbol + symbol?: string; + // the volume + volume?: number; +} + +export interface NewsRequest { + // cryptocurrency ticker to request news for e.g BTC + symbol?: string; +} + +export interface NewsResponse { + // list of articles + articles?: Article[]; + // symbol requested for + symbol?: string; +} + +export interface PriceRequest { + // the crypto symbol e.g BTCUSD + symbol?: string; +} + +export interface PriceResponse { + // the last price + price?: number; + // the crypto symbol e.g BTCUSD + symbol?: string; +} + +export interface QuoteRequest { + // the crypto symbol e.g BTCUSD + symbol?: string; +} + +export interface QuoteResponse { + // the asking price + askPrice?: number; + // the ask size + askSize?: number; + // the bidding price + bidPrice?: number; + // the bid size + bidSize?: number; + // the crypto symbol + symbol?: string; + // the UTC timestamp of the quote + timestamp?: string; +} diff --git a/clients/ts/currency/index.ts b/clients/ts/currency/index.ts new file mode 100755 index 0000000..a65b7e2 --- /dev/null +++ b/clients/ts/currency/index.ts @@ -0,0 +1,102 @@ +import * as m3o from "@m3o/m3o-node"; + +export class CurrencyService { + private client: m3o.Client; + + constructor(token: string) { + this.client = new m3o.Client({ token: token }); + } + // Codes returns the supported currency codes for the API + codes(request: CodesRequest): Promise { + return this.client.call( + "currency", + "Codes", + request + ) as Promise; + } + // Convert returns the currency conversion rate between two pairs e.g USD/GBP + convert(request: ConvertRequest): Promise { + return this.client.call( + "currency", + "Convert", + request + ) as Promise; + } + // Returns the historic rates for a currency on a given date + history(request: HistoryRequest): Promise { + return this.client.call( + "currency", + "History", + request + ) as Promise; + } + // Rates returns the currency rates for a given code e.g USD + rates(request: RatesRequest): Promise { + return this.client.call( + "currency", + "Rates", + request + ) as Promise; + } +} + +export interface Code { + // e.g United States Dollar + currency?: string; + // e.g USD + name?: string; +} + +export interface CodesRequest {} + +export interface CodesResponse { + codes?: Code[]; +} + +export interface ConvertRequest { + // optional amount to convert e.g 10.0 + amount?: number; + // base code to convert from e.g USD + from?: string; + // target code to convert to e.g GBP + to?: string; +} + +export interface ConvertResponse { + // converted amount e.g 7.10 + amount?: number; + // the base code e.g USD + from?: string; + // conversion rate e.g 0.71 + rate?: number; + // the target code e.g GBP + to?: string; +} + +export interface HistoryRequest { + // currency code e.g USD + code?: string; + // date formatted as YYYY-MM-DD + date?: string; +} + +export interface HistoryResponse { + // The code of the request + code?: string; + // The date requested + date?: string; + // The rate for the day as code:rate + rates?: { [key: string]: number }; +} + +export interface RatesRequest { + // The currency code to get rates for e.g USD + code?: string; +} + +export interface RatesResponse { + // The code requested e.g USD + code?: string; + // The rates for the given code as key-value pairs code:rate + rates?: { [key: string]: number }; +} diff --git a/clients/ts/db/index.ts b/clients/ts/db/index.ts new file mode 100755 index 0000000..f23acf2 --- /dev/null +++ b/clients/ts/db/index.ts @@ -0,0 +1,101 @@ +import * as m3o from "@m3o/m3o-node"; + +export class DbService { + private client: m3o.Client; + + constructor(token: string) { + this.client = new m3o.Client({ token: token }); + } + // Create a record in the database. Optionally include an "id" field otherwise it's set automatically. + create(request: CreateRequest): Promise { + return this.client.call("db", "Create", request) as Promise; + } + // Delete a record in the database by id. + delete(request: DeleteRequest): Promise { + return this.client.call("db", "Delete", request) as Promise; + } + // Read data from a table. Lookup can be by ID or via querying any field in the record. + read(request: ReadRequest): Promise { + return this.client.call("db", "Read", request) as Promise; + } + // Truncate the records in a table + truncate(request: TruncateRequest): Promise { + return this.client.call( + "db", + "Truncate", + request + ) as Promise; + } + // Update a record in the database. Include an "id" in the record to update. + update(request: UpdateRequest): Promise { + return this.client.call("db", "Update", request) as Promise; + } +} + +export interface CreateRequest { + // JSON encoded record or records (can be array or object) + record?: { [key: string]: any }; + // Optional table name. Defaults to 'default' + table?: string; +} + +export interface CreateResponse { + // The id of the record (either specified or automatically created) + id?: string; +} + +export interface DeleteRequest { + // id of the record + id?: string; + // Optional table name. Defaults to 'default' + table?: string; +} + +export interface DeleteResponse {} + +export interface ReadRequest { + // Read by id. Equivalent to 'id == "your-id"' + id?: string; + // Maximum number of records to return. Default limit is 25. + // Maximum limit is 1000. Anything higher will return an error. + limit?: number; + offset?: number; + // 'asc' (default), 'desc' + order?: string; + // field name to order by + orderBy?: string; + // 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; + // Optional table name. Defaults to 'default' + table?: string; +} + +export interface ReadResponse { + // JSON encoded records + records?: { [key: string]: any }[]; +} + +export interface TruncateRequest { + // Optional table name. Defaults to 'default' + table?: string; +} + +export interface TruncateResponse { + // The table truncated + table?: string; +} + +export interface UpdateRequest { + // The id of the record. If not specified it is inferred from the 'id' field of the record + id?: string; + // record, JSON object + record?: { [key: string]: any }; + // Optional table name. Defaults to 'default' + table?: string; +} + +export interface UpdateResponse {} diff --git a/clients/ts/email/index.ts b/clients/ts/email/index.ts new file mode 100755 index 0000000..e124f9d --- /dev/null +++ b/clients/ts/email/index.ts @@ -0,0 +1,30 @@ +import * as m3o from "@m3o/m3o-node"; + +export class EmailService { + private client: m3o.Client; + + constructor(token: string) { + this.client = new m3o.Client({ token: token }); + } + // Send an email by passing in from, to, subject, and a text or html body + send(request: SendRequest): Promise { + return this.client.call("email", "Send", request) as Promise; + } +} + +export interface SendRequest { + // the display name of the sender + from?: string; + // the html body + htmlBody?: string; + // an optional reply to email address + replyTo?: string; + // the email subject + subject?: string; + // the text body + textBody?: string; + // the email address of the recipient + to?: string; +} + +export interface SendResponse {} diff --git a/clients/ts/emoji/index.ts b/clients/ts/emoji/index.ts new file mode 100755 index 0000000..26b163f --- /dev/null +++ b/clients/ts/emoji/index.ts @@ -0,0 +1,74 @@ +import * as m3o from "@m3o/m3o-node"; + +export class EmojiService { + private client: m3o.Client; + + constructor(token: string) { + this.client = new m3o.Client({ token: token }); + } + // Find an emoji by its alias e.g :beer: + find(request: FindRequest): Promise { + return this.client.call("emoji", "Find", request) as Promise; + } + // Get the flag for a country. Requires country code e.g GB for great britain + flag(request: FlagRequest): Promise { + return this.client.call("emoji", "Flag", request) as Promise; + } + // Print text and renders the emojis with aliases e.g + // let's grab a :beer: becomes let's grab a 🍺 + print(request: PrintRequest): Promise { + return this.client.call( + "emoji", + "Print", + request + ) as Promise; + } + // Send an emoji to anyone via SMS. Messages are sent in the form ' Sent from ' + send(request: SendRequest): Promise { + return this.client.call("emoji", "Send", request) as Promise; + } +} + +export interface FindRequest { + // the alias code e.g :beer: + alias?: string; +} + +export interface FindResponse { + // the unicode emoji 🍺 + emoji?: string; +} + +export interface FlagRequest { + // country code e.g GB + code?: string; +} + +export interface FlagResponse { + // the emoji flag + flag?: string; +} + +export interface PrintRequest { + // text including any alias e.g let's grab a :beer: + text?: string; +} + +export interface PrintResponse { + // text with rendered emojis + text?: string; +} + +export interface SendRequest { + // the name of the sender from e.g Alice + from?: string; + // message to send including emoji aliases + message?: string; + // phone number to send to (including international dialing code) + to?: string; +} + +export interface SendResponse { + // whether or not it succeeded + success?: boolean; +} diff --git a/clients/ts/file/index.ts b/clients/ts/file/index.ts new file mode 100755 index 0000000..1412f3a --- /dev/null +++ b/clients/ts/file/index.ts @@ -0,0 +1,92 @@ +import * as m3o from "@m3o/m3o-node"; + +export class FileService { + private client: m3o.Client; + + constructor(token: string) { + this.client = new m3o.Client({ token: token }); + } + // Delete a file by project name/path + delete(request: DeleteRequest): Promise { + return this.client.call( + "file", + "Delete", + request + ) as Promise; + } + // List files by their project and optionally a path. + list(request: ListRequest): Promise { + return this.client.call("file", "List", request) as Promise; + } + // Read a file by path + read(request: ReadRequest): Promise { + return this.client.call("file", "Read", request) as Promise; + } + // Save a file + save(request: SaveRequest): Promise { + return this.client.call("file", "Save", request) as Promise; + } +} + +export interface BatchSaveRequest { + files?: Record[]; +} + +export interface BatchSaveResponse {} + +export interface DeleteRequest { + // Path to the file + path?: string; + // The project name + project?: string; +} + +export interface DeleteResponse {} + +export interface ListRequest { + // 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; + // Project, required for listing. + project?: string; +} + +export interface ListResponse { + files?: Record[]; +} + +export interface ReadRequest { + // Path to the file + path?: string; + // Project name + project?: string; +} + +export interface ReadResponse { + // Returns the file + file?: Record; +} + +export interface Record { + // File contents + content?: string; + // Time the file was created e.g 2021-05-20T13:37:21Z + created?: string; + // Any other associated metadata as a map of key-value pairs + metadata?: { [key: string]: string }; + // Path to file or folder eg. '/documents/text-files/file.txt'. + path?: string; + // A custom project to group files + // eg. file-of-mywebsite.com + project?: string; + // Time the file was updated e.g 2021-05-20T13:37:21Z + updated?: string; +} + +export interface SaveRequest { + file?: Record; +} + +export interface SaveResponse {} diff --git a/clients/ts/forex/index.ts b/clients/ts/forex/index.ts new file mode 100755 index 0000000..b0d22e2 --- /dev/null +++ b/clients/ts/forex/index.ts @@ -0,0 +1,83 @@ +import * as m3o from "@m3o/m3o-node"; + +export class ForexService { + private client: m3o.Client; + + constructor(token: string) { + this.client = new m3o.Client({ token: token }); + } + // Returns the data for the previous close + history(request: HistoryRequest): Promise { + return this.client.call( + "forex", + "History", + request + ) as Promise; + } + // Get the latest price for a given forex ticker + price(request: PriceRequest): Promise { + return this.client.call( + "forex", + "Price", + request + ) as Promise; + } + // Get the latest quote for the forex + quote(request: QuoteRequest): Promise { + return this.client.call( + "forex", + "Quote", + request + ) as Promise; + } +} + +export interface HistoryRequest { + // the forex symbol e.g GBPUSD + symbol?: string; +} + +export interface HistoryResponse { + // the close price + close?: number; + // the date + date?: string; + // the peak price + high?: number; + // the low price + low?: number; + // the open price + open?: number; + // the forex symbol + symbol?: string; + // the volume + volume?: number; +} + +export interface PriceRequest { + // forex symbol e.g GBPUSD + symbol?: string; +} + +export interface PriceResponse { + // the last price + price?: number; + // the forex symbol e.g GBPUSD + symbol?: string; +} + +export interface QuoteRequest { + // the forex symbol e.g GBPUSD + symbol?: string; +} + +export interface QuoteResponse { + // the asking price + askPrice?: number; + // the bidding price + bidPrice?: number; + // the forex symbol + symbol?: string; + // the UTC timestamp of the quote + timestamp?: string; +} diff --git a/clients/ts/geocoding/index.ts b/clients/ts/geocoding/index.ts new file mode 100755 index 0000000..36ecc6b --- /dev/null +++ b/clients/ts/geocoding/index.ts @@ -0,0 +1,60 @@ +import * as m3o from "@m3o/m3o-node"; + +export class GeocodingService { + private client: m3o.Client; + + constructor(token: string) { + this.client = new m3o.Client({ token: token }); + } + // Lookup returns a geocoded address including normalized address and gps coordinates. All fields are optional, provide more to get more accurate results + lookup(request: LookupRequest): Promise { + return this.client.call( + "geocoding", + "Lookup", + request + ) as Promise; + } + // Reverse lookup an address from gps coordinates + reverse(request: ReverseRequest): Promise { + return this.client.call( + "geocoding", + "Reverse", + request + ) as Promise; + } +} + +export interface Address { + city?: string; + country?: string; + lineOne?: string; + lineTwo?: string; + postcode?: string; +} + +export interface Location { + latitude?: number; + longitude?: number; +} + +export interface LookupRequest { + address?: string; + city?: string; + country?: string; + postcode?: string; +} + +export interface LookupResponse { + address?: { [key: string]: any }; + location?: { [key: string]: any }; +} + +export interface ReverseRequest { + latitude?: number; + longitude?: number; +} + +export interface ReverseResponse { + address?: { [key: string]: any }; + location?: { [key: string]: any }; +} diff --git a/clients/ts/helloworld/index.ts b/clients/ts/helloworld/index.ts new file mode 100755 index 0000000..54144d3 --- /dev/null +++ b/clients/ts/helloworld/index.ts @@ -0,0 +1,43 @@ +import * as m3o from "@m3o/m3o-node"; + +export class HelloworldService { + private client: m3o.Client; + + constructor(token: string) { + this.client = new m3o.Client({ token: token }); + } + // Call returns a personalised "Hello $name" response + call(request: CallRequest): Promise { + return this.client.call( + "helloworld", + "Call", + request + ) as Promise; + } + // Stream returns a stream of "Hello $name" responses + stream(request: StreamRequest): Promise { + return this.client.call( + "helloworld", + "Stream", + request + ) as Promise; + } +} + +export interface CallRequest { + name?: string; +} + +export interface CallResponse { + message?: string; +} + +export interface StreamRequest { + // the number of messages to send back + messages?: number; + name?: string; +} + +export interface StreamResponse { + message?: string; +} diff --git a/clients/ts/id/index.ts b/clients/ts/id/index.ts new file mode 100755 index 0000000..28c228e --- /dev/null +++ b/clients/ts/id/index.ts @@ -0,0 +1,39 @@ +import * as m3o from "@m3o/m3o-node"; + +export class IdService { + private client: m3o.Client; + + constructor(token: string) { + this.client = new m3o.Client({ token: token }); + } + // Generate a unique ID. Defaults to uuid. + generate(request: GenerateRequest): Promise { + return this.client.call( + "id", + "Generate", + request + ) as Promise; + } + // List the types of IDs available. No query params needed. + types(request: TypesRequest): Promise { + return this.client.call("id", "Types", request) as Promise; + } +} + +export interface GenerateRequest { + // type of id e.g uuid, shortid, snowflake (64 bit), bigflake (128 bit) + type?: string; +} + +export interface GenerateResponse { + // the unique id generated + id?: string; + // the type of id generated + type?: string; +} + +export interface TypesRequest {} + +export interface TypesResponse { + types?: string[]; +} diff --git a/clients/ts/image/index.ts b/clients/ts/image/index.ts new file mode 100755 index 0000000..4267163 --- /dev/null +++ b/clients/ts/image/index.ts @@ -0,0 +1,113 @@ +import * as m3o from "@m3o/m3o-node"; + +export class ImageService { + private client: m3o.Client; + + constructor(token: string) { + this.client = new m3o.Client({ token: token }); + } + // 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. + convert(request: ConvertRequest): Promise { + return this.client.call( + "image", + "Convert", + request + ) as Promise; + } + // 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. + resize(request: ResizeRequest): Promise { + return this.client.call( + "image", + "Resize", + request + ) as Promise; + } + // 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. + upload(request: UploadRequest): Promise { + return this.client.call( + "image", + "Upload", + request + ) as Promise; + } +} + +export interface ConvertRequest { + // base64 encoded image to resize, + // ie. "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==" + base64?: string; + // output name of the image including extension, ie. "cat.png" + name?: string; + // make output a URL and not a base64 response + outputURL?: boolean; + // url of the image to resize + url?: string; +} + +export interface ConvertResponse { + base64?: string; + url?: string; +} + +export interface CropOptions { + // Crop anchor point: "top", "top left", "top right", + // "left", "center", "right" + // "bottom left", "bottom", "bottom right". + // Optional. Defaults to center. + anchor?: string; + // height to crop to + height?: number; + // width to crop to + width?: number; +} + +export interface Point { + x?: number; + y?: number; +} + +export interface Rectangle { + max?: Point; + min?: Point; +} + +export interface ResizeRequest { + // base64 encoded image to resize, + // ie. "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==" + base64?: string; + // optional crop options + // if provided, after resize, the image + // will be cropped + cropOptions?: CropOptions; + height?: number; + // output name of the image including extension, ie. "cat.png" + name?: string; + // make output a URL and not a base64 response + outputURL?: boolean; + // url of the image to resize + url?: string; + width?: number; +} + +export interface ResizeResponse { + base64?: string; + url?: string; +} + +export interface UploadRequest { + // Base64 encoded image to upload, + // ie. "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==" + base64?: string; + // Output name of the image including extension, ie. "cat.png" + name?: string; + // URL of the image to upload + url?: string; +} + +export interface UploadResponse { + url?: string; +} diff --git a/clients/ts/index.ts b/clients/ts/index.ts new file mode 100755 index 0000000..b2439ee --- /dev/null +++ b/clients/ts/index.ts @@ -0,0 +1,96 @@ +import * as address from "./address"; +import * as answer from "./answer"; +import * as cache from "./cache"; +import * as crypto from "./crypto"; +import * as currency from "./currency"; +import * as db from "./db"; +import * as email from "./email"; +import * as emoji from "./emoji"; +import * as file from "./file"; +import * as forex from "./forex"; +import * as geocoding from "./geocoding"; +import * as helloworld from "./helloworld"; +import * as id from "./id"; +import * as image from "./image"; +import * as ip from "./ip"; +import * as location from "./location"; +import * as otp from "./otp"; +import * as postcode from "./postcode"; +import * as quran from "./quran"; +import * as routing from "./routing"; +import * as rss from "./rss"; +import * as sentiment from "./sentiment"; +import * as sms from "./sms"; +import * as stock from "./stock"; +import * as stream from "./stream"; +import * as thumbnail from "./thumbnail"; +import * as time from "./time"; +import * as url from "./url"; +import * as user from "./user"; +import * as weather from "./weather"; + +export class Client { + constructor(token: string) { + this.addressService = new address.AddressService(token); + this.answerService = new answer.AnswerService(token); + this.cacheService = new cache.CacheService(token); + this.cryptoService = new crypto.CryptoService(token); + this.currencyService = new currency.CurrencyService(token); + this.dbService = new db.DbService(token); + this.emailService = new email.EmailService(token); + this.emojiService = new emoji.EmojiService(token); + this.fileService = new file.FileService(token); + this.forexService = new forex.ForexService(token); + this.geocodingService = new geocoding.GeocodingService(token); + this.helloworldService = new helloworld.HelloworldService(token); + this.idService = new id.IdService(token); + this.imageService = new image.ImageService(token); + this.ipService = new ip.IpService(token); + this.locationService = new location.LocationService(token); + this.otpService = new otp.OtpService(token); + this.postcodeService = new postcode.PostcodeService(token); + this.quranService = new quran.QuranService(token); + this.routingService = new routing.RoutingService(token); + this.rssService = new rss.RssService(token); + this.sentimentService = new sentiment.SentimentService(token); + this.smsService = new sms.SmsService(token); + this.stockService = new stock.StockService(token); + this.streamService = new stream.StreamService(token); + this.thumbnailService = new thumbnail.ThumbnailService(token); + this.timeService = new time.TimeService(token); + this.urlService = new url.UrlService(token); + this.userService = new user.UserService(token); + this.weatherService = new weather.WeatherService(token); + } + + addressService: address.AddressService; + answerService: answer.AnswerService; + cacheService: cache.CacheService; + cryptoService: crypto.CryptoService; + currencyService: currency.CurrencyService; + dbService: db.DbService; + emailService: email.EmailService; + emojiService: emoji.EmojiService; + fileService: file.FileService; + forexService: forex.ForexService; + geocodingService: geocoding.GeocodingService; + helloworldService: helloworld.HelloworldService; + idService: id.IdService; + imageService: image.ImageService; + ipService: ip.IpService; + locationService: location.LocationService; + otpService: otp.OtpService; + postcodeService: postcode.PostcodeService; + quranService: quran.QuranService; + routingService: routing.RoutingService; + rssService: rss.RssService; + sentimentService: sentiment.SentimentService; + smsService: sms.SmsService; + stockService: stock.StockService; + streamService: stream.StreamService; + thumbnailService: thumbnail.ThumbnailService; + timeService: time.TimeService; + urlService: url.UrlService; + userService: user.UserService; + weatherService: weather.WeatherService; +} diff --git a/clients/ts/ip/index.ts b/clients/ts/ip/index.ts new file mode 100755 index 0000000..cead97f --- /dev/null +++ b/clients/ts/ip/index.ts @@ -0,0 +1,37 @@ +import * as m3o from "@m3o/m3o-node"; + +export class IpService { + private client: m3o.Client; + + constructor(token: string) { + this.client = new m3o.Client({ token: token }); + } + // Lookup the geolocation information for an IP address + lookup(request: LookupRequest): Promise { + return this.client.call("ip", "Lookup", request) as Promise; + } +} + +export interface LookupRequest { + // IP to lookup + ip?: string; +} + +export interface LookupResponse { + // Autonomous system number + asn?: number; + // Name of the city + city?: string; + // Name of the continent + continent?: string; + // Name of the country + country?: string; + // IP of the query + ip?: string; + // Latitude e.g 52.523219 + latitude?: number; + // Longitude e.g 13.428555 + longitude?: number; + // Timezone e.g Europe/Rome + timezone?: string; +} diff --git a/clients/ts/location/index.ts b/clients/ts/location/index.ts new file mode 100755 index 0000000..13f8f57 --- /dev/null +++ b/clients/ts/location/index.ts @@ -0,0 +1,75 @@ +import * as m3o from "@m3o/m3o-node"; + +export class LocationService { + private client: m3o.Client; + + constructor(token: string) { + this.client = new m3o.Client({ token: token }); + } + // Read an entity by its ID + read(request: ReadRequest): Promise { + return this.client.call( + "location", + "Read", + request + ) as Promise; + } + // Save an entity's current position + save(request: SaveRequest): Promise { + return this.client.call( + "location", + "Save", + request + ) as Promise; + } + // Search for entities in a given radius + search(request: SearchRequest): Promise { + return this.client.call( + "location", + "Search", + request + ) as Promise; + } +} + +export interface Entity { + id?: string; + location?: Point; + type?: string; +} + +export interface Point { + latitude?: number; + longitude?: number; + timestamp?: number; +} + +export interface ReadRequest { + // the entity id + id?: string; +} + +export interface ReadResponse { + entity?: { [key: string]: any }; +} + +export interface SaveRequest { + entity?: { [key: string]: any }; +} + +export interface SaveResponse {} + +export interface SearchRequest { + // Central position to search from + center?: Point; + // Maximum number of entities to return + numEntities?: number; + // radius in meters + radius?: number; + // type of entities to filter + type?: string; +} + +export interface SearchResponse { + entities?: Entity[]; +} diff --git a/clients/ts/otp/index.ts b/clients/ts/otp/index.ts new file mode 100755 index 0000000..e00e58b --- /dev/null +++ b/clients/ts/otp/index.ts @@ -0,0 +1,51 @@ +import * as m3o from "@m3o/m3o-node"; + +export class OtpService { + private client: m3o.Client; + + constructor(token: string) { + this.client = new m3o.Client({ token: token }); + } + // Generate an OTP (one time pass) code + generate(request: GenerateRequest): Promise { + return this.client.call( + "otp", + "Generate", + request + ) as Promise; + } + // Validate the OTP code + validate(request: ValidateRequest): Promise { + return this.client.call( + "otp", + "Validate", + request + ) as Promise; + } +} + +export interface GenerateRequest { + // expiration in seconds (default: 60) + expiry?: number; + // unique id, email or user to generate an OTP for + id?: string; + // number of characters (default: 6) + size?: number; +} + +export interface GenerateResponse { + // one time pass code + code?: string; +} + +export interface ValidateRequest { + // one time pass code to validate + code?: string; + // unique id, email or user for which the code was generated + id?: string; +} + +export interface ValidateResponse { + // returns true if the code is valid for the ID + success?: boolean; +} diff --git a/clients/ts/package-lock.json b/clients/ts/package-lock.json new file mode 100644 index 0000000..2f90a3c --- /dev/null +++ b/clients/ts/package-lock.json @@ -0,0 +1,566 @@ +{ + "name": "@micro/services", + "version": "1.0.1", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "name": "@micro/services", + "version": "1.0.1", + "license": "ISC", + "dependencies": { + "@m3o/m3o-node": "^0.0.24" + }, + "devDependencies": { + "typescript": "^3.5.1" + } + }, + "node_modules/@m3o/m3o-node": { + "version": "0.0.24", + "resolved": "https://registry.npmjs.org/@m3o/m3o-node/-/m3o-node-0.0.24.tgz", + "integrity": "sha512-W6VqmZUTFodwBUai5uQ9nO4ylIztUXKYPFfZg2qqTv1lHkOYQ0XiJgFVn+SEOlp4GU/JI9OzCt4k1Ui5XaXGdw==", + "dependencies": { + "@types/ws": "^7.2.2", + "axios": "^0.21.1", + "body-parser": "^1.19.0", + "dotenv": "^10.0.0", + "jsonfile": "^6.1.0", + "ws": "^7.2.3" + } + }, + "node_modules/@types/node": { + "version": "16.7.10", + "resolved": "https://registry.npmjs.org/@types/node/-/node-16.7.10.tgz", + "integrity": "sha512-S63Dlv4zIPb8x6MMTgDq5WWRJQe56iBEY0O3SOFA9JrRienkOVDXSXBjjJw6HTNQYSE2JI6GMCR6LVbIMHJVvA==" + }, + "node_modules/@types/ws": { + "version": "7.4.7", + "resolved": "https://registry.npmjs.org/@types/ws/-/ws-7.4.7.tgz", + "integrity": "sha512-JQbbmxZTZehdc2iszGKs5oC3NFnjeay7mtAWrdt7qNtAVK0g19muApzAy4bm9byz79xa2ZnO/BOBC2R8RC5Lww==", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/axios": { + "version": "0.21.1", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.1.tgz", + "integrity": "sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA==", + "dependencies": { + "follow-redirects": "^1.10.0" + } + }, + "node_modules/body-parser": { + "version": "1.19.0", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz", + "integrity": "sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw==", + "dependencies": { + "bytes": "3.1.0", + "content-type": "~1.0.4", + "debug": "2.6.9", + "depd": "~1.1.2", + "http-errors": "1.7.2", + "iconv-lite": "0.4.24", + "on-finished": "~2.3.0", + "qs": "6.7.0", + "raw-body": "2.4.0", + "type-is": "~1.6.17" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/bytes": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz", + "integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/content-type": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", + "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/depd": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", + "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/dotenv": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz", + "integrity": "sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==", + "engines": { + "node": ">=10" + } + }, + "node_modules/ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" + }, + "node_modules/follow-redirects": { + "version": "1.14.3", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.3.tgz", + "integrity": "sha512-3MkHxknWMUtb23apkgz/83fDoe+y+qr0TdgacGIA7bew+QLBo3vdgEN2xEsuXNivpFy4CyDhBBZnNZOtalmenw==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, + "node_modules/graceful-fs": { + "version": "4.2.8", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.8.tgz", + "integrity": "sha512-qkIilPUYcNhJpd33n0GBXTB1MMPp14TxEsEs0pTrsSVucApsYzW5V+Q8Qxhik6KU3evy+qkAAowTByymK0avdg==", + "optional": true + }, + "node_modules/http-errors": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz", + "integrity": "sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==", + "dependencies": { + "depd": "~1.1.2", + "inherits": "2.0.3", + "setprototypeof": "1.1.1", + "statuses": ">= 1.5.0 < 2", + "toidentifier": "1.0.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + }, + "node_modules/jsonfile": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", + "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", + "dependencies": { + "universalify": "^2.0.0" + }, + "optionalDependencies": { + "graceful-fs": "^4.1.6" + } + }, + "node_modules/media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-db": { + "version": "1.49.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.49.0.tgz", + "integrity": "sha512-CIc8j9URtOVApSFCQIF+VBkX1RwXp/oMMOrqdyXSBXq5RWNEsRfyj1kiRnQgmNXmHxPoFIxOroKA3zcU9P+nAA==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.32", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.32.tgz", + "integrity": "sha512-hJGaVS4G4c9TSMYh2n6SQAGrC4RnfU+daP8G7cSCmaqNjiOoUY0VHCMS42pxnQmVF1GWwFhbHWn3RIxCqTmZ9A==", + "dependencies": { + "mime-db": "1.49.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + }, + "node_modules/on-finished": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", + "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", + "dependencies": { + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/qs": { + "version": "6.7.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", + "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==", + "engines": { + "node": ">=0.6" + } + }, + "node_modules/raw-body": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.0.tgz", + "integrity": "sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q==", + "dependencies": { + "bytes": "3.1.0", + "http-errors": "1.7.2", + "iconv-lite": "0.4.24", + "unpipe": "1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + }, + "node_modules/setprototypeof": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz", + "integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==" + }, + "node_modules/statuses": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", + "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/toidentifier": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz", + "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==", + "engines": { + "node": ">=0.6" + } + }, + "node_modules/type-is": { + "version": "1.6.18", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", + "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", + "dependencies": { + "media-typer": "0.3.0", + "mime-types": "~2.1.24" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/typescript": { + "version": "3.9.10", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.10.tgz", + "integrity": "sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, + "node_modules/universalify": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", + "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==", + "engines": { + "node": ">= 10.0.0" + } + }, + "node_modules/unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/ws": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.4.tgz", + "integrity": "sha512-zP9z6GXm6zC27YtspwH99T3qTG7bBFv2VIkeHstMLrLlDJuzA7tQ5ls3OJ1hOGGCzTQPniNJoHXIAOS0Jljohg==", + "engines": { + "node": ">=8.3.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": "^5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + } + }, + "dependencies": { + "@m3o/m3o-node": { + "version": "0.0.24", + "resolved": "https://registry.npmjs.org/@m3o/m3o-node/-/m3o-node-0.0.24.tgz", + "integrity": "sha512-W6VqmZUTFodwBUai5uQ9nO4ylIztUXKYPFfZg2qqTv1lHkOYQ0XiJgFVn+SEOlp4GU/JI9OzCt4k1Ui5XaXGdw==", + "requires": { + "@types/ws": "^7.2.2", + "axios": "^0.21.1", + "body-parser": "^1.19.0", + "dotenv": "^10.0.0", + "jsonfile": "^6.1.0", + "ws": "^7.2.3" + } + }, + "@types/node": { + "version": "16.7.10", + "resolved": "https://registry.npmjs.org/@types/node/-/node-16.7.10.tgz", + "integrity": "sha512-S63Dlv4zIPb8x6MMTgDq5WWRJQe56iBEY0O3SOFA9JrRienkOVDXSXBjjJw6HTNQYSE2JI6GMCR6LVbIMHJVvA==" + }, + "@types/ws": { + "version": "7.4.7", + "resolved": "https://registry.npmjs.org/@types/ws/-/ws-7.4.7.tgz", + "integrity": "sha512-JQbbmxZTZehdc2iszGKs5oC3NFnjeay7mtAWrdt7qNtAVK0g19muApzAy4bm9byz79xa2ZnO/BOBC2R8RC5Lww==", + "requires": { + "@types/node": "*" + } + }, + "axios": { + "version": "0.21.1", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.1.tgz", + "integrity": "sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA==", + "requires": { + "follow-redirects": "^1.10.0" + } + }, + "body-parser": { + "version": "1.19.0", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz", + "integrity": "sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw==", + "requires": { + "bytes": "3.1.0", + "content-type": "~1.0.4", + "debug": "2.6.9", + "depd": "~1.1.2", + "http-errors": "1.7.2", + "iconv-lite": "0.4.24", + "on-finished": "~2.3.0", + "qs": "6.7.0", + "raw-body": "2.4.0", + "type-is": "~1.6.17" + } + }, + "bytes": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz", + "integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==" + }, + "content-type": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", + "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==" + }, + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "requires": { + "ms": "2.0.0" + } + }, + "depd": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", + "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=" + }, + "dotenv": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz", + "integrity": "sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==" + }, + "ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" + }, + "follow-redirects": { + "version": "1.14.3", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.3.tgz", + "integrity": "sha512-3MkHxknWMUtb23apkgz/83fDoe+y+qr0TdgacGIA7bew+QLBo3vdgEN2xEsuXNivpFy4CyDhBBZnNZOtalmenw==" + }, + "graceful-fs": { + "version": "4.2.8", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.8.tgz", + "integrity": "sha512-qkIilPUYcNhJpd33n0GBXTB1MMPp14TxEsEs0pTrsSVucApsYzW5V+Q8Qxhik6KU3evy+qkAAowTByymK0avdg==", + "optional": true + }, + "http-errors": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz", + "integrity": "sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==", + "requires": { + "depd": "~1.1.2", + "inherits": "2.0.3", + "setprototypeof": "1.1.1", + "statuses": ">= 1.5.0 < 2", + "toidentifier": "1.0.0" + } + }, + "iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "requires": { + "safer-buffer": ">= 2.1.2 < 3" + } + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + }, + "jsonfile": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", + "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", + "requires": { + "graceful-fs": "^4.1.6", + "universalify": "^2.0.0" + } + }, + "media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=" + }, + "mime-db": { + "version": "1.49.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.49.0.tgz", + "integrity": "sha512-CIc8j9URtOVApSFCQIF+VBkX1RwXp/oMMOrqdyXSBXq5RWNEsRfyj1kiRnQgmNXmHxPoFIxOroKA3zcU9P+nAA==" + }, + "mime-types": { + "version": "2.1.32", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.32.tgz", + "integrity": "sha512-hJGaVS4G4c9TSMYh2n6SQAGrC4RnfU+daP8G7cSCmaqNjiOoUY0VHCMS42pxnQmVF1GWwFhbHWn3RIxCqTmZ9A==", + "requires": { + "mime-db": "1.49.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + }, + "on-finished": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", + "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", + "requires": { + "ee-first": "1.1.1" + } + }, + "qs": { + "version": "6.7.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", + "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==" + }, + "raw-body": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.0.tgz", + "integrity": "sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q==", + "requires": { + "bytes": "3.1.0", + "http-errors": "1.7.2", + "iconv-lite": "0.4.24", + "unpipe": "1.0.0" + } + }, + "safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + }, + "setprototypeof": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz", + "integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==" + }, + "statuses": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", + "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=" + }, + "toidentifier": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz", + "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==" + }, + "type-is": { + "version": "1.6.18", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", + "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", + "requires": { + "media-typer": "0.3.0", + "mime-types": "~2.1.24" + } + }, + "typescript": { + "version": "3.9.10", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.10.tgz", + "integrity": "sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==", + "dev": true + }, + "universalify": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", + "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==" + }, + "unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" + }, + "ws": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.4.tgz", + "integrity": "sha512-zP9z6GXm6zC27YtspwH99T3qTG7bBFv2VIkeHstMLrLlDJuzA7tQ5ls3OJ1hOGGCzTQPniNJoHXIAOS0Jljohg==", + "requires": {} + } + } +} diff --git a/clients/ts/package.json b/clients/ts/package.json new file mode 100644 index 0000000..60809a7 --- /dev/null +++ b/clients/ts/package.json @@ -0,0 +1,60 @@ +{ + "author": "", + "dependencies": { + "@m3o/m3o-node": "^0.0.24" + }, + "description": "", + "devDependencies": { + "typescript": "^3.5.1" + }, + "exports": { + "./address": "./dist/address/index.js", + "./answer": "./dist/answer/index.js", + "./cache": "./dist/cache/index.js", + "./cmd": "./dist/cmd/index.js", + "./crypto": "./dist/crypto/index.js", + "./currency": "./dist/currency/index.js", + "./db": "./dist/db/index.js", + "./email": "./dist/email/index.js", + "./emoji": "./dist/emoji/index.js", + "./file": "./dist/file/index.js", + "./forex": "./dist/forex/index.js", + "./geocoding": "./dist/geocoding/index.js", + "./helloworld": "./dist/helloworld/index.js", + "./id": "./dist/id/index.js", + "./image": "./dist/image/index.js", + "./ip": "./dist/ip/index.js", + "./location": "./dist/location/index.js", + "./otp": "./dist/otp/index.js", + "./pkg": "./dist/pkg/index.js", + "./postcode": "./dist/postcode/index.js", + "./quran": "./dist/quran/index.js", + "./routing": "./dist/routing/index.js", + "./rss": "./dist/rss/index.js", + "./sentiment": "./dist/sentiment/index.js", + "./sms": "./dist/sms/index.js", + "./stock": "./dist/stock/index.js", + "./stream": "./dist/stream/index.js", + "./test": "./dist/test/index.js", + "./thumbnail": "./dist/thumbnail/index.js", + "./time": "./dist/time/index.js", + "./url": "./dist/url/index.js", + "./user": "./dist/user/index.js", + "./weather": "./dist/weather/index.js" + }, + "license": "ISC", + "main": "dist/index.js", + "name": "m3o", + "repository": { + "type": "git", + "url": "https://github.com/micro/services" + }, + "scripts": { + "build": "tsc", + "prepare": "npm run build", + "test": "echo \"Error: no test specified\" \u0026\u0026 exit 1" + }, + "type": "module", + "types": "dist/index.d.ts", + "version": "1.0.509" +} \ No newline at end of file diff --git a/clients/ts/postcode/index.ts b/clients/ts/postcode/index.ts new file mode 100755 index 0000000..3415d68 --- /dev/null +++ b/clients/ts/postcode/index.ts @@ -0,0 +1,84 @@ +import * as m3o from "@m3o/m3o-node"; + +export class PostcodeService { + private client: m3o.Client; + + constructor(token: string) { + this.client = new m3o.Client({ token: token }); + } + // Lookup a postcode to retrieve the related region, county, etc + lookup(request: LookupRequest): Promise { + return this.client.call( + "postcode", + "Lookup", + request + ) as Promise; + } + // Return a random postcode and its related info + random(request: RandomRequest): Promise { + return this.client.call( + "postcode", + "Random", + request + ) as Promise; + } + // Validate a postcode. + validate(request: ValidateRequest): Promise { + return this.client.call( + "postcode", + "Validate", + request + ) as Promise; + } +} + +export interface LookupRequest { + // UK postcode e.g SW1A 2AA + postcode?: string; +} + +export interface LookupResponse { + // country e.g United Kingdom + country?: string; + // e.g Westminster + district?: string; + // e.g 51.50354 + latitude?: number; + // e.g -0.127695 + longitude?: number; + // UK postcode e.g SW1A 2AA + postcode?: string; + // related region e.g London + region?: string; + // e.g St James's + ward?: string; +} + +export interface RandomRequest {} + +export interface RandomResponse { + // country e.g United Kingdom + country?: string; + // e.g Westminster + district?: string; + // e.g 51.50354 + latitude?: number; + // e.g -0.127695 + longitude?: number; + // UK postcode e.g SW1A 2AA + postcode?: string; + // related region e.g London + region?: string; + // e.g St James's + ward?: string; +} + +export interface ValidateRequest { + // UK postcode e.g SW1A 2AA + postcode?: string; +} + +export interface ValidateResponse { + // Is the postcode valid (true) or not (false) + valid?: boolean; +} diff --git a/clients/ts/quran/index.ts b/clients/ts/quran/index.ts new file mode 100755 index 0000000..969f465 --- /dev/null +++ b/clients/ts/quran/index.ts @@ -0,0 +1,216 @@ +import * as m3o from "@m3o/m3o-node"; + +export class QuranService { + private client: m3o.Client; + + constructor(token: string) { + this.client = new m3o.Client({ token: token }); + } + // List the Chapters (surahs) of the Quran + chapters(request: ChaptersRequest): Promise { + return this.client.call( + "quran", + "Chapters", + request + ) as Promise; + } + // Search the Quran for any form of query or questions + search(request: SearchRequest): Promise { + return this.client.call( + "quran", + "Search", + request + ) as Promise; + } + // Get a summary for a given chapter (surah) + summary(request: SummaryRequest): Promise { + return this.client.call( + "quran", + "Summary", + request + ) as Promise; + } + // Lookup the verses (ayahs) for a chapter + verses(request: VersesRequest): Promise { + return this.client.call( + "quran", + "Verses", + request + ) as Promise; + } +} + +export interface Chapter { + // The arabic name of the chapter + arabicName?: string; + // The complex name of the chapter + complexName?: string; + // The id of the chapter as a number e.g 1 + id?: number; + // The simple name of the chapter + name?: string; + // The pages from and to e.g 1, 1 + pages?: number[]; + // Should the chapter start with bismillah + prefixBismillah?: boolean; + // The order in which it was revealed + revelationOrder?: number; + // The place of revelation + revelationPlace?: string; + // The translated name + translatedName?: string; + // The number of verses in the chapter + verses?: number; +} + +export interface ChaptersRequest { + // Specify the language e.g en + language?: string; +} + +export interface ChaptersResponse { + chapters?: Chapter[]; +} + +export interface Interpretation { + // The unique id of the interpretation + id?: number; + // The source of the interpretation + source?: string; + // The translated text + text?: string; +} + +export interface Result { + // The associated arabic text + text?: string; + // The related translations to the text + translations?: Interpretation[]; + // The unique verse id across the Quran + verseId?: number; + // The verse key e.g 1:1 + verseKey?: string; +} + +export interface SearchRequest { + // The language for translation + language?: string; + // The number of results to return + limit?: number; + // The pagination number + page?: number; + // The query to ask + query?: string; +} + +export interface SearchResponse { + // The current page + page?: number; + // The question asked + query?: string; + // The results for the query + results?: Result[]; + // The total pages + totalPages?: number; + // The total results returned + totalResults?: number; +} + +export interface SummaryRequest { + // The chapter id e.g 1 + chapter?: number; + // Specify the language e.g en + language?: string; +} + +export interface SummaryResponse { + // The chapter id + chapter?: number; + // The source of the summary + source?: string; + // The short summary for the chapter + summary?: string; + // The full description for the chapter + text?: string; +} + +export interface Translation { + // The unique id of the translation + id?: number; + // The source of the translation + source?: string; + // The translated text + text?: string; +} + +export interface Verse { + // The unique id of the verse in the whole book + id?: number; + // The interpretations of the verse + interpretations?: Translation[]; + // The key of this verse (chapter:verse) e.g 1:1 + key?: string; + // The verse number in this chapter + number?: number; + // The page of the Quran this verse is on + page?: number; + // The arabic text for this verse + text?: string; + // The basic translation of the verse + translatedText?: string; + // The alternative translations for the verse + translations?: Translation[]; + // The phonetic transliteration from arabic + transliteration?: string; + // The individual words within the verse (Ayah) + words?: Word[]; +} + +export interface VersesRequest { + // The chapter id to retrieve + chapter?: number; + // Return the interpretation (tafsir) + interpret?: boolean; + // The language of translation + language?: string; + // The verses per page + limit?: number; + // The page number to request + page?: number; + // Return alternate translations + translate?: boolean; + // Return the individual words with the verses + words?: boolean; +} + +export interface VersesResponse { + // The chapter requested + chapter?: number; + // The page requested + page?: number; + // The total pages + totalPages?: number; + // The verses on the page + verses?: Verse[]; +} + +export interface Word { + // The character type e.g word, end + charType?: string; + // The QCF v2 font code + code?: string; + // The id of the word within the verse + id?: number; + // The line number + line?: number; + // The page number + page?: number; + // The position of the word + position?: number; + // The arabic text for this word + text?: string; + // The translated text + translation?: string; + // The transliteration text + transliteration?: string; +} diff --git a/clients/ts/routing/index.ts b/clients/ts/routing/index.ts new file mode 100755 index 0000000..7f471f9 --- /dev/null +++ b/clients/ts/routing/index.ts @@ -0,0 +1,123 @@ +import * as m3o from "@m3o/m3o-node"; + +export class RoutingService { + private client: m3o.Client; + + constructor(token: string) { + this.client = new m3o.Client({ token: token }); + } + // Turn by turn directions from a start point to an end point including maneuvers and bearings + directions(request: DirectionsRequest): Promise { + return this.client.call( + "routing", + "Directions", + request + ) as Promise; + } + // Get the eta for a route from origin to destination. The eta is an estimated time based on car routes + eta(request: EtaRequest): Promise { + return this.client.call("routing", "Eta", request) as Promise; + } + // Retrieve a route as a simple list of gps points along with total distance and estimated duration + route(request: RouteRequest): Promise { + return this.client.call( + "routing", + "Route", + request + ) as Promise; + } +} + +export interface Direction { + // distance to travel in meters + distance?: number; + // duration to travel in seconds + duration?: number; + // human readable instruction + instruction?: string; + // intersections on route + intersections?: Intersection[]; + // maneuver to take + maneuver?: { [key: string]: any }; + // street name or location + name?: string; + // alternative reference + reference?: string; +} + +export interface DirectionsRequest { + // The destination of the journey + destination?: Point; + // The staring point for the journey + origin?: Point; +} + +export interface DirectionsResponse { + // Turn by turn directions + directions?: Direction[]; + // Estimated distance of the route in meters + distance?: number; + // Estimated duration of the route in seconds + duration?: number; + // The waypoints on the route + waypoints?: Waypoint[]; +} + +export interface EtaRequest { + // The end point for the eta calculation + destination?: Point; + // The starting point for the eta calculation + origin?: Point; + // speed in kilometers + speed?: number; + // type of transport. Only "car" is supported currently. + type?: string; +} + +export interface EtaResponse { + // eta in seconds + duration?: number; +} + +export interface Intersection { + bearings?: number[]; + location?: Point; +} + +export interface Maneuver { + action?: string; + bearingAfter?: number; + bearingBefore?: number; + direction?: string; + location?: Point; +} + +export interface Point { + // Lat e.g 52.523219 + latitude?: number; + // Long e.g 13.428555 + longitude?: number; +} + +export interface RouteRequest { + // Point of destination for the trip + destination?: Point; + // Point of origin for the trip + origin?: Point; +} + +export interface RouteResponse { + // estimated distance in meters + distance?: number; + // estimated duration in seconds + duration?: number; + // waypoints on the route + waypoints?: Waypoint[]; +} + +export interface Waypoint { + // gps point coordinates + location?: Point; + // street name or related reference + name?: string; +} diff --git a/clients/ts/rss/index.ts b/clients/ts/rss/index.ts new file mode 100755 index 0000000..99e3427 --- /dev/null +++ b/clients/ts/rss/index.ts @@ -0,0 +1,99 @@ +import * as m3o from "@m3o/m3o-node"; + +export class RssService { + private client: m3o.Client; + + constructor(token: string) { + this.client = new m3o.Client({ token: token }); + } + // Add a new RSS feed with a name, url, and category + add(request: AddRequest): Promise { + return this.client.call("rss", "Add", request) as Promise; + } + // Get an RSS feed by name. If no name is given, all feeds are returned. Default limit is 25 entries. + feed(request: FeedRequest): Promise { + return this.client.call("rss", "Feed", request) as Promise; + } + // List the saved RSS fields + list(request: ListRequest): Promise { + return this.client.call("rss", "List", request) as Promise; + } + // Remove an RSS feed by name + remove(request: RemoveRequest): Promise { + return this.client.call( + "rss", + "Remove", + request + ) as Promise; + } +} + +export interface AddRequest { + // category to add e.g news + category?: string; + // rss feed name + // eg. a16z + name?: string; + // rss feed url + // eg. http://a16z.com/feed/ + url?: string; +} + +export interface AddResponse {} + +export interface Entry { + // article content + content?: string; + // data of the entry + date?: string; + // the rss feed where it came from + feed?: string; + // unique id of the entry + id?: string; + // rss feed url of the entry + link?: string; + // article summary + summary?: string; + // title of the entry + title?: string; +} + +export interface Feed { + // category of the feed e.g news + category?: string; + // unique id + id?: string; + // rss feed name + // eg. a16z + name?: string; + // rss feed url + // eg. http://a16z.com/feed/ + url?: string; +} + +export interface FeedRequest { + // limit entries returned + limit?: number; + // rss feed name + name?: string; + // offset entries + offset?: number; +} + +export interface FeedResponse { + entries?: Entry[]; +} + +export interface ListRequest {} + +export interface ListResponse { + feeds?: Feed[]; +} + +export interface RemoveRequest { + // rss feed name + // eg. a16z + name?: string; +} + +export interface RemoveResponse {} diff --git a/clients/ts/sentiment/index.ts b/clients/ts/sentiment/index.ts new file mode 100755 index 0000000..8ecfd5a --- /dev/null +++ b/clients/ts/sentiment/index.ts @@ -0,0 +1,29 @@ +import * as m3o from "@m3o/m3o-node"; + +export class SentimentService { + private client: m3o.Client; + + constructor(token: string) { + this.client = new m3o.Client({ token: token }); + } + // Analyze and score a piece of text + analyze(request: AnalyzeRequest): Promise { + return this.client.call( + "sentiment", + "Analyze", + request + ) as Promise; + } +} + +export interface AnalyzeRequest { + // The language. Defaults to english. + lang?: string; + // The text to analyze + text?: string; +} + +export interface AnalyzeResponse { + // The score of the text {positive is 1, negative is 0} + score?: number; +} diff --git a/clients/ts/sms/index.ts b/clients/ts/sms/index.ts new file mode 100755 index 0000000..b0077ba --- /dev/null +++ b/clients/ts/sms/index.ts @@ -0,0 +1,29 @@ +import * as m3o from "@m3o/m3o-node"; + +export class SmsService { + private client: m3o.Client; + + constructor(token: string) { + this.client = new m3o.Client({ token: token }); + } + // Send an SMS. + send(request: SendRequest): Promise { + return this.client.call("sms", "Send", request) as Promise; + } +} + +export interface SendRequest { + // who is the message from? The message will be suffixed with "Sent from " + from?: string; + // the main body of the message to send + message?: string; + // the destination phone number including the international dialling code (e.g. +44) + to?: string; +} + +export interface SendResponse { + // any additional info + info?: string; + // will return "ok" if successful + status?: string; +} diff --git a/clients/ts/stock/index.ts b/clients/ts/stock/index.ts new file mode 100755 index 0000000..d896389 --- /dev/null +++ b/clients/ts/stock/index.ts @@ -0,0 +1,132 @@ +import * as m3o from "@m3o/m3o-node"; + +export class StockService { + private client: m3o.Client; + + constructor(token: string) { + this.client = new m3o.Client({ token: token }); + } + // Get the historic open-close for a given day + history(request: HistoryRequest): Promise { + return this.client.call( + "stock", + "History", + request + ) as Promise; + } + // Get the historic order book and each trade by timestamp + orderBook(request: OrderBookRequest): Promise { + return this.client.call( + "stock", + "OrderBook", + request + ) as Promise; + } + // Get the last price for a given stock ticker + price(request: PriceRequest): Promise { + return this.client.call( + "stock", + "Price", + request + ) as Promise; + } + // Get the last quote for the stock + quote(request: QuoteRequest): Promise { + return this.client.call( + "stock", + "Quote", + request + ) as Promise; + } +} + +export interface HistoryRequest { + // date to retrieve as YYYY-MM-DD + date?: string; + // the stock symbol e.g AAPL + stock?: string; +} + +export interface HistoryResponse { + // the close price + close?: number; + // the date + date?: string; + // the peak price + high?: number; + // the low price + low?: number; + // the open price + open?: number; + // the stock symbol + symbol?: string; + // the volume + volume?: number; +} + +export interface Order { + // the asking price + askPrice?: number; + // the ask size + askSize?: number; + // the bidding price + bidPrice?: number; + // the bid size + bidSize?: number; + // the UTC timestamp of the quote + timestamp?: string; +} + +export interface OrderBookRequest { + // the date in format YYYY-MM-dd + date?: string; + // optional RFC3339Nano end time e.g 2006-01-02T15:04:05.999999999Z07:00 + end?: string; + // limit number of prices + limit?: number; + // optional RFC3339Nano start time e.g 2006-01-02T15:04:05.999999999Z07:00 + start?: string; + // stock to retrieve e.g AAPL + stock?: string; +} + +export interface OrderBookResponse { + // date of the request + date?: string; + // list of orders + orders?: Order[]; + // the stock symbol + symbol?: string; +} + +export interface PriceRequest { + // stock symbol e.g AAPL + symbol?: string; +} + +export interface PriceResponse { + // the last price + price?: number; + // the stock symbol e.g AAPL + symbol?: string; +} + +export interface QuoteRequest { + // the stock symbol e.g AAPL + symbol?: string; +} + +export interface QuoteResponse { + // the asking price + askPrice?: number; + // the ask size + askSize?: number; + // the bidding price + bidPrice?: number; + // the bid size + bidSize?: number; + // the stock symbol + symbol?: string; + // the UTC timestamp of the quote + timestamp?: string; +} diff --git a/clients/ts/stream/index.ts b/clients/ts/stream/index.ts new file mode 100755 index 0000000..cb619db --- /dev/null +++ b/clients/ts/stream/index.ts @@ -0,0 +1,46 @@ +import * as m3o from "@m3o/m3o-node"; + +export class StreamService { + private client: m3o.Client; + + constructor(token: string) { + this.client = new m3o.Client({ token: token }); + } + // Publish a message to the stream. Specify a topic to group messages for a specific topic. + publish(request: PublishRequest): Promise { + return this.client.call( + "stream", + "Publish", + request + ) as Promise; + } + // Subscribe to messages for a given topic. + subscribe(request: SubscribeRequest): Promise { + return this.client.call( + "stream", + "Subscribe", + request + ) as Promise; + } +} + +export interface PublishRequest { + // The json message to publish + message?: { [key: string]: any }; + // The topic to publish to + topic?: string; +} + +export interface PublishResponse {} + +export interface SubscribeRequest { + // The topic to subscribe to + topic?: string; +} + +export interface SubscribeResponse { + // The next json message on the topic + message?: { [key: string]: any }; + // The topic subscribed to + topic?: string; +} diff --git a/clients/ts/thumbnail/index.ts b/clients/ts/thumbnail/index.ts new file mode 100755 index 0000000..bc634c3 --- /dev/null +++ b/clients/ts/thumbnail/index.ts @@ -0,0 +1,29 @@ +import * as m3o from "@m3o/m3o-node"; + +export class ThumbnailService { + private client: m3o.Client; + + constructor(token: string) { + this.client = new m3o.Client({ token: token }); + } + // Create a thumbnail screenshot by passing in a url, height and width + screenshot(request: ScreenshotRequest): Promise { + return this.client.call( + "thumbnail", + "Screenshot", + request + ) as Promise; + } +} + +export interface ScreenshotRequest { + // height of the browser window, optional + height?: number; + url?: string; + // width of the browser window. optional + width?: number; +} + +export interface ScreenshotResponse { + imageURL?: string; +} diff --git a/clients/ts/time/index.ts b/clients/ts/time/index.ts new file mode 100755 index 0000000..a07678a --- /dev/null +++ b/clients/ts/time/index.ts @@ -0,0 +1,61 @@ +import * as m3o from "@m3o/m3o-node"; + +export class TimeService { + private client: m3o.Client; + + constructor(token: string) { + this.client = new m3o.Client({ token: token }); + } + // Get the current time + now(request: NowRequest): Promise { + return this.client.call("time", "Now", request) as Promise; + } + // Get the timezone info for a specific location + zone(request: ZoneRequest): Promise { + return this.client.call("time", "Zone", request) as Promise; + } +} + +export interface NowRequest { + // optional location, otherwise returns UTC + location?: string; +} + +export interface NowResponse { + // the current time as HH:MM:SS + localtime?: string; + // the location as Europe/London + location?: string; + // timestamp as 2006-01-02T15:04:05.999999999Z07:00 + timestamp?: string; + // the timezone as BST + timezone?: string; + // the unix timestamp + unix?: number; +} + +export interface ZoneRequest { + // location to lookup e.g postcode, city, ip address + location?: string; +} + +export interface ZoneResponse { + // the abbreviated code e.g BST + abbreviation?: string; + // country of the timezone + country?: string; + // is daylight savings + dst?: boolean; + // e.g 51.42 + latitude?: number; + // the local time + localtime?: string; + // location requested + location?: string; + // e.g -0.37 + longitude?: number; + // region of timezone + region?: string; + // the timezone e.g Europe/London + timezone?: string; +} diff --git a/clients/ts/tsconfig.json b/clients/ts/tsconfig.json new file mode 100644 index 0000000..d64b6c4 --- /dev/null +++ b/clients/ts/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "module": "es6", + "target": "es5", + "declaration": true, + "lib": ["es2015", "dom"], + "experimentalDecorators": true, + "emitDecoratorMetadata": true, + "outDir": "./dist", + "strict": true, + "moduleResolution": "node", + "esModuleInterop": true + }, + "include": ["index.ts", "./*"], + "exclude": ["src/**/*.spec.*", "./dist", "./node_modules"] +} \ No newline at end of file diff --git a/clients/ts/url/index.ts b/clients/ts/url/index.ts new file mode 100755 index 0000000..b71edfb --- /dev/null +++ b/clients/ts/url/index.ts @@ -0,0 +1,63 @@ +import * as m3o from "@m3o/m3o-node"; + +export class UrlService { + private client: m3o.Client; + + constructor(token: string) { + this.client = new m3o.Client({ token: token }); + } + // List information on all the shortened URLs that you have created + list(request: ListRequest): Promise { + return this.client.call("url", "List", request) as Promise; + } + // Proxy returns the destination URL of a short URL. + proxy(request: ProxyRequest): Promise { + return this.client.call("url", "Proxy", request) as Promise; + } + // Shortens a destination URL and returns a full short URL. + shorten(request: ShortenRequest): Promise { + return this.client.call( + "url", + "Shorten", + request + ) as Promise; + } +} + +export interface ListRequest { + // filter by short URL, optional + shortURL?: string; +} + +export interface ListResponse { + urlPairs?: URLPair; +} + +export interface ProxyRequest { + // short url ID, without the domain, eg. if your short URL is + // `m3o.one/u/someshorturlid` then pass in `someshorturlid` + shortURL?: string; +} + +export interface ProxyResponse { + destinationURL?: string; +} + +export interface ShortenRequest { + destinationURL?: string; +} + +export interface ShortenResponse { + shortURL?: string; +} + +export interface URLPair { + created?: number; + destinationURL?: string; + // 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?: number; + owner?: string; + shortURL?: string; +} diff --git a/clients/ts/user/index.ts b/clients/ts/user/index.ts new file mode 100755 index 0000000..28eab98 --- /dev/null +++ b/clients/ts/user/index.ts @@ -0,0 +1,233 @@ +import * as m3o from "@m3o/m3o-node"; + +export class UserService { + private client: m3o.Client; + + constructor(token: string) { + this.client = new m3o.Client({ token: token }); + } + // Create a new user account. The email address and username for the account must be unique. + create(request: CreateRequest): Promise { + return this.client.call( + "user", + "Create", + request + ) as Promise; + } + // Delete an account by id + delete(request: DeleteRequest): Promise { + return this.client.call( + "user", + "Delete", + request + ) as Promise; + } + // 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 + login(request: LoginRequest): Promise { + return this.client.call("user", "Login", request) as Promise; + } + // Logout a user account + logout(request: LogoutRequest): Promise { + return this.client.call( + "user", + "Logout", + request + ) as Promise; + } + // Read an account by id, username or email. Only one need to be specified. + read(request: ReadRequest): Promise { + return this.client.call("user", "Read", request) as Promise; + } + // Read a session by the session id. In the event it has expired or is not found and error is returned. + readSession(request: ReadSessionRequest): Promise { + return this.client.call( + "user", + "ReadSession", + request + ) as Promise; + } + // 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' + sendVerificationEmail( + request: SendVerificationEmailRequest + ): Promise { + return this.client.call( + "user", + "SendVerificationEmail", + request + ) as Promise; + } + // Update the account password + updatePassword( + request: UpdatePasswordRequest + ): Promise { + return this.client.call( + "user", + "UpdatePassword", + request + ) as Promise; + } + // Update the account username or email + update(request: UpdateRequest): Promise { + return this.client.call( + "user", + "Update", + request + ) as Promise; + } + // Verify the email address of an account from a token sent in an email to the user. + verifyEmail(request: VerifyEmailRequest): Promise { + return this.client.call( + "user", + "VerifyEmail", + request + ) as Promise; + } +} + +export interface Account { + // unix timestamp + created?: number; + // an email address + email?: string; + // unique account id + id?: string; + // Store any custom data you want about your users in this fields. + profile?: { [key: string]: string }; + // unix timestamp + updated?: number; + // alphanumeric username + username?: string; + verificationDate?: number; + verified?: boolean; +} + +export interface CreateRequest { + // the email address + email?: string; + // optional account id + id?: string; + // the user password + password?: string; + // optional user profile as map + profile?: { [key: string]: string }; + // the username + username?: string; +} + +export interface CreateResponse { + account?: { [key: string]: any }; +} + +export interface DeleteRequest { + // the account id + id?: string; +} + +export interface DeleteResponse {} + +export interface LoginRequest { + // The email address of the user + email?: string; + // The password of the user + password?: string; + // The username of the user + username?: string; +} + +export interface LoginResponse { + // The session of the logged in user + session?: { [key: string]: any }; +} + +export interface LogoutRequest { + sessionId?: string; +} + +export interface LogoutResponse {} + +export interface ReadRequest { + // the account email + email?: string; + // the account id + id?: string; + // the account username + username?: string; +} + +export interface ReadResponse { + account?: { [key: string]: any }; +} + +export interface ReadSessionRequest { + // The unique session id + sessionId?: string; +} + +export interface ReadSessionResponse { + session?: { [key: string]: any }; +} + +export interface SendVerificationEmailRequest { + email?: string; + failureRedirectUrl?: string; + // Display name of the sender for the email. Note: the email address will still be 'support@m3o.com' + fromName?: string; + redirectUrl?: string; + subject?: string; + // 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; +} + +export interface SendVerificationEmailResponse {} + +export interface Session { + // unix timestamp + created?: number; + // unix timestamp + expires?: number; + // the session id + id?: string; + // the associated user id + userId?: string; +} + +export interface UpdatePasswordRequest { + // confirm new password + confirmPassword?: string; + // the new password + newPassword?: string; + // the old password + oldPassword?: string; + // the account id + userId?: string; +} + +export interface UpdatePasswordResponse {} + +export interface UpdateRequest { + // the new email address + email?: string; + // the account id + id?: string; + // the user profile as map + profile?: { [key: string]: string }; + // the new username + username?: string; +} + +export interface UpdateResponse {} + +export interface VerifyEmailRequest { + // The token from the verification email + token?: string; +} + +export interface VerifyEmailResponse {} diff --git a/clients/ts/weather/index.ts b/clients/ts/weather/index.ts new file mode 100755 index 0000000..65dc60e --- /dev/null +++ b/clients/ts/weather/index.ts @@ -0,0 +1,124 @@ +import * as m3o from "@m3o/m3o-node"; + +export class WeatherService { + private client: m3o.Client; + + constructor(token: string) { + this.client = new m3o.Client({ token: token }); + } + // Get the weather forecast for the next 1-10 days + forecast(request: ForecastRequest): Promise { + return this.client.call( + "weather", + "Forecast", + request + ) as Promise; + } + // Get the current weather report for a location by postcode, city, zip code, ip address + now(request: NowRequest): Promise { + return this.client.call("weather", "Now", request) as Promise; + } +} + +export interface Forecast { + // the average temp in celsius + avgTempC?: number; + // the average temp in fahrenheit + avgTempF?: number; + // chance of rain (percentage) + chanceOfRain?: number; + // forecast condition + condition?: string; + // date of the forecast + date?: string; + // the URL of forecast condition icon. Simply prefix with either http or https to use it + iconUrl?: string; + // max temp in celsius + maxTempC?: number; + // max temp in fahrenheit + maxTempF?: number; + // minimum temp in celsius + minTempC?: number; + // minimum temp in fahrenheit + minTempF?: number; + // time of sunrise + sunrise?: string; + // time of sunset + sunset?: string; + // will it rain + willItRain?: boolean; +} + +export interface ForecastRequest { + // number of days. default 1, max 10 + days?: number; + // location of the forecase + location?: string; +} + +export interface ForecastResponse { + // country of the request + country?: string; + // forecast for the next number of days + forecast?: { [key: string]: any }[]; + // e.g 37.55 + latitude?: number; + // the local time + localTime?: string; + // location of the request + location?: string; + // e.g -77.46 + longitude?: number; + // region related to the location + region?: string; + // timezone of the location + timezone?: string; +} + +export interface NowRequest { + // location to get weather e.g postcode, city + location?: string; +} + +export interface NowResponse { + // cloud cover percentage + cloud?: number; + // the weather condition + condition?: string; + // country of the request + country?: string; + // whether its daytime + daytime?: boolean; + // feels like in celsius + feelsLikeC?: number; + // feels like in fahrenheit + feelsLikeF?: number; + // the humidity percentage + humidity?: number; + // the URL of the related icon. Simply prefix with either http or https to use it + iconUrl?: string; + // e.g 37.55 + latitude?: number; + // the local time + localTime?: string; + // location of the request + location?: string; + // e.g -77.46 + longitude?: number; + // region related to the location + region?: string; + // temperature in celsius + tempC?: number; + // temperature in fahrenheit + tempF?: number; + // timezone of the location + timezone?: string; + // wind degree + windDegree?: number; + // wind direction + windDirection?: string; + // wind in kph + windKph?: number; + // wind in mph + windMph?: number; +} diff --git a/cmd/clients/go_template.go b/cmd/clients/go_template.go index a6f55cf..f3551cb 100644 --- a/cmd/clients/go_template.go +++ b/cmd/clients/go_template.go @@ -1,9 +1,9 @@ package main -const goIndexTemplate = `package micro +const goIndexTemplate = `package m3o import( - {{ range $service := .services }}"github.com/micro/micro-go/{{ $service.Name}}" + {{ range $service := .services }}"github.com/micro/services/clients/go/{{ $service.Name}}" {{ end }} ) @@ -59,7 +59,7 @@ const goExampleTemplate = `{{ $service := .service }}package example import( "fmt" "os" - "github.com/micro/micro-go/{{ $service.Name }}" + "github.com/micro/services/clients/go/{{ $service.Name}}" ) {{ if endpointComment .endpoint $service.Spec.Components.Schemas }}{{ endpointComment .endpoint $service.Spec.Components.Schemas }}{{ end }}func {{ .funcName }}() { diff --git a/cmd/clients/main.go b/cmd/clients/main.go index 8f36c15..042f7f9 100644 --- a/cmd/clients/main.go +++ b/cmd/clients/main.go @@ -52,6 +52,13 @@ func main() { fmt.Println(err) os.Exit(1) } + examplesPath := filepath.Join(workDir, "examples") + err = os.MkdirAll(goPath, 0777) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + funcs := map[string]interface{}{ "recursiveTypeDefinition": func(language, serviceName, typeName string, schemas map[string]*openapi3.SchemaRef) string { return schemaToType(language, serviceName, typeName, schemas) @@ -103,6 +110,9 @@ func main() { services := []service{} tsExportsMap := map[string]string{} for _, f := range files { + if strings.Contains(f.Name(), "clients") || strings.Contains(f.Name(), "examples") { + continue + } if f.IsDir() && !strings.HasPrefix(f.Name(), ".") { serviceName := f.Name() // see https://stackoverflow.com/questions/44345257/import-from-subfolder-of-npm-package @@ -277,12 +287,12 @@ func main() { } // create go examples directory - err = os.MkdirAll(filepath.Join(goPath, serviceName, "examples", endpoint), 0777) + err = os.MkdirAll(filepath.Join(examplesPath, serviceName, endpoint, "go"), 0777) if err != nil { fmt.Println(err) os.Exit(1) } - goExampleFile := filepath.Join(goPath, serviceName, "examples", endpoint, title+".go") + goExampleFile := filepath.Join(examplesPath, serviceName, endpoint, "go", title+".go") f, err = os.OpenFile(goExampleFile, os.O_TRUNC|os.O_WRONLY|os.O_CREATE, 0744) if err != nil { fmt.Println("Failed to open schema file", err) @@ -297,7 +307,7 @@ func main() { } cmd := exec.Command("gofmt", "-w", title+".go") - cmd.Dir = filepath.Join(goPath, serviceName, "examples", endpoint) + cmd.Dir = filepath.Join(examplesPath, serviceName, endpoint, "go") outp, err = cmd.CombinedOutput() if err != nil { fmt.Println(fmt.Sprintf("Problem with '%v' example '%v': %v", serviceName, endpoint, string(outp))) @@ -319,12 +329,12 @@ func main() { "funcName": strcase.UpperCamelCase(title), }) - err = os.MkdirAll(filepath.Join(tsPath, serviceName, "examples", endpoint), 0777) + err = os.MkdirAll(filepath.Join(examplesPath, serviceName, endpoint, "node"), 0777) if err != nil { fmt.Println(err) os.Exit(1) } - tsExampleFile := filepath.Join(tsPath, serviceName, "examples", endpoint, title+".js") + tsExampleFile := filepath.Join(examplesPath, serviceName, endpoint, "node", title+".js") f, err = os.OpenFile(tsExampleFile, os.O_TRUNC|os.O_WRONLY|os.O_CREATE, 0744) if err != nil { fmt.Println("Failed to open schema file", err) @@ -339,7 +349,7 @@ func main() { } cmd = exec.Command("prettier", "-w", title+".js") - cmd.Dir = filepath.Join(tsPath, serviceName, "examples", endpoint) + cmd.Dir = filepath.Join(examplesPath, serviceName, endpoint, "node") outp, err = cmd.CombinedOutput() if err != nil { fmt.Println(fmt.Sprintf("Problem with '%v' example '%v': %v", serviceName, endpoint, string(outp))) @@ -361,7 +371,13 @@ func main() { "funcName": strcase.UpperCamelCase(title), }) - curlExampleFile := filepath.Join(goPath, serviceName, "examples", endpoint, title+".sh") + err = os.MkdirAll(filepath.Join(examplesPath, serviceName, endpoint, "curl"), 0777) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + curlExampleFile := filepath.Join(examplesPath, serviceName, endpoint, "curl", title+".sh") f, err = os.OpenFile(curlExampleFile, os.O_TRUNC|os.O_WRONLY|os.O_CREATE, 0744) if err != nil { fmt.Println("Failed to open schema file", err) @@ -378,7 +394,7 @@ func main() { // only build after each example is generated as old files from // previous generation might not compile cmd = exec.Command("go", "build", "-o", "/tmp/bin/outputfile") - cmd.Dir = filepath.Join(goPath, serviceName, "examples", endpoint) + cmd.Dir = filepath.Join(examplesPath, serviceName, endpoint, "go") outp, err = cmd.CombinedOutput() if err != nil { fmt.Println(fmt.Sprintf("Problem with '%v' example '%v': %v", serviceName, endpoint, string(outp))) @@ -425,7 +441,7 @@ func main() { os.Exit(1) } tsFiles := filepath.Join(workDir, "cmd", "clients", "ts") - cmd = exec.Command("cp", filepath.Join(tsFiles, "package.json"), filepath.Join(tsFiles, ".npmrc"), filepath.Join(tsFiles, ".gitignore"), filepath.Join(tsFiles, "package-lock.json"), filepath.Join(tsFiles, "tsconfig.json"), filepath.Join(workDir, "clients", "ts")) + cmd = exec.Command("cp", filepath.Join(tsFiles, "package.json"), filepath.Join(tsFiles, ".gitignore"), filepath.Join(tsFiles, "package-lock.json"), filepath.Join(tsFiles, "tsconfig.json"), filepath.Join(workDir, "clients", "ts")) cmd.Dir = filepath.Join(tsPath) outp, err = cmd.CombinedOutput() if err != nil { @@ -474,7 +490,7 @@ func main() { } // login to NPM - f, err = os.OpenFile(filepath.Join(tsPath, ".npmrc"), os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0600) + f, err = os.OpenFile(filepath.Join(tsPath, ".npmrc"), os.O_TRUNC|os.O_WRONLY|os.O_CREATE, 0600) if err != nil { fmt.Println("Failed to open npmrc", err) os.Exit(1) @@ -485,13 +501,13 @@ func main() { fmt.Println("No NPM_TOKEN env found") os.Exit(1) } - if _, err = f.WriteString("\n//npm.pkg.github.com/:_authToken=" + os.Getenv("NPM_TOKEN")); err != nil { + if _, err = f.WriteString("//registry.npmjs.org/:_authToken=" + os.Getenv("NPM_TOKEN")); err != nil { fmt.Println("Failed to open npmrc", err) os.Exit(1) } // get latest version from github - getVersions := exec.Command("npm", "show", "@micro/services", "--time", "--json") + getVersions := exec.Command("npm", "show", "m3o", "--time", "--json") getVersions.Dir = tsPath outp, err = getVersions.CombinedOutput() @@ -553,7 +569,7 @@ func main() { os.Exit(1) } m["exports"] = tsExportsMap - pakJS, err := json.Marshal(m) + pakJS, err := json.MarshalIndent(m, "", " ") if err != nil { fmt.Println(err) os.Exit(1) diff --git a/cmd/clients/ts/.npmrc b/cmd/clients/ts/.npmrc deleted file mode 100644 index 48c7fa5..0000000 --- a/cmd/clients/ts/.npmrc +++ /dev/null @@ -1 +0,0 @@ -registry=https://npm.pkg.github.com/micro diff --git a/cmd/clients/ts/package.json b/cmd/clients/ts/package.json index b65bfc6..18a04e2 100644 --- a/cmd/clients/ts/package.json +++ b/cmd/clients/ts/package.json @@ -1,5 +1,5 @@ { - "name": "@micro/services", + "name": "m3o", "version": "1.0.1", "description": "", "main": "dist/index.js", diff --git a/cmd/clients/ts_template.go b/cmd/clients/ts_template.go index 763f572..55c5036 100644 --- a/cmd/clients/ts_template.go +++ b/cmd/clients/ts_template.go @@ -35,7 +35,7 @@ export interface {{ title $typeName }}{{ "{" }} {{end}} ` -const tsExampleTemplate = `{{ $service := .service }}import * as {{ $service.Name }} from '@m3o/services/{{ $service.Name }}'; +const tsExampleTemplate = `{{ $service := .service }}import * as {{ $service.Name }} from 'm3o/{{ $service.Name }}'; {{ if endpointComment .endpoint $service.Spec.Components.Schemas }}{{ endpointComment .endpoint $service.Spec.Components.Schemas }}{{ end }}async function {{ .funcName }}() { let {{ $service.Name }}Service = new {{ $service.Name }}.{{ title $service.Name }}Service(process.env.MICRO_API_TOKEN) diff --git a/cmd/publisher/main.go b/cmd/publisher/main.go index 19950fc..36d7588 100644 --- a/cmd/publisher/main.go +++ b/cmd/publisher/main.go @@ -68,6 +68,9 @@ func main() { workDir, _ := os.Getwd() for _, f := range files { + if strings.Contains(f.Name(), "clients") || strings.Contains(f.Name(), "examples") { + continue + } if f.IsDir() && !strings.HasPrefix(f.Name(), ".") { serviceDir := filepath.Join(workDir, f.Name()) serviceFiles, err := ioutil.ReadDir(serviceDir) diff --git a/examples/address/lookupPostcode/curl/lookupPostcode.sh b/examples/address/lookupPostcode/curl/lookupPostcode.sh new file mode 100755 index 0000000..1a0a7fd --- /dev/null +++ b/examples/address/lookupPostcode/curl/lookupPostcode.sh @@ -0,0 +1,6 @@ +curl "https://api.m3o.com/v1/address/LookupPostcode" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "postcode": "SW1A 2AA" +}' \ No newline at end of file diff --git a/examples/address/lookupPostcode/go/lookupPostcode.go b/examples/address/lookupPostcode/go/lookupPostcode.go new file mode 100755 index 0000000..81f87d4 --- /dev/null +++ b/examples/address/lookupPostcode/go/lookupPostcode.go @@ -0,0 +1,16 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/address" + "os" +) + +// Lookup a list of UK addresses by postcode +func LookupPostcode() { + addressService := address.NewAddressService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := addressService.LookupPostcode(&address.LookupPostcodeRequest{ + Postcode: "SW1A 2AA", + }) + fmt.Println(rsp, err) +} diff --git a/examples/address/lookupPostcode/node/lookupPostcode.js b/examples/address/lookupPostcode/node/lookupPostcode.js new file mode 100755 index 0000000..ba14fcd --- /dev/null +++ b/examples/address/lookupPostcode/node/lookupPostcode.js @@ -0,0 +1,12 @@ +import * as address from "m3o/address"; + +// Lookup a list of UK addresses by postcode +async function LookupPostcode() { + let addressService = new address.AddressService(process.env.MICRO_API_TOKEN); + let rsp = await addressService.lookupPostcode({ + postcode: "SW1A 2AA", + }); + console.log(rsp); +} + +await LookupPostcode(); diff --git a/examples/answer/question/curl/askAQuestion.sh b/examples/answer/question/curl/askAQuestion.sh new file mode 100755 index 0000000..6613a65 --- /dev/null +++ b/examples/answer/question/curl/askAQuestion.sh @@ -0,0 +1,6 @@ +curl "https://api.m3o.com/v1/answer/Question" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "query": "google" +}' \ No newline at end of file diff --git a/examples/answer/question/go/askAQuestion.go b/examples/answer/question/go/askAQuestion.go new file mode 100755 index 0000000..eae2f63 --- /dev/null +++ b/examples/answer/question/go/askAQuestion.go @@ -0,0 +1,16 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/answer" + "os" +) + +// Ask a question and receive an instant answer +func AskAquestion() { + answerService := answer.NewAnswerService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := answerService.Question(&answer.QuestionRequest{ + Query: "google", + }) + fmt.Println(rsp, err) +} diff --git a/examples/answer/question/node/askAQuestion.js b/examples/answer/question/node/askAQuestion.js new file mode 100755 index 0000000..cdab5c3 --- /dev/null +++ b/examples/answer/question/node/askAQuestion.js @@ -0,0 +1,12 @@ +import * as answer from "m3o/answer"; + +// Ask a question and receive an instant answer +async function AskAquestion() { + let answerService = new answer.AnswerService(process.env.MICRO_API_TOKEN); + let rsp = await answerService.question({ + query: "google", + }); + console.log(rsp); +} + +await AskAquestion(); diff --git a/examples/cache/decrement/curl/decrementAValue.sh b/examples/cache/decrement/curl/decrementAValue.sh new file mode 100755 index 0000000..3ed6f0d --- /dev/null +++ b/examples/cache/decrement/curl/decrementAValue.sh @@ -0,0 +1,7 @@ +curl "https://api.m3o.com/v1/cache/Decrement" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "key": "counter", + "value": 2 +}' \ No newline at end of file diff --git a/examples/cache/decrement/go/decrementAValue.go b/examples/cache/decrement/go/decrementAValue.go new file mode 100755 index 0000000..c9e5099 --- /dev/null +++ b/examples/cache/decrement/go/decrementAValue.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/cache" + "os" +) + +// Decrement a value (if it's a number) +func DecrementAvalue() { + cacheService := cache.NewCacheService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := cacheService.Decrement(&cache.DecrementRequest{ + Key: "counter", + Value: 2, + }) + fmt.Println(rsp, err) +} diff --git a/examples/cache/decrement/node/decrementAValue.js b/examples/cache/decrement/node/decrementAValue.js new file mode 100755 index 0000000..61aa25f --- /dev/null +++ b/examples/cache/decrement/node/decrementAValue.js @@ -0,0 +1,13 @@ +import * as cache from "m3o/cache"; + +// Decrement a value (if it's a number) +async function DecrementAvalue() { + let cacheService = new cache.CacheService(process.env.MICRO_API_TOKEN); + let rsp = await cacheService.decrement({ + key: "counter", + value: 2, + }); + console.log(rsp); +} + +await DecrementAvalue(); diff --git a/examples/cache/delete/curl/deleteAValue.sh b/examples/cache/delete/curl/deleteAValue.sh new file mode 100755 index 0000000..431cac5 --- /dev/null +++ b/examples/cache/delete/curl/deleteAValue.sh @@ -0,0 +1,6 @@ +curl "https://api.m3o.com/v1/cache/Delete" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "key": "foo" +}' \ No newline at end of file diff --git a/examples/cache/delete/go/deleteAValue.go b/examples/cache/delete/go/deleteAValue.go new file mode 100755 index 0000000..9abd8f4 --- /dev/null +++ b/examples/cache/delete/go/deleteAValue.go @@ -0,0 +1,16 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/cache" + "os" +) + +// Delete a value from the cache +func DeleteAvalue() { + cacheService := cache.NewCacheService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := cacheService.Delete(&cache.DeleteRequest{ + Key: "foo", + }) + fmt.Println(rsp, err) +} diff --git a/examples/cache/delete/node/deleteAValue.js b/examples/cache/delete/node/deleteAValue.js new file mode 100755 index 0000000..2711e7e --- /dev/null +++ b/examples/cache/delete/node/deleteAValue.js @@ -0,0 +1,12 @@ +import * as cache from "m3o/cache"; + +// Delete a value from the cache +async function DeleteAvalue() { + let cacheService = new cache.CacheService(process.env.MICRO_API_TOKEN); + let rsp = await cacheService.delete({ + key: "foo", + }); + console.log(rsp); +} + +await DeleteAvalue(); diff --git a/examples/cache/get/curl/getAValue.sh b/examples/cache/get/curl/getAValue.sh new file mode 100755 index 0000000..3821929 --- /dev/null +++ b/examples/cache/get/curl/getAValue.sh @@ -0,0 +1,6 @@ +curl "https://api.m3o.com/v1/cache/Get" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "key": "foo" +}' \ No newline at end of file diff --git a/examples/cache/get/go/getAValue.go b/examples/cache/get/go/getAValue.go new file mode 100755 index 0000000..86d2120 --- /dev/null +++ b/examples/cache/get/go/getAValue.go @@ -0,0 +1,16 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/cache" + "os" +) + +// Get an item from the cache by key +func GetAvalue() { + cacheService := cache.NewCacheService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := cacheService.Get(&cache.GetRequest{ + Key: "foo", + }) + fmt.Println(rsp, err) +} diff --git a/examples/cache/get/node/getAValue.js b/examples/cache/get/node/getAValue.js new file mode 100755 index 0000000..dc579a2 --- /dev/null +++ b/examples/cache/get/node/getAValue.js @@ -0,0 +1,12 @@ +import * as cache from "m3o/cache"; + +// Get an item from the cache by key +async function GetAvalue() { + let cacheService = new cache.CacheService(process.env.MICRO_API_TOKEN); + let rsp = await cacheService.get({ + key: "foo", + }); + console.log(rsp); +} + +await GetAvalue(); diff --git a/examples/cache/increment/curl/incrementAValue.sh b/examples/cache/increment/curl/incrementAValue.sh new file mode 100755 index 0000000..2da7099 --- /dev/null +++ b/examples/cache/increment/curl/incrementAValue.sh @@ -0,0 +1,7 @@ +curl "https://api.m3o.com/v1/cache/Increment" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "key": "counter", + "value": 2 +}' \ No newline at end of file diff --git a/examples/cache/increment/go/incrementAValue.go b/examples/cache/increment/go/incrementAValue.go new file mode 100755 index 0000000..ec6c2cf --- /dev/null +++ b/examples/cache/increment/go/incrementAValue.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/cache" + "os" +) + +// Increment a value (if it's a number) +func IncrementAvalue() { + cacheService := cache.NewCacheService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := cacheService.Increment(&cache.IncrementRequest{ + Key: "counter", + Value: 2, + }) + fmt.Println(rsp, err) +} diff --git a/examples/cache/increment/node/incrementAValue.js b/examples/cache/increment/node/incrementAValue.js new file mode 100755 index 0000000..f944757 --- /dev/null +++ b/examples/cache/increment/node/incrementAValue.js @@ -0,0 +1,13 @@ +import * as cache from "m3o/cache"; + +// Increment a value (if it's a number) +async function IncrementAvalue() { + let cacheService = new cache.CacheService(process.env.MICRO_API_TOKEN); + let rsp = await cacheService.increment({ + key: "counter", + value: 2, + }); + console.log(rsp); +} + +await IncrementAvalue(); diff --git a/examples/cache/set/curl/setAValue.sh b/examples/cache/set/curl/setAValue.sh new file mode 100755 index 0000000..eb569cb --- /dev/null +++ b/examples/cache/set/curl/setAValue.sh @@ -0,0 +1,7 @@ +curl "https://api.m3o.com/v1/cache/Set" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "key": "foo", + "value": "bar" +}' \ No newline at end of file diff --git a/examples/cache/set/go/setAValue.go b/examples/cache/set/go/setAValue.go new file mode 100755 index 0000000..5f0a09e --- /dev/null +++ b/examples/cache/set/go/setAValue.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/cache" + "os" +) + +// Set an item in the cache. Overwrites any existing value already set. +func SetAvalue() { + cacheService := cache.NewCacheService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := cacheService.Set(&cache.SetRequest{ + Key: "foo", + Value: "bar", + }) + fmt.Println(rsp, err) +} diff --git a/examples/cache/set/node/setAValue.js b/examples/cache/set/node/setAValue.js new file mode 100755 index 0000000..007f6c2 --- /dev/null +++ b/examples/cache/set/node/setAValue.js @@ -0,0 +1,13 @@ +import * as cache from "m3o/cache"; + +// Set an item in the cache. Overwrites any existing value already set. +async function SetAvalue() { + let cacheService = new cache.CacheService(process.env.MICRO_API_TOKEN); + let rsp = await cacheService.set({ + key: "foo", + value: "bar", + }); + console.log(rsp); +} + +await SetAvalue(); diff --git a/examples/crypto/history/curl/getPreviousClose.sh b/examples/crypto/history/curl/getPreviousClose.sh new file mode 100755 index 0000000..c83ac76 --- /dev/null +++ b/examples/crypto/history/curl/getPreviousClose.sh @@ -0,0 +1,6 @@ +curl "https://api.m3o.com/v1/crypto/History" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "symbol": "BTCUSD" +}' \ No newline at end of file diff --git a/examples/crypto/history/go/getPreviousClose.go b/examples/crypto/history/go/getPreviousClose.go new file mode 100755 index 0000000..c627158 --- /dev/null +++ b/examples/crypto/history/go/getPreviousClose.go @@ -0,0 +1,16 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/crypto" + "os" +) + +// Returns the history for the previous close +func GetPreviousClose() { + cryptoService := crypto.NewCryptoService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := cryptoService.History(&crypto.HistoryRequest{ + Symbol: "BTCUSD", + }) + fmt.Println(rsp, err) +} diff --git a/examples/crypto/history/node/getPreviousClose.js b/examples/crypto/history/node/getPreviousClose.js new file mode 100755 index 0000000..dfe503e --- /dev/null +++ b/examples/crypto/history/node/getPreviousClose.js @@ -0,0 +1,12 @@ +import * as crypto from "m3o/crypto"; + +// Returns the history for the previous close +async function GetPreviousClose() { + let cryptoService = new crypto.CryptoService(process.env.MICRO_API_TOKEN); + let rsp = await cryptoService.history({ + symbol: "BTCUSD", + }); + console.log(rsp); +} + +await GetPreviousClose(); diff --git a/examples/crypto/price/curl/getCryptocurrencyPrice.sh b/examples/crypto/price/curl/getCryptocurrencyPrice.sh new file mode 100755 index 0000000..d0024d3 --- /dev/null +++ b/examples/crypto/price/curl/getCryptocurrencyPrice.sh @@ -0,0 +1,6 @@ +curl "https://api.m3o.com/v1/crypto/Price" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "symbol": "BTCUSD" +}' \ No newline at end of file diff --git a/examples/crypto/price/go/getCryptocurrencyPrice.go b/examples/crypto/price/go/getCryptocurrencyPrice.go new file mode 100755 index 0000000..f939f4a --- /dev/null +++ b/examples/crypto/price/go/getCryptocurrencyPrice.go @@ -0,0 +1,16 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/crypto" + "os" +) + +// Get the last price for a given crypto ticker +func GetCryptocurrencyPrice() { + cryptoService := crypto.NewCryptoService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := cryptoService.Price(&crypto.PriceRequest{ + Symbol: "BTCUSD", + }) + fmt.Println(rsp, err) +} diff --git a/examples/crypto/price/node/getCryptocurrencyPrice.js b/examples/crypto/price/node/getCryptocurrencyPrice.js new file mode 100755 index 0000000..8fbf07d --- /dev/null +++ b/examples/crypto/price/node/getCryptocurrencyPrice.js @@ -0,0 +1,12 @@ +import * as crypto from "m3o/crypto"; + +// Get the last price for a given crypto ticker +async function GetCryptocurrencyPrice() { + let cryptoService = new crypto.CryptoService(process.env.MICRO_API_TOKEN); + let rsp = await cryptoService.price({ + symbol: "BTCUSD", + }); + console.log(rsp); +} + +await GetCryptocurrencyPrice(); diff --git a/examples/crypto/quote/curl/getACryptocurrencyQuote.sh b/examples/crypto/quote/curl/getACryptocurrencyQuote.sh new file mode 100755 index 0000000..1deafac --- /dev/null +++ b/examples/crypto/quote/curl/getACryptocurrencyQuote.sh @@ -0,0 +1,6 @@ +curl "https://api.m3o.com/v1/crypto/Quote" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "symbol": "BTCUSD" +}' \ No newline at end of file diff --git a/examples/crypto/quote/go/getACryptocurrencyQuote.go b/examples/crypto/quote/go/getACryptocurrencyQuote.go new file mode 100755 index 0000000..183aff6 --- /dev/null +++ b/examples/crypto/quote/go/getACryptocurrencyQuote.go @@ -0,0 +1,16 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/crypto" + "os" +) + +// Get the last quote for a given crypto ticker +func GetAcryptocurrencyQuote() { + cryptoService := crypto.NewCryptoService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := cryptoService.Quote(&crypto.QuoteRequest{ + Symbol: "BTCUSD", + }) + fmt.Println(rsp, err) +} diff --git a/examples/crypto/quote/node/getACryptocurrencyQuote.js b/examples/crypto/quote/node/getACryptocurrencyQuote.js new file mode 100755 index 0000000..e3e2c4d --- /dev/null +++ b/examples/crypto/quote/node/getACryptocurrencyQuote.js @@ -0,0 +1,12 @@ +import * as crypto from "m3o/crypto"; + +// Get the last quote for a given crypto ticker +async function GetAcryptocurrencyQuote() { + let cryptoService = new crypto.CryptoService(process.env.MICRO_API_TOKEN); + let rsp = await cryptoService.quote({ + symbol: "BTCUSD", + }); + console.log(rsp); +} + +await GetAcryptocurrencyQuote(); diff --git a/examples/currency/codes/curl/getSupportedCodes.sh b/examples/currency/codes/curl/getSupportedCodes.sh new file mode 100755 index 0000000..f8b7ddb --- /dev/null +++ b/examples/currency/codes/curl/getSupportedCodes.sh @@ -0,0 +1,4 @@ +curl "https://api.m3o.com/v1/currency/Codes" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{}' \ No newline at end of file diff --git a/examples/currency/codes/go/getSupportedCodes.go b/examples/currency/codes/go/getSupportedCodes.go new file mode 100755 index 0000000..0b68b04 --- /dev/null +++ b/examples/currency/codes/go/getSupportedCodes.go @@ -0,0 +1,14 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/currency" + "os" +) + +// Codes returns the supported currency codes for the API +func GetSupportedCodes() { + currencyService := currency.NewCurrencyService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := currencyService.Codes(¤cy.CodesRequest{}) + fmt.Println(rsp, err) +} diff --git a/examples/currency/codes/node/getSupportedCodes.js b/examples/currency/codes/node/getSupportedCodes.js new file mode 100755 index 0000000..7e99073 --- /dev/null +++ b/examples/currency/codes/node/getSupportedCodes.js @@ -0,0 +1,12 @@ +import * as currency from "m3o/currency"; + +// Codes returns the supported currency codes for the API +async function GetSupportedCodes() { + let currencyService = new currency.CurrencyService( + process.env.MICRO_API_TOKEN + ); + let rsp = await currencyService.codes({}); + console.log(rsp); +} + +await GetSupportedCodes(); diff --git a/examples/currency/convert/curl/convert10UsdToGbp.sh b/examples/currency/convert/curl/convert10UsdToGbp.sh new file mode 100755 index 0000000..d2ebee2 --- /dev/null +++ b/examples/currency/convert/curl/convert10UsdToGbp.sh @@ -0,0 +1,8 @@ +curl "https://api.m3o.com/v1/currency/Convert" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "amount": 10, + "from": "USD", + "to": "GBP" +}' \ No newline at end of file diff --git a/examples/currency/convert/curl/convertUsdToGbp.sh b/examples/currency/convert/curl/convertUsdToGbp.sh new file mode 100755 index 0000000..dbe41b3 --- /dev/null +++ b/examples/currency/convert/curl/convertUsdToGbp.sh @@ -0,0 +1,7 @@ +curl "https://api.m3o.com/v1/currency/Convert" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "from": "USD", + "to": "GBP" +}' \ No newline at end of file diff --git a/examples/currency/convert/go/convert10UsdToGbp.go b/examples/currency/convert/go/convert10UsdToGbp.go new file mode 100755 index 0000000..35c5eea --- /dev/null +++ b/examples/currency/convert/go/convert10UsdToGbp.go @@ -0,0 +1,18 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/currency" + "os" +) + +// Convert returns the currency conversion rate between two pairs e.g USD/GBP +func Convert10usdToGbp() { + currencyService := currency.NewCurrencyService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := currencyService.Convert(¤cy.ConvertRequest{ + Amount: 10, + From: "USD", + To: "GBP", + }) + fmt.Println(rsp, err) +} diff --git a/examples/currency/convert/go/convertUsdToGbp.go b/examples/currency/convert/go/convertUsdToGbp.go new file mode 100755 index 0000000..c5617ba --- /dev/null +++ b/examples/currency/convert/go/convertUsdToGbp.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/currency" + "os" +) + +// Convert returns the currency conversion rate between two pairs e.g USD/GBP +func ConvertUsdToGbp() { + currencyService := currency.NewCurrencyService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := currencyService.Convert(¤cy.ConvertRequest{ + From: "USD", + To: "GBP", + }) + fmt.Println(rsp, err) +} diff --git a/examples/currency/convert/node/convert10UsdToGbp.js b/examples/currency/convert/node/convert10UsdToGbp.js new file mode 100755 index 0000000..e9b4cd7 --- /dev/null +++ b/examples/currency/convert/node/convert10UsdToGbp.js @@ -0,0 +1,16 @@ +import * as currency from "m3o/currency"; + +// Convert returns the currency conversion rate between two pairs e.g USD/GBP +async function Convert10usdToGbp() { + let currencyService = new currency.CurrencyService( + process.env.MICRO_API_TOKEN + ); + let rsp = await currencyService.convert({ + amount: 10, + from: "USD", + to: "GBP", + }); + console.log(rsp); +} + +await Convert10usdToGbp(); diff --git a/examples/currency/convert/node/convertUsdToGbp.js b/examples/currency/convert/node/convertUsdToGbp.js new file mode 100755 index 0000000..6435a83 --- /dev/null +++ b/examples/currency/convert/node/convertUsdToGbp.js @@ -0,0 +1,15 @@ +import * as currency from "m3o/currency"; + +// Convert returns the currency conversion rate between two pairs e.g USD/GBP +async function ConvertUsdToGbp() { + let currencyService = new currency.CurrencyService( + process.env.MICRO_API_TOKEN + ); + let rsp = await currencyService.convert({ + from: "USD", + to: "GBP", + }); + console.log(rsp); +} + +await ConvertUsdToGbp(); diff --git a/examples/currency/rates/curl/getRatesForUsd.sh b/examples/currency/rates/curl/getRatesForUsd.sh new file mode 100755 index 0000000..6d32bda --- /dev/null +++ b/examples/currency/rates/curl/getRatesForUsd.sh @@ -0,0 +1,6 @@ +curl "https://api.m3o.com/v1/currency/Rates" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "code": "USD" +}' \ No newline at end of file diff --git a/examples/currency/rates/go/getRatesForUsd.go b/examples/currency/rates/go/getRatesForUsd.go new file mode 100755 index 0000000..6692525 --- /dev/null +++ b/examples/currency/rates/go/getRatesForUsd.go @@ -0,0 +1,16 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/currency" + "os" +) + +// Rates returns the currency rates for a given code e.g USD +func GetRatesForUsd() { + currencyService := currency.NewCurrencyService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := currencyService.Rates(¤cy.RatesRequest{ + Code: "USD", + }) + fmt.Println(rsp, err) +} diff --git a/examples/currency/rates/node/getRatesForUsd.js b/examples/currency/rates/node/getRatesForUsd.js new file mode 100755 index 0000000..5b2e8ac --- /dev/null +++ b/examples/currency/rates/node/getRatesForUsd.js @@ -0,0 +1,14 @@ +import * as currency from "m3o/currency"; + +// Rates returns the currency rates for a given code e.g USD +async function GetRatesForUsd() { + let currencyService = new currency.CurrencyService( + process.env.MICRO_API_TOKEN + ); + let rsp = await currencyService.rates({ + code: "USD", + }); + console.log(rsp); +} + +await GetRatesForUsd(); diff --git a/examples/db/create/curl/createARecord.sh b/examples/db/create/curl/createARecord.sh new file mode 100755 index 0000000..d5a7793 --- /dev/null +++ b/examples/db/create/curl/createARecord.sh @@ -0,0 +1,12 @@ +curl "https://api.m3o.com/v1/db/Create" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "record": { + "age": 42, + "id": "1", + "isActive": true, + "name": "Jane" + }, + "table": "users" +}' \ No newline at end of file diff --git a/examples/db/create/go/createARecord.go b/examples/db/create/go/createARecord.go new file mode 100755 index 0000000..c57135b --- /dev/null +++ b/examples/db/create/go/createARecord.go @@ -0,0 +1,22 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/db" + "os" +) + +// Create a record in the database. Optionally include an "id" field otherwise it's set automatically. +func CreateArecord() { + dbService := db.NewDbService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := dbService.Create(&db.CreateRequest{ + Record: map[string]interface{}{ + "age": 42, + "isActive": true, + "id": "1", + "name": "Jane", + }, + Table: "users", + }) + fmt.Println(rsp, err) +} diff --git a/examples/db/create/node/createARecord.js b/examples/db/create/node/createARecord.js new file mode 100755 index 0000000..62b0b1d --- /dev/null +++ b/examples/db/create/node/createARecord.js @@ -0,0 +1,18 @@ +import * as db from "m3o/db"; + +// Create a record in the database. Optionally include an "id" field otherwise it's set automatically. +async function CreateArecord() { + let dbService = new db.DbService(process.env.MICRO_API_TOKEN); + let rsp = await dbService.create({ + record: { + age: 42, + id: "1", + isActive: true, + name: "Jane", + }, + table: "users", + }); + console.log(rsp); +} + +await CreateArecord(); diff --git a/examples/db/delete/curl/deleteARecord.sh b/examples/db/delete/curl/deleteARecord.sh new file mode 100755 index 0000000..04aebb4 --- /dev/null +++ b/examples/db/delete/curl/deleteARecord.sh @@ -0,0 +1,7 @@ +curl "https://api.m3o.com/v1/db/Delete" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "id": "1", + "table": "users" +}' \ No newline at end of file diff --git a/examples/db/delete/go/deleteARecord.go b/examples/db/delete/go/deleteARecord.go new file mode 100755 index 0000000..6dee4d5 --- /dev/null +++ b/examples/db/delete/go/deleteARecord.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/db" + "os" +) + +// Delete a record in the database by id. +func DeleteArecord() { + dbService := db.NewDbService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := dbService.Delete(&db.DeleteRequest{ + Id: "1", + Table: "users", + }) + fmt.Println(rsp, err) +} diff --git a/examples/db/delete/node/deleteARecord.js b/examples/db/delete/node/deleteARecord.js new file mode 100755 index 0000000..3431c43 --- /dev/null +++ b/examples/db/delete/node/deleteARecord.js @@ -0,0 +1,13 @@ +import * as db from "m3o/db"; + +// Delete a record in the database by id. +async function DeleteArecord() { + let dbService = new db.DbService(process.env.MICRO_API_TOKEN); + let rsp = await dbService.delete({ + id: "1", + table: "users", + }); + console.log(rsp); +} + +await DeleteArecord(); diff --git a/examples/db/read/curl/readRecords.sh b/examples/db/read/curl/readRecords.sh new file mode 100755 index 0000000..ba3ec7b --- /dev/null +++ b/examples/db/read/curl/readRecords.sh @@ -0,0 +1,7 @@ +curl "https://api.m3o.com/v1/db/Read" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "query": "age == 43", + "table": "users" +}' \ No newline at end of file diff --git a/examples/db/read/go/readRecords.go b/examples/db/read/go/readRecords.go new file mode 100755 index 0000000..6795248 --- /dev/null +++ b/examples/db/read/go/readRecords.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/db" + "os" +) + +// Read data from a table. Lookup can be by ID or via querying any field in the record. +func ReadRecords() { + dbService := db.NewDbService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := dbService.Read(&db.ReadRequest{ + Query: "age == 43", + Table: "users", + }) + fmt.Println(rsp, err) +} diff --git a/examples/db/read/node/readRecords.js b/examples/db/read/node/readRecords.js new file mode 100755 index 0000000..92e1efe --- /dev/null +++ b/examples/db/read/node/readRecords.js @@ -0,0 +1,13 @@ +import * as db from "m3o/db"; + +// Read data from a table. Lookup can be by ID or via querying any field in the record. +async function ReadRecords() { + let dbService = new db.DbService(process.env.MICRO_API_TOKEN); + let rsp = await dbService.read({ + query: "age == 43", + table: "users", + }); + console.log(rsp); +} + +await ReadRecords(); diff --git a/examples/db/truncate/curl/truncateTable.sh b/examples/db/truncate/curl/truncateTable.sh new file mode 100755 index 0000000..a2edeb1 --- /dev/null +++ b/examples/db/truncate/curl/truncateTable.sh @@ -0,0 +1,6 @@ +curl "https://api.m3o.com/v1/db/Truncate" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "table": "users" +}' \ No newline at end of file diff --git a/examples/db/truncate/go/truncateTable.go b/examples/db/truncate/go/truncateTable.go new file mode 100755 index 0000000..b179286 --- /dev/null +++ b/examples/db/truncate/go/truncateTable.go @@ -0,0 +1,16 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/db" + "os" +) + +// Truncate the records in a table +func TruncateTable() { + dbService := db.NewDbService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := dbService.Truncate(&db.TruncateRequest{ + Table: "users", + }) + fmt.Println(rsp, err) +} diff --git a/examples/db/truncate/node/truncateTable.js b/examples/db/truncate/node/truncateTable.js new file mode 100755 index 0000000..754918e --- /dev/null +++ b/examples/db/truncate/node/truncateTable.js @@ -0,0 +1,12 @@ +import * as db from "m3o/db"; + +// Truncate the records in a table +async function TruncateTable() { + let dbService = new db.DbService(process.env.MICRO_API_TOKEN); + let rsp = await dbService.truncate({ + table: "users", + }); + console.log(rsp); +} + +await TruncateTable(); diff --git a/examples/db/update/curl/updateARecord.sh b/examples/db/update/curl/updateARecord.sh new file mode 100755 index 0000000..a787614 --- /dev/null +++ b/examples/db/update/curl/updateARecord.sh @@ -0,0 +1,10 @@ +curl "https://api.m3o.com/v1/db/Update" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "record": { + "age": 43, + "id": "1" + }, + "table": "users" +}' \ No newline at end of file diff --git a/examples/db/update/go/updateARecord.go b/examples/db/update/go/updateARecord.go new file mode 100755 index 0000000..4c7b7e9 --- /dev/null +++ b/examples/db/update/go/updateARecord.go @@ -0,0 +1,20 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/db" + "os" +) + +// Update a record in the database. Include an "id" in the record to update. +func UpdateArecord() { + dbService := db.NewDbService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := dbService.Update(&db.UpdateRequest{ + Record: map[string]interface{}{ + "age": 43, + "id": "1", + }, + Table: "users", + }) + fmt.Println(rsp, err) +} diff --git a/examples/db/update/node/updateARecord.js b/examples/db/update/node/updateARecord.js new file mode 100755 index 0000000..7829fa7 --- /dev/null +++ b/examples/db/update/node/updateARecord.js @@ -0,0 +1,16 @@ +import * as db from "m3o/db"; + +// Update a record in the database. Include an "id" in the record to update. +async function UpdateArecord() { + let dbService = new db.DbService(process.env.MICRO_API_TOKEN); + let rsp = await dbService.update({ + record: { + age: 43, + id: "1", + }, + table: "users", + }); + console.log(rsp); +} + +await UpdateArecord(); diff --git a/examples/email/send/curl/sendEmail.sh b/examples/email/send/curl/sendEmail.sh new file mode 100755 index 0000000..44ab6b2 --- /dev/null +++ b/examples/email/send/curl/sendEmail.sh @@ -0,0 +1,8 @@ +curl "https://api.m3o.com/v1/email/Send" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "from": "Awesome Dot Com", + "subject": "Email verification", + "textBody": "Hi there,\n\nPlease verify your email by clicking this link: $micro_verification_link" +}' \ No newline at end of file diff --git a/examples/email/send/go/sendEmail.go b/examples/email/send/go/sendEmail.go new file mode 100755 index 0000000..8e20932 --- /dev/null +++ b/examples/email/send/go/sendEmail.go @@ -0,0 +1,20 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/email" + "os" +) + +// Send an email by passing in from, to, subject, and a text or html body +func SendEmail() { + emailService := email.NewEmailService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := emailService.Send(&email.SendRequest{ + From: "Awesome Dot Com", + Subject: "Email verification", + TextBody: `Hi there, + +Please verify your email by clicking this link: $micro_verification_link`, + }) + fmt.Println(rsp, err) +} diff --git a/examples/email/send/node/sendEmail.js b/examples/email/send/node/sendEmail.js new file mode 100755 index 0000000..43fc591 --- /dev/null +++ b/examples/email/send/node/sendEmail.js @@ -0,0 +1,15 @@ +import * as email from "m3o/email"; + +// Send an email by passing in from, to, subject, and a text or html body +async function SendEmail() { + let emailService = new email.EmailService(process.env.MICRO_API_TOKEN); + let rsp = await emailService.send({ + from: "Awesome Dot Com", + subject: "Email verification", + textBody: + "Hi there,\n\nPlease verify your email by clicking this link: $micro_verification_link", + }); + console.log(rsp); +} + +await SendEmail(); diff --git a/examples/emoji/find/curl/findEmoji.sh b/examples/emoji/find/curl/findEmoji.sh new file mode 100755 index 0000000..8f261ce --- /dev/null +++ b/examples/emoji/find/curl/findEmoji.sh @@ -0,0 +1,6 @@ +curl "https://api.m3o.com/v1/emoji/Find" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "alias": ":beer:" +}' \ No newline at end of file diff --git a/examples/emoji/find/go/findEmoji.go b/examples/emoji/find/go/findEmoji.go new file mode 100755 index 0000000..250263e --- /dev/null +++ b/examples/emoji/find/go/findEmoji.go @@ -0,0 +1,16 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/emoji" + "os" +) + +// Find an emoji by its alias e.g :beer: +func FindEmoji() { + emojiService := emoji.NewEmojiService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := emojiService.Find(&emoji.FindRequest{ + Alias: ":beer:", + }) + fmt.Println(rsp, err) +} diff --git a/examples/emoji/find/node/findEmoji.js b/examples/emoji/find/node/findEmoji.js new file mode 100755 index 0000000..ac01b65 --- /dev/null +++ b/examples/emoji/find/node/findEmoji.js @@ -0,0 +1,12 @@ +import * as emoji from "m3o/emoji"; + +// Find an emoji by its alias e.g :beer: +async function FindEmoji() { + let emojiService = new emoji.EmojiService(process.env.MICRO_API_TOKEN); + let rsp = await emojiService.find({ + alias: ":beer:", + }); + console.log(rsp); +} + +await FindEmoji(); diff --git a/examples/emoji/flag/curl/getFlagByCountryCode.sh b/examples/emoji/flag/curl/getFlagByCountryCode.sh new file mode 100755 index 0000000..3635803 --- /dev/null +++ b/examples/emoji/flag/curl/getFlagByCountryCode.sh @@ -0,0 +1,6 @@ +curl "https://api.m3o.com/v1/emoji/Flag" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "alias": "GB" +}' \ No newline at end of file diff --git a/examples/emoji/flag/go/getFlagByCountryCode.go b/examples/emoji/flag/go/getFlagByCountryCode.go new file mode 100755 index 0000000..21d786d --- /dev/null +++ b/examples/emoji/flag/go/getFlagByCountryCode.go @@ -0,0 +1,14 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/emoji" + "os" +) + +// Get the flag for a country. Requires country code e.g GB for great britain +func GetFlagByCountryCode() { + emojiService := emoji.NewEmojiService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := emojiService.Flag(&emoji.FlagRequest{}) + fmt.Println(rsp, err) +} diff --git a/examples/emoji/flag/node/getFlagByCountryCode.js b/examples/emoji/flag/node/getFlagByCountryCode.js new file mode 100755 index 0000000..b2eaf17 --- /dev/null +++ b/examples/emoji/flag/node/getFlagByCountryCode.js @@ -0,0 +1,12 @@ +import * as emoji from "m3o/emoji"; + +// Get the flag for a country. Requires country code e.g GB for great britain +async function GetFlagByCountryCode() { + let emojiService = new emoji.EmojiService(process.env.MICRO_API_TOKEN); + let rsp = await emojiService.flag({ + alias: "GB", + }); + console.log(rsp); +} + +await GetFlagByCountryCode(); diff --git a/examples/emoji/print/curl/printTextIncludingEmoji.sh b/examples/emoji/print/curl/printTextIncludingEmoji.sh new file mode 100755 index 0000000..621886b --- /dev/null +++ b/examples/emoji/print/curl/printTextIncludingEmoji.sh @@ -0,0 +1,6 @@ +curl "https://api.m3o.com/v1/emoji/Print" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "text": "let's grab a :beer:" +}' \ No newline at end of file diff --git a/examples/emoji/print/go/printTextIncludingEmoji.go b/examples/emoji/print/go/printTextIncludingEmoji.go new file mode 100755 index 0000000..b88bfab --- /dev/null +++ b/examples/emoji/print/go/printTextIncludingEmoji.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/emoji" + "os" +) + +// Print text and renders the emojis with aliases e.g +// let's grab a :beer: becomes let's grab a 🍺 +func PrintTextIncludingEmoji() { + emojiService := emoji.NewEmojiService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := emojiService.Print(&emoji.PrintRequest{ + Text: "let's grab a :beer:", + }) + fmt.Println(rsp, err) +} diff --git a/examples/emoji/print/node/printTextIncludingEmoji.js b/examples/emoji/print/node/printTextIncludingEmoji.js new file mode 100755 index 0000000..7cdddbd --- /dev/null +++ b/examples/emoji/print/node/printTextIncludingEmoji.js @@ -0,0 +1,13 @@ +import * as emoji from "m3o/emoji"; + +// Print text and renders the emojis with aliases e.g +// let's grab a :beer: becomes let's grab a 🍺 +async function PrintTextIncludingEmoji() { + let emojiService = new emoji.EmojiService(process.env.MICRO_API_TOKEN); + let rsp = await emojiService.print({ + text: "let's grab a :beer:", + }); + console.log(rsp); +} + +await PrintTextIncludingEmoji(); diff --git a/examples/emoji/send/curl/sendATextContainingAnEmojiToAnyoneViaSms.sh b/examples/emoji/send/curl/sendATextContainingAnEmojiToAnyoneViaSms.sh new file mode 100755 index 0000000..b69043e --- /dev/null +++ b/examples/emoji/send/curl/sendATextContainingAnEmojiToAnyoneViaSms.sh @@ -0,0 +1,8 @@ +curl "https://api.m3o.com/v1/emoji/Send" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "from": "Alice", + "message": "let's grab a :beer:", + "to": "+44782669123" +}' \ No newline at end of file diff --git a/examples/emoji/send/go/sendATextContainingAnEmojiToAnyoneViaSms.go b/examples/emoji/send/go/sendATextContainingAnEmojiToAnyoneViaSms.go new file mode 100755 index 0000000..d49af6f --- /dev/null +++ b/examples/emoji/send/go/sendATextContainingAnEmojiToAnyoneViaSms.go @@ -0,0 +1,18 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/emoji" + "os" +) + +// Send an emoji to anyone via SMS. Messages are sent in the form ' Sent from ' +func SendAtextContainingAnEmojiToAnyoneViaSms() { + emojiService := emoji.NewEmojiService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := emojiService.Send(&emoji.SendRequest{ + From: "Alice", + Message: "let's grab a :beer:", + To: "+44782669123", + }) + fmt.Println(rsp, err) +} diff --git a/examples/emoji/send/node/sendATextContainingAnEmojiToAnyoneViaSms.js b/examples/emoji/send/node/sendATextContainingAnEmojiToAnyoneViaSms.js new file mode 100755 index 0000000..140e8af --- /dev/null +++ b/examples/emoji/send/node/sendATextContainingAnEmojiToAnyoneViaSms.js @@ -0,0 +1,14 @@ +import * as emoji from "m3o/emoji"; + +// Send an emoji to anyone via SMS. Messages are sent in the form ' Sent from ' +async function SendAtextContainingAnEmojiToAnyoneViaSms() { + let emojiService = new emoji.EmojiService(process.env.MICRO_API_TOKEN); + let rsp = await emojiService.send({ + from: "Alice", + message: "let's grab a :beer:", + to: "+44782669123", + }); + console.log(rsp); +} + +await SendAtextContainingAnEmojiToAnyoneViaSms(); diff --git a/examples/file/delete/curl/deleteFile.sh b/examples/file/delete/curl/deleteFile.sh new file mode 100755 index 0000000..5bab3da --- /dev/null +++ b/examples/file/delete/curl/deleteFile.sh @@ -0,0 +1,7 @@ +curl "https://api.m3o.com/v1/file/Delete" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "path": "/document/text-files/file.txt", + "project": "examples" +}' \ No newline at end of file diff --git a/examples/file/delete/go/deleteFile.go b/examples/file/delete/go/deleteFile.go new file mode 100755 index 0000000..f9e5268 --- /dev/null +++ b/examples/file/delete/go/deleteFile.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/file" + "os" +) + +// Delete a file by project name/path +func DeleteFile() { + fileService := file.NewFileService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := fileService.Delete(&file.DeleteRequest{ + Path: "/document/text-files/file.txt", + Project: "examples", + }) + fmt.Println(rsp, err) +} diff --git a/examples/file/delete/node/deleteFile.js b/examples/file/delete/node/deleteFile.js new file mode 100755 index 0000000..202aaa4 --- /dev/null +++ b/examples/file/delete/node/deleteFile.js @@ -0,0 +1,13 @@ +import * as file from "m3o/file"; + +// Delete a file by project name/path +async function DeleteFile() { + let fileService = new file.FileService(process.env.MICRO_API_TOKEN); + let rsp = await fileService.delete({ + path: "/document/text-files/file.txt", + project: "examples", + }); + console.log(rsp); +} + +await DeleteFile(); diff --git a/examples/file/list/curl/listFiles.sh b/examples/file/list/curl/listFiles.sh new file mode 100755 index 0000000..9d2061d --- /dev/null +++ b/examples/file/list/curl/listFiles.sh @@ -0,0 +1,6 @@ +curl "https://api.m3o.com/v1/file/List" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "project": "examples" +}' \ No newline at end of file diff --git a/examples/file/list/go/listFiles.go b/examples/file/list/go/listFiles.go new file mode 100755 index 0000000..f19e558 --- /dev/null +++ b/examples/file/list/go/listFiles.go @@ -0,0 +1,16 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/file" + "os" +) + +// List files by their project and optionally a path. +func ListFiles() { + fileService := file.NewFileService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := fileService.List(&file.ListRequest{ + Project: "examples", + }) + fmt.Println(rsp, err) +} diff --git a/examples/file/list/node/listFiles.js b/examples/file/list/node/listFiles.js new file mode 100755 index 0000000..d270209 --- /dev/null +++ b/examples/file/list/node/listFiles.js @@ -0,0 +1,12 @@ +import * as file from "m3o/file"; + +// List files by their project and optionally a path. +async function ListFiles() { + let fileService = new file.FileService(process.env.MICRO_API_TOKEN); + let rsp = await fileService.list({ + project: "examples", + }); + console.log(rsp); +} + +await ListFiles(); diff --git a/examples/file/read/curl/readFile.sh b/examples/file/read/curl/readFile.sh new file mode 100755 index 0000000..7bc0675 --- /dev/null +++ b/examples/file/read/curl/readFile.sh @@ -0,0 +1,7 @@ +curl "https://api.m3o.com/v1/file/Read" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "path": "/document/text-files/file.txt", + "project": "examples" +}' \ No newline at end of file diff --git a/examples/file/read/go/readFile.go b/examples/file/read/go/readFile.go new file mode 100755 index 0000000..d975d07 --- /dev/null +++ b/examples/file/read/go/readFile.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/file" + "os" +) + +// Read a file by path +func ReadFile() { + fileService := file.NewFileService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := fileService.Read(&file.ReadRequest{ + Path: "/document/text-files/file.txt", + Project: "examples", + }) + fmt.Println(rsp, err) +} diff --git a/examples/file/read/node/readFile.js b/examples/file/read/node/readFile.js new file mode 100755 index 0000000..6077ee7 --- /dev/null +++ b/examples/file/read/node/readFile.js @@ -0,0 +1,13 @@ +import * as file from "m3o/file"; + +// Read a file by path +async function ReadFile() { + let fileService = new file.FileService(process.env.MICRO_API_TOKEN); + let rsp = await fileService.read({ + path: "/document/text-files/file.txt", + project: "examples", + }); + console.log(rsp); +} + +await ReadFile(); diff --git a/examples/file/save/curl/saveFile.sh b/examples/file/save/curl/saveFile.sh new file mode 100755 index 0000000..2a9aadf --- /dev/null +++ b/examples/file/save/curl/saveFile.sh @@ -0,0 +1,10 @@ +curl "https://api.m3o.com/v1/file/Save" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "file": { + "content": "file content example", + "path": "/document/text-files/file.txt", + "project": "examples" + } +}' \ No newline at end of file diff --git a/examples/file/save/go/saveFile.go b/examples/file/save/go/saveFile.go new file mode 100755 index 0000000..70b69b5 --- /dev/null +++ b/examples/file/save/go/saveFile.go @@ -0,0 +1,20 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/file" + "os" +) + +// Save a file +func SaveFile() { + fileService := file.NewFileService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := fileService.Save(&file.SaveRequest{ + File: &file.Record{ + Content: "file content example", + Path: "/document/text-files/file.txt", + Project: "examples", + }, + }) + fmt.Println(rsp, err) +} diff --git a/examples/file/save/node/saveFile.js b/examples/file/save/node/saveFile.js new file mode 100755 index 0000000..cc06378 --- /dev/null +++ b/examples/file/save/node/saveFile.js @@ -0,0 +1,16 @@ +import * as file from "m3o/file"; + +// Save a file +async function SaveFile() { + let fileService = new file.FileService(process.env.MICRO_API_TOKEN); + let rsp = await fileService.save({ + file: { + content: "file content example", + path: "/document/text-files/file.txt", + project: "examples", + }, + }); + console.log(rsp); +} + +await SaveFile(); diff --git a/examples/forex/history/curl/getPreviousClose.sh b/examples/forex/history/curl/getPreviousClose.sh new file mode 100755 index 0000000..3482e8d --- /dev/null +++ b/examples/forex/history/curl/getPreviousClose.sh @@ -0,0 +1,6 @@ +curl "https://api.m3o.com/v1/forex/History" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "symbol": "GBPUSD" +}' \ No newline at end of file diff --git a/examples/forex/history/go/getPreviousClose.go b/examples/forex/history/go/getPreviousClose.go new file mode 100755 index 0000000..8ce980b --- /dev/null +++ b/examples/forex/history/go/getPreviousClose.go @@ -0,0 +1,16 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/forex" + "os" +) + +// Returns the data for the previous close +func GetPreviousClose() { + forexService := forex.NewForexService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := forexService.History(&forex.HistoryRequest{ + Symbol: "GBPUSD", + }) + fmt.Println(rsp, err) +} diff --git a/examples/forex/history/node/getPreviousClose.js b/examples/forex/history/node/getPreviousClose.js new file mode 100755 index 0000000..78eb67e --- /dev/null +++ b/examples/forex/history/node/getPreviousClose.js @@ -0,0 +1,12 @@ +import * as forex from "m3o/forex"; + +// Returns the data for the previous close +async function GetPreviousClose() { + let forexService = new forex.ForexService(process.env.MICRO_API_TOKEN); + let rsp = await forexService.history({ + symbol: "GBPUSD", + }); + console.log(rsp); +} + +await GetPreviousClose(); diff --git a/examples/forex/price/curl/getAnFxPrice.sh b/examples/forex/price/curl/getAnFxPrice.sh new file mode 100755 index 0000000..40e56b7 --- /dev/null +++ b/examples/forex/price/curl/getAnFxPrice.sh @@ -0,0 +1,6 @@ +curl "https://api.m3o.com/v1/forex/Price" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "symbol": "GBPUSD" +}' \ No newline at end of file diff --git a/examples/forex/price/go/getAnFxPrice.go b/examples/forex/price/go/getAnFxPrice.go new file mode 100755 index 0000000..2f2be42 --- /dev/null +++ b/examples/forex/price/go/getAnFxPrice.go @@ -0,0 +1,16 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/forex" + "os" +) + +// Get the latest price for a given forex ticker +func GetAnFxPrice() { + forexService := forex.NewForexService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := forexService.Price(&forex.PriceRequest{ + Symbol: "GBPUSD", + }) + fmt.Println(rsp, err) +} diff --git a/examples/forex/price/node/getAnFxPrice.js b/examples/forex/price/node/getAnFxPrice.js new file mode 100755 index 0000000..5b2c470 --- /dev/null +++ b/examples/forex/price/node/getAnFxPrice.js @@ -0,0 +1,12 @@ +import * as forex from "m3o/forex"; + +// Get the latest price for a given forex ticker +async function GetAnFxPrice() { + let forexService = new forex.ForexService(process.env.MICRO_API_TOKEN); + let rsp = await forexService.price({ + symbol: "GBPUSD", + }); + console.log(rsp); +} + +await GetAnFxPrice(); diff --git a/examples/forex/quote/curl/getAFxQuote.sh b/examples/forex/quote/curl/getAFxQuote.sh new file mode 100755 index 0000000..c31a982 --- /dev/null +++ b/examples/forex/quote/curl/getAFxQuote.sh @@ -0,0 +1,6 @@ +curl "https://api.m3o.com/v1/forex/Quote" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "symbol": "GBPUSD" +}' \ No newline at end of file diff --git a/examples/forex/quote/go/getAFxQuote.go b/examples/forex/quote/go/getAFxQuote.go new file mode 100755 index 0000000..d2b6b80 --- /dev/null +++ b/examples/forex/quote/go/getAFxQuote.go @@ -0,0 +1,16 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/forex" + "os" +) + +// Get the latest quote for the forex +func GetAfxQuote() { + forexService := forex.NewForexService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := forexService.Quote(&forex.QuoteRequest{ + Symbol: "GBPUSD", + }) + fmt.Println(rsp, err) +} diff --git a/examples/forex/quote/node/getAFxQuote.js b/examples/forex/quote/node/getAFxQuote.js new file mode 100755 index 0000000..60d52e8 --- /dev/null +++ b/examples/forex/quote/node/getAFxQuote.js @@ -0,0 +1,12 @@ +import * as forex from "m3o/forex"; + +// Get the latest quote for the forex +async function GetAfxQuote() { + let forexService = new forex.ForexService(process.env.MICRO_API_TOKEN); + let rsp = await forexService.quote({ + symbol: "GBPUSD", + }); + console.log(rsp); +} + +await GetAfxQuote(); diff --git a/examples/geocoding/lookup/curl/geocodeAnAddress.sh b/examples/geocoding/lookup/curl/geocodeAnAddress.sh new file mode 100755 index 0000000..a548486 --- /dev/null +++ b/examples/geocoding/lookup/curl/geocodeAnAddress.sh @@ -0,0 +1,9 @@ +curl "https://api.m3o.com/v1/geocoding/Lookup" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "address": "10 russell st", + "city": "london", + "country": "uk", + "postcode": "wc2b" +}' \ No newline at end of file diff --git a/examples/geocoding/lookup/go/geocodeAnAddress.go b/examples/geocoding/lookup/go/geocodeAnAddress.go new file mode 100755 index 0000000..cf7610d --- /dev/null +++ b/examples/geocoding/lookup/go/geocodeAnAddress.go @@ -0,0 +1,19 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/geocoding" + "os" +) + +// Lookup returns a geocoded address including normalized address and gps coordinates. All fields are optional, provide more to get more accurate results +func GeocodeAnAddress() { + geocodingService := geocoding.NewGeocodingService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := geocodingService.Lookup(&geocoding.LookupRequest{ + Address: "10 russell st", + City: "london", + Country: "uk", + Postcode: "wc2b", + }) + fmt.Println(rsp, err) +} diff --git a/examples/geocoding/lookup/node/geocodeAnAddress.js b/examples/geocoding/lookup/node/geocodeAnAddress.js new file mode 100755 index 0000000..c59486d --- /dev/null +++ b/examples/geocoding/lookup/node/geocodeAnAddress.js @@ -0,0 +1,17 @@ +import * as geocoding from "m3o/geocoding"; + +// Lookup returns a geocoded address including normalized address and gps coordinates. All fields are optional, provide more to get more accurate results +async function GeocodeAnAddress() { + let geocodingService = new geocoding.GeocodingService( + process.env.MICRO_API_TOKEN + ); + let rsp = await geocodingService.lookup({ + address: "10 russell st", + city: "london", + country: "uk", + postcode: "wc2b", + }); + console.log(rsp); +} + +await GeocodeAnAddress(); diff --git a/examples/geocoding/reverse/curl/reverseGeocodeLocation.sh b/examples/geocoding/reverse/curl/reverseGeocodeLocation.sh new file mode 100755 index 0000000..76e34ba --- /dev/null +++ b/examples/geocoding/reverse/curl/reverseGeocodeLocation.sh @@ -0,0 +1,7 @@ +curl "https://api.m3o.com/v1/geocoding/Reverse" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "latitude": 51.5123064, + "longitude": -0.1216235 +}' \ No newline at end of file diff --git a/examples/geocoding/reverse/go/reverseGeocodeLocation.go b/examples/geocoding/reverse/go/reverseGeocodeLocation.go new file mode 100755 index 0000000..fa17d2e --- /dev/null +++ b/examples/geocoding/reverse/go/reverseGeocodeLocation.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/geocoding" + "os" +) + +// Reverse lookup an address from gps coordinates +func ReverseGeocodeLocation() { + geocodingService := geocoding.NewGeocodingService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := geocodingService.Reverse(&geocoding.ReverseRequest{ + Latitude: 51.5123064, + Longitude: -0.1216235, + }) + fmt.Println(rsp, err) +} diff --git a/examples/geocoding/reverse/node/reverseGeocodeLocation.js b/examples/geocoding/reverse/node/reverseGeocodeLocation.js new file mode 100755 index 0000000..a9aa77f --- /dev/null +++ b/examples/geocoding/reverse/node/reverseGeocodeLocation.js @@ -0,0 +1,15 @@ +import * as geocoding from "m3o/geocoding"; + +// Reverse lookup an address from gps coordinates +async function ReverseGeocodeLocation() { + let geocodingService = new geocoding.GeocodingService( + process.env.MICRO_API_TOKEN + ); + let rsp = await geocodingService.reverse({ + latitude: 51.5123064, + longitude: -0.1216235, + }); + console.log(rsp); +} + +await ReverseGeocodeLocation(); diff --git a/examples/helloworld/call/curl/callTheHelloworldService.sh b/examples/helloworld/call/curl/callTheHelloworldService.sh new file mode 100755 index 0000000..59c5366 --- /dev/null +++ b/examples/helloworld/call/curl/callTheHelloworldService.sh @@ -0,0 +1,6 @@ +curl "https://api.m3o.com/v1/helloworld/Call" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "name": "John" +}' \ No newline at end of file diff --git a/examples/helloworld/call/go/callTheHelloworldService.go b/examples/helloworld/call/go/callTheHelloworldService.go new file mode 100755 index 0000000..8105a1b --- /dev/null +++ b/examples/helloworld/call/go/callTheHelloworldService.go @@ -0,0 +1,16 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/helloworld" + "os" +) + +// Call returns a personalised "Hello $name" response +func CallTheHelloworldService() { + helloworldService := helloworld.NewHelloworldService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := helloworldService.Call(&helloworld.CallRequest{ + Name: "John", + }) + fmt.Println(rsp, err) +} diff --git a/examples/helloworld/call/node/callTheHelloworldService.js b/examples/helloworld/call/node/callTheHelloworldService.js new file mode 100755 index 0000000..7dcd391 --- /dev/null +++ b/examples/helloworld/call/node/callTheHelloworldService.js @@ -0,0 +1,14 @@ +import * as helloworld from "m3o/helloworld"; + +// Call returns a personalised "Hello $name" response +async function CallTheHelloworldService() { + let helloworldService = new helloworld.HelloworldService( + process.env.MICRO_API_TOKEN + ); + let rsp = await helloworldService.call({ + name: "John", + }); + console.log(rsp); +} + +await CallTheHelloworldService(); diff --git a/examples/id/generate/curl/generateABigflakeId.sh b/examples/id/generate/curl/generateABigflakeId.sh new file mode 100755 index 0000000..3bfd483 --- /dev/null +++ b/examples/id/generate/curl/generateABigflakeId.sh @@ -0,0 +1,6 @@ +curl "https://api.m3o.com/v1/id/Generate" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "type": "bigflake" +}' \ No newline at end of file diff --git a/examples/id/generate/curl/generateAShortId.sh b/examples/id/generate/curl/generateAShortId.sh new file mode 100755 index 0000000..cd0f54a --- /dev/null +++ b/examples/id/generate/curl/generateAShortId.sh @@ -0,0 +1,6 @@ +curl "https://api.m3o.com/v1/id/Generate" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "type": "shortid" +}' \ No newline at end of file diff --git a/examples/id/generate/curl/generateASnowflakeId.sh b/examples/id/generate/curl/generateASnowflakeId.sh new file mode 100755 index 0000000..2ce118c --- /dev/null +++ b/examples/id/generate/curl/generateASnowflakeId.sh @@ -0,0 +1,6 @@ +curl "https://api.m3o.com/v1/id/Generate" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "type": "snowflake" +}' \ No newline at end of file diff --git a/examples/id/generate/curl/generateAUniqueId.sh b/examples/id/generate/curl/generateAUniqueId.sh new file mode 100755 index 0000000..792fdbf --- /dev/null +++ b/examples/id/generate/curl/generateAUniqueId.sh @@ -0,0 +1,6 @@ +curl "https://api.m3o.com/v1/id/Generate" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "type": "uuid" +}' \ No newline at end of file diff --git a/examples/id/generate/go/generateABigflakeId.go b/examples/id/generate/go/generateABigflakeId.go new file mode 100755 index 0000000..b571ffb --- /dev/null +++ b/examples/id/generate/go/generateABigflakeId.go @@ -0,0 +1,16 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/id" + "os" +) + +// Generate a unique ID. Defaults to uuid. +func GenerateAbigflakeId() { + idService := id.NewIdService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := idService.Generate(&id.GenerateRequest{ + Type: "bigflake", + }) + fmt.Println(rsp, err) +} diff --git a/examples/id/generate/go/generateAShortId.go b/examples/id/generate/go/generateAShortId.go new file mode 100755 index 0000000..f2df0a1 --- /dev/null +++ b/examples/id/generate/go/generateAShortId.go @@ -0,0 +1,16 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/id" + "os" +) + +// Generate a unique ID. Defaults to uuid. +func GenerateAshortId() { + idService := id.NewIdService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := idService.Generate(&id.GenerateRequest{ + Type: "shortid", + }) + fmt.Println(rsp, err) +} diff --git a/examples/id/generate/go/generateASnowflakeId.go b/examples/id/generate/go/generateASnowflakeId.go new file mode 100755 index 0000000..f53c42b --- /dev/null +++ b/examples/id/generate/go/generateASnowflakeId.go @@ -0,0 +1,16 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/id" + "os" +) + +// Generate a unique ID. Defaults to uuid. +func GenerateAsnowflakeId() { + idService := id.NewIdService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := idService.Generate(&id.GenerateRequest{ + Type: "snowflake", + }) + fmt.Println(rsp, err) +} diff --git a/examples/id/generate/go/generateAUniqueId.go b/examples/id/generate/go/generateAUniqueId.go new file mode 100755 index 0000000..da40eb6 --- /dev/null +++ b/examples/id/generate/go/generateAUniqueId.go @@ -0,0 +1,16 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/id" + "os" +) + +// Generate a unique ID. Defaults to uuid. +func GenerateAuniqueId() { + idService := id.NewIdService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := idService.Generate(&id.GenerateRequest{ + Type: "uuid", + }) + fmt.Println(rsp, err) +} diff --git a/examples/id/generate/node/generateABigflakeId.js b/examples/id/generate/node/generateABigflakeId.js new file mode 100755 index 0000000..be8b662 --- /dev/null +++ b/examples/id/generate/node/generateABigflakeId.js @@ -0,0 +1,12 @@ +import * as id from "m3o/id"; + +// Generate a unique ID. Defaults to uuid. +async function GenerateAbigflakeId() { + let idService = new id.IdService(process.env.MICRO_API_TOKEN); + let rsp = await idService.generate({ + type: "bigflake", + }); + console.log(rsp); +} + +await GenerateAbigflakeId(); diff --git a/examples/id/generate/node/generateAShortId.js b/examples/id/generate/node/generateAShortId.js new file mode 100755 index 0000000..f455744 --- /dev/null +++ b/examples/id/generate/node/generateAShortId.js @@ -0,0 +1,12 @@ +import * as id from "m3o/id"; + +// Generate a unique ID. Defaults to uuid. +async function GenerateAshortId() { + let idService = new id.IdService(process.env.MICRO_API_TOKEN); + let rsp = await idService.generate({ + type: "shortid", + }); + console.log(rsp); +} + +await GenerateAshortId(); diff --git a/examples/id/generate/node/generateASnowflakeId.js b/examples/id/generate/node/generateASnowflakeId.js new file mode 100755 index 0000000..960b3bd --- /dev/null +++ b/examples/id/generate/node/generateASnowflakeId.js @@ -0,0 +1,12 @@ +import * as id from "m3o/id"; + +// Generate a unique ID. Defaults to uuid. +async function GenerateAsnowflakeId() { + let idService = new id.IdService(process.env.MICRO_API_TOKEN); + let rsp = await idService.generate({ + type: "snowflake", + }); + console.log(rsp); +} + +await GenerateAsnowflakeId(); diff --git a/examples/id/generate/node/generateAUniqueId.js b/examples/id/generate/node/generateAUniqueId.js new file mode 100755 index 0000000..33ac826 --- /dev/null +++ b/examples/id/generate/node/generateAUniqueId.js @@ -0,0 +1,12 @@ +import * as id from "m3o/id"; + +// Generate a unique ID. Defaults to uuid. +async function GenerateAuniqueId() { + let idService = new id.IdService(process.env.MICRO_API_TOKEN); + let rsp = await idService.generate({ + type: "uuid", + }); + console.log(rsp); +} + +await GenerateAuniqueId(); diff --git a/examples/image/convert/curl/convertAPngImageToAJpegTakenFromAUrlAndSavedToAUrlOnMicrosCdn.sh b/examples/image/convert/curl/convertAPngImageToAJpegTakenFromAUrlAndSavedToAUrlOnMicrosCdn.sh new file mode 100755 index 0000000..b34b665 --- /dev/null +++ b/examples/image/convert/curl/convertAPngImageToAJpegTakenFromAUrlAndSavedToAUrlOnMicrosCdn.sh @@ -0,0 +1,8 @@ +curl "https://api.m3o.com/v1/image/Convert" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "name": "cat.jpeg", + "outputURL": true, + "url": "somewebsite.com/cat.png" +}' \ No newline at end of file diff --git a/examples/image/convert/go/convertAPngImageToAJpegTakenFromAUrlAndSavedToAUrlOnMicrosCdn.go b/examples/image/convert/go/convertAPngImageToAJpegTakenFromAUrlAndSavedToAUrlOnMicrosCdn.go new file mode 100755 index 0000000..2e396f3 --- /dev/null +++ b/examples/image/convert/go/convertAPngImageToAJpegTakenFromAUrlAndSavedToAUrlOnMicrosCdn.go @@ -0,0 +1,18 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/image" + "os" +) + +// 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 ConvertApngImageToAjpegTakenFromAurlAndSavedToAurlOnMicrosCdn() { + imageService := image.NewImageService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := imageService.Convert(&image.ConvertRequest{ + Name: "cat.jpeg", + Url: "somewebsite.com/cat.png", + }) + fmt.Println(rsp, err) +} diff --git a/examples/image/convert/node/convertAPngImageToAJpegTakenFromAUrlAndSavedToAUrlOnMicrosCdn.js b/examples/image/convert/node/convertAPngImageToAJpegTakenFromAUrlAndSavedToAUrlOnMicrosCdn.js new file mode 100755 index 0000000..df5f1b0 --- /dev/null +++ b/examples/image/convert/node/convertAPngImageToAJpegTakenFromAUrlAndSavedToAUrlOnMicrosCdn.js @@ -0,0 +1,15 @@ +import * as image from "m3o/image"; + +// 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. +async function ConvertApngImageToAjpegTakenFromAurlAndSavedToAurlOnMicrosCdn() { + let imageService = new image.ImageService(process.env.MICRO_API_TOKEN); + let rsp = await imageService.convert({ + name: "cat.jpeg", + outputURL: true, + url: "somewebsite.com/cat.png", + }); + console.log(rsp); +} + +await ConvertApngImageToAjpegTakenFromAurlAndSavedToAurlOnMicrosCdn(); diff --git a/examples/image/resize/curl/base64ToBase64Image.sh b/examples/image/resize/curl/base64ToBase64Image.sh new file mode 100755 index 0000000..4b19edd --- /dev/null +++ b/examples/image/resize/curl/base64ToBase64Image.sh @@ -0,0 +1,8 @@ +curl "https://api.m3o.com/v1/image/Resize" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "base64": "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==", + "height": 100, + "width": 100 +}' \ No newline at end of file diff --git a/examples/image/resize/curl/base64ToBase64ImageWithCropping.sh b/examples/image/resize/curl/base64ToBase64ImageWithCropping.sh new file mode 100755 index 0000000..3199051 --- /dev/null +++ b/examples/image/resize/curl/base64ToBase64ImageWithCropping.sh @@ -0,0 +1,12 @@ +curl "https://api.m3o.com/v1/image/Resize" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "base64": "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==", + "cropOptions": { + "height": 50, + "width": 50 + }, + "height": 100, + "width": 100 +}' \ No newline at end of file diff --git a/examples/image/resize/curl/base64ToHostedImage.sh b/examples/image/resize/curl/base64ToHostedImage.sh new file mode 100755 index 0000000..85626ec --- /dev/null +++ b/examples/image/resize/curl/base64ToHostedImage.sh @@ -0,0 +1,10 @@ +curl "https://api.m3o.com/v1/image/Resize" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "base64": "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==", + "height": 100, + "name": "cat.png", + "outputURL": true, + "width": 100 +}' \ No newline at end of file diff --git a/examples/image/resize/go/base64ToBase64Image.go b/examples/image/resize/go/base64ToBase64Image.go new file mode 100755 index 0000000..d81c03b --- /dev/null +++ b/examples/image/resize/go/base64ToBase64Image.go @@ -0,0 +1,20 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/image" + "os" +) + +// 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 Base64toBase64image() { + imageService := image.NewImageService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := imageService.Resize(&image.ResizeRequest{ + Base64: "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==", + Height: 100, + Width: 100, + }) + fmt.Println(rsp, err) +} diff --git a/examples/image/resize/go/base64ToBase64ImageWithCropping.go b/examples/image/resize/go/base64ToBase64ImageWithCropping.go new file mode 100755 index 0000000..187ca54 --- /dev/null +++ b/examples/image/resize/go/base64ToBase64ImageWithCropping.go @@ -0,0 +1,24 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/image" + "os" +) + +// 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 Base64toBase64imageWithCropping() { + imageService := image.NewImageService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := imageService.Resize(&image.ResizeRequest{ + Base64: "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==", + CropOptions: &image.CropOptions{ + Height: 50, + Width: 50, + }, + Height: 100, + Width: 100, + }) + fmt.Println(rsp, err) +} diff --git a/examples/image/resize/go/base64ToHostedImage.go b/examples/image/resize/go/base64ToHostedImage.go new file mode 100755 index 0000000..067d6e2 --- /dev/null +++ b/examples/image/resize/go/base64ToHostedImage.go @@ -0,0 +1,21 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/image" + "os" +) + +// 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 Base64toHostedImage() { + imageService := image.NewImageService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := imageService.Resize(&image.ResizeRequest{ + Base64: "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==", + Height: 100, + Name: "cat.png", + Width: 100, + }) + fmt.Println(rsp, err) +} diff --git a/examples/image/resize/node/base64ToBase64Image.js b/examples/image/resize/node/base64ToBase64Image.js new file mode 100755 index 0000000..4e7a67d --- /dev/null +++ b/examples/image/resize/node/base64ToBase64Image.js @@ -0,0 +1,17 @@ +import * as image from "m3o/image"; + +// 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. +async function Base64toBase64image() { + let imageService = new image.ImageService(process.env.MICRO_API_TOKEN); + let rsp = await imageService.resize({ + base64: + "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==", + height: 100, + width: 100, + }); + console.log(rsp); +} + +await Base64toBase64image(); diff --git a/examples/image/resize/node/base64ToBase64ImageWithCropping.js b/examples/image/resize/node/base64ToBase64ImageWithCropping.js new file mode 100755 index 0000000..02b418e --- /dev/null +++ b/examples/image/resize/node/base64ToBase64ImageWithCropping.js @@ -0,0 +1,21 @@ +import * as image from "m3o/image"; + +// 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. +async function Base64toBase64imageWithCropping() { + let imageService = new image.ImageService(process.env.MICRO_API_TOKEN); + let rsp = await imageService.resize({ + base64: + "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==", + cropOptions: { + height: 50, + width: 50, + }, + height: 100, + width: 100, + }); + console.log(rsp); +} + +await Base64toBase64imageWithCropping(); diff --git a/examples/image/resize/node/base64ToHostedImage.js b/examples/image/resize/node/base64ToHostedImage.js new file mode 100755 index 0000000..7acaf0a --- /dev/null +++ b/examples/image/resize/node/base64ToHostedImage.js @@ -0,0 +1,19 @@ +import * as image from "m3o/image"; + +// 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. +async function Base64toHostedImage() { + let imageService = new image.ImageService(process.env.MICRO_API_TOKEN); + let rsp = await imageService.resize({ + base64: + "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==", + height: 100, + name: "cat.png", + outputURL: true, + width: 100, + }); + console.log(rsp); +} + +await Base64toHostedImage(); diff --git a/examples/image/upload/curl/uploadABase64ImageToMicrosCdn.sh b/examples/image/upload/curl/uploadABase64ImageToMicrosCdn.sh new file mode 100755 index 0000000..86073ea --- /dev/null +++ b/examples/image/upload/curl/uploadABase64ImageToMicrosCdn.sh @@ -0,0 +1,8 @@ +curl "https://api.m3o.com/v1/image/Upload" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "base64": "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAx0lEQVR4nOzaMaoDMQyE4ZHj+x82vVdhwQoTkzKQEcwP5r0ihT7sbjUTeAJ4HCegXQJYfOYefOyjDuBiz3yjwJBoCIl6QZOeUjTC1Ix1IxEJXF9+0KWsf2bD4bn37OO/c/wuQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9Sa/NG94Tf3j4WBdaxudMEkn4IM2rZBA0wBrvo7aOcpj2emXvLeVt0IGm0GVXUj91mvAAAA//+V2CZl+4AKXwAAAABJRU5ErkJggg==", + "name": "cat.jpeg", + "outputURL": true +}' \ No newline at end of file diff --git a/examples/image/upload/curl/uploadAnImageFromAUrlToMicrosCdn.sh b/examples/image/upload/curl/uploadAnImageFromAUrlToMicrosCdn.sh new file mode 100755 index 0000000..d1c35ca --- /dev/null +++ b/examples/image/upload/curl/uploadAnImageFromAUrlToMicrosCdn.sh @@ -0,0 +1,7 @@ +curl "https://api.m3o.com/v1/image/Upload" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "name": "cat.jpeg", + "url": "somewebsite.com/cat.png" +}' \ No newline at end of file diff --git a/examples/image/upload/go/uploadABase64ImageToMicrosCdn.go b/examples/image/upload/go/uploadABase64ImageToMicrosCdn.go new file mode 100755 index 0000000..3d81a5b --- /dev/null +++ b/examples/image/upload/go/uploadABase64ImageToMicrosCdn.go @@ -0,0 +1,18 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/image" + "os" +) + +// Upload an image by either sending a base64 encoded image to this endpoint or a URL. +// To resize an image before uploading, see the Resize endpoint. +func UploadAbase64imageToMicrosCdn() { + imageService := image.NewImageService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := imageService.Upload(&image.UploadRequest{ + Base64: "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAx0lEQVR4nOzaMaoDMQyE4ZHj+x82vVdhwQoTkzKQEcwP5r0ihT7sbjUTeAJ4HCegXQJYfOYefOyjDuBiz3yjwJBoCIl6QZOeUjTC1Ix1IxEJXF9+0KWsf2bD4bn37OO/c/wuQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9Sa/NG94Tf3j4WBdaxudMEkn4IM2rZBA0wBrvo7aOcpj2emXvLeVt0IGm0GVXUj91mvAAAA//+V2CZl+4AKXwAAAABJRU5ErkJggg==", + Name: "cat.jpeg", + }) + fmt.Println(rsp, err) +} diff --git a/examples/image/upload/go/uploadAnImageFromAUrlToMicrosCdn.go b/examples/image/upload/go/uploadAnImageFromAUrlToMicrosCdn.go new file mode 100755 index 0000000..e05e477 --- /dev/null +++ b/examples/image/upload/go/uploadAnImageFromAUrlToMicrosCdn.go @@ -0,0 +1,18 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/image" + "os" +) + +// Upload an image by either sending a base64 encoded image to this endpoint or a URL. +// To resize an image before uploading, see the Resize endpoint. +func UploadAnImageFromAurlToMicrosCdn() { + imageService := image.NewImageService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := imageService.Upload(&image.UploadRequest{ + Name: "cat.jpeg", + Url: "somewebsite.com/cat.png", + }) + fmt.Println(rsp, err) +} diff --git a/examples/image/upload/node/uploadABase64ImageToMicrosCdn.js b/examples/image/upload/node/uploadABase64ImageToMicrosCdn.js new file mode 100755 index 0000000..3caf344 --- /dev/null +++ b/examples/image/upload/node/uploadABase64ImageToMicrosCdn.js @@ -0,0 +1,16 @@ +import * as image from "m3o/image"; + +// Upload an image by either sending a base64 encoded image to this endpoint or a URL. +// To resize an image before uploading, see the Resize endpoint. +async function UploadAbase64imageToMicrosCdn() { + let imageService = new image.ImageService(process.env.MICRO_API_TOKEN); + let rsp = await imageService.upload({ + base64: + "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAx0lEQVR4nOzaMaoDMQyE4ZHj+x82vVdhwQoTkzKQEcwP5r0ihT7sbjUTeAJ4HCegXQJYfOYefOyjDuBiz3yjwJBoCIl6QZOeUjTC1Ix1IxEJXF9+0KWsf2bD4bn37OO/c/wuQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9Sa/NG94Tf3j4WBdaxudMEkn4IM2rZBA0wBrvo7aOcpj2emXvLeVt0IGm0GVXUj91mvAAAA//+V2CZl+4AKXwAAAABJRU5ErkJggg==", + name: "cat.jpeg", + outputURL: true, + }); + console.log(rsp); +} + +await UploadAbase64imageToMicrosCdn(); diff --git a/examples/image/upload/node/uploadAnImageFromAUrlToMicrosCdn.js b/examples/image/upload/node/uploadAnImageFromAUrlToMicrosCdn.js new file mode 100755 index 0000000..940f701 --- /dev/null +++ b/examples/image/upload/node/uploadAnImageFromAUrlToMicrosCdn.js @@ -0,0 +1,14 @@ +import * as image from "m3o/image"; + +// Upload an image by either sending a base64 encoded image to this endpoint or a URL. +// To resize an image before uploading, see the Resize endpoint. +async function UploadAnImageFromAurlToMicrosCdn() { + let imageService = new image.ImageService(process.env.MICRO_API_TOKEN); + let rsp = await imageService.upload({ + name: "cat.jpeg", + url: "somewebsite.com/cat.png", + }); + console.log(rsp); +} + +await UploadAnImageFromAurlToMicrosCdn(); diff --git a/examples/ip/lookup/curl/lookupIpInfo.sh b/examples/ip/lookup/curl/lookupIpInfo.sh new file mode 100755 index 0000000..8677cc9 --- /dev/null +++ b/examples/ip/lookup/curl/lookupIpInfo.sh @@ -0,0 +1,6 @@ +curl "https://api.m3o.com/v1/ip/Lookup" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "ip": "93.148.214.31" +}' \ No newline at end of file diff --git a/examples/ip/lookup/go/lookupIpInfo.go b/examples/ip/lookup/go/lookupIpInfo.go new file mode 100755 index 0000000..9ebaa3c --- /dev/null +++ b/examples/ip/lookup/go/lookupIpInfo.go @@ -0,0 +1,16 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/ip" + "os" +) + +// Lookup the geolocation information for an IP address +func LookupIpInfo() { + ipService := ip.NewIpService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := ipService.Lookup(&ip.LookupRequest{ + Ip: "93.148.214.31", + }) + fmt.Println(rsp, err) +} diff --git a/examples/ip/lookup/node/lookupIpInfo.js b/examples/ip/lookup/node/lookupIpInfo.js new file mode 100755 index 0000000..d08cce7 --- /dev/null +++ b/examples/ip/lookup/node/lookupIpInfo.js @@ -0,0 +1,12 @@ +import * as ip from "m3o/ip"; + +// Lookup the geolocation information for an IP address +async function LookupIpInfo() { + let ipService = new ip.IpService(process.env.MICRO_API_TOKEN); + let rsp = await ipService.lookup({ + ip: "93.148.214.31", + }); + console.log(rsp); +} + +await LookupIpInfo(); diff --git a/examples/location/read/curl/getLocationById.sh b/examples/location/read/curl/getLocationById.sh new file mode 100755 index 0000000..2febbf1 --- /dev/null +++ b/examples/location/read/curl/getLocationById.sh @@ -0,0 +1,6 @@ +curl "https://api.m3o.com/v1/location/Read" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "id": "1" +}' \ No newline at end of file diff --git a/examples/location/read/go/getLocationById.go b/examples/location/read/go/getLocationById.go new file mode 100755 index 0000000..ed26378 --- /dev/null +++ b/examples/location/read/go/getLocationById.go @@ -0,0 +1,16 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/location" + "os" +) + +// Read an entity by its ID +func GetLocationById() { + locationService := location.NewLocationService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := locationService.Read(&location.ReadRequest{ + Id: "1", + }) + fmt.Println(rsp, err) +} diff --git a/examples/location/read/node/getLocationById.js b/examples/location/read/node/getLocationById.js new file mode 100755 index 0000000..e89cb68 --- /dev/null +++ b/examples/location/read/node/getLocationById.js @@ -0,0 +1,14 @@ +import * as location from "m3o/location"; + +// Read an entity by its ID +async function GetLocationById() { + let locationService = new location.LocationService( + process.env.MICRO_API_TOKEN + ); + let rsp = await locationService.read({ + id: "1", + }); + console.log(rsp); +} + +await GetLocationById(); diff --git a/examples/location/save/curl/saveAnEntity.sh b/examples/location/save/curl/saveAnEntity.sh new file mode 100755 index 0000000..e5afe49 --- /dev/null +++ b/examples/location/save/curl/saveAnEntity.sh @@ -0,0 +1,14 @@ +curl "https://api.m3o.com/v1/location/Save" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "entity": { + "id": "1", + "location": { + "latitude": 51.511061, + "longitude": -0.120022, + "timestamp": "1622802761" + }, + "type": "bike" + } +}' \ No newline at end of file diff --git a/examples/location/save/go/saveAnEntity.go b/examples/location/save/go/saveAnEntity.go new file mode 100755 index 0000000..508c903 --- /dev/null +++ b/examples/location/save/go/saveAnEntity.go @@ -0,0 +1,24 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/location" + "os" +) + +// Save an entity's current position +func SaveAnEntity() { + locationService := location.NewLocationService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := locationService.Save(&location.SaveRequest{ + Entity: &location.Entity{ + Id: "1", + Location: &location.Point{ + Latitude: 51.511061, + Longitude: -0.120022, + Timestamp: 1622802761, + }, + Type: "bike", + }, + }) + fmt.Println(rsp, err) +} diff --git a/examples/location/save/node/saveAnEntity.js b/examples/location/save/node/saveAnEntity.js new file mode 100755 index 0000000..2a18288 --- /dev/null +++ b/examples/location/save/node/saveAnEntity.js @@ -0,0 +1,22 @@ +import * as location from "m3o/location"; + +// Save an entity's current position +async function SaveAnEntity() { + let locationService = new location.LocationService( + process.env.MICRO_API_TOKEN + ); + let rsp = await locationService.save({ + entity: { + id: "1", + location: { + latitude: 51.511061, + longitude: -0.120022, + timestamp: "1622802761", + }, + type: "bike", + }, + }); + console.log(rsp); +} + +await SaveAnEntity(); diff --git a/examples/location/search/curl/searchForLocations.sh b/examples/location/search/curl/searchForLocations.sh new file mode 100755 index 0000000..58322b5 --- /dev/null +++ b/examples/location/search/curl/searchForLocations.sh @@ -0,0 +1,12 @@ +curl "https://api.m3o.com/v1/location/Search" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "center": { + "latitude": 51.511061, + "longitude": -0.120022 + }, + "numEntities": 10, + "radius": 100, + "type": "bike" +}' \ No newline at end of file diff --git a/examples/location/search/go/searchForLocations.go b/examples/location/search/go/searchForLocations.go new file mode 100755 index 0000000..9cb4063 --- /dev/null +++ b/examples/location/search/go/searchForLocations.go @@ -0,0 +1,22 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/location" + "os" +) + +// Search for entities in a given radius +func SearchForLocations() { + locationService := location.NewLocationService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := locationService.Search(&location.SearchRequest{ + Center: &location.Point{ + Latitude: 51.511061, + Longitude: -0.120022, + }, + NumEntities: 10, + Radius: 100, + Type: "bike", + }) + fmt.Println(rsp, err) +} diff --git a/examples/location/search/node/searchForLocations.js b/examples/location/search/node/searchForLocations.js new file mode 100755 index 0000000..6878276 --- /dev/null +++ b/examples/location/search/node/searchForLocations.js @@ -0,0 +1,20 @@ +import * as location from "m3o/location"; + +// Search for entities in a given radius +async function SearchForLocations() { + let locationService = new location.LocationService( + process.env.MICRO_API_TOKEN + ); + let rsp = await locationService.search({ + center: { + latitude: 51.511061, + longitude: -0.120022, + }, + numEntities: 10, + radius: 100, + type: "bike", + }); + console.log(rsp); +} + +await SearchForLocations(); diff --git a/examples/otp/generate/curl/generateOtp.sh b/examples/otp/generate/curl/generateOtp.sh new file mode 100755 index 0000000..e9222c8 --- /dev/null +++ b/examples/otp/generate/curl/generateOtp.sh @@ -0,0 +1,6 @@ +curl "https://api.m3o.com/v1/otp/Generate" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "id": "asim@example.com" +}' \ No newline at end of file diff --git a/examples/otp/generate/go/generateOtp.go b/examples/otp/generate/go/generateOtp.go new file mode 100755 index 0000000..6b4d1d9 --- /dev/null +++ b/examples/otp/generate/go/generateOtp.go @@ -0,0 +1,16 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/otp" + "os" +) + +// Generate an OTP (one time pass) code +func GenerateOtp() { + otpService := otp.NewOtpService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := otpService.Generate(&otp.GenerateRequest{ + Id: "asim@example.com", + }) + fmt.Println(rsp, err) +} diff --git a/examples/otp/generate/node/generateOtp.js b/examples/otp/generate/node/generateOtp.js new file mode 100755 index 0000000..b86b62c --- /dev/null +++ b/examples/otp/generate/node/generateOtp.js @@ -0,0 +1,12 @@ +import * as otp from "m3o/otp"; + +// Generate an OTP (one time pass) code +async function GenerateOtp() { + let otpService = new otp.OtpService(process.env.MICRO_API_TOKEN); + let rsp = await otpService.generate({ + id: "asim@example.com", + }); + console.log(rsp); +} + +await GenerateOtp(); diff --git a/examples/otp/validate/curl/validateOtp.sh b/examples/otp/validate/curl/validateOtp.sh new file mode 100755 index 0000000..1006312 --- /dev/null +++ b/examples/otp/validate/curl/validateOtp.sh @@ -0,0 +1,7 @@ +curl "https://api.m3o.com/v1/otp/Validate" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "code": "656211", + "id": "asim@example.com" +}' \ No newline at end of file diff --git a/examples/otp/validate/go/validateOtp.go b/examples/otp/validate/go/validateOtp.go new file mode 100755 index 0000000..cda57d9 --- /dev/null +++ b/examples/otp/validate/go/validateOtp.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/otp" + "os" +) + +// Validate the OTP code +func ValidateOtp() { + otpService := otp.NewOtpService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := otpService.Validate(&otp.ValidateRequest{ + Code: "656211", + Id: "asim@example.com", + }) + fmt.Println(rsp, err) +} diff --git a/examples/otp/validate/node/validateOtp.js b/examples/otp/validate/node/validateOtp.js new file mode 100755 index 0000000..9177a38 --- /dev/null +++ b/examples/otp/validate/node/validateOtp.js @@ -0,0 +1,13 @@ +import * as otp from "m3o/otp"; + +// Validate the OTP code +async function ValidateOtp() { + let otpService = new otp.OtpService(process.env.MICRO_API_TOKEN); + let rsp = await otpService.validate({ + code: "656211", + id: "asim@example.com", + }); + console.log(rsp); +} + +await ValidateOtp(); diff --git a/examples/postcode/lookup/curl/lookupPostcode.sh b/examples/postcode/lookup/curl/lookupPostcode.sh new file mode 100755 index 0000000..51fe297 --- /dev/null +++ b/examples/postcode/lookup/curl/lookupPostcode.sh @@ -0,0 +1,6 @@ +curl "https://api.m3o.com/v1/postcode/Lookup" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "postcode": "SW1A 2AA" +}' \ No newline at end of file diff --git a/examples/postcode/lookup/go/lookupPostcode.go b/examples/postcode/lookup/go/lookupPostcode.go new file mode 100755 index 0000000..029b5fc --- /dev/null +++ b/examples/postcode/lookup/go/lookupPostcode.go @@ -0,0 +1,16 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/postcode" + "os" +) + +// Lookup a postcode to retrieve the related region, county, etc +func LookupPostcode() { + postcodeService := postcode.NewPostcodeService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := postcodeService.Lookup(&postcode.LookupRequest{ + Postcode: "SW1A 2AA", + }) + fmt.Println(rsp, err) +} diff --git a/examples/postcode/lookup/node/lookupPostcode.js b/examples/postcode/lookup/node/lookupPostcode.js new file mode 100755 index 0000000..f60edab --- /dev/null +++ b/examples/postcode/lookup/node/lookupPostcode.js @@ -0,0 +1,14 @@ +import * as postcode from "m3o/postcode"; + +// Lookup a postcode to retrieve the related region, county, etc +async function LookupPostcode() { + let postcodeService = new postcode.PostcodeService( + process.env.MICRO_API_TOKEN + ); + let rsp = await postcodeService.lookup({ + postcode: "SW1A 2AA", + }); + console.log(rsp); +} + +await LookupPostcode(); diff --git a/examples/postcode/random/curl/returnARandomPostcodeAndItsInformation.sh b/examples/postcode/random/curl/returnARandomPostcodeAndItsInformation.sh new file mode 100755 index 0000000..eebad2a --- /dev/null +++ b/examples/postcode/random/curl/returnARandomPostcodeAndItsInformation.sh @@ -0,0 +1,4 @@ +curl "https://api.m3o.com/v1/postcode/Random" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{}' \ No newline at end of file diff --git a/examples/postcode/random/go/returnARandomPostcodeAndItsInformation.go b/examples/postcode/random/go/returnARandomPostcodeAndItsInformation.go new file mode 100755 index 0000000..0a15f99 --- /dev/null +++ b/examples/postcode/random/go/returnARandomPostcodeAndItsInformation.go @@ -0,0 +1,14 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/postcode" + "os" +) + +// Return a random postcode and its related info +func ReturnArandomPostcodeAndItsInformation() { + postcodeService := postcode.NewPostcodeService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := postcodeService.Random(&postcode.RandomRequest{}) + fmt.Println(rsp, err) +} diff --git a/examples/postcode/random/node/returnARandomPostcodeAndItsInformation.js b/examples/postcode/random/node/returnARandomPostcodeAndItsInformation.js new file mode 100755 index 0000000..71976a8 --- /dev/null +++ b/examples/postcode/random/node/returnARandomPostcodeAndItsInformation.js @@ -0,0 +1,12 @@ +import * as postcode from "m3o/postcode"; + +// Return a random postcode and its related info +async function ReturnArandomPostcodeAndItsInformation() { + let postcodeService = new postcode.PostcodeService( + process.env.MICRO_API_TOKEN + ); + let rsp = await postcodeService.random({}); + console.log(rsp); +} + +await ReturnArandomPostcodeAndItsInformation(); diff --git a/examples/postcode/validate/curl/returnARandomPostcodeAndItsInformation.sh b/examples/postcode/validate/curl/returnARandomPostcodeAndItsInformation.sh new file mode 100755 index 0000000..272d736 --- /dev/null +++ b/examples/postcode/validate/curl/returnARandomPostcodeAndItsInformation.sh @@ -0,0 +1,6 @@ +curl "https://api.m3o.com/v1/postcode/Validate" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "postcode": "SW1A 2AA" +}' \ No newline at end of file diff --git a/examples/postcode/validate/go/returnARandomPostcodeAndItsInformation.go b/examples/postcode/validate/go/returnARandomPostcodeAndItsInformation.go new file mode 100755 index 0000000..3c59dab --- /dev/null +++ b/examples/postcode/validate/go/returnARandomPostcodeAndItsInformation.go @@ -0,0 +1,16 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/postcode" + "os" +) + +// Validate a postcode. +func ReturnArandomPostcodeAndItsInformation() { + postcodeService := postcode.NewPostcodeService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := postcodeService.Validate(&postcode.ValidateRequest{ + Postcode: "SW1A 2AA", + }) + fmt.Println(rsp, err) +} diff --git a/examples/postcode/validate/node/returnARandomPostcodeAndItsInformation.js b/examples/postcode/validate/node/returnARandomPostcodeAndItsInformation.js new file mode 100755 index 0000000..22d9fd1 --- /dev/null +++ b/examples/postcode/validate/node/returnARandomPostcodeAndItsInformation.js @@ -0,0 +1,14 @@ +import * as postcode from "m3o/postcode"; + +// Validate a postcode. +async function ReturnArandomPostcodeAndItsInformation() { + let postcodeService = new postcode.PostcodeService( + process.env.MICRO_API_TOKEN + ); + let rsp = await postcodeService.validate({ + postcode: "SW1A 2AA", + }); + console.log(rsp); +} + +await ReturnArandomPostcodeAndItsInformation(); diff --git a/examples/quran/chapters/curl/listChapters.sh b/examples/quran/chapters/curl/listChapters.sh new file mode 100755 index 0000000..a313444 --- /dev/null +++ b/examples/quran/chapters/curl/listChapters.sh @@ -0,0 +1,6 @@ +curl "https://api.m3o.com/v1/quran/Chapters" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "language": "en" +}' \ No newline at end of file diff --git a/examples/quran/chapters/go/listChapters.go b/examples/quran/chapters/go/listChapters.go new file mode 100755 index 0000000..5a9b74b --- /dev/null +++ b/examples/quran/chapters/go/listChapters.go @@ -0,0 +1,16 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/quran" + "os" +) + +// List the Chapters (surahs) of the Quran +func ListChapters() { + quranService := quran.NewQuranService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := quranService.Chapters(&quran.ChaptersRequest{ + Language: "en", + }) + fmt.Println(rsp, err) +} diff --git a/examples/quran/chapters/node/listChapters.js b/examples/quran/chapters/node/listChapters.js new file mode 100755 index 0000000..163b1ec --- /dev/null +++ b/examples/quran/chapters/node/listChapters.js @@ -0,0 +1,12 @@ +import * as quran from "m3o/quran"; + +// List the Chapters (surahs) of the Quran +async function ListChapters() { + let quranService = new quran.QuranService(process.env.MICRO_API_TOKEN); + let rsp = await quranService.chapters({ + language: "en", + }); + console.log(rsp); +} + +await ListChapters(); diff --git a/examples/quran/search/curl/searchTheQuran.sh b/examples/quran/search/curl/searchTheQuran.sh new file mode 100755 index 0000000..a0e4367 --- /dev/null +++ b/examples/quran/search/curl/searchTheQuran.sh @@ -0,0 +1,6 @@ +curl "https://api.m3o.com/v1/quran/Search" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "query": "messenger" +}' \ No newline at end of file diff --git a/examples/quran/search/go/searchTheQuran.go b/examples/quran/search/go/searchTheQuran.go new file mode 100755 index 0000000..03970b5 --- /dev/null +++ b/examples/quran/search/go/searchTheQuran.go @@ -0,0 +1,16 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/quran" + "os" +) + +// Search the Quran for any form of query or questions +func SearchTheQuran() { + quranService := quran.NewQuranService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := quranService.Search(&quran.SearchRequest{ + Query: "messenger", + }) + fmt.Println(rsp, err) +} diff --git a/examples/quran/search/node/searchTheQuran.js b/examples/quran/search/node/searchTheQuran.js new file mode 100755 index 0000000..e8fc5d2 --- /dev/null +++ b/examples/quran/search/node/searchTheQuran.js @@ -0,0 +1,12 @@ +import * as quran from "m3o/quran"; + +// Search the Quran for any form of query or questions +async function SearchTheQuran() { + let quranService = new quran.QuranService(process.env.MICRO_API_TOKEN); + let rsp = await quranService.search({ + query: "messenger", + }); + console.log(rsp); +} + +await SearchTheQuran(); diff --git a/examples/quran/summary/curl/getChapterSummary.sh b/examples/quran/summary/curl/getChapterSummary.sh new file mode 100755 index 0000000..cb2d85d --- /dev/null +++ b/examples/quran/summary/curl/getChapterSummary.sh @@ -0,0 +1,6 @@ +curl "https://api.m3o.com/v1/quran/Summary" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "chapter": 1 +}' \ No newline at end of file diff --git a/examples/quran/summary/go/getChapterSummary.go b/examples/quran/summary/go/getChapterSummary.go new file mode 100755 index 0000000..cc6111a --- /dev/null +++ b/examples/quran/summary/go/getChapterSummary.go @@ -0,0 +1,16 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/quran" + "os" +) + +// Get a summary for a given chapter (surah) +func GetChapterSummary() { + quranService := quran.NewQuranService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := quranService.Summary(&quran.SummaryRequest{ + Chapter: 1, + }) + fmt.Println(rsp, err) +} diff --git a/examples/quran/summary/node/getChapterSummary.js b/examples/quran/summary/node/getChapterSummary.js new file mode 100755 index 0000000..59b6295 --- /dev/null +++ b/examples/quran/summary/node/getChapterSummary.js @@ -0,0 +1,12 @@ +import * as quran from "m3o/quran"; + +// Get a summary for a given chapter (surah) +async function GetChapterSummary() { + let quranService = new quran.QuranService(process.env.MICRO_API_TOKEN); + let rsp = await quranService.summary({ + chapter: 1, + }); + console.log(rsp); +} + +await GetChapterSummary(); diff --git a/examples/quran/verses/curl/getVersesOfAChapter.sh b/examples/quran/verses/curl/getVersesOfAChapter.sh new file mode 100755 index 0000000..8fcf18e --- /dev/null +++ b/examples/quran/verses/curl/getVersesOfAChapter.sh @@ -0,0 +1,6 @@ +curl "https://api.m3o.com/v1/quran/Verses" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "chapter": 1 +}' \ No newline at end of file diff --git a/examples/quran/verses/go/getVersesOfAChapter.go b/examples/quran/verses/go/getVersesOfAChapter.go new file mode 100755 index 0000000..1661d11 --- /dev/null +++ b/examples/quran/verses/go/getVersesOfAChapter.go @@ -0,0 +1,16 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/quran" + "os" +) + +// Lookup the verses (ayahs) for a chapter +func GetVersesOfAchapter() { + quranService := quran.NewQuranService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := quranService.Verses(&quran.VersesRequest{ + Chapter: 1, + }) + fmt.Println(rsp, err) +} diff --git a/examples/quran/verses/node/getVersesOfAChapter.js b/examples/quran/verses/node/getVersesOfAChapter.js new file mode 100755 index 0000000..abdf00d --- /dev/null +++ b/examples/quran/verses/node/getVersesOfAChapter.js @@ -0,0 +1,12 @@ +import * as quran from "m3o/quran"; + +// Lookup the verses (ayahs) for a chapter +async function GetVersesOfAchapter() { + let quranService = new quran.QuranService(process.env.MICRO_API_TOKEN); + let rsp = await quranService.verses({ + chapter: 1, + }); + console.log(rsp); +} + +await GetVersesOfAchapter(); diff --git a/examples/routing/directions/curl/turnByTurnDirections.sh b/examples/routing/directions/curl/turnByTurnDirections.sh new file mode 100755 index 0000000..c6b60ff --- /dev/null +++ b/examples/routing/directions/curl/turnByTurnDirections.sh @@ -0,0 +1,13 @@ +curl "https://api.m3o.com/v1/routing/Directions" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "destination": { + "latitude": 52.529407, + "longitude": 13.397634 + }, + "origin": { + "latitude": 52.517037, + "longitude": 13.38886 + } +}' \ No newline at end of file diff --git a/examples/routing/directions/go/turnByTurnDirections.go b/examples/routing/directions/go/turnByTurnDirections.go new file mode 100755 index 0000000..8b19a96 --- /dev/null +++ b/examples/routing/directions/go/turnByTurnDirections.go @@ -0,0 +1,23 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/routing" + "os" +) + +// Turn by turn directions from a start point to an end point including maneuvers and bearings +func TurnByTurnDirections() { + routingService := routing.NewRoutingService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := routingService.Directions(&routing.DirectionsRequest{ + Destination: &routing.Point{ + Latitude: 52.529407, + Longitude: 13.397634, + }, + Origin: &routing.Point{ + Latitude: 52.517037, + Longitude: 13.38886, + }, + }) + fmt.Println(rsp, err) +} diff --git a/examples/routing/directions/node/turnByTurnDirections.js b/examples/routing/directions/node/turnByTurnDirections.js new file mode 100755 index 0000000..09267ee --- /dev/null +++ b/examples/routing/directions/node/turnByTurnDirections.js @@ -0,0 +1,19 @@ +import * as routing from "m3o/routing"; + +// Turn by turn directions from a start point to an end point including maneuvers and bearings +async function TurnByTurnDirections() { + let routingService = new routing.RoutingService(process.env.MICRO_API_TOKEN); + let rsp = await routingService.directions({ + destination: { + latitude: 52.529407, + longitude: 13.397634, + }, + origin: { + latitude: 52.517037, + longitude: 13.38886, + }, + }); + console.log(rsp); +} + +await TurnByTurnDirections(); diff --git a/examples/routing/eta/curl/etaFromPointAToPointB.sh b/examples/routing/eta/curl/etaFromPointAToPointB.sh new file mode 100755 index 0000000..d6a38c9 --- /dev/null +++ b/examples/routing/eta/curl/etaFromPointAToPointB.sh @@ -0,0 +1,13 @@ +curl "https://api.m3o.com/v1/routing/Eta" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "destination": { + "latitude": 52.529407, + "longitude": 13.397634 + }, + "origin": { + "latitude": 52.517037, + "longitude": 13.38886 + } +}' \ No newline at end of file diff --git a/examples/routing/eta/go/etaFromPointAToPointB.go b/examples/routing/eta/go/etaFromPointAToPointB.go new file mode 100755 index 0000000..183f639 --- /dev/null +++ b/examples/routing/eta/go/etaFromPointAToPointB.go @@ -0,0 +1,23 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/routing" + "os" +) + +// Get the eta for a route from origin to destination. The eta is an estimated time based on car routes +func EtaFromPointAtoPointB() { + routingService := routing.NewRoutingService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := routingService.Eta(&routing.EtaRequest{ + Destination: &routing.Point{ + Latitude: 52.529407, + Longitude: 13.397634, + }, + Origin: &routing.Point{ + Latitude: 52.517037, + Longitude: 13.38886, + }, + }) + fmt.Println(rsp, err) +} diff --git a/examples/routing/eta/node/etaFromPointAToPointB.js b/examples/routing/eta/node/etaFromPointAToPointB.js new file mode 100755 index 0000000..aea195d --- /dev/null +++ b/examples/routing/eta/node/etaFromPointAToPointB.js @@ -0,0 +1,19 @@ +import * as routing from "m3o/routing"; + +// Get the eta for a route from origin to destination. The eta is an estimated time based on car routes +async function EtaFromPointAtoPointB() { + let routingService = new routing.RoutingService(process.env.MICRO_API_TOKEN); + let rsp = await routingService.eta({ + destination: { + latitude: 52.529407, + longitude: 13.397634, + }, + origin: { + latitude: 52.517037, + longitude: 13.38886, + }, + }); + console.log(rsp); +} + +await EtaFromPointAtoPointB(); diff --git a/examples/routing/route/curl/gpsPointsForARoute.sh b/examples/routing/route/curl/gpsPointsForARoute.sh new file mode 100755 index 0000000..3e448d7 --- /dev/null +++ b/examples/routing/route/curl/gpsPointsForARoute.sh @@ -0,0 +1,13 @@ +curl "https://api.m3o.com/v1/routing/Route" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "destination": { + "latitude": 52.529407, + "longitude": 13.397634 + }, + "origin": { + "latitude": 52.517037, + "longitude": 13.38886 + } +}' \ No newline at end of file diff --git a/examples/routing/route/go/gpsPointsForARoute.go b/examples/routing/route/go/gpsPointsForARoute.go new file mode 100755 index 0000000..63008ed --- /dev/null +++ b/examples/routing/route/go/gpsPointsForARoute.go @@ -0,0 +1,23 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/routing" + "os" +) + +// Retrieve a route as a simple list of gps points along with total distance and estimated duration +func GpsPointsForAroute() { + routingService := routing.NewRoutingService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := routingService.Route(&routing.RouteRequest{ + Destination: &routing.Point{ + Latitude: 52.529407, + Longitude: 13.397634, + }, + Origin: &routing.Point{ + Latitude: 52.517037, + Longitude: 13.38886, + }, + }) + fmt.Println(rsp, err) +} diff --git a/examples/routing/route/node/gpsPointsForARoute.js b/examples/routing/route/node/gpsPointsForARoute.js new file mode 100755 index 0000000..5135434 --- /dev/null +++ b/examples/routing/route/node/gpsPointsForARoute.js @@ -0,0 +1,19 @@ +import * as routing from "m3o/routing"; + +// Retrieve a route as a simple list of gps points along with total distance and estimated duration +async function GpsPointsForAroute() { + let routingService = new routing.RoutingService(process.env.MICRO_API_TOKEN); + let rsp = await routingService.route({ + destination: { + latitude: 52.529407, + longitude: 13.397634, + }, + origin: { + latitude: 52.517037, + longitude: 13.38886, + }, + }); + console.log(rsp); +} + +await GpsPointsForAroute(); diff --git a/examples/rss/add/curl/addANewFeed.sh b/examples/rss/add/curl/addANewFeed.sh new file mode 100755 index 0000000..1ec08f4 --- /dev/null +++ b/examples/rss/add/curl/addANewFeed.sh @@ -0,0 +1,8 @@ +curl "https://api.m3o.com/v1/rss/Add" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "category": "news", + "name": "bbc", + "url": "http://feeds.bbci.co.uk/news/rss.xml" +}' \ No newline at end of file diff --git a/examples/rss/add/go/addANewFeed.go b/examples/rss/add/go/addANewFeed.go new file mode 100755 index 0000000..45746aa --- /dev/null +++ b/examples/rss/add/go/addANewFeed.go @@ -0,0 +1,18 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/rss" + "os" +) + +// Add a new RSS feed with a name, url, and category +func AddAnewFeed() { + rssService := rss.NewRssService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := rssService.Add(&rss.AddRequest{ + Category: "news", + Name: "bbc", + Url: "http://feeds.bbci.co.uk/news/rss.xml", + }) + fmt.Println(rsp, err) +} diff --git a/examples/rss/add/node/addANewFeed.js b/examples/rss/add/node/addANewFeed.js new file mode 100755 index 0000000..637b612 --- /dev/null +++ b/examples/rss/add/node/addANewFeed.js @@ -0,0 +1,14 @@ +import * as rss from "m3o/rss"; + +// Add a new RSS feed with a name, url, and category +async function AddAnewFeed() { + let rssService = new rss.RssService(process.env.MICRO_API_TOKEN); + let rsp = await rssService.add({ + category: "news", + name: "bbc", + url: "http://feeds.bbci.co.uk/news/rss.xml", + }); + console.log(rsp); +} + +await AddAnewFeed(); diff --git a/examples/rss/feed/curl/readAFeed.sh b/examples/rss/feed/curl/readAFeed.sh new file mode 100755 index 0000000..a768f9c --- /dev/null +++ b/examples/rss/feed/curl/readAFeed.sh @@ -0,0 +1,6 @@ +curl "https://api.m3o.com/v1/rss/Feed" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "name": "bbc" +}' \ No newline at end of file diff --git a/examples/rss/feed/go/readAFeed.go b/examples/rss/feed/go/readAFeed.go new file mode 100755 index 0000000..4b7efd6 --- /dev/null +++ b/examples/rss/feed/go/readAFeed.go @@ -0,0 +1,16 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/rss" + "os" +) + +// Get an RSS feed by name. If no name is given, all feeds are returned. Default limit is 25 entries. +func ReadAfeed() { + rssService := rss.NewRssService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := rssService.Feed(&rss.FeedRequest{ + Name: "bbc", + }) + fmt.Println(rsp, err) +} diff --git a/examples/rss/feed/node/readAFeed.js b/examples/rss/feed/node/readAFeed.js new file mode 100755 index 0000000..09bd84e --- /dev/null +++ b/examples/rss/feed/node/readAFeed.js @@ -0,0 +1,12 @@ +import * as rss from "m3o/rss"; + +// Get an RSS feed by name. If no name is given, all feeds are returned. Default limit is 25 entries. +async function ReadAfeed() { + let rssService = new rss.RssService(process.env.MICRO_API_TOKEN); + let rsp = await rssService.feed({ + name: "bbc", + }); + console.log(rsp); +} + +await ReadAfeed(); diff --git a/examples/rss/list/curl/listRssFeeds.sh b/examples/rss/list/curl/listRssFeeds.sh new file mode 100755 index 0000000..57e53cb --- /dev/null +++ b/examples/rss/list/curl/listRssFeeds.sh @@ -0,0 +1,4 @@ +curl "https://api.m3o.com/v1/rss/List" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{}' \ No newline at end of file diff --git a/examples/rss/list/go/listRssFeeds.go b/examples/rss/list/go/listRssFeeds.go new file mode 100755 index 0000000..9a97a7d --- /dev/null +++ b/examples/rss/list/go/listRssFeeds.go @@ -0,0 +1,14 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/rss" + "os" +) + +// List the saved RSS fields +func ListRssFeeds() { + rssService := rss.NewRssService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := rssService.List(&rss.ListRequest{}) + fmt.Println(rsp, err) +} diff --git a/examples/rss/list/node/listRssFeeds.js b/examples/rss/list/node/listRssFeeds.js new file mode 100755 index 0000000..0fae051 --- /dev/null +++ b/examples/rss/list/node/listRssFeeds.js @@ -0,0 +1,10 @@ +import * as rss from "m3o/rss"; + +// List the saved RSS fields +async function ListRssFeeds() { + let rssService = new rss.RssService(process.env.MICRO_API_TOKEN); + let rsp = await rssService.list({}); + console.log(rsp); +} + +await ListRssFeeds(); diff --git a/examples/rss/remove/curl/removeAFeed.sh b/examples/rss/remove/curl/removeAFeed.sh new file mode 100755 index 0000000..ca7a07d --- /dev/null +++ b/examples/rss/remove/curl/removeAFeed.sh @@ -0,0 +1,6 @@ +curl "https://api.m3o.com/v1/rss/Remove" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "name": "bbc" +}' \ No newline at end of file diff --git a/examples/rss/remove/go/removeAFeed.go b/examples/rss/remove/go/removeAFeed.go new file mode 100755 index 0000000..09e3137 --- /dev/null +++ b/examples/rss/remove/go/removeAFeed.go @@ -0,0 +1,16 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/rss" + "os" +) + +// Remove an RSS feed by name +func RemoveAfeed() { + rssService := rss.NewRssService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := rssService.Remove(&rss.RemoveRequest{ + Name: "bbc", + }) + fmt.Println(rsp, err) +} diff --git a/examples/rss/remove/node/removeAFeed.js b/examples/rss/remove/node/removeAFeed.js new file mode 100755 index 0000000..a887166 --- /dev/null +++ b/examples/rss/remove/node/removeAFeed.js @@ -0,0 +1,12 @@ +import * as rss from "m3o/rss"; + +// Remove an RSS feed by name +async function RemoveAfeed() { + let rssService = new rss.RssService(process.env.MICRO_API_TOKEN); + let rsp = await rssService.remove({ + name: "bbc", + }); + console.log(rsp); +} + +await RemoveAfeed(); diff --git a/examples/sentiment/analyze/curl/analyzeAPieceOfText.sh b/examples/sentiment/analyze/curl/analyzeAPieceOfText.sh new file mode 100755 index 0000000..8df9ed0 --- /dev/null +++ b/examples/sentiment/analyze/curl/analyzeAPieceOfText.sh @@ -0,0 +1,6 @@ +curl "https://api.m3o.com/v1/sentiment/Analyze" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "text": "this is amazing" +}' \ No newline at end of file diff --git a/examples/sentiment/analyze/go/analyzeAPieceOfText.go b/examples/sentiment/analyze/go/analyzeAPieceOfText.go new file mode 100755 index 0000000..8d5f704 --- /dev/null +++ b/examples/sentiment/analyze/go/analyzeAPieceOfText.go @@ -0,0 +1,16 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/sentiment" + "os" +) + +// Analyze and score a piece of text +func AnalyzeApieceOfText() { + sentimentService := sentiment.NewSentimentService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := sentimentService.Analyze(&sentiment.AnalyzeRequest{ + Text: "this is amazing", + }) + fmt.Println(rsp, err) +} diff --git a/examples/sentiment/analyze/node/analyzeAPieceOfText.js b/examples/sentiment/analyze/node/analyzeAPieceOfText.js new file mode 100755 index 0000000..2d85a17 --- /dev/null +++ b/examples/sentiment/analyze/node/analyzeAPieceOfText.js @@ -0,0 +1,14 @@ +import * as sentiment from "m3o/sentiment"; + +// Analyze and score a piece of text +async function AnalyzeApieceOfText() { + let sentimentService = new sentiment.SentimentService( + process.env.MICRO_API_TOKEN + ); + let rsp = await sentimentService.analyze({ + text: "this is amazing", + }); + console.log(rsp); +} + +await AnalyzeApieceOfText(); diff --git a/examples/sms/send/curl/sendSms.sh b/examples/sms/send/curl/sendSms.sh new file mode 100755 index 0000000..d271ffc --- /dev/null +++ b/examples/sms/send/curl/sendSms.sh @@ -0,0 +1,8 @@ +curl "https://api.m3o.com/v1/sms/Send" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "from": "Alice", + "message": "Hi there!", + "to": "+447681129" +}' \ No newline at end of file diff --git a/examples/sms/send/go/sendSms.go b/examples/sms/send/go/sendSms.go new file mode 100755 index 0000000..4c5322f --- /dev/null +++ b/examples/sms/send/go/sendSms.go @@ -0,0 +1,18 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/sms" + "os" +) + +// Send an SMS. +func SendSms() { + smsService := sms.NewSmsService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := smsService.Send(&sms.SendRequest{ + From: "Alice", + Message: "Hi there!", + To: "+447681129", + }) + fmt.Println(rsp, err) +} diff --git a/examples/sms/send/node/sendSms.js b/examples/sms/send/node/sendSms.js new file mode 100755 index 0000000..759020b --- /dev/null +++ b/examples/sms/send/node/sendSms.js @@ -0,0 +1,14 @@ +import * as sms from "m3o/sms"; + +// Send an SMS. +async function SendSms() { + let smsService = new sms.SmsService(process.env.MICRO_API_TOKEN); + let rsp = await smsService.send({ + from: "Alice", + message: "Hi there!", + to: "+447681129", + }); + console.log(rsp); +} + +await SendSms(); diff --git a/examples/stock/history/curl/getHistoricData.sh b/examples/stock/history/curl/getHistoricData.sh new file mode 100755 index 0000000..ff57bc5 --- /dev/null +++ b/examples/stock/history/curl/getHistoricData.sh @@ -0,0 +1,7 @@ +curl "https://api.m3o.com/v1/stock/History" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "date": "2020-10-01", + "stock": "AAPL" +}' \ No newline at end of file diff --git a/examples/stock/history/go/getHistoricData.go b/examples/stock/history/go/getHistoricData.go new file mode 100755 index 0000000..12027ed --- /dev/null +++ b/examples/stock/history/go/getHistoricData.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/stock" + "os" +) + +// Get the historic open-close for a given day +func GetHistoricData() { + stockService := stock.NewStockService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := stockService.History(&stock.HistoryRequest{ + Date: "2020-10-01", + Stock: "AAPL", + }) + fmt.Println(rsp, err) +} diff --git a/examples/stock/history/node/getHistoricData.js b/examples/stock/history/node/getHistoricData.js new file mode 100755 index 0000000..1f3e275 --- /dev/null +++ b/examples/stock/history/node/getHistoricData.js @@ -0,0 +1,13 @@ +import * as stock from "m3o/stock"; + +// Get the historic open-close for a given day +async function GetHistoricData() { + let stockService = new stock.StockService(process.env.MICRO_API_TOKEN); + let rsp = await stockService.history({ + date: "2020-10-01", + stock: "AAPL", + }); + console.log(rsp); +} + +await GetHistoricData(); diff --git a/examples/stock/orderBook/curl/orderBookHistory.sh b/examples/stock/orderBook/curl/orderBookHistory.sh new file mode 100755 index 0000000..19dda17 --- /dev/null +++ b/examples/stock/orderBook/curl/orderBookHistory.sh @@ -0,0 +1,10 @@ +curl "https://api.m3o.com/v1/stock/OrderBook" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "date": "2020-10-01", + "end": "2020-10-01T11:00:00Z", + "limit": 3, + "start": "2020-10-01T10:00:00Z", + "stock": "AAPL" +}' \ No newline at end of file diff --git a/examples/stock/orderBook/go/orderBookHistory.go b/examples/stock/orderBook/go/orderBookHistory.go new file mode 100755 index 0000000..a59897f --- /dev/null +++ b/examples/stock/orderBook/go/orderBookHistory.go @@ -0,0 +1,20 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/stock" + "os" +) + +// Get the historic order book and each trade by timestamp +func OrderBookHistory() { + stockService := stock.NewStockService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := stockService.OrderBook(&stock.OrderBookRequest{ + Date: "2020-10-01", + End: "2020-10-01T11:00:00Z", + Limit: 3, + Start: "2020-10-01T10:00:00Z", + Stock: "AAPL", + }) + fmt.Println(rsp, err) +} diff --git a/examples/stock/orderBook/node/orderBookHistory.js b/examples/stock/orderBook/node/orderBookHistory.js new file mode 100755 index 0000000..3161f41 --- /dev/null +++ b/examples/stock/orderBook/node/orderBookHistory.js @@ -0,0 +1,16 @@ +import * as stock from "m3o/stock"; + +// Get the historic order book and each trade by timestamp +async function OrderBookHistory() { + let stockService = new stock.StockService(process.env.MICRO_API_TOKEN); + let rsp = await stockService.orderBook({ + date: "2020-10-01", + end: "2020-10-01T11:00:00Z", + limit: 3, + start: "2020-10-01T10:00:00Z", + stock: "AAPL", + }); + console.log(rsp); +} + +await OrderBookHistory(); diff --git a/examples/stock/price/curl/getAStockPrice.sh b/examples/stock/price/curl/getAStockPrice.sh new file mode 100755 index 0000000..9c97c1d --- /dev/null +++ b/examples/stock/price/curl/getAStockPrice.sh @@ -0,0 +1,6 @@ +curl "https://api.m3o.com/v1/stock/Price" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "symbol": "AAPL" +}' \ No newline at end of file diff --git a/examples/stock/price/go/getAStockPrice.go b/examples/stock/price/go/getAStockPrice.go new file mode 100755 index 0000000..ae055c7 --- /dev/null +++ b/examples/stock/price/go/getAStockPrice.go @@ -0,0 +1,16 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/stock" + "os" +) + +// Get the last price for a given stock ticker +func GetAstockPrice() { + stockService := stock.NewStockService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := stockService.Price(&stock.PriceRequest{ + Symbol: "AAPL", + }) + fmt.Println(rsp, err) +} diff --git a/examples/stock/price/node/getAStockPrice.js b/examples/stock/price/node/getAStockPrice.js new file mode 100755 index 0000000..fb5f46f --- /dev/null +++ b/examples/stock/price/node/getAStockPrice.js @@ -0,0 +1,12 @@ +import * as stock from "m3o/stock"; + +// Get the last price for a given stock ticker +async function GetAstockPrice() { + let stockService = new stock.StockService(process.env.MICRO_API_TOKEN); + let rsp = await stockService.price({ + symbol: "AAPL", + }); + console.log(rsp); +} + +await GetAstockPrice(); diff --git a/examples/stock/quote/curl/getAStockQuote.sh b/examples/stock/quote/curl/getAStockQuote.sh new file mode 100755 index 0000000..85cb2c4 --- /dev/null +++ b/examples/stock/quote/curl/getAStockQuote.sh @@ -0,0 +1,6 @@ +curl "https://api.m3o.com/v1/stock/Quote" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "symbol": "AAPL" +}' \ No newline at end of file diff --git a/examples/stock/quote/go/getAStockQuote.go b/examples/stock/quote/go/getAStockQuote.go new file mode 100755 index 0000000..d6fbbda --- /dev/null +++ b/examples/stock/quote/go/getAStockQuote.go @@ -0,0 +1,16 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/stock" + "os" +) + +// Get the last quote for the stock +func GetAstockQuote() { + stockService := stock.NewStockService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := stockService.Quote(&stock.QuoteRequest{ + Symbol: "AAPL", + }) + fmt.Println(rsp, err) +} diff --git a/examples/stock/quote/node/getAStockQuote.js b/examples/stock/quote/node/getAStockQuote.js new file mode 100755 index 0000000..c61ff8a --- /dev/null +++ b/examples/stock/quote/node/getAStockQuote.js @@ -0,0 +1,12 @@ +import * as stock from "m3o/stock"; + +// Get the last quote for the stock +async function GetAstockQuote() { + let stockService = new stock.StockService(process.env.MICRO_API_TOKEN); + let rsp = await stockService.quote({ + symbol: "AAPL", + }); + console.log(rsp); +} + +await GetAstockQuote(); diff --git a/examples/stream/publish/curl/publishAMessage.sh b/examples/stream/publish/curl/publishAMessage.sh new file mode 100755 index 0000000..d4b145e --- /dev/null +++ b/examples/stream/publish/curl/publishAMessage.sh @@ -0,0 +1,11 @@ +curl "https://api.m3o.com/v1/stream/Publish" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "message": { + "id": "1", + "type": "signup", + "user": "john" + }, + "topic": "events" +}' \ No newline at end of file diff --git a/examples/stream/publish/go/publishAMessage.go b/examples/stream/publish/go/publishAMessage.go new file mode 100755 index 0000000..af88ee1 --- /dev/null +++ b/examples/stream/publish/go/publishAMessage.go @@ -0,0 +1,21 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/stream" + "os" +) + +// Publish a message to the stream. Specify a topic to group messages for a specific topic. +func PublishAmessage() { + streamService := stream.NewStreamService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := streamService.Publish(&stream.PublishRequest{ + Message: map[string]interface{}{ + "id": "1", + "type": "signup", + "user": "john", + }, + Topic: "events", + }) + fmt.Println(rsp, err) +} diff --git a/examples/stream/publish/node/publishAMessage.js b/examples/stream/publish/node/publishAMessage.js new file mode 100755 index 0000000..25d900f --- /dev/null +++ b/examples/stream/publish/node/publishAMessage.js @@ -0,0 +1,17 @@ +import * as stream from "m3o/stream"; + +// Publish a message to the stream. Specify a topic to group messages for a specific topic. +async function PublishAmessage() { + let streamService = new stream.StreamService(process.env.MICRO_API_TOKEN); + let rsp = await streamService.publish({ + message: { + id: "1", + type: "signup", + user: "john", + }, + topic: "events", + }); + console.log(rsp); +} + +await PublishAmessage(); diff --git a/examples/thumbnail/screenshot/curl/takeScreenshotOfAUrl.sh b/examples/thumbnail/screenshot/curl/takeScreenshotOfAUrl.sh new file mode 100755 index 0000000..a67be2a --- /dev/null +++ b/examples/thumbnail/screenshot/curl/takeScreenshotOfAUrl.sh @@ -0,0 +1,8 @@ +curl "https://api.m3o.com/v1/thumbnail/Screenshot" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "height": 600, + "url": "https://m3o.com", + "width": 600 +}' \ No newline at end of file diff --git a/examples/thumbnail/screenshot/go/takeScreenshotOfAUrl.go b/examples/thumbnail/screenshot/go/takeScreenshotOfAUrl.go new file mode 100755 index 0000000..d6a63b7 --- /dev/null +++ b/examples/thumbnail/screenshot/go/takeScreenshotOfAUrl.go @@ -0,0 +1,18 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/thumbnail" + "os" +) + +// Create a thumbnail screenshot by passing in a url, height and width +func TakeScreenshotOfAurl() { + thumbnailService := thumbnail.NewThumbnailService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := thumbnailService.Screenshot(&thumbnail.ScreenshotRequest{ + Height: 600, + Url: "https://m3o.com", + Width: 600, + }) + fmt.Println(rsp, err) +} diff --git a/examples/thumbnail/screenshot/node/takeScreenshotOfAUrl.js b/examples/thumbnail/screenshot/node/takeScreenshotOfAUrl.js new file mode 100755 index 0000000..8ef83d3 --- /dev/null +++ b/examples/thumbnail/screenshot/node/takeScreenshotOfAUrl.js @@ -0,0 +1,16 @@ +import * as thumbnail from "m3o/thumbnail"; + +// Create a thumbnail screenshot by passing in a url, height and width +async function TakeScreenshotOfAurl() { + let thumbnailService = new thumbnail.ThumbnailService( + process.env.MICRO_API_TOKEN + ); + let rsp = await thumbnailService.screenshot({ + height: 600, + url: "https://m3o.com", + width: 600, + }); + console.log(rsp); +} + +await TakeScreenshotOfAurl(); diff --git a/examples/time/now/curl/returnsCurrentTimeOptionallyWithLocation.sh b/examples/time/now/curl/returnsCurrentTimeOptionallyWithLocation.sh new file mode 100755 index 0000000..482401c --- /dev/null +++ b/examples/time/now/curl/returnsCurrentTimeOptionallyWithLocation.sh @@ -0,0 +1,4 @@ +curl "https://api.m3o.com/v1/time/Now" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{}' \ No newline at end of file diff --git a/examples/time/now/go/returnsCurrentTimeOptionallyWithLocation.go b/examples/time/now/go/returnsCurrentTimeOptionallyWithLocation.go new file mode 100755 index 0000000..6fb33a9 --- /dev/null +++ b/examples/time/now/go/returnsCurrentTimeOptionallyWithLocation.go @@ -0,0 +1,14 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/time" + "os" +) + +// Get the current time +func ReturnsCurrentTimeOptionallyWithLocation() { + timeService := time.NewTimeService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := timeService.Now(&time.NowRequest{}) + fmt.Println(rsp, err) +} diff --git a/examples/time/now/node/returnsCurrentTimeOptionallyWithLocation.js b/examples/time/now/node/returnsCurrentTimeOptionallyWithLocation.js new file mode 100755 index 0000000..d932bcc --- /dev/null +++ b/examples/time/now/node/returnsCurrentTimeOptionallyWithLocation.js @@ -0,0 +1,10 @@ +import * as time from "m3o/time"; + +// Get the current time +async function ReturnsCurrentTimeOptionallyWithLocation() { + let timeService = new time.TimeService(process.env.MICRO_API_TOKEN); + let rsp = await timeService.now({}); + console.log(rsp); +} + +await ReturnsCurrentTimeOptionallyWithLocation(); diff --git a/examples/time/zone/curl/getTheTimezoneInfoForASpecificLocation.sh b/examples/time/zone/curl/getTheTimezoneInfoForASpecificLocation.sh new file mode 100755 index 0000000..ee94d8f --- /dev/null +++ b/examples/time/zone/curl/getTheTimezoneInfoForASpecificLocation.sh @@ -0,0 +1,6 @@ +curl "https://api.m3o.com/v1/time/Zone" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "location": "London" +}' \ No newline at end of file diff --git a/examples/time/zone/go/getTheTimezoneInfoForASpecificLocation.go b/examples/time/zone/go/getTheTimezoneInfoForASpecificLocation.go new file mode 100755 index 0000000..c98a6a0 --- /dev/null +++ b/examples/time/zone/go/getTheTimezoneInfoForASpecificLocation.go @@ -0,0 +1,16 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/time" + "os" +) + +// Get the timezone info for a specific location +func GetTheTimezoneInfoForAspecificLocation() { + timeService := time.NewTimeService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := timeService.Zone(&time.ZoneRequest{ + Location: "London", + }) + fmt.Println(rsp, err) +} diff --git a/examples/time/zone/node/getTheTimezoneInfoForASpecificLocation.js b/examples/time/zone/node/getTheTimezoneInfoForASpecificLocation.js new file mode 100755 index 0000000..2d670f3 --- /dev/null +++ b/examples/time/zone/node/getTheTimezoneInfoForASpecificLocation.js @@ -0,0 +1,12 @@ +import * as time from "m3o/time"; + +// Get the timezone info for a specific location +async function GetTheTimezoneInfoForAspecificLocation() { + let timeService = new time.TimeService(process.env.MICRO_API_TOKEN); + let rsp = await timeService.zone({ + location: "London", + }); + console.log(rsp); +} + +await GetTheTimezoneInfoForAspecificLocation(); diff --git a/examples/url/list/curl/listYourShortenedUrls.sh b/examples/url/list/curl/listYourShortenedUrls.sh new file mode 100755 index 0000000..25a070a --- /dev/null +++ b/examples/url/list/curl/listYourShortenedUrls.sh @@ -0,0 +1,4 @@ +curl "https://api.m3o.com/v1/url/List" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{}' \ No newline at end of file diff --git a/examples/url/list/go/listYourShortenedUrls.go b/examples/url/list/go/listYourShortenedUrls.go new file mode 100755 index 0000000..ae51144 --- /dev/null +++ b/examples/url/list/go/listYourShortenedUrls.go @@ -0,0 +1,14 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/url" + "os" +) + +// List information on all the shortened URLs that you have created +func ListYourShortenedUrls() { + urlService := url.NewUrlService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := urlService.List(&url.ListRequest{}) + fmt.Println(rsp, err) +} diff --git a/examples/url/list/node/listYourShortenedUrls.js b/examples/url/list/node/listYourShortenedUrls.js new file mode 100755 index 0000000..2879c08 --- /dev/null +++ b/examples/url/list/node/listYourShortenedUrls.js @@ -0,0 +1,10 @@ +import * as url from "m3o/url"; + +// List information on all the shortened URLs that you have created +async function ListYourShortenedUrls() { + let urlService = new url.UrlService(process.env.MICRO_API_TOKEN); + let rsp = await urlService.list({}); + console.log(rsp); +} + +await ListYourShortenedUrls(); diff --git a/examples/url/proxy/curl/resolveAShortUrlToALongDestinationUrl.sh b/examples/url/proxy/curl/resolveAShortUrlToALongDestinationUrl.sh new file mode 100755 index 0000000..7922557 --- /dev/null +++ b/examples/url/proxy/curl/resolveAShortUrlToALongDestinationUrl.sh @@ -0,0 +1,6 @@ +curl "https://api.m3o.com/v1/url/Proxy" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "shortURL": "https://m3o.one/u/ck6SGVkYp" +}' \ No newline at end of file diff --git a/examples/url/proxy/go/resolveAShortUrlToALongDestinationUrl.go b/examples/url/proxy/go/resolveAShortUrlToALongDestinationUrl.go new file mode 100755 index 0000000..f176a53 --- /dev/null +++ b/examples/url/proxy/go/resolveAShortUrlToALongDestinationUrl.go @@ -0,0 +1,14 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/url" + "os" +) + +// Proxy returns the destination URL of a short URL. +func ResolveAshortUrlToAlongDestinationUrl() { + urlService := url.NewUrlService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := urlService.Proxy(&url.ProxyRequest{}) + fmt.Println(rsp, err) +} diff --git a/examples/url/proxy/node/resolveAShortUrlToALongDestinationUrl.js b/examples/url/proxy/node/resolveAShortUrlToALongDestinationUrl.js new file mode 100755 index 0000000..9f5dd8a --- /dev/null +++ b/examples/url/proxy/node/resolveAShortUrlToALongDestinationUrl.js @@ -0,0 +1,12 @@ +import * as url from "m3o/url"; + +// Proxy returns the destination URL of a short URL. +async function ResolveAshortUrlToAlongDestinationUrl() { + let urlService = new url.UrlService(process.env.MICRO_API_TOKEN); + let rsp = await urlService.proxy({ + shortURL: "https://m3o.one/u/ck6SGVkYp", + }); + console.log(rsp); +} + +await ResolveAshortUrlToAlongDestinationUrl(); diff --git a/examples/url/shorten/curl/shortenALongUrl.sh b/examples/url/shorten/curl/shortenALongUrl.sh new file mode 100755 index 0000000..ea71e39 --- /dev/null +++ b/examples/url/shorten/curl/shortenALongUrl.sh @@ -0,0 +1,6 @@ +curl "https://api.m3o.com/v1/url/Shorten" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "destinationURL": "https://mysite.com/this-is-a-rather-long-web-address" +}' \ No newline at end of file diff --git a/examples/url/shorten/go/shortenALongUrl.go b/examples/url/shorten/go/shortenALongUrl.go new file mode 100755 index 0000000..4490097 --- /dev/null +++ b/examples/url/shorten/go/shortenALongUrl.go @@ -0,0 +1,14 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/url" + "os" +) + +// Shortens a destination URL and returns a full short URL. +func ShortenAlongUrl() { + urlService := url.NewUrlService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := urlService.Shorten(&url.ShortenRequest{}) + fmt.Println(rsp, err) +} diff --git a/examples/url/shorten/node/shortenALongUrl.js b/examples/url/shorten/node/shortenALongUrl.js new file mode 100755 index 0000000..ede0045 --- /dev/null +++ b/examples/url/shorten/node/shortenALongUrl.js @@ -0,0 +1,12 @@ +import * as url from "m3o/url"; + +// Shortens a destination URL and returns a full short URL. +async function ShortenAlongUrl() { + let urlService = new url.UrlService(process.env.MICRO_API_TOKEN); + let rsp = await urlService.shorten({ + destinationURL: "https://mysite.com/this-is-a-rather-long-web-address", + }); + console.log(rsp); +} + +await ShortenAlongUrl(); diff --git a/examples/user/create/curl/createAnAccount.sh b/examples/user/create/curl/createAnAccount.sh new file mode 100755 index 0000000..d80e21e --- /dev/null +++ b/examples/user/create/curl/createAnAccount.sh @@ -0,0 +1,9 @@ +curl "https://api.m3o.com/v1/user/Create" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "email": "joe@example.com", + "id": "usrid-1", + "password": "mySecretPass123", + "username": "usrname-1" +}' \ No newline at end of file diff --git a/examples/user/create/go/createAnAccount.go b/examples/user/create/go/createAnAccount.go new file mode 100755 index 0000000..6cd5e1f --- /dev/null +++ b/examples/user/create/go/createAnAccount.go @@ -0,0 +1,19 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/user" + "os" +) + +// Create a new user account. The email address and username for the account must be unique. +func CreateAnAccount() { + userService := user.NewUserService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := userService.Create(&user.CreateRequest{ + Email: "joe@example.com", + Id: "usrid-1", + Password: "mySecretPass123", + Username: "usrname-1", + }) + fmt.Println(rsp, err) +} diff --git a/examples/user/create/node/createAnAccount.js b/examples/user/create/node/createAnAccount.js new file mode 100755 index 0000000..80a755f --- /dev/null +++ b/examples/user/create/node/createAnAccount.js @@ -0,0 +1,15 @@ +import * as user from "m3o/user"; + +// Create a new user account. The email address and username for the account must be unique. +async function CreateAnAccount() { + let userService = new user.UserService(process.env.MICRO_API_TOKEN); + let rsp = await userService.create({ + email: "joe@example.com", + id: "usrid-1", + password: "mySecretPass123", + username: "usrname-1", + }); + console.log(rsp); +} + +await CreateAnAccount(); diff --git a/examples/user/delete/curl/deleteUserAccount.sh b/examples/user/delete/curl/deleteUserAccount.sh new file mode 100755 index 0000000..7fe2832 --- /dev/null +++ b/examples/user/delete/curl/deleteUserAccount.sh @@ -0,0 +1,6 @@ +curl "https://api.m3o.com/v1/user/Delete" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "id": "fdf34f34f34-f34f34-f43f43f34-f4f34f" +}' \ No newline at end of file diff --git a/examples/user/delete/go/deleteUserAccount.go b/examples/user/delete/go/deleteUserAccount.go new file mode 100755 index 0000000..05995b4 --- /dev/null +++ b/examples/user/delete/go/deleteUserAccount.go @@ -0,0 +1,16 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/user" + "os" +) + +// Delete an account by id +func DeleteUserAccount() { + userService := user.NewUserService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := userService.Delete(&user.DeleteRequest{ + Id: "fdf34f34f34-f34f34-f43f43f34-f4f34f", + }) + fmt.Println(rsp, err) +} diff --git a/examples/user/delete/node/deleteUserAccount.js b/examples/user/delete/node/deleteUserAccount.js new file mode 100755 index 0000000..abe3ecb --- /dev/null +++ b/examples/user/delete/node/deleteUserAccount.js @@ -0,0 +1,12 @@ +import * as user from "m3o/user"; + +// Delete an account by id +async function DeleteUserAccount() { + let userService = new user.UserService(process.env.MICRO_API_TOKEN); + let rsp = await userService.delete({ + id: "fdf34f34f34-f34f34-f43f43f34-f4f34f", + }); + console.log(rsp); +} + +await DeleteUserAccount(); diff --git a/examples/user/login/curl/logAUserIn.sh b/examples/user/login/curl/logAUserIn.sh new file mode 100755 index 0000000..ae134f5 --- /dev/null +++ b/examples/user/login/curl/logAUserIn.sh @@ -0,0 +1,7 @@ +curl "https://api.m3o.com/v1/user/Login" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "email": "joe@example.com", + "password": "mySecretPass123" +}' \ No newline at end of file diff --git a/examples/user/login/go/logAUserIn.go b/examples/user/login/go/logAUserIn.go new file mode 100755 index 0000000..a300581 --- /dev/null +++ b/examples/user/login/go/logAUserIn.go @@ -0,0 +1,18 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/user" + "os" +) + +// Login using username or email. The response will return a new session for successful login, +// 401 in the case of login failure and 500 for any other error +func LogAuserIn() { + userService := user.NewUserService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := userService.Login(&user.LoginRequest{ + Email: "joe@example.com", + Password: "mySecretPass123", + }) + fmt.Println(rsp, err) +} diff --git a/examples/user/login/node/logAUserIn.js b/examples/user/login/node/logAUserIn.js new file mode 100755 index 0000000..b5994cf --- /dev/null +++ b/examples/user/login/node/logAUserIn.js @@ -0,0 +1,14 @@ +import * as user from "m3o/user"; + +// Login using username or email. The response will return a new session for successful login, +// 401 in the case of login failure and 500 for any other error +async function LogAuserIn() { + let userService = new user.UserService(process.env.MICRO_API_TOKEN); + let rsp = await userService.login({ + email: "joe@example.com", + password: "mySecretPass123", + }); + console.log(rsp); +} + +await LogAuserIn(); diff --git a/examples/user/logout/curl/logAUserOut.sh b/examples/user/logout/curl/logAUserOut.sh new file mode 100755 index 0000000..fb3d2c1 --- /dev/null +++ b/examples/user/logout/curl/logAUserOut.sh @@ -0,0 +1,6 @@ +curl "https://api.m3o.com/v1/user/Logout" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "sessionId": "sds34s34s34-s34s34-s43s43s34-s4s34s" +}' \ No newline at end of file diff --git a/examples/user/logout/go/logAUserOut.go b/examples/user/logout/go/logAUserOut.go new file mode 100755 index 0000000..a7660ad --- /dev/null +++ b/examples/user/logout/go/logAUserOut.go @@ -0,0 +1,16 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/user" + "os" +) + +// Logout a user account +func LogAuserOut() { + userService := user.NewUserService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := userService.Logout(&user.LogoutRequest{ + SessionId: "sds34s34s34-s34s34-s43s43s34-s4s34s", + }) + fmt.Println(rsp, err) +} diff --git a/examples/user/logout/node/logAUserOut.js b/examples/user/logout/node/logAUserOut.js new file mode 100755 index 0000000..910a98f --- /dev/null +++ b/examples/user/logout/node/logAUserOut.js @@ -0,0 +1,12 @@ +import * as user from "m3o/user"; + +// Logout a user account +async function LogAuserOut() { + let userService = new user.UserService(process.env.MICRO_API_TOKEN); + let rsp = await userService.logout({ + sessionId: "sds34s34s34-s34s34-s43s43s34-s4s34s", + }); + console.log(rsp); +} + +await LogAuserOut(); diff --git a/examples/user/read/curl/readAccountByEmail.sh b/examples/user/read/curl/readAccountByEmail.sh new file mode 100755 index 0000000..9896fc4 --- /dev/null +++ b/examples/user/read/curl/readAccountByEmail.sh @@ -0,0 +1,6 @@ +curl "https://api.m3o.com/v1/user/Read" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "email": "joe@example.com" +}' \ No newline at end of file diff --git a/examples/user/read/curl/readAccountByUsernameOrEmail.sh b/examples/user/read/curl/readAccountByUsernameOrEmail.sh new file mode 100755 index 0000000..35b0276 --- /dev/null +++ b/examples/user/read/curl/readAccountByUsernameOrEmail.sh @@ -0,0 +1,6 @@ +curl "https://api.m3o.com/v1/user/Read" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "username": "usrname-1" +}' \ No newline at end of file diff --git a/examples/user/read/curl/readAnAccountById.sh b/examples/user/read/curl/readAnAccountById.sh new file mode 100755 index 0000000..841af4b --- /dev/null +++ b/examples/user/read/curl/readAnAccountById.sh @@ -0,0 +1,6 @@ +curl "https://api.m3o.com/v1/user/Read" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "id": "usrid-1" +}' \ No newline at end of file diff --git a/examples/user/read/go/readAccountByEmail.go b/examples/user/read/go/readAccountByEmail.go new file mode 100755 index 0000000..de82ebb --- /dev/null +++ b/examples/user/read/go/readAccountByEmail.go @@ -0,0 +1,16 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/user" + "os" +) + +// Read an account by id, username or email. Only one need to be specified. +func ReadAccountByEmail() { + userService := user.NewUserService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := userService.Read(&user.ReadRequest{ + Email: "joe@example.com", + }) + fmt.Println(rsp, err) +} diff --git a/examples/user/read/go/readAccountByUsernameOrEmail.go b/examples/user/read/go/readAccountByUsernameOrEmail.go new file mode 100755 index 0000000..56f0ea7 --- /dev/null +++ b/examples/user/read/go/readAccountByUsernameOrEmail.go @@ -0,0 +1,16 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/user" + "os" +) + +// Read an account by id, username or email. Only one need to be specified. +func ReadAccountByUsernameOrEmail() { + userService := user.NewUserService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := userService.Read(&user.ReadRequest{ + Username: "usrname-1", + }) + fmt.Println(rsp, err) +} diff --git a/examples/user/read/go/readAnAccountById.go b/examples/user/read/go/readAnAccountById.go new file mode 100755 index 0000000..aa47405 --- /dev/null +++ b/examples/user/read/go/readAnAccountById.go @@ -0,0 +1,16 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/user" + "os" +) + +// Read an account by id, username or email. Only one need to be specified. +func ReadAnAccountById() { + userService := user.NewUserService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := userService.Read(&user.ReadRequest{ + Id: "usrid-1", + }) + fmt.Println(rsp, err) +} diff --git a/examples/user/read/node/readAccountByEmail.js b/examples/user/read/node/readAccountByEmail.js new file mode 100755 index 0000000..5513de7 --- /dev/null +++ b/examples/user/read/node/readAccountByEmail.js @@ -0,0 +1,12 @@ +import * as user from "m3o/user"; + +// Read an account by id, username or email. Only one need to be specified. +async function ReadAccountByEmail() { + let userService = new user.UserService(process.env.MICRO_API_TOKEN); + let rsp = await userService.read({ + email: "joe@example.com", + }); + console.log(rsp); +} + +await ReadAccountByEmail(); diff --git a/examples/user/read/node/readAccountByUsernameOrEmail.js b/examples/user/read/node/readAccountByUsernameOrEmail.js new file mode 100755 index 0000000..0938bd3 --- /dev/null +++ b/examples/user/read/node/readAccountByUsernameOrEmail.js @@ -0,0 +1,12 @@ +import * as user from "m3o/user"; + +// Read an account by id, username or email. Only one need to be specified. +async function ReadAccountByUsernameOrEmail() { + let userService = new user.UserService(process.env.MICRO_API_TOKEN); + let rsp = await userService.read({ + username: "usrname-1", + }); + console.log(rsp); +} + +await ReadAccountByUsernameOrEmail(); diff --git a/examples/user/read/node/readAnAccountById.js b/examples/user/read/node/readAnAccountById.js new file mode 100755 index 0000000..07a7753 --- /dev/null +++ b/examples/user/read/node/readAnAccountById.js @@ -0,0 +1,12 @@ +import * as user from "m3o/user"; + +// Read an account by id, username or email. Only one need to be specified. +async function ReadAnAccountById() { + let userService = new user.UserService(process.env.MICRO_API_TOKEN); + let rsp = await userService.read({ + id: "usrid-1", + }); + console.log(rsp); +} + +await ReadAnAccountById(); diff --git a/examples/user/sendVerificationEmail/curl/sendVerificationEmail.sh b/examples/user/sendVerificationEmail/curl/sendVerificationEmail.sh new file mode 100755 index 0000000..7274034 --- /dev/null +++ b/examples/user/sendVerificationEmail/curl/sendVerificationEmail.sh @@ -0,0 +1,11 @@ +curl "https://api.m3o.com/v1/user/SendVerificationEmail" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "email": "joe@example.com", + "failureRedirectUrl": "https://m3o.com/verification-failed", + "fromName": "Awesome Dot Com", + "redirectUrl": "https://m3o.com", + "subject": "Email verification", + "textContent": "Hi there,\n\nPlease verify your email by clicking this link: $micro_verification_link" +}' \ No newline at end of file diff --git a/examples/user/sendVerificationEmail/go/sendVerificationEmail.go b/examples/user/sendVerificationEmail/go/sendVerificationEmail.go new file mode 100755 index 0000000..424a353 --- /dev/null +++ b/examples/user/sendVerificationEmail/go/sendVerificationEmail.go @@ -0,0 +1,29 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/user" + "os" +) + +// 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 SendVerificationEmail() { + userService := user.NewUserService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := userService.SendVerificationEmail(&user.SendVerificationEmailRequest{ + Email: "joe@example.com", + FailureRedirectUrl: "https://m3o.com/verification-failed", + FromName: "Awesome Dot Com", + RedirectUrl: "https://m3o.com", + Subject: "Email verification", + TextContent: `Hi there, + +Please verify your email by clicking this link: $micro_verification_link`, + }) + fmt.Println(rsp, err) +} diff --git a/examples/user/sendVerificationEmail/node/sendVerificationEmail.js b/examples/user/sendVerificationEmail/node/sendVerificationEmail.js new file mode 100755 index 0000000..aa71cde --- /dev/null +++ b/examples/user/sendVerificationEmail/node/sendVerificationEmail.js @@ -0,0 +1,24 @@ +import * as user from "m3o/user"; + +// Send a verification email +// to the user being signed up. Email from will be from 'support@m3o.com', +// but you can provide the title and contents. +// The verification link will be injected in to the email as a template variable, $micro_verification_link. +// Example: 'Hi there, welcome onboard! Use the link below to verify your email: $micro_verification_link' +// The variable will be replaced with an actual url that will look similar to this: +// 'https://user.m3o.com/user/verify?token=a-verification-token&rediretUrl=your-redir-url' +async function SendVerificationEmail() { + let userService = new user.UserService(process.env.MICRO_API_TOKEN); + let rsp = await userService.sendVerificationEmail({ + email: "joe@example.com", + failureRedirectUrl: "https://m3o.com/verification-failed", + fromName: "Awesome Dot Com", + redirectUrl: "https://m3o.com", + subject: "Email verification", + textContent: + "Hi there,\n\nPlease verify your email by clicking this link: $micro_verification_link", + }); + console.log(rsp); +} + +await SendVerificationEmail(); diff --git a/examples/weather/now/curl/getCurrentWeather.sh b/examples/weather/now/curl/getCurrentWeather.sh new file mode 100755 index 0000000..34d23d1 --- /dev/null +++ b/examples/weather/now/curl/getCurrentWeather.sh @@ -0,0 +1,6 @@ +curl "https://api.m3o.com/v1/weather/Now" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "location": "london" +}' \ No newline at end of file diff --git a/examples/weather/now/go/getCurrentWeather.go b/examples/weather/now/go/getCurrentWeather.go new file mode 100755 index 0000000..b6dcea7 --- /dev/null +++ b/examples/weather/now/go/getCurrentWeather.go @@ -0,0 +1,16 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/weather" + "os" +) + +// Get the current weather report for a location by postcode, city, zip code, ip address +func GetCurrentWeather() { + weatherService := weather.NewWeatherService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := weatherService.Now(&weather.NowRequest{ + Location: "london", + }) + fmt.Println(rsp, err) +} diff --git a/examples/weather/now/node/getCurrentWeather.js b/examples/weather/now/node/getCurrentWeather.js new file mode 100755 index 0000000..46525fb --- /dev/null +++ b/examples/weather/now/node/getCurrentWeather.js @@ -0,0 +1,12 @@ +import * as weather from "m3o/weather"; + +// Get the current weather report for a location by postcode, city, zip code, ip address +async function GetCurrentWeather() { + let weatherService = new weather.WeatherService(process.env.MICRO_API_TOKEN); + let rsp = await weatherService.now({ + location: "london", + }); + console.log(rsp); +} + +await GetCurrentWeather(); diff --git a/go.mod b/go.mod index df4acda..f32fa59 100644 --- a/go.mod +++ b/go.mod @@ -29,6 +29,7 @@ require ( github.com/kevinburke/twilio-go v0.0.0-20210327194925-1623146bcf73 github.com/lib/pq v1.9.0 // indirect github.com/m3o/goduckgo v0.0.0-20210630141545-c760fe67b945 + github.com/m3o/m3o-go/client v0.0.0-20210421144725-8bfd7992ada3 github.com/mattheath/base62 v0.0.0-20150408093626-b80cdc656a7a // indirect github.com/mattheath/kala v0.0.0-20171219141654-d6276794bf0e github.com/micro/micro/v3 v3.4.1-0.20210910132548-f8bfb12823c0 diff --git a/go.sum b/go.sum index e9991bb..613eb30 100644 --- a/go.sum +++ b/go.sum @@ -219,6 +219,7 @@ github.com/gorilla/handlers v1.5.1/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/mux v1.7.3 h1:gnP5JzjVOuiZD07fKKToCAOjS0yOpj/qPETTXCCS6hw= github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= +github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/grpc-ecosystem/grpc-gateway v1.8.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= @@ -346,6 +347,9 @@ github.com/linode/linodego v0.10.0/go.mod h1:cziNP7pbvE3mXIPneHj0oRY8L1WtGEIKlZ8 github.com/liquidweb/liquidweb-go v1.6.0/go.mod h1:UDcVnAMDkZxpw4Y7NOHkqoeiGacVLEIG/i5J9cyixzQ= github.com/m3o/goduckgo v0.0.0-20210630141545-c760fe67b945 h1:jcOqgh+pYNSaPoPOgDaaU5t9j45JzHG3wOBLXUMBfQ0= github.com/m3o/goduckgo v0.0.0-20210630141545-c760fe67b945/go.mod h1:wQOw7PY6509VQbepPrclbyXfbQ5lpOtIoHdBKbB+OGc= +github.com/m3o/m3o-go v0.0.0-20210915113633-a4f018a78d79 h1:WJ7AfarocyVqqvXLzjA11U4PEmZ6P2fqMtAXNhtmNU4= +github.com/m3o/m3o-go/client v0.0.0-20210421144725-8bfd7992ada3 h1:RVt7rqWl4al36BH9OY9k7IXnnooOP0Feanu1bed6X2s= +github.com/m3o/m3o-go/client v0.0.0-20210421144725-8bfd7992ada3/go.mod h1:vmeaYrKYpgVNhny/l7iH8mXS88S7ijUiYni3gZUrCq0= github.com/mattheath/base62 v0.0.0-20150408093626-b80cdc656a7a h1:rnrxZue85aKdMU4nJ50GgKA31lCaVbft+7Xl8OXj55U= github.com/mattheath/base62 v0.0.0-20150408093626-b80cdc656a7a/go.mod h1:hJJYoBMTZIONmUEpX3+9v2057zuRM0n3n77U4Ob4wE4= github.com/mattheath/kala v0.0.0-20171219141654-d6276794bf0e h1:cj+w63ez19o7y7vunA8Q3rUIWwKEOUx7foqjnr4qbtI=