mirror of
https://github.com/kevin-DL/m3o-go.git
synced 2026-01-11 18:44:26 +00:00
Commit from m3o/m3o action
This commit is contained in:
57
address/address.go
Executable file
57
address/address.go
Executable file
@@ -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"`
|
||||||
|
}
|
||||||
37
answer/answer.go
Executable file
37
answer/answer.go
Executable file
@@ -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"`
|
||||||
|
}
|
||||||
113
cache/cache.go
vendored
Executable file
113
cache/cache.go
vendored
Executable file
@@ -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,string"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type DecrementResponse struct {
|
||||||
|
// The key decremented
|
||||||
|
Key string `json:"key"`
|
||||||
|
// The new value
|
||||||
|
Value int64 `json:"value,string"`
|
||||||
|
}
|
||||||
|
|
||||||
|
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,string"`
|
||||||
|
// 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,string"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type IncrementResponse struct {
|
||||||
|
// The key incremented
|
||||||
|
Key string `json:"key"`
|
||||||
|
// The new value
|
||||||
|
Value int64 `json:"value,string"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type SetRequest struct {
|
||||||
|
// The key to update
|
||||||
|
Key string `json:"key"`
|
||||||
|
// Time to live in seconds
|
||||||
|
Ttl int64 `json:"ttl,string"`
|
||||||
|
// The value to set
|
||||||
|
Value string `json:"value"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type SetResponse struct {
|
||||||
|
// Returns "ok" if successful
|
||||||
|
Status string `json:"status"`
|
||||||
|
}
|
||||||
120
crypto/crypto.go
Executable file
120
crypto/crypto.go
Executable file
@@ -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"`
|
||||||
|
}
|
||||||
103
currency/currency.go
Executable file
103
currency/currency.go
Executable file
@@ -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"`
|
||||||
|
}
|
||||||
133
db/db.go
Executable file
133
db/db.go
Executable file
@@ -0,0 +1,133 @@
|
|||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
// Count records in a table
|
||||||
|
func (t *DbService) Count(request *CountRequest) (*CountResponse, error) {
|
||||||
|
rsp := &CountResponse{}
|
||||||
|
return rsp, t.client.Call("db", "Count", request, rsp)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
|
||||||
|
func (t *DbService) Create(request *CreateRequest) (*CreateResponse, error) {
|
||||||
|
rsp := &CreateResponse{}
|
||||||
|
return rsp, t.client.Call("db", "Create", request, rsp)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete a record in the database by id.
|
||||||
|
func (t *DbService) Delete(request *DeleteRequest) (*DeleteResponse, error) {
|
||||||
|
rsp := &DeleteResponse{}
|
||||||
|
return rsp, t.client.Call("db", "Delete", request, rsp)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read data from a table. Lookup can be by ID or via querying any field in the record.
|
||||||
|
func (t *DbService) Read(request *ReadRequest) (*ReadResponse, error) {
|
||||||
|
rsp := &ReadResponse{}
|
||||||
|
return rsp, t.client.Call("db", "Read", request, rsp)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Truncate the records in a table
|
||||||
|
func (t *DbService) Truncate(request *TruncateRequest) (*TruncateResponse, error) {
|
||||||
|
rsp := &TruncateResponse{}
|
||||||
|
return rsp, t.client.Call("db", "Truncate", request, rsp)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update a record in the database. Include an "id" in the record to update.
|
||||||
|
func (t *DbService) Update(request *UpdateRequest) (*UpdateResponse, error) {
|
||||||
|
rsp := &UpdateResponse{}
|
||||||
|
return rsp, t.client.Call("db", "Update", request, rsp)
|
||||||
|
}
|
||||||
|
|
||||||
|
type CountRequest struct {
|
||||||
|
// specify the table name
|
||||||
|
Table string `json:"table"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CountResponse struct {
|
||||||
|
// the number of records in the table
|
||||||
|
Count int32 `json:"count"`
|
||||||
|
}
|
||||||
|
|
||||||
|
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 {
|
||||||
|
}
|
||||||
41
email/email.go
Executable file
41
email/email.go
Executable file
@@ -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 {
|
||||||
|
}
|
||||||
86
emoji/emoji.go
Executable file
86
emoji/emoji.go
Executable file
@@ -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 '<message> Sent from <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"`
|
||||||
|
}
|
||||||
240
evchargers/evchargers.go
Executable file
240
evchargers/evchargers.go
Executable file
@@ -0,0 +1,240 @@
|
|||||||
|
package evchargers
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/m3o/m3o-go/client"
|
||||||
|
)
|
||||||
|
|
||||||
|
func NewEvchargersService(token string) *EvchargersService {
|
||||||
|
return &EvchargersService{
|
||||||
|
client: client.NewClient(&client.Options{
|
||||||
|
Token: token,
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type EvchargersService struct {
|
||||||
|
client *client.Client
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve reference data as used by this API and in conjunction with the Search endpoint
|
||||||
|
func (t *EvchargersService) ReferenceData(request *ReferenceDataRequest) (*ReferenceDataResponse, error) {
|
||||||
|
rsp := &ReferenceDataResponse{}
|
||||||
|
return rsp, t.client.Call("evchargers", "ReferenceData", request, rsp)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Search by giving a coordinate and a max distance, or bounding box and optional filters
|
||||||
|
func (t *EvchargersService) Search(request *SearchRequest) (*SearchResponse, error) {
|
||||||
|
rsp := &SearchResponse{}
|
||||||
|
return rsp, t.client.Call("evchargers", "Search", request, rsp)
|
||||||
|
}
|
||||||
|
|
||||||
|
type Address struct {
|
||||||
|
// Any comments about how to access the charger
|
||||||
|
AccessComments string `json:"accessComments"`
|
||||||
|
AddressLine1 string `json:"addressLine1"`
|
||||||
|
AddressLine2 string `json:"addressLine2"`
|
||||||
|
Country *Country `json:"country"`
|
||||||
|
CountryId string `json:"countryId"`
|
||||||
|
LatLng string `json:"latLng"`
|
||||||
|
Location *Coordinates `json:"location"`
|
||||||
|
Postcode string `json:"postcode"`
|
||||||
|
StateOrProvince string `json:"stateOrProvince"`
|
||||||
|
Title string `json:"title"`
|
||||||
|
Town string `json:"town"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type BoundingBox struct {
|
||||||
|
BottomLeft *Coordinates `json:"bottomLeft"`
|
||||||
|
TopRight *Coordinates `json:"topRight"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ChargerType struct {
|
||||||
|
Comments string `json:"comments"`
|
||||||
|
Id string `json:"id"`
|
||||||
|
// Is this 40KW+
|
||||||
|
IsFastChargeCapable bool `json:"isFastChargeCapable"`
|
||||||
|
Title string `json:"title"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CheckinStatusType struct {
|
||||||
|
Id string `json:"id"`
|
||||||
|
IsAutomated bool `json:"isAutomated"`
|
||||||
|
IsPositive bool `json:"isPositive"`
|
||||||
|
Title string `json:"title"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Connection struct {
|
||||||
|
// The amps offered
|
||||||
|
Amps float64 `json:"amps"`
|
||||||
|
ConnectionType *ConnectionType `json:"connectionType"`
|
||||||
|
// The ID of the connection type
|
||||||
|
ConnectionTypeId string `json:"connectionTypeId"`
|
||||||
|
// The current
|
||||||
|
Current string `json:"current"`
|
||||||
|
Level *ChargerType `json:"level"`
|
||||||
|
// The level of charging power available
|
||||||
|
LevelId string `json:"levelId"`
|
||||||
|
// The power in KW
|
||||||
|
Power float64 `json:"power"`
|
||||||
|
Reference string `json:"reference"`
|
||||||
|
// The voltage offered
|
||||||
|
Voltage float64 `json:"voltage"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ConnectionType struct {
|
||||||
|
FormalName string `json:"formalName"`
|
||||||
|
Id string `json:"id"`
|
||||||
|
IsDiscontinued bool `json:"isDiscontinued"`
|
||||||
|
IsObsolete bool `json:"isObsolete"`
|
||||||
|
Title string `json:"title"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Coordinates struct {
|
||||||
|
Latitude float64 `json:"latitude"`
|
||||||
|
Longitude float64 `json:"longitude"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Country struct {
|
||||||
|
ContinentCode string `json:"continentCode"`
|
||||||
|
Id string `json:"id"`
|
||||||
|
IsoCode string `json:"isoCode"`
|
||||||
|
Title string `json:"title"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CurrentType struct {
|
||||||
|
Description string `json:"description"`
|
||||||
|
Id string `json:"id"`
|
||||||
|
Title string `json:"title"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type DataProvider struct {
|
||||||
|
Comments string `json:"comments"`
|
||||||
|
DataProviderStatusType *DataProviderStatusType `json:"dataProviderStatusType"`
|
||||||
|
Id string `json:"id"`
|
||||||
|
// How is this data licensed
|
||||||
|
License string `json:"license"`
|
||||||
|
Title string `json:"title"`
|
||||||
|
Website string `json:"website"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type DataProviderStatusType struct {
|
||||||
|
Id string `json:"id"`
|
||||||
|
IsProviderEnabled bool `json:"isProviderEnabled"`
|
||||||
|
Title string `json:"title"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Operator struct {
|
||||||
|
Comments string `json:"comments"`
|
||||||
|
ContactEmail string `json:"contactEmail"`
|
||||||
|
FaultReportEmail string `json:"faultReportEmail"`
|
||||||
|
Id string `json:"id"`
|
||||||
|
// Is this operator a private individual vs a company
|
||||||
|
IsPrivateIndividual bool `json:"isPrivateIndividual"`
|
||||||
|
PhonePrimary string `json:"phonePrimary"`
|
||||||
|
PhoneSecondary string `json:"phoneSecondary"`
|
||||||
|
Title string `json:"title"`
|
||||||
|
Website string `json:"website"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Poi struct {
|
||||||
|
// The address
|
||||||
|
Address *Address `json:"address"`
|
||||||
|
// The connections available at this charge point
|
||||||
|
Connections []Connection `json:"connections"`
|
||||||
|
// The cost of charging
|
||||||
|
Cost string `json:"cost"`
|
||||||
|
// The ID of the data provider
|
||||||
|
DataProviderId string `json:"dataProviderId"`
|
||||||
|
// The ID of the charger
|
||||||
|
Id string `json:"id"`
|
||||||
|
// The number of charging points
|
||||||
|
NumPoints int64 `json:"numPoints,string"`
|
||||||
|
// The operator
|
||||||
|
Operator *Operator `json:"operator"`
|
||||||
|
// The ID of the operator of the charger
|
||||||
|
OperatorId string `json:"operatorId"`
|
||||||
|
// The type of usage
|
||||||
|
UsageType *UsageType `json:"usageType"`
|
||||||
|
// The type of usage for this charger point (is it public, membership required, etc)
|
||||||
|
UsageTypeId string `json:"usageTypeId"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ReferenceDataRequest struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
type ReferenceDataResponse struct {
|
||||||
|
// The types of charger
|
||||||
|
ChargerTypes *ChargerType `json:"chargerTypes"`
|
||||||
|
// The types of checkin status
|
||||||
|
CheckinStatusTypes *CheckinStatusType `json:"checkinStatusTypes"`
|
||||||
|
// The types of connection
|
||||||
|
ConnectionTypes *ConnectionType `json:"connectionTypes"`
|
||||||
|
// The countries
|
||||||
|
Countries []Country `json:"countries"`
|
||||||
|
// The types of current
|
||||||
|
CurrentTypes *CurrentType `json:"currentTypes"`
|
||||||
|
// The providers of the charger data
|
||||||
|
DataProviders *DataProvider `json:"dataProviders"`
|
||||||
|
// The companies operating the chargers
|
||||||
|
Operators []Operator `json:"operators"`
|
||||||
|
// The status of the charger
|
||||||
|
StatusTypes *StatusType `json:"statusTypes"`
|
||||||
|
// The status of a submission
|
||||||
|
SubmissionStatusTypes *SubmissionStatusType `json:"submissionStatusTypes"`
|
||||||
|
// The different types of usage
|
||||||
|
UsageTypes *UsageType `json:"usageTypes"`
|
||||||
|
// The types of user comment
|
||||||
|
UserCommentTypes *UserCommentType `json:"userCommentTypes"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type SearchRequest struct {
|
||||||
|
// Bounding box to search within (top left and bottom right coordinates)
|
||||||
|
Box *BoundingBox `json:"box"`
|
||||||
|
// IDs of the connection type
|
||||||
|
ConnectionTypes string `json:"connectionTypes"`
|
||||||
|
// Country ID
|
||||||
|
CountryId string `json:"countryId"`
|
||||||
|
// Search distance from point in metres, defaults to 5000m
|
||||||
|
Distance int64 `json:"distance,string"`
|
||||||
|
// Supported charging levels
|
||||||
|
Levels []string `json:"levels"`
|
||||||
|
// Coordinates from which to begin search
|
||||||
|
Location *Coordinates `json:"location"`
|
||||||
|
// Maximum number of results to return, defaults to 100
|
||||||
|
MaxResults int64 `json:"maxResults,string"`
|
||||||
|
// Minimum power in KW. Note: data not available for many chargers
|
||||||
|
MinPower int64 `json:"minPower,string"`
|
||||||
|
// IDs of the the EV charger operator
|
||||||
|
Operators []string `json:"operators"`
|
||||||
|
// Usage of the charge point (is it public, membership required, etc)
|
||||||
|
UsageTypes string `json:"usageTypes"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type SearchResponse struct {
|
||||||
|
Pois []Poi `json:"pois"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type StatusType struct {
|
||||||
|
Id string `json:"id"`
|
||||||
|
IsOperational bool `json:"isOperational"`
|
||||||
|
Title string `json:"title"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type SubmissionStatusType struct {
|
||||||
|
Id string `json:"id"`
|
||||||
|
IsLive bool `json:"isLive"`
|
||||||
|
Title string `json:"title"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type UsageType struct {
|
||||||
|
Id string `json:"id"`
|
||||||
|
IsAccessKeyRequired bool `json:"isAccessKeyRequired"`
|
||||||
|
IsMembershipRequired bool `json:"isMembershipRequired"`
|
||||||
|
IsPayAtLocation bool `json:"isPayAtLocation"`
|
||||||
|
Title string `json:"title"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type UserCommentType struct {
|
||||||
|
Id string `json:"id"`
|
||||||
|
Title string `json:"title"`
|
||||||
|
}
|
||||||
107
file/file.go
Executable file
107
file/file.go
Executable file
@@ -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 {
|
||||||
|
}
|
||||||
85
forex/forex.go
Executable file
85
forex/forex.go
Executable file
@@ -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"`
|
||||||
|
}
|
||||||
151
function/function.go
Executable file
151
function/function.go
Executable file
@@ -0,0 +1,151 @@
|
|||||||
|
package function
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/m3o/m3o-go/client"
|
||||||
|
)
|
||||||
|
|
||||||
|
func NewFunctionService(token string) *FunctionService {
|
||||||
|
return &FunctionService{
|
||||||
|
client: client.NewClient(&client.Options{
|
||||||
|
Token: token,
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type FunctionService struct {
|
||||||
|
client *client.Client
|
||||||
|
}
|
||||||
|
|
||||||
|
// Call a function by name
|
||||||
|
func (t *FunctionService) Call(request *CallRequest) (*CallResponse, error) {
|
||||||
|
rsp := &CallResponse{}
|
||||||
|
return rsp, t.client.Call("function", "Call", request, rsp)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete a function by name
|
||||||
|
func (t *FunctionService) Delete(request *DeleteRequest) (*DeleteResponse, error) {
|
||||||
|
rsp := &DeleteResponse{}
|
||||||
|
return rsp, t.client.Call("function", "Delete", request, rsp)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deploy a group of functions
|
||||||
|
func (t *FunctionService) Deploy(request *DeployRequest) (*DeployResponse, error) {
|
||||||
|
rsp := &DeployResponse{}
|
||||||
|
return rsp, t.client.Call("function", "Deploy", request, rsp)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the info for a deployed function
|
||||||
|
func (t *FunctionService) Describe(request *DescribeRequest) (*DescribeResponse, error) {
|
||||||
|
rsp := &DescribeResponse{}
|
||||||
|
return rsp, t.client.Call("function", "Describe", request, rsp)
|
||||||
|
}
|
||||||
|
|
||||||
|
// List all the deployed functions
|
||||||
|
func (t *FunctionService) List(request *ListRequest) (*ListResponse, error) {
|
||||||
|
rsp := &ListResponse{}
|
||||||
|
return rsp, t.client.Call("function", "List", request, rsp)
|
||||||
|
}
|
||||||
|
|
||||||
|
type CallRequest struct {
|
||||||
|
// Name of the function
|
||||||
|
Name string `json:"name"`
|
||||||
|
// Request body that will be passed to the function
|
||||||
|
Request map[string]interface{} `json:"request"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CallResponse struct {
|
||||||
|
// Response body that the function returned
|
||||||
|
Response map[string]interface{} `json:"response"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type DeleteRequest struct {
|
||||||
|
// The name of the function
|
||||||
|
Name string `json:"name"`
|
||||||
|
// Optional project name
|
||||||
|
Project string `json:"project"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type DeleteResponse struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
type DeployRequest struct {
|
||||||
|
// entry point, ie. handler name in the source code
|
||||||
|
// if not provided, defaults to the name parameter
|
||||||
|
Entrypoint string `json:"entrypoint"`
|
||||||
|
// environment variables to pass in at runtime
|
||||||
|
EnvVars map[string]string `json:"envVars"`
|
||||||
|
// function name
|
||||||
|
Name string `json:"name"`
|
||||||
|
// project is used for namespacing your functions
|
||||||
|
// optional. defaults to "default".
|
||||||
|
Project string `json:"project"`
|
||||||
|
// github url to repo
|
||||||
|
Repo string `json:"repo"`
|
||||||
|
// runtime/language of the function
|
||||||
|
// eg: php74,
|
||||||
|
// nodejs6, nodejs8, nodejs10, nodejs12, nodejs14, nodejs16
|
||||||
|
// dotnet3
|
||||||
|
// java11
|
||||||
|
// ruby26, ruby27
|
||||||
|
// go111, go113, go116
|
||||||
|
// python37, python38, python39
|
||||||
|
Runtime string `json:"runtime"`
|
||||||
|
// optional subfolder path
|
||||||
|
Subfolder string `json:"subfolder"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type DeployResponse struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
type DescribeRequest struct {
|
||||||
|
// The name of the function
|
||||||
|
Name string `json:"name"`
|
||||||
|
// Optional project name
|
||||||
|
Project string `json:"project"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type DescribeResponse struct {
|
||||||
|
// The function requested
|
||||||
|
Function *Func `json:"function"`
|
||||||
|
// The timeout for requests to the function
|
||||||
|
Timeout string `json:"timeout"`
|
||||||
|
// The time at which the function was updated
|
||||||
|
UpdatedAt string `json:"updatedAt"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Func struct {
|
||||||
|
// name of handler in source code
|
||||||
|
Entrypoint string `json:"entrypoint"`
|
||||||
|
// function name
|
||||||
|
// limitation: must be unique across projects
|
||||||
|
Name string `json:"name"`
|
||||||
|
// project of function, optional
|
||||||
|
// defaults to literal "default"
|
||||||
|
// used to namespace functions
|
||||||
|
Project string `json:"project"`
|
||||||
|
// git repo address
|
||||||
|
Repo string `json:"repo"`
|
||||||
|
// runtime/language of the function
|
||||||
|
// eg: php74,
|
||||||
|
// nodejs6, nodejs8, nodejs10, nodejs12, nodejs14, nodejs16
|
||||||
|
// dotnet3
|
||||||
|
// java11
|
||||||
|
// ruby26, ruby27
|
||||||
|
// go111, go113, go116
|
||||||
|
// python37, python38, python39
|
||||||
|
Runtime string `json:"runtime"`
|
||||||
|
// eg. ACTIVE, DEPLOY_IN_PROGRESS, OFFLINE etc
|
||||||
|
Status string `json:"status"`
|
||||||
|
// subfolder path to entrypoint
|
||||||
|
Subfolder string `json:"subfolder"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ListRequest struct {
|
||||||
|
// optional project name
|
||||||
|
Project string `json:"project"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ListResponse struct {
|
||||||
|
// List of functions deployed
|
||||||
|
Functions []Func `json:"functions"`
|
||||||
|
}
|
||||||
64
geocoding/geocoding.go
Executable file
64
geocoding/geocoding.go
Executable file
@@ -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"`
|
||||||
|
}
|
||||||
135
gifs/gifs.go
Executable file
135
gifs/gifs.go
Executable file
@@ -0,0 +1,135 @@
|
|||||||
|
package gifs
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/m3o/m3o-go/client"
|
||||||
|
)
|
||||||
|
|
||||||
|
func NewGifsService(token string) *GifsService {
|
||||||
|
return &GifsService{
|
||||||
|
client: client.NewClient(&client.Options{
|
||||||
|
Token: token,
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type GifsService struct {
|
||||||
|
client *client.Client
|
||||||
|
}
|
||||||
|
|
||||||
|
// Search for a GIF
|
||||||
|
func (t *GifsService) Search(request *SearchRequest) (*SearchResponse, error) {
|
||||||
|
rsp := &SearchResponse{}
|
||||||
|
return rsp, t.client.Call("gifs", "Search", request, rsp)
|
||||||
|
}
|
||||||
|
|
||||||
|
type Gif struct {
|
||||||
|
// URL used for embedding the GIF
|
||||||
|
EmbedUrl string `json:"embedUrl"`
|
||||||
|
// The ID of the GIF
|
||||||
|
Id string `json:"id"`
|
||||||
|
// The different formats available for this GIF
|
||||||
|
Images *ImageFormats `json:"images"`
|
||||||
|
// The content rating for the GIF
|
||||||
|
Rating string `json:"rating"`
|
||||||
|
// A short URL for this GIF
|
||||||
|
ShortUrl string `json:"shortUrl"`
|
||||||
|
// The slug used in the GIF's URL
|
||||||
|
Slug string `json:"slug"`
|
||||||
|
// The page on which this GIF was found
|
||||||
|
Source string `json:"source"`
|
||||||
|
// The title for this GIF
|
||||||
|
Title string `json:"title"`
|
||||||
|
// The URL for this GIF
|
||||||
|
Url string `json:"url"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ImageFormat struct {
|
||||||
|
// height
|
||||||
|
Height int32 `json:"height"`
|
||||||
|
// size of the MP4 version
|
||||||
|
Mp4size int32 `json:"mp4size"`
|
||||||
|
// URL to an MP4 version of the gif
|
||||||
|
Mp4url string `json:"mp4url"`
|
||||||
|
// size in bytes
|
||||||
|
Size int32 `json:"size"`
|
||||||
|
// URL of the gif
|
||||||
|
Url string `json:"url"`
|
||||||
|
// size of the webp version
|
||||||
|
WebpSize int32 `json:"webpSize"`
|
||||||
|
// URL to a webp version of the gif
|
||||||
|
WebpUrl string `json:"webpUrl"`
|
||||||
|
// width
|
||||||
|
Width int32 `json:"width"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ImageFormats struct {
|
||||||
|
// A downsized version of the GIF < 2MB
|
||||||
|
Downsized *ImageFormat `json:"downsized"`
|
||||||
|
// A downsized version of the GIF < 8MB
|
||||||
|
DownsizedLarge *ImageFormat `json:"downsizedLarge"`
|
||||||
|
// A downsized version of the GIF < 5MB
|
||||||
|
DownsizedMedium *ImageFormat `json:"downsizedMedium"`
|
||||||
|
// A downsized version of the GIF < 200kb
|
||||||
|
DownsizedSmall *ImageFormat `json:"downsizedSmall"`
|
||||||
|
// Static image of the downsized version of the GIF
|
||||||
|
DownsizedStill *ImageFormat `json:"downsizedStill"`
|
||||||
|
// Version of the GIF with fixed height of 200 pixels. Good for mobile use
|
||||||
|
FixedHeight *ImageFormat `json:"fixedHeight"`
|
||||||
|
// Version of the GIF with fixed height of 200 pixels and number of frames reduced to 6
|
||||||
|
FixedHeightDownsampled *ImageFormat `json:"fixedHeightDownsampled"`
|
||||||
|
// Version of the GIF with fixed height of 100 pixels. Good for mobile keyboards
|
||||||
|
FixedHeightSmall *ImageFormat `json:"fixedHeightSmall"`
|
||||||
|
// Static image of the GIF with fixed height of 100 pixels
|
||||||
|
FixedHeightSmallStill *ImageFormat `json:"fixedHeightSmallStill"`
|
||||||
|
// Static image of the GIF with fixed height of 200 pixels
|
||||||
|
FixedHeightStill *ImageFormat `json:"fixedHeightStill"`
|
||||||
|
// Version of the GIF with fixed width of 200 pixels. Good for mobile use
|
||||||
|
FixedWidth *ImageFormat `json:"fixedWidth"`
|
||||||
|
// Version of the GIF with fixed width of 200 pixels and number of frames reduced to 6
|
||||||
|
FixedWidthDownsampled *ImageFormat `json:"fixedWidthDownsampled"`
|
||||||
|
// Version of the GIF with fixed width of 100 pixels. Good for mobile keyboards
|
||||||
|
FixedWidthSmall *ImageFormat `json:"fixedWidthSmall"`
|
||||||
|
// Static image of the GIF with fixed width of 100 pixels
|
||||||
|
FixedWidthSmallStill *ImageFormat `json:"fixedWidthSmallStill"`
|
||||||
|
// Static image of the GIF with fixed width of 200 pixels
|
||||||
|
FixedWidthStill *ImageFormat `json:"fixedWidthStill"`
|
||||||
|
// 15 second version of the GIF looping
|
||||||
|
Looping *ImageFormat `json:"looping"`
|
||||||
|
// The original GIF. Good for desktop use
|
||||||
|
Original *ImageFormat `json:"original"`
|
||||||
|
// Static image of the original version of the GIF
|
||||||
|
OriginalStill *ImageFormat `json:"originalStill"`
|
||||||
|
// mp4 version of the GIF <50kb displaying first 1-2 secs
|
||||||
|
Preview *ImageFormat `json:"preview"`
|
||||||
|
// Version of the GIF <50kb displaying first 1-2 secs
|
||||||
|
PreviewGif *ImageFormat `json:"previewGif"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Pagination struct {
|
||||||
|
// total number returned in this response
|
||||||
|
Count int32 `json:"count"`
|
||||||
|
// position in pagination
|
||||||
|
Offset int32 `json:"offset"`
|
||||||
|
// total number of results available
|
||||||
|
TotalCount int32 `json:"totalCount"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type SearchRequest struct {
|
||||||
|
// ISO 2 letter language code for regional content
|
||||||
|
Lang string `json:"lang"`
|
||||||
|
// Max number of gifs to return. Defaults to 25
|
||||||
|
Limit int32 `json:"limit"`
|
||||||
|
// The start position of results (used with pagination)
|
||||||
|
Offset int32 `json:"offset"`
|
||||||
|
// The search term
|
||||||
|
Query string `json:"query"`
|
||||||
|
// Apply age related content filter. "g", "pg", "pg-13", or "r". Defaults to "g"
|
||||||
|
Rating string `json:"rating"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type SearchResponse struct {
|
||||||
|
// list of results
|
||||||
|
Data []Gif `json:"data"`
|
||||||
|
// information on pagination
|
||||||
|
Pagination *Pagination `json:"pagination"`
|
||||||
|
}
|
||||||
48
google/google.go
Executable file
48
google/google.go
Executable file
@@ -0,0 +1,48 @@
|
|||||||
|
package google
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/m3o/m3o-go/client"
|
||||||
|
)
|
||||||
|
|
||||||
|
func NewGoogleService(token string) *GoogleService {
|
||||||
|
return &GoogleService{
|
||||||
|
client: client.NewClient(&client.Options{
|
||||||
|
Token: token,
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type GoogleService struct {
|
||||||
|
client *client.Client
|
||||||
|
}
|
||||||
|
|
||||||
|
// Search for videos on Google
|
||||||
|
func (t *GoogleService) Search(request *SearchRequest) (*SearchResponse, error) {
|
||||||
|
rsp := &SearchResponse{}
|
||||||
|
return rsp, t.client.Call("google", "Search", request, rsp)
|
||||||
|
}
|
||||||
|
|
||||||
|
type SearchRequest struct {
|
||||||
|
// Query to search for
|
||||||
|
Query string `json:"query"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type SearchResponse struct {
|
||||||
|
// List of results for the query
|
||||||
|
Results []SearchResult `json:"results"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type SearchResult struct {
|
||||||
|
// abridged version of this search result’s URL, e.g. www.exampe.com
|
||||||
|
DisplayUrl string `json:"displayUrl"`
|
||||||
|
// id of the result
|
||||||
|
Id string `json:"id"`
|
||||||
|
// kind of result; "search"
|
||||||
|
Kind string `json:"kind"`
|
||||||
|
// the result snippet
|
||||||
|
Snippet string `json:"snippet"`
|
||||||
|
// title of the result
|
||||||
|
Title string `json:"title"`
|
||||||
|
// the full url for the result
|
||||||
|
Url string `json:"url"`
|
||||||
|
}
|
||||||
47
helloworld/helloworld.go
Executable file
47
helloworld/helloworld.go
Executable file
@@ -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,string"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type StreamResponse struct {
|
||||||
|
Message string `json:"message"`
|
||||||
|
}
|
||||||
69
holidays/holidays.go
Executable file
69
holidays/holidays.go
Executable file
@@ -0,0 +1,69 @@
|
|||||||
|
package holidays
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/m3o/m3o-go/client"
|
||||||
|
)
|
||||||
|
|
||||||
|
func NewHolidaysService(token string) *HolidaysService {
|
||||||
|
return &HolidaysService{
|
||||||
|
client: client.NewClient(&client.Options{
|
||||||
|
Token: token,
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type HolidaysService struct {
|
||||||
|
client *client.Client
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the list of countries that are supported by this API
|
||||||
|
func (t *HolidaysService) Countries(request *CountriesRequest) (*CountriesResponse, error) {
|
||||||
|
rsp := &CountriesResponse{}
|
||||||
|
return rsp, t.client.Call("holidays", "Countries", request, rsp)
|
||||||
|
}
|
||||||
|
|
||||||
|
// List the holiday dates for a given country and year
|
||||||
|
func (t *HolidaysService) List(request *ListRequest) (*ListResponse, error) {
|
||||||
|
rsp := &ListResponse{}
|
||||||
|
return rsp, t.client.Call("holidays", "List", request, rsp)
|
||||||
|
}
|
||||||
|
|
||||||
|
type CountriesRequest struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
type CountriesResponse struct {
|
||||||
|
Countries []Country `json:"countries"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Country struct {
|
||||||
|
// The 2 letter country code (as defined in ISO 3166-1 alpha-2)
|
||||||
|
Code string `json:"code"`
|
||||||
|
// The English name of the country
|
||||||
|
Name string `json:"name"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Holiday struct {
|
||||||
|
// the country this holiday occurs in
|
||||||
|
CountryCode string `json:"countryCode"`
|
||||||
|
// date of the holiday in yyyy-mm-dd format
|
||||||
|
Date string `json:"date"`
|
||||||
|
// the local name of the holiday
|
||||||
|
LocalName string `json:"localName"`
|
||||||
|
// the name of the holiday in English
|
||||||
|
Name string `json:"name"`
|
||||||
|
// the regions within the country that observe this holiday (if not all of them)
|
||||||
|
Regions []string `json:"regions"`
|
||||||
|
// the type of holiday Public, Bank, School, Authorities, Optional, Observance
|
||||||
|
Types []string `json:"types"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ListRequest struct {
|
||||||
|
// The 2 letter country code (as defined in ISO 3166-1 alpha-2)
|
||||||
|
CountryCode string `json:"countryCode"`
|
||||||
|
// The year to list holidays for
|
||||||
|
Year int64 `json:"year,string"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ListResponse struct {
|
||||||
|
Holidays []Holiday `json:"holidays"`
|
||||||
|
}
|
||||||
48
id/id.go
Executable file
48
id/id.go
Executable file
@@ -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"`
|
||||||
|
}
|
||||||
112
image/image.go
Executable file
112
image/image.go
Executable file
@@ -0,0 +1,112 @@
|
|||||||
|
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,
|
||||||
|
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,
|
||||||
|
Base64 string `json:"base64"`
|
||||||
|
// optional crop options
|
||||||
|
// if provided, after resize, the image
|
||||||
|
// will be cropped
|
||||||
|
CropOptions *CropOptions `json:"cropOptions"`
|
||||||
|
Height int64 `json:"height,string"`
|
||||||
|
// 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,string"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ResizeResponse struct {
|
||||||
|
Base64 string `json:"base64"`
|
||||||
|
Url string `json:"url"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type UploadRequest struct {
|
||||||
|
// Base64 encoded image to upload,
|
||||||
|
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"`
|
||||||
|
}
|
||||||
47
ip/ip.go
Executable file
47
ip/ip.go
Executable file
@@ -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"`
|
||||||
|
}
|
||||||
78
location/location.go
Executable file
78
location/location.go
Executable file
@@ -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,string"`
|
||||||
|
}
|
||||||
|
|
||||||
|
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,string"`
|
||||||
|
// radius in meters
|
||||||
|
Radius float64 `json:"radius"`
|
||||||
|
// type of entities to filter
|
||||||
|
Type string `json:"type"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type SearchResponse struct {
|
||||||
|
Entities []Entity `json:"entities"`
|
||||||
|
}
|
||||||
142
m3o.go
Executable file
142
m3o.go
Executable file
@@ -0,0 +1,142 @@
|
|||||||
|
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/evchargers"
|
||||||
|
"github.com/micro/services/clients/go/file"
|
||||||
|
"github.com/micro/services/clients/go/forex"
|
||||||
|
"github.com/micro/services/clients/go/function"
|
||||||
|
"github.com/micro/services/clients/go/geocoding"
|
||||||
|
"github.com/micro/services/clients/go/gifs"
|
||||||
|
"github.com/micro/services/clients/go/google"
|
||||||
|
"github.com/micro/services/clients/go/helloworld"
|
||||||
|
"github.com/micro/services/clients/go/holidays"
|
||||||
|
"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/notes"
|
||||||
|
"github.com/micro/services/clients/go/otp"
|
||||||
|
"github.com/micro/services/clients/go/postcode"
|
||||||
|
"github.com/micro/services/clients/go/prayer"
|
||||||
|
"github.com/micro/services/clients/go/qr"
|
||||||
|
"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/sunnah"
|
||||||
|
"github.com/micro/services/clients/go/thumbnail"
|
||||||
|
"github.com/micro/services/clients/go/time"
|
||||||
|
"github.com/micro/services/clients/go/twitter"
|
||||||
|
"github.com/micro/services/clients/go/url"
|
||||||
|
"github.com/micro/services/clients/go/user"
|
||||||
|
"github.com/micro/services/clients/go/vehicle"
|
||||||
|
"github.com/micro/services/clients/go/weather"
|
||||||
|
"github.com/micro/services/clients/go/youtube"
|
||||||
|
)
|
||||||
|
|
||||||
|
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),
|
||||||
|
EvchargersService: evchargers.NewEvchargersService(token),
|
||||||
|
FileService: file.NewFileService(token),
|
||||||
|
ForexService: forex.NewForexService(token),
|
||||||
|
FunctionService: function.NewFunctionService(token),
|
||||||
|
GeocodingService: geocoding.NewGeocodingService(token),
|
||||||
|
GifsService: gifs.NewGifsService(token),
|
||||||
|
GoogleService: google.NewGoogleService(token),
|
||||||
|
HelloworldService: helloworld.NewHelloworldService(token),
|
||||||
|
HolidaysService: holidays.NewHolidaysService(token),
|
||||||
|
IdService: id.NewIdService(token),
|
||||||
|
ImageService: image.NewImageService(token),
|
||||||
|
IpService: ip.NewIpService(token),
|
||||||
|
LocationService: location.NewLocationService(token),
|
||||||
|
NotesService: notes.NewNotesService(token),
|
||||||
|
OtpService: otp.NewOtpService(token),
|
||||||
|
PostcodeService: postcode.NewPostcodeService(token),
|
||||||
|
PrayerService: prayer.NewPrayerService(token),
|
||||||
|
QrService: qr.NewQrService(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),
|
||||||
|
SunnahService: sunnah.NewSunnahService(token),
|
||||||
|
ThumbnailService: thumbnail.NewThumbnailService(token),
|
||||||
|
TimeService: time.NewTimeService(token),
|
||||||
|
TwitterService: twitter.NewTwitterService(token),
|
||||||
|
UrlService: url.NewUrlService(token),
|
||||||
|
UserService: user.NewUserService(token),
|
||||||
|
VehicleService: vehicle.NewVehicleService(token),
|
||||||
|
WeatherService: weather.NewWeatherService(token),
|
||||||
|
YoutubeService: youtube.NewYoutubeService(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
|
||||||
|
EvchargersService *evchargers.EvchargersService
|
||||||
|
FileService *file.FileService
|
||||||
|
ForexService *forex.ForexService
|
||||||
|
FunctionService *function.FunctionService
|
||||||
|
GeocodingService *geocoding.GeocodingService
|
||||||
|
GifsService *gifs.GifsService
|
||||||
|
GoogleService *google.GoogleService
|
||||||
|
HelloworldService *helloworld.HelloworldService
|
||||||
|
HolidaysService *holidays.HolidaysService
|
||||||
|
IdService *id.IdService
|
||||||
|
ImageService *image.ImageService
|
||||||
|
IpService *ip.IpService
|
||||||
|
LocationService *location.LocationService
|
||||||
|
NotesService *notes.NotesService
|
||||||
|
OtpService *otp.OtpService
|
||||||
|
PostcodeService *postcode.PostcodeService
|
||||||
|
PrayerService *prayer.PrayerService
|
||||||
|
QrService *qr.QrService
|
||||||
|
QuranService *quran.QuranService
|
||||||
|
RoutingService *routing.RoutingService
|
||||||
|
RssService *rss.RssService
|
||||||
|
SentimentService *sentiment.SentimentService
|
||||||
|
SmsService *sms.SmsService
|
||||||
|
StockService *stock.StockService
|
||||||
|
StreamService *stream.StreamService
|
||||||
|
SunnahService *sunnah.SunnahService
|
||||||
|
ThumbnailService *thumbnail.ThumbnailService
|
||||||
|
TimeService *time.TimeService
|
||||||
|
TwitterService *twitter.TwitterService
|
||||||
|
UrlService *url.UrlService
|
||||||
|
UserService *user.UserService
|
||||||
|
VehicleService *vehicle.VehicleService
|
||||||
|
WeatherService *weather.WeatherService
|
||||||
|
YoutubeService *youtube.YoutubeService
|
||||||
|
}
|
||||||
125
notes/notes.go
Executable file
125
notes/notes.go
Executable file
@@ -0,0 +1,125 @@
|
|||||||
|
package notes
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/m3o/m3o-go/client"
|
||||||
|
)
|
||||||
|
|
||||||
|
func NewNotesService(token string) *NotesService {
|
||||||
|
return &NotesService{
|
||||||
|
client: client.NewClient(&client.Options{
|
||||||
|
Token: token,
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type NotesService struct {
|
||||||
|
client *client.Client
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a new note
|
||||||
|
func (t *NotesService) Create(request *CreateRequest) (*CreateResponse, error) {
|
||||||
|
rsp := &CreateResponse{}
|
||||||
|
return rsp, t.client.Call("notes", "Create", request, rsp)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete a note
|
||||||
|
func (t *NotesService) Delete(request *DeleteRequest) (*DeleteResponse, error) {
|
||||||
|
rsp := &DeleteResponse{}
|
||||||
|
return rsp, t.client.Call("notes", "Delete", request, rsp)
|
||||||
|
}
|
||||||
|
|
||||||
|
// List all the notes
|
||||||
|
func (t *NotesService) List(request *ListRequest) (*ListResponse, error) {
|
||||||
|
rsp := &ListResponse{}
|
||||||
|
return rsp, t.client.Call("notes", "List", request, rsp)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read a note
|
||||||
|
func (t *NotesService) Read(request *ReadRequest) (*ReadResponse, error) {
|
||||||
|
rsp := &ReadResponse{}
|
||||||
|
return rsp, t.client.Call("notes", "Read", request, rsp)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Specify the note to events
|
||||||
|
func (t *NotesService) Subscribe(request *SubscribeRequest) (*SubscribeResponse, error) {
|
||||||
|
rsp := &SubscribeResponse{}
|
||||||
|
return rsp, t.client.Call("notes", "Subscribe", request, rsp)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update a note
|
||||||
|
func (t *NotesService) Update(request *UpdateRequest) (*UpdateResponse, error) {
|
||||||
|
rsp := &UpdateResponse{}
|
||||||
|
return rsp, t.client.Call("notes", "Update", request, rsp)
|
||||||
|
}
|
||||||
|
|
||||||
|
type CreateRequest struct {
|
||||||
|
// note text
|
||||||
|
Text string `json:"text"`
|
||||||
|
// note title
|
||||||
|
Title string `json:"title"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CreateResponse struct {
|
||||||
|
// The created note
|
||||||
|
Note *Note `json:"note"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type DeleteRequest struct {
|
||||||
|
// specify the id of the note
|
||||||
|
Id string `json:"id"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type DeleteResponse struct {
|
||||||
|
Note *Note `json:"note"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ListRequest struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
type ListResponse struct {
|
||||||
|
// the list of notes
|
||||||
|
Notes []Note `json:"notes"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Note struct {
|
||||||
|
// time at which the note was created
|
||||||
|
Created string `json:"created"`
|
||||||
|
// unique id for the note, generated if not specified
|
||||||
|
Id string `json:"id"`
|
||||||
|
// text within the note
|
||||||
|
Text string `json:"text"`
|
||||||
|
// title of the note
|
||||||
|
Title string `json:"title"`
|
||||||
|
// time at which the note was updated
|
||||||
|
Updated string `json:"updated"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ReadRequest struct {
|
||||||
|
// the note id
|
||||||
|
Id string `json:"id"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ReadResponse struct {
|
||||||
|
// The note
|
||||||
|
Note *Note `json:"note"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type SubscribeRequest struct {
|
||||||
|
// optionally specify a note id
|
||||||
|
Id string `json:"id"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type SubscribeResponse struct {
|
||||||
|
// the event which occured; created, deleted, updated
|
||||||
|
Event string `json:"event"`
|
||||||
|
// the note which the operation occured on
|
||||||
|
Note *Note `json:"note"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type UpdateRequest struct {
|
||||||
|
Note *Note `json:"note"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type UpdateResponse struct {
|
||||||
|
Note *Note `json:"note"`
|
||||||
|
}
|
||||||
55
otp/otp.go
Executable file
55
otp/otp.go
Executable file
@@ -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,string"`
|
||||||
|
// unique id, email or user to generate an OTP for
|
||||||
|
Id string `json:"id"`
|
||||||
|
// number of characters (default: 6)
|
||||||
|
Size int64 `json:"size,string"`
|
||||||
|
}
|
||||||
|
|
||||||
|
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"`
|
||||||
|
}
|
||||||
87
postcode/postcode.go
Executable file
87
postcode/postcode.go
Executable file
@@ -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"`
|
||||||
|
}
|
||||||
69
prayer/prayer.go
Executable file
69
prayer/prayer.go
Executable file
@@ -0,0 +1,69 @@
|
|||||||
|
package prayer
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/m3o/m3o-go/client"
|
||||||
|
)
|
||||||
|
|
||||||
|
func NewPrayerService(token string) *PrayerService {
|
||||||
|
return &PrayerService{
|
||||||
|
client: client.NewClient(&client.Options{
|
||||||
|
Token: token,
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type PrayerService struct {
|
||||||
|
client *client.Client
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the prayer (salah) times for a location on a given date
|
||||||
|
func (t *PrayerService) Times(request *TimesRequest) (*TimesResponse, error) {
|
||||||
|
rsp := &TimesResponse{}
|
||||||
|
return rsp, t.client.Call("prayer", "Times", request, rsp)
|
||||||
|
}
|
||||||
|
|
||||||
|
type PrayerTime struct {
|
||||||
|
// asr time
|
||||||
|
Asr string `json:"asr"`
|
||||||
|
// date for prayer times in YYYY-MM-DD format
|
||||||
|
Date string `json:"date"`
|
||||||
|
// fajr time
|
||||||
|
Fajr string `json:"fajr"`
|
||||||
|
// isha time
|
||||||
|
Isha string `json:"isha"`
|
||||||
|
// maghrib time
|
||||||
|
Maghrib string `json:"maghrib"`
|
||||||
|
// time of sunrise
|
||||||
|
Sunrise string `json:"sunrise"`
|
||||||
|
// zuhr time
|
||||||
|
Zuhr string `json:"zuhr"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type TimesRequest struct {
|
||||||
|
// optional date in YYYY-MM-DD format, otherwise uses today
|
||||||
|
Date string `json:"date"`
|
||||||
|
// number of days to request times for
|
||||||
|
Days int32 `json:"days"`
|
||||||
|
// optional latitude used in place of location
|
||||||
|
Latitude float64 `json:"latitude"`
|
||||||
|
// location to retrieve prayer times for.
|
||||||
|
// this can be a specific address, city, etc
|
||||||
|
Location string `json:"location"`
|
||||||
|
// optional longitude used in place of location
|
||||||
|
Longitude float64 `json:"longitude"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type TimesResponse struct {
|
||||||
|
// date of request
|
||||||
|
Date string `json:"date"`
|
||||||
|
// number of days
|
||||||
|
Days int32 `json:"days"`
|
||||||
|
// latitude of location
|
||||||
|
Latitude float64 `json:"latitude"`
|
||||||
|
// location for the request
|
||||||
|
Location string `json:"location"`
|
||||||
|
// longitude of location
|
||||||
|
Longitude float64 `json:"longitude"`
|
||||||
|
// prayer times for the given location
|
||||||
|
Times []PrayerTime `json:"times"`
|
||||||
|
}
|
||||||
35
qr/qr.go
Executable file
35
qr/qr.go
Executable file
@@ -0,0 +1,35 @@
|
|||||||
|
package qr
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/m3o/m3o-go/client"
|
||||||
|
)
|
||||||
|
|
||||||
|
func NewQrService(token string) *QrService {
|
||||||
|
return &QrService{
|
||||||
|
client: client.NewClient(&client.Options{
|
||||||
|
Token: token,
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type QrService struct {
|
||||||
|
client *client.Client
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate a QR code with a specific text and size
|
||||||
|
func (t *QrService) Generate(request *GenerateRequest) (*GenerateResponse, error) {
|
||||||
|
rsp := &GenerateResponse{}
|
||||||
|
return rsp, t.client.Call("qr", "Generate", request, rsp)
|
||||||
|
}
|
||||||
|
|
||||||
|
type GenerateRequest struct {
|
||||||
|
// the size (height and width) in pixels of the generated QR code. Defaults to 256
|
||||||
|
Size int64 `json:"size,string"`
|
||||||
|
// the text to encode as a QR code (URL, phone number, email, etc)
|
||||||
|
Text string `json:"text"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type GenerateResponse struct {
|
||||||
|
// link to the QR code image in PNG format
|
||||||
|
Qr string `json:"qr"`
|
||||||
|
}
|
||||||
218
quran/quran.go
Executable file
218
quran/quran.go
Executable file
@@ -0,0 +1,218 @@
|
|||||||
|
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 including
|
||||||
|
// translation, interpretation and breakdown by individual
|
||||||
|
// words.
|
||||||
|
func (t *QuranService) Verses(request *VersesRequest) (*VersesResponse, error) {
|
||||||
|
rsp := &VersesResponse{}
|
||||||
|
return rsp, t.client.Call("quran", "Verses", request, rsp)
|
||||||
|
}
|
||||||
|
|
||||||
|
type Chapter struct {
|
||||||
|
// 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 []Interpretation `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"`
|
||||||
|
}
|
||||||
129
routing/routing.go
Executable file
129
routing/routing.go
Executable file
@@ -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"`
|
||||||
|
}
|
||||||
114
rss/rss.go
Executable file
114
rss/rss.go
Executable file
@@ -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,string"`
|
||||||
|
// rss feed name
|
||||||
|
Name string `json:"name"`
|
||||||
|
// offset entries
|
||||||
|
Offset int64 `json:"offset,string"`
|
||||||
|
}
|
||||||
|
|
||||||
|
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 {
|
||||||
|
}
|
||||||
35
sentiment/sentiment.go
Executable file
35
sentiment/sentiment.go
Executable file
@@ -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"`
|
||||||
|
}
|
||||||
39
sms/sms.go
Executable file
39
sms/sms.go
Executable file
@@ -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>"
|
||||||
|
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"`
|
||||||
|
}
|
||||||
132
stock/stock.go
Executable file
132
stock/stock.go
Executable file
@@ -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"`
|
||||||
|
}
|
||||||
51
stream/stream.go
Executable file
51
stream/stream.go
Executable file
@@ -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"`
|
||||||
|
}
|
||||||
183
sunnah/sunnah.go
Executable file
183
sunnah/sunnah.go
Executable file
@@ -0,0 +1,183 @@
|
|||||||
|
package sunnah
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/m3o/m3o-go/client"
|
||||||
|
)
|
||||||
|
|
||||||
|
func NewSunnahService(token string) *SunnahService {
|
||||||
|
return &SunnahService{
|
||||||
|
client: client.NewClient(&client.Options{
|
||||||
|
Token: token,
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type SunnahService struct {
|
||||||
|
client *client.Client
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get a list of books from within a collection. A book can contain many chapters
|
||||||
|
// each with its own hadiths.
|
||||||
|
func (t *SunnahService) Books(request *BooksRequest) (*BooksResponse, error) {
|
||||||
|
rsp := &BooksResponse{}
|
||||||
|
return rsp, t.client.Call("sunnah", "Books", request, rsp)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get all the chapters of a given book within a collection.
|
||||||
|
func (t *SunnahService) Chapters(request *ChaptersRequest) (*ChaptersResponse, error) {
|
||||||
|
rsp := &ChaptersResponse{}
|
||||||
|
return rsp, t.client.Call("sunnah", "Chapters", request, rsp)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get a list of available collections. A collection is
|
||||||
|
// a compilation of hadiths collected and written by an author.
|
||||||
|
func (t *SunnahService) Collections(request *CollectionsRequest) (*CollectionsResponse, error) {
|
||||||
|
rsp := &CollectionsResponse{}
|
||||||
|
return rsp, t.client.Call("sunnah", "Collections", request, rsp)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hadiths returns a list of hadiths and their corresponding text for a
|
||||||
|
// given book within a collection.
|
||||||
|
func (t *SunnahService) Hadiths(request *HadithsRequest) (*HadithsResponse, error) {
|
||||||
|
rsp := &HadithsResponse{}
|
||||||
|
return rsp, t.client.Call("sunnah", "Hadiths", request, rsp)
|
||||||
|
}
|
||||||
|
|
||||||
|
type Book struct {
|
||||||
|
// arabic name of the book
|
||||||
|
ArabicName string `json:"arabicName"`
|
||||||
|
// number of hadiths in the book
|
||||||
|
Hadiths int32 `json:"hadiths"`
|
||||||
|
// number of the book e.g 1
|
||||||
|
Id int32 `json:"id"`
|
||||||
|
// name of the book
|
||||||
|
Name string `json:"name"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type BooksRequest struct {
|
||||||
|
// Name of the collection
|
||||||
|
Collection string `json:"collection"`
|
||||||
|
// Limit the number of books returned
|
||||||
|
Limit int32 `json:"limit"`
|
||||||
|
// The page in the pagination
|
||||||
|
Page int32 `json:"page"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type BooksResponse struct {
|
||||||
|
// A list of books
|
||||||
|
Books []Book `json:"books"`
|
||||||
|
// Name of the collection
|
||||||
|
Collection string `json:"collection"`
|
||||||
|
// The limit specified
|
||||||
|
Limit int32 `json:"limit"`
|
||||||
|
// The page requested
|
||||||
|
Page int32 `json:"page"`
|
||||||
|
// The total overall books
|
||||||
|
Total int32 `json:"total"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Chapter struct {
|
||||||
|
// arabic title
|
||||||
|
ArabicTitle string `json:"arabicTitle"`
|
||||||
|
// the book number
|
||||||
|
Book int32 `json:"book"`
|
||||||
|
// the chapter id e.g 1
|
||||||
|
Id int32 `json:"id"`
|
||||||
|
// the chapter key e.g 1.00
|
||||||
|
Key string `json:"key"`
|
||||||
|
// title of the chapter
|
||||||
|
Title string `json:"title"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ChaptersRequest struct {
|
||||||
|
// number of the book
|
||||||
|
Book int32 `json:"book"`
|
||||||
|
// name of the collection
|
||||||
|
Collection string `json:"collection"`
|
||||||
|
// Limit the number of chapters returned
|
||||||
|
Limit int32 `json:"limit"`
|
||||||
|
// The page in the pagination
|
||||||
|
Page int32 `json:"page"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ChaptersResponse struct {
|
||||||
|
// number of the book
|
||||||
|
Book int32 `json:"book"`
|
||||||
|
// The chapters of the book
|
||||||
|
Chapters []Chapter `json:"chapters"`
|
||||||
|
// name of the collection
|
||||||
|
Collection string `json:"collection"`
|
||||||
|
// Limit the number of chapters returned
|
||||||
|
Limit int32 `json:"limit"`
|
||||||
|
// The page in the pagination
|
||||||
|
Page int32 `json:"page"`
|
||||||
|
// Total chapters in the book
|
||||||
|
Total int32 `json:"total"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Collection struct {
|
||||||
|
// Arabic title if available
|
||||||
|
ArabicTitle string `json:"arabicTitle"`
|
||||||
|
// Total hadiths in the collection
|
||||||
|
Hadiths int32 `json:"hadiths"`
|
||||||
|
// Name of the collection e.g bukhari
|
||||||
|
Name string `json:"name"`
|
||||||
|
// An introduction explaining the collection
|
||||||
|
Summary string `json:"summary"`
|
||||||
|
// Title of the collection e.g Sahih al-Bukhari
|
||||||
|
Title string `json:"title"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CollectionsRequest struct {
|
||||||
|
// Number of collections to limit to
|
||||||
|
Limit int32 `json:"limit"`
|
||||||
|
// The page in the pagination
|
||||||
|
Page int32 `json:"page"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CollectionsResponse struct {
|
||||||
|
Collections []Collection `json:"collections"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Hadith struct {
|
||||||
|
// the arabic chapter title
|
||||||
|
ArabicChapterTitle string `json:"arabicChapterTitle"`
|
||||||
|
// the arabic text
|
||||||
|
ArabicText string `json:"arabicText"`
|
||||||
|
// the chapter id
|
||||||
|
Chapter int32 `json:"chapter"`
|
||||||
|
// the chapter key
|
||||||
|
ChapterKey string `json:"chapterKey"`
|
||||||
|
// the chapter title
|
||||||
|
ChapterTitle string `json:"chapterTitle"`
|
||||||
|
// hadith id
|
||||||
|
Id int32 `json:"id"`
|
||||||
|
// hadith text
|
||||||
|
Text string `json:"text"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type HadithsRequest struct {
|
||||||
|
// number of the book
|
||||||
|
Book int32 `json:"book"`
|
||||||
|
// name of the collection
|
||||||
|
Collection string `json:"collection"`
|
||||||
|
// Limit the number of hadiths
|
||||||
|
Limit int32 `json:"limit"`
|
||||||
|
// The page in the pagination
|
||||||
|
Page int32 `json:"page"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type HadithsResponse struct {
|
||||||
|
// number of the book
|
||||||
|
Book int32 `json:"book"`
|
||||||
|
// name of the collection
|
||||||
|
Collection string `json:"collection"`
|
||||||
|
// The hadiths of the book
|
||||||
|
Hadiths []Hadith `json:"hadiths"`
|
||||||
|
// Limit the number of hadiths returned
|
||||||
|
Limit int32 `json:"limit"`
|
||||||
|
// The page in the pagination
|
||||||
|
Page int32 `json:"page"`
|
||||||
|
// Total hadiths in the book
|
||||||
|
Total int32 `json:"total"`
|
||||||
|
}
|
||||||
35
thumbnail/thumbnail.go
Executable file
35
thumbnail/thumbnail.go
Executable file
@@ -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"`
|
||||||
|
}
|
||||||
73
time/time.go
Executable file
73
time/time.go
Executable file
@@ -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,string"`
|
||||||
|
}
|
||||||
|
|
||||||
|
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"`
|
||||||
|
}
|
||||||
132
twitter/twitter.go
Executable file
132
twitter/twitter.go
Executable file
@@ -0,0 +1,132 @@
|
|||||||
|
package twitter
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/m3o/m3o-go/client"
|
||||||
|
)
|
||||||
|
|
||||||
|
func NewTwitterService(token string) *TwitterService {
|
||||||
|
return &TwitterService{
|
||||||
|
client: client.NewClient(&client.Options{
|
||||||
|
Token: token,
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type TwitterService struct {
|
||||||
|
client *client.Client
|
||||||
|
}
|
||||||
|
|
||||||
|
// Search for tweets with a simple query
|
||||||
|
func (t *TwitterService) Search(request *SearchRequest) (*SearchResponse, error) {
|
||||||
|
rsp := &SearchResponse{}
|
||||||
|
return rsp, t.client.Call("twitter", "Search", request, rsp)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the timeline for a given user
|
||||||
|
func (t *TwitterService) Timeline(request *TimelineRequest) (*TimelineResponse, error) {
|
||||||
|
rsp := &TimelineResponse{}
|
||||||
|
return rsp, t.client.Call("twitter", "Timeline", request, rsp)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the current global trending topics
|
||||||
|
func (t *TwitterService) Trends(request *TrendsRequest) (*TrendsResponse, error) {
|
||||||
|
rsp := &TrendsResponse{}
|
||||||
|
return rsp, t.client.Call("twitter", "Trends", request, rsp)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get a user's twitter profile
|
||||||
|
func (t *TwitterService) User(request *UserRequest) (*UserResponse, error) {
|
||||||
|
rsp := &UserResponse{}
|
||||||
|
return rsp, t.client.Call("twitter", "User", request, rsp)
|
||||||
|
}
|
||||||
|
|
||||||
|
type Profile struct {
|
||||||
|
// the account creation date
|
||||||
|
CreatedAt string `json:"createdAt"`
|
||||||
|
// the user description
|
||||||
|
Description string `json:"description"`
|
||||||
|
// the follower count
|
||||||
|
Followers int64 `json:"followers,string"`
|
||||||
|
// the user id
|
||||||
|
Id int64 `json:"id,string"`
|
||||||
|
// The user's profile picture
|
||||||
|
ImageUrl string `json:"imageUrl"`
|
||||||
|
// the user's location
|
||||||
|
Location string `json:"location"`
|
||||||
|
// display name of the user
|
||||||
|
Name string `json:"name"`
|
||||||
|
// if the account is private
|
||||||
|
Private bool `json:"private"`
|
||||||
|
// the username
|
||||||
|
Username string `json:"username"`
|
||||||
|
// if the account is verified
|
||||||
|
Verified bool `json:"verified"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type SearchRequest struct {
|
||||||
|
// number of tweets to return. default: 20
|
||||||
|
Limit int32 `json:"limit"`
|
||||||
|
// the query to search for
|
||||||
|
Query string `json:"query"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type SearchResponse struct {
|
||||||
|
// the related tweets for the search
|
||||||
|
Tweets []Tweet `json:"tweets"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type TimelineRequest struct {
|
||||||
|
// number of tweets to return. default: 20
|
||||||
|
Limit int32 `json:"limit"`
|
||||||
|
// the username to request the timeline for
|
||||||
|
Username string `json:"username"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type TimelineResponse struct {
|
||||||
|
// The recent tweets for the user
|
||||||
|
Tweets []Tweet `json:"tweets"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Trend struct {
|
||||||
|
// name of the trend
|
||||||
|
Name string `json:"name"`
|
||||||
|
// the volume of tweets in last 24 hours
|
||||||
|
TweetVolume int64 `json:"tweetVolume,string"`
|
||||||
|
// the twitter url
|
||||||
|
Url string `json:"url"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type TrendsRequest struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
type TrendsResponse struct {
|
||||||
|
// a list of trending topics
|
||||||
|
Trends []Trend `json:"trends"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Tweet struct {
|
||||||
|
// time of tweet
|
||||||
|
CreatedAt string `json:"createdAt"`
|
||||||
|
// number of times favourited
|
||||||
|
FavouritedCount int64 `json:"favouritedCount,string"`
|
||||||
|
// id of the tweet
|
||||||
|
Id int64 `json:"id,string"`
|
||||||
|
// number of times retweeted
|
||||||
|
RetweetedCount int64 `json:"retweetedCount,string"`
|
||||||
|
// text of the tweet
|
||||||
|
Text string `json:"text"`
|
||||||
|
// username of the person who tweeted
|
||||||
|
Username string `json:"username"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type UserRequest struct {
|
||||||
|
// the username to lookup
|
||||||
|
Username string `json:"username"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type UserResponse struct {
|
||||||
|
// The requested user profile
|
||||||
|
Profile *Profile `json:"profile"`
|
||||||
|
// the current user status
|
||||||
|
Status *Tweet `json:"status"`
|
||||||
|
}
|
||||||
73
url/url.go
Executable file
73
url/url.go
Executable file
@@ -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,string"`
|
||||||
|
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,string"`
|
||||||
|
Owner string `json:"owner"`
|
||||||
|
ShortUrl string `json:"shortUrl"`
|
||||||
|
}
|
||||||
233
user/user.go
Executable file
233
user/user.go
Executable file
@@ -0,0 +1,233 @@
|
|||||||
|
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&redirectUrl=your-redir-url'
|
||||||
|
func (t *UserService) SendVerificationEmail(request *SendVerificationEmailRequest) (*SendVerificationEmailResponse, error) {
|
||||||
|
rsp := &SendVerificationEmailResponse{}
|
||||||
|
return rsp, t.client.Call("user", "SendVerificationEmail", request, rsp)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the account password
|
||||||
|
func (t *UserService) UpdatePassword(request *UpdatePasswordRequest) (*UpdatePasswordResponse, error) {
|
||||||
|
rsp := &UpdatePasswordResponse{}
|
||||||
|
return rsp, t.client.Call("user", "UpdatePassword", request, rsp)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the account username or email
|
||||||
|
func (t *UserService) Update(request *UpdateRequest) (*UpdateResponse, error) {
|
||||||
|
rsp := &UpdateResponse{}
|
||||||
|
return rsp, t.client.Call("user", "Update", request, rsp)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify the email address of an account from a token sent in an email to the user.
|
||||||
|
func (t *UserService) VerifyEmail(request *VerifyEmailRequest) (*VerifyEmailResponse, error) {
|
||||||
|
rsp := &VerifyEmailResponse{}
|
||||||
|
return rsp, t.client.Call("user", "VerifyEmail", request, rsp)
|
||||||
|
}
|
||||||
|
|
||||||
|
type Account struct {
|
||||||
|
// unix timestamp
|
||||||
|
Created int64 `json:"created,string"`
|
||||||
|
// 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,string"`
|
||||||
|
// alphanumeric username
|
||||||
|
Username string `json:"username"`
|
||||||
|
// date of verification
|
||||||
|
VerificationDate int64 `json:"verificationDate,string"`
|
||||||
|
// if the account is verified
|
||||||
|
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<string,string>
|
||||||
|
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,string"`
|
||||||
|
// unix timestamp
|
||||||
|
Expires int64 `json:"expires,string"`
|
||||||
|
// 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<string,string>
|
||||||
|
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 {
|
||||||
|
}
|
||||||
61
vehicle/vehicle.go
Executable file
61
vehicle/vehicle.go
Executable file
@@ -0,0 +1,61 @@
|
|||||||
|
package vehicle
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/m3o/m3o-go/client"
|
||||||
|
)
|
||||||
|
|
||||||
|
func NewVehicleService(token string) *VehicleService {
|
||||||
|
return &VehicleService{
|
||||||
|
client: client.NewClient(&client.Options{
|
||||||
|
Token: token,
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type VehicleService struct {
|
||||||
|
client *client.Client
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lookup a UK vehicle by it's registration number
|
||||||
|
func (t *VehicleService) Lookup(request *LookupRequest) (*LookupResponse, error) {
|
||||||
|
rsp := &LookupResponse{}
|
||||||
|
return rsp, t.client.Call("vehicle", "Lookup", request, rsp)
|
||||||
|
}
|
||||||
|
|
||||||
|
type LookupRequest struct {
|
||||||
|
// the vehicle registration number
|
||||||
|
Registration string `json:"registration"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type LookupResponse struct {
|
||||||
|
// co2 emmissions
|
||||||
|
Co2emissions float64 `json:"co2emissions"`
|
||||||
|
// colour of vehicle
|
||||||
|
Colour string `json:"colour"`
|
||||||
|
// engine capacity
|
||||||
|
EngineCapacity int32 `json:"engineCapacity"`
|
||||||
|
// fuel type e.g petrol, diesel
|
||||||
|
FuelType string `json:"fuelType"`
|
||||||
|
// date of last v5 issue
|
||||||
|
LastV5issued string `json:"lastV5issued"`
|
||||||
|
// make of vehicle
|
||||||
|
Make string `json:"make"`
|
||||||
|
// month of first registration
|
||||||
|
MonthOfFirstRegistration string `json:"monthOfFirstRegistration"`
|
||||||
|
// mot expiry
|
||||||
|
MotExpiry string `json:"motExpiry"`
|
||||||
|
// mot status
|
||||||
|
MotStatus string `json:"motStatus"`
|
||||||
|
// registration number
|
||||||
|
Registration string `json:"registration"`
|
||||||
|
// tax due data
|
||||||
|
TaxDueDate string `json:"taxDueDate"`
|
||||||
|
// tax status
|
||||||
|
TaxStatus string `json:"taxStatus"`
|
||||||
|
// type approvale
|
||||||
|
TypeApproval string `json:"typeApproval"`
|
||||||
|
// wheel plan
|
||||||
|
Wheelplan string `json:"wheelplan"`
|
||||||
|
// year of manufacture
|
||||||
|
YearOfManufacture int32 `json:"yearOfManufacture"`
|
||||||
|
}
|
||||||
132
weather/weather.go
Executable file
132
weather/weather.go
Executable file
@@ -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"`
|
||||||
|
}
|
||||||
55
youtube/youtube.go
Executable file
55
youtube/youtube.go
Executable file
@@ -0,0 +1,55 @@
|
|||||||
|
package youtube
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/m3o/m3o-go/client"
|
||||||
|
)
|
||||||
|
|
||||||
|
func NewYoutubeService(token string) *YoutubeService {
|
||||||
|
return &YoutubeService{
|
||||||
|
client: client.NewClient(&client.Options{
|
||||||
|
Token: token,
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type YoutubeService struct {
|
||||||
|
client *client.Client
|
||||||
|
}
|
||||||
|
|
||||||
|
// Search for videos on YouTube
|
||||||
|
func (t *YoutubeService) Search(request *SearchRequest) (*SearchResponse, error) {
|
||||||
|
rsp := &SearchResponse{}
|
||||||
|
return rsp, t.client.Call("youtube", "Search", request, rsp)
|
||||||
|
}
|
||||||
|
|
||||||
|
type SearchRequest struct {
|
||||||
|
// Query to search for
|
||||||
|
Query string `json:"query"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type SearchResponse struct {
|
||||||
|
// List of results for the query
|
||||||
|
Results []SearchResult `json:"results"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type SearchResult struct {
|
||||||
|
// if live broadcast then indicates activity.
|
||||||
|
// none, upcoming, live, completed
|
||||||
|
Broadcasting string `json:"broadcasting"`
|
||||||
|
// the channel id
|
||||||
|
ChannelId string `json:"channelId"`
|
||||||
|
// the channel title
|
||||||
|
ChannelTitle string `json:"channelTitle"`
|
||||||
|
// the result description
|
||||||
|
Description string `json:"description"`
|
||||||
|
// id of the result
|
||||||
|
Id string `json:"id"`
|
||||||
|
// kind of result; "video", "channel", "playlist"
|
||||||
|
Kind string `json:"kind"`
|
||||||
|
// published at time
|
||||||
|
PublishedAt string `json:"publishedAt"`
|
||||||
|
// title of the result
|
||||||
|
Title string `json:"title"`
|
||||||
|
// the associated url
|
||||||
|
Url string `json:"url"`
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user