mirror of
https://github.com/kevin-DL/m3o-go.git
synced 2026-01-24 15:35:30 +00:00
Compare commits
218 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c362c676b2 | ||
|
|
9702ed5306 | ||
|
|
afe052b320 | ||
|
|
a7879d3ff0 | ||
|
|
45d3c6a791 | ||
|
|
3760aaf9dd | ||
|
|
3953482915 | ||
|
|
9864b467b8 | ||
|
|
675871d282 | ||
|
|
3ac4947f91 | ||
|
|
3167558049 | ||
|
|
2958807fe2 | ||
|
|
8e553f6e16 | ||
|
|
bc769baed5 | ||
|
|
2ca79f5288 | ||
|
|
a22b8a3053 | ||
|
|
fd05c41d21 | ||
|
|
9bfc15e14a | ||
|
|
b522b298f3 | ||
|
|
14d247a66c | ||
|
|
ef2606dc60 | ||
|
|
be8f5aeae4 | ||
|
|
8dcea9e986 | ||
|
|
af0c644ac3 | ||
|
|
ebd60b1d5c | ||
|
|
38d4ff491f | ||
|
|
21395762be | ||
|
|
28a3532ecb | ||
|
|
7fec9491f1 | ||
|
|
ae8a49329f | ||
|
|
93af926271 | ||
|
|
40f0fb073d | ||
|
|
4c6a11492e | ||
|
|
e5f79370cd | ||
|
|
4e8f9de392 | ||
|
|
03b2b439e5 | ||
|
|
f1e6613177 | ||
|
|
ea7e43f6cd | ||
|
|
edd466a2f9 | ||
|
|
730ab1fa1e | ||
|
|
23dd049bf8 | ||
|
|
1947d31ee7 | ||
|
|
2b6719c9c6 | ||
|
|
00d34547f3 | ||
|
|
0f8436ce86 | ||
|
|
bb53f7cc48 | ||
|
|
9e5bed8e5a | ||
|
|
caac0f5355 | ||
|
|
5685e31a37 | ||
|
|
c43f57ce29 | ||
|
|
d9476960d4 | ||
|
|
3f583e059f | ||
|
|
bd1dcf3fed | ||
|
|
baff11e1d7 | ||
|
|
7c67ac14c2 | ||
|
|
fb8efda643 | ||
|
|
6fcd1d7028 | ||
|
|
02558a8f3f | ||
|
|
17f624b6a7 | ||
|
|
3f9d7cccf8 | ||
|
|
cb7f8b3403 | ||
|
|
072d96b1ca | ||
|
|
03a7225806 | ||
|
|
1083f55216 | ||
|
|
bd469033e2 | ||
|
|
b5f58efe8b | ||
|
|
018e87a593 | ||
|
|
07312f010e | ||
|
|
2321fde555 | ||
|
|
be676eff6c | ||
|
|
9dcc428a55 | ||
|
|
b6d8111005 | ||
|
|
1e54e284f6 | ||
|
|
d31fde4be4 | ||
|
|
d2adcc0208 | ||
|
|
956adcbced | ||
|
|
fab7b1892d | ||
|
|
7d037fe871 | ||
|
|
53a197a685 | ||
|
|
a7586670e6 | ||
|
|
2b5509db64 | ||
|
|
03a720c4d0 | ||
|
|
581945da61 | ||
|
|
d27ecddd94 | ||
|
|
034d9aa5ac | ||
|
|
328997c217 | ||
|
|
f87a55000e | ||
|
|
5ec5e88b61 | ||
|
|
d664134226 | ||
|
|
20bb0adb52 | ||
|
|
b32923c69c | ||
|
|
bb8552ac72 | ||
|
|
2e2264a045 | ||
|
|
8fbc04d515 | ||
|
|
6c77e113d7 | ||
|
|
be500e861e | ||
|
|
8217b63c9a | ||
|
|
5e75ed6f44 | ||
|
|
3ea4ec9b77 | ||
|
|
6715cd7575 | ||
|
|
36fa586811 | ||
|
|
f3c2a87ba8 | ||
|
|
48a07e015a | ||
|
|
2deeb0ca70 | ||
|
|
1305ec64f5 | ||
|
|
120c1cfe31 | ||
|
|
3c1c9769fb | ||
|
|
9404bd621a | ||
|
|
429d8543ba | ||
|
|
0515ac3485 | ||
|
|
36ebf2726c | ||
|
|
13eb3a674c | ||
|
|
b724299623 | ||
|
|
a2eea8e982 | ||
|
|
b36641e39e | ||
|
|
e9f001a53c | ||
|
|
80c683fa2a | ||
|
|
7b1ff7cdba | ||
|
|
93b0465212 | ||
|
|
0c2f5b7138 | ||
|
|
0d4aacf4c1 | ||
|
|
3cd6a304e8 | ||
|
|
5ed7ec293a | ||
|
|
b69dce32b5 | ||
|
|
24a8774b65 | ||
|
|
c70c849348 | ||
|
|
48a87453db | ||
|
|
d02ff341b9 | ||
|
|
e357681055 | ||
|
|
01728ef128 | ||
|
|
57653a725d | ||
|
|
ceba4eac78 | ||
|
|
e2457aa0ef | ||
|
|
eff7396cfd | ||
|
|
b6914f82d4 | ||
|
|
e3e358df0b | ||
|
|
78900e379e | ||
|
|
39cf329baa | ||
|
|
c4df401021 | ||
|
|
7d5d0555b3 | ||
|
|
16e313b176 | ||
|
|
f5e55c81b0 | ||
|
|
d0307610bc | ||
|
|
cab87b9b3e | ||
|
|
c18a866b71 | ||
|
|
5f43c72002 | ||
|
|
d9c5465869 | ||
|
|
bf17b77f32 | ||
|
|
dc963b5c18 | ||
|
|
d0c9e6f959 | ||
|
|
87139ca743 | ||
|
|
c9438a2715 | ||
|
|
fcf0cacf5f | ||
|
|
dd375dcb39 | ||
|
|
df176092d8 | ||
|
|
5c96743ac2 | ||
|
|
2293c9ffcd | ||
|
|
6814ff2132 | ||
|
|
3b0248b764 | ||
|
|
b71caa6818 | ||
|
|
857cdfd2ad | ||
|
|
de3da7ad78 | ||
|
|
9661bd5ae1 | ||
|
|
4ffa2e1a25 | ||
|
|
bab7357a54 | ||
|
|
e5e197566d | ||
|
|
e256e24571 | ||
|
|
a72108fe32 | ||
|
|
a88d369ab2 | ||
|
|
784c4e4c37 | ||
|
|
2e374bf3b0 | ||
|
|
36ea54da44 | ||
|
|
6a5d769c70 | ||
|
|
5963caaa3f | ||
|
|
611202c283 | ||
|
|
1645b031e1 | ||
|
|
d87e334dca | ||
|
|
9a245d66ac | ||
|
|
7335a0576f | ||
|
|
aecab5372c | ||
|
|
a3f66cea0b | ||
|
|
2a5dc16cef | ||
|
|
3af01580b7 | ||
|
|
49e533797f | ||
|
|
2283f13e57 | ||
|
|
e59c2bcc38 | ||
|
|
c6b213570b | ||
|
|
8e6e73a8eb | ||
|
|
075c121632 | ||
|
|
99e2f22d5b | ||
|
|
8623e7fec8 | ||
|
|
114660a002 | ||
|
|
913e2d609a | ||
|
|
ec70bb0b96 | ||
|
|
0e5e506abb | ||
|
|
96b0791847 | ||
|
|
15117f4033 | ||
|
|
716231b211 | ||
|
|
abbc8bcd49 | ||
|
|
c5f35e9f42 | ||
|
|
1b52b0f771 | ||
|
|
6533fdf6ff | ||
|
|
476fc61f51 | ||
|
|
fa2e8a5283 | ||
|
|
a8b7e20a0c | ||
|
|
d38b38c742 | ||
|
|
47e7a6709f | ||
|
|
68b5269093 | ||
|
|
4707018011 | ||
|
|
f3da9bd908 | ||
|
|
2ccc1a4d17 | ||
|
|
eff35e79ef | ||
|
|
fe077602a7 | ||
|
|
e2913e9e7c | ||
|
|
0561a7f7c2 | ||
|
|
21ded67c07 | ||
|
|
b3f128386d | ||
|
|
97f56e72a2 |
31
.github/workflows/generate.yml
vendored
Normal file
31
.github/workflows/generate.yml
vendored
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
name: Test Clients
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- beta
|
||||||
|
- ci
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
generate:
|
||||||
|
name: Test Clients
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Check out repo
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
path: clients
|
||||||
|
#ref: main
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
working-directory: clients
|
||||||
|
env:
|
||||||
|
M3O_API_TOKEN: ${{ secrets.M3O_API_TOKEN }}
|
||||||
|
run: |
|
||||||
|
# stream is temporarily excluded as it hangs forever because test does not close connection
|
||||||
|
# @TODO remove "idempotent: true" from stream example
|
||||||
|
O=$(find . -name ".run" | grep -v stream | xargs -n1 dirname | xargs -n1 go run)
|
||||||
|
echo $O
|
||||||
|
if grep -q Detail "$O"; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
@@ -18,8 +18,10 @@ type AddressService struct {
|
|||||||
|
|
||||||
// Lookup a list of UK addresses by postcode
|
// Lookup a list of UK addresses by postcode
|
||||||
func (t *AddressService) LookupPostcode(request *LookupPostcodeRequest) (*LookupPostcodeResponse, error) {
|
func (t *AddressService) LookupPostcode(request *LookupPostcodeRequest) (*LookupPostcodeResponse, error) {
|
||||||
|
|
||||||
rsp := &LookupPostcodeResponse{}
|
rsp := &LookupPostcodeResponse{}
|
||||||
return rsp, t.client.Call("address", "LookupPostcode", request, rsp)
|
return rsp, t.client.Call("address", "LookupPostcode", request, rsp)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type LookupPostcodeRequest struct {
|
type LookupPostcodeRequest struct {
|
||||||
|
|||||||
@@ -18,8 +18,10 @@ type AnswerService struct {
|
|||||||
|
|
||||||
// Ask a question and receive an instant answer
|
// Ask a question and receive an instant answer
|
||||||
func (t *AnswerService) Question(request *QuestionRequest) (*QuestionResponse, error) {
|
func (t *AnswerService) Question(request *QuestionRequest) (*QuestionResponse, error) {
|
||||||
|
|
||||||
rsp := &QuestionResponse{}
|
rsp := &QuestionResponse{}
|
||||||
return rsp, t.client.Call("answer", "Question", request, rsp)
|
return rsp, t.client.Call("answer", "Question", request, rsp)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type QuestionRequest struct {
|
type QuestionRequest struct {
|
||||||
|
|||||||
18
cache/cache.go
vendored
18
cache/cache.go
vendored
@@ -16,34 +16,44 @@ type CacheService struct {
|
|||||||
client *client.Client
|
client *client.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decrement a value (if it's a number)
|
// Decrement a value (if it's a number). If key not found it is equivalent to set.
|
||||||
func (t *CacheService) Decrement(request *DecrementRequest) (*DecrementResponse, error) {
|
func (t *CacheService) Decrement(request *DecrementRequest) (*DecrementResponse, error) {
|
||||||
|
|
||||||
rsp := &DecrementResponse{}
|
rsp := &DecrementResponse{}
|
||||||
return rsp, t.client.Call("cache", "Decrement", request, rsp)
|
return rsp, t.client.Call("cache", "Decrement", request, rsp)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete a value from the cache
|
// Delete a value from the cache. If key not found a success response is returned.
|
||||||
func (t *CacheService) Delete(request *DeleteRequest) (*DeleteResponse, error) {
|
func (t *CacheService) Delete(request *DeleteRequest) (*DeleteResponse, error) {
|
||||||
|
|
||||||
rsp := &DeleteResponse{}
|
rsp := &DeleteResponse{}
|
||||||
return rsp, t.client.Call("cache", "Delete", request, rsp)
|
return rsp, t.client.Call("cache", "Delete", request, rsp)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get an item from the cache by key
|
// Get an item from the cache by key. If key is not found, an empty response is returned.
|
||||||
func (t *CacheService) Get(request *GetRequest) (*GetResponse, error) {
|
func (t *CacheService) Get(request *GetRequest) (*GetResponse, error) {
|
||||||
|
|
||||||
rsp := &GetResponse{}
|
rsp := &GetResponse{}
|
||||||
return rsp, t.client.Call("cache", "Get", request, rsp)
|
return rsp, t.client.Call("cache", "Get", request, rsp)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Increment a value (if it's a number)
|
// Increment a value (if it's a number). If key not found it is equivalent to set.
|
||||||
func (t *CacheService) Increment(request *IncrementRequest) (*IncrementResponse, error) {
|
func (t *CacheService) Increment(request *IncrementRequest) (*IncrementResponse, error) {
|
||||||
|
|
||||||
rsp := &IncrementResponse{}
|
rsp := &IncrementResponse{}
|
||||||
return rsp, t.client.Call("cache", "Increment", request, rsp)
|
return rsp, t.client.Call("cache", "Increment", request, rsp)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set an item in the cache. Overwrites any existing value already set.
|
// Set an item in the cache. Overwrites any existing value already set.
|
||||||
func (t *CacheService) Set(request *SetRequest) (*SetResponse, error) {
|
func (t *CacheService) Set(request *SetRequest) (*SetResponse, error) {
|
||||||
|
|
||||||
rsp := &SetResponse{}
|
rsp := &SetResponse{}
|
||||||
return rsp, t.client.Call("cache", "Set", request, rsp)
|
return rsp, t.client.Call("cache", "Set", request, rsp)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type DecrementRequest struct {
|
type DecrementRequest struct {
|
||||||
|
|||||||
@@ -6,6 +6,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestBasicCall(t *testing.T) {
|
func TestBasicCall(t *testing.T) {
|
||||||
|
if v := os.Getenv("IN_TRAVIS"); v == "yes" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
response := map[string]interface{}{}
|
response := map[string]interface{}{}
|
||||||
if err := NewClient(&Options{
|
if err := NewClient(&Options{
|
||||||
Token: os.Getenv("TOKEN"),
|
Token: os.Getenv("TOKEN"),
|
||||||
|
|||||||
@@ -18,26 +18,34 @@ type CryptoService struct {
|
|||||||
|
|
||||||
// Returns the history for the previous close
|
// Returns the history for the previous close
|
||||||
func (t *CryptoService) History(request *HistoryRequest) (*HistoryResponse, error) {
|
func (t *CryptoService) History(request *HistoryRequest) (*HistoryResponse, error) {
|
||||||
|
|
||||||
rsp := &HistoryResponse{}
|
rsp := &HistoryResponse{}
|
||||||
return rsp, t.client.Call("crypto", "History", request, rsp)
|
return rsp, t.client.Call("crypto", "History", request, rsp)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get news related to a currency
|
// Get news related to a currency
|
||||||
func (t *CryptoService) News(request *NewsRequest) (*NewsResponse, error) {
|
func (t *CryptoService) News(request *NewsRequest) (*NewsResponse, error) {
|
||||||
|
|
||||||
rsp := &NewsResponse{}
|
rsp := &NewsResponse{}
|
||||||
return rsp, t.client.Call("crypto", "News", request, rsp)
|
return rsp, t.client.Call("crypto", "News", request, rsp)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the last price for a given crypto ticker
|
// Get the last price for a given crypto ticker
|
||||||
func (t *CryptoService) Price(request *PriceRequest) (*PriceResponse, error) {
|
func (t *CryptoService) Price(request *PriceRequest) (*PriceResponse, error) {
|
||||||
|
|
||||||
rsp := &PriceResponse{}
|
rsp := &PriceResponse{}
|
||||||
return rsp, t.client.Call("crypto", "Price", request, rsp)
|
return rsp, t.client.Call("crypto", "Price", request, rsp)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the last quote for a given crypto ticker
|
// Get the last quote for a given crypto ticker
|
||||||
func (t *CryptoService) Quote(request *QuoteRequest) (*QuoteResponse, error) {
|
func (t *CryptoService) Quote(request *QuoteRequest) (*QuoteResponse, error) {
|
||||||
|
|
||||||
rsp := &QuoteResponse{}
|
rsp := &QuoteResponse{}
|
||||||
return rsp, t.client.Call("crypto", "Quote", request, rsp)
|
return rsp, t.client.Call("crypto", "Quote", request, rsp)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Article struct {
|
type Article struct {
|
||||||
|
|||||||
@@ -18,26 +18,34 @@ type CurrencyService struct {
|
|||||||
|
|
||||||
// Codes returns the supported currency codes for the API
|
// Codes returns the supported currency codes for the API
|
||||||
func (t *CurrencyService) Codes(request *CodesRequest) (*CodesResponse, error) {
|
func (t *CurrencyService) Codes(request *CodesRequest) (*CodesResponse, error) {
|
||||||
|
|
||||||
rsp := &CodesResponse{}
|
rsp := &CodesResponse{}
|
||||||
return rsp, t.client.Call("currency", "Codes", request, rsp)
|
return rsp, t.client.Call("currency", "Codes", request, rsp)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert returns the currency conversion rate between two pairs e.g USD/GBP
|
// Convert returns the currency conversion rate between two pairs e.g USD/GBP
|
||||||
func (t *CurrencyService) Convert(request *ConvertRequest) (*ConvertResponse, error) {
|
func (t *CurrencyService) Convert(request *ConvertRequest) (*ConvertResponse, error) {
|
||||||
|
|
||||||
rsp := &ConvertResponse{}
|
rsp := &ConvertResponse{}
|
||||||
return rsp, t.client.Call("currency", "Convert", request, rsp)
|
return rsp, t.client.Call("currency", "Convert", request, rsp)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the historic rates for a currency on a given date
|
// Returns the historic rates for a currency on a given date
|
||||||
func (t *CurrencyService) History(request *HistoryRequest) (*HistoryResponse, error) {
|
func (t *CurrencyService) History(request *HistoryRequest) (*HistoryResponse, error) {
|
||||||
|
|
||||||
rsp := &HistoryResponse{}
|
rsp := &HistoryResponse{}
|
||||||
return rsp, t.client.Call("currency", "History", request, rsp)
|
return rsp, t.client.Call("currency", "History", request, rsp)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rates returns the currency rates for a given code e.g USD
|
// Rates returns the currency rates for a given code e.g USD
|
||||||
func (t *CurrencyService) Rates(request *RatesRequest) (*RatesResponse, error) {
|
func (t *CurrencyService) Rates(request *RatesRequest) (*RatesResponse, error) {
|
||||||
|
|
||||||
rsp := &RatesResponse{}
|
rsp := &RatesResponse{}
|
||||||
return rsp, t.client.Call("currency", "Rates", request, rsp)
|
return rsp, t.client.Call("currency", "Rates", request, rsp)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Code struct {
|
type Code struct {
|
||||||
|
|||||||
64
db/db.go
64
db/db.go
@@ -18,38 +18,74 @@ type DbService struct {
|
|||||||
|
|
||||||
// Count records in a table
|
// Count records in a table
|
||||||
func (t *DbService) Count(request *CountRequest) (*CountResponse, error) {
|
func (t *DbService) Count(request *CountRequest) (*CountResponse, error) {
|
||||||
|
|
||||||
rsp := &CountResponse{}
|
rsp := &CountResponse{}
|
||||||
return rsp, t.client.Call("db", "Count", request, rsp)
|
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.
|
// Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
|
||||||
func (t *DbService) Create(request *CreateRequest) (*CreateResponse, error) {
|
func (t *DbService) Create(request *CreateRequest) (*CreateResponse, error) {
|
||||||
|
|
||||||
rsp := &CreateResponse{}
|
rsp := &CreateResponse{}
|
||||||
return rsp, t.client.Call("db", "Create", request, rsp)
|
return rsp, t.client.Call("db", "Create", request, rsp)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete a record in the database by id.
|
// Delete a record in the database by id.
|
||||||
func (t *DbService) Delete(request *DeleteRequest) (*DeleteResponse, error) {
|
func (t *DbService) Delete(request *DeleteRequest) (*DeleteResponse, error) {
|
||||||
|
|
||||||
rsp := &DeleteResponse{}
|
rsp := &DeleteResponse{}
|
||||||
return rsp, t.client.Call("db", "Delete", request, rsp)
|
return rsp, t.client.Call("db", "Delete", request, rsp)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Drop a table in the DB
|
||||||
|
func (t *DbService) DropTable(request *DropTableRequest) (*DropTableResponse, error) {
|
||||||
|
|
||||||
|
rsp := &DropTableResponse{}
|
||||||
|
return rsp, t.client.Call("db", "DropTable", request, rsp)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// List tables in the DB
|
||||||
|
func (t *DbService) ListTables(request *ListTablesRequest) (*ListTablesResponse, error) {
|
||||||
|
|
||||||
|
rsp := &ListTablesResponse{}
|
||||||
|
return rsp, t.client.Call("db", "ListTables", request, rsp)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read data from a table. Lookup can be by ID or via querying any field in the record.
|
// 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) {
|
func (t *DbService) Read(request *ReadRequest) (*ReadResponse, error) {
|
||||||
|
|
||||||
rsp := &ReadResponse{}
|
rsp := &ReadResponse{}
|
||||||
return rsp, t.client.Call("db", "Read", request, rsp)
|
return rsp, t.client.Call("db", "Read", request, rsp)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rename a table
|
||||||
|
func (t *DbService) RenameTable(request *RenameTableRequest) (*RenameTableResponse, error) {
|
||||||
|
|
||||||
|
rsp := &RenameTableResponse{}
|
||||||
|
return rsp, t.client.Call("db", "RenameTable", request, rsp)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Truncate the records in a table
|
// Truncate the records in a table
|
||||||
func (t *DbService) Truncate(request *TruncateRequest) (*TruncateResponse, error) {
|
func (t *DbService) Truncate(request *TruncateRequest) (*TruncateResponse, error) {
|
||||||
|
|
||||||
rsp := &TruncateResponse{}
|
rsp := &TruncateResponse{}
|
||||||
return rsp, t.client.Call("db", "Truncate", request, rsp)
|
return rsp, t.client.Call("db", "Truncate", request, rsp)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update a record in the database. Include an "id" in the record to update.
|
// Update a record in the database. Include an "id" in the record to update.
|
||||||
func (t *DbService) Update(request *UpdateRequest) (*UpdateResponse, error) {
|
func (t *DbService) Update(request *UpdateRequest) (*UpdateResponse, error) {
|
||||||
|
|
||||||
rsp := &UpdateResponse{}
|
rsp := &UpdateResponse{}
|
||||||
return rsp, t.client.Call("db", "Update", request, rsp)
|
return rsp, t.client.Call("db", "Update", request, rsp)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type CountRequest struct {
|
type CountRequest struct {
|
||||||
@@ -84,6 +120,21 @@ type DeleteRequest struct {
|
|||||||
type DeleteResponse struct {
|
type DeleteResponse struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type DropTableRequest struct {
|
||||||
|
Table string `json:"table"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type DropTableResponse struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
type ListTablesRequest struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
type ListTablesResponse struct {
|
||||||
|
// list of tables
|
||||||
|
Tables []string `json:"tables"`
|
||||||
|
}
|
||||||
|
|
||||||
type ReadRequest struct {
|
type ReadRequest struct {
|
||||||
// Read by id. Equivalent to 'id == "your-id"'
|
// Read by id. Equivalent to 'id == "your-id"'
|
||||||
Id string `json:"id"`
|
Id string `json:"id"`
|
||||||
@@ -110,14 +161,21 @@ type ReadResponse struct {
|
|||||||
Records []map[string]interface{} `json:"records"`
|
Records []map[string]interface{} `json:"records"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type RenameTableRequest struct {
|
||||||
|
// current table name
|
||||||
|
From string `json:"from"`
|
||||||
|
// new table name
|
||||||
|
To string `json:"to"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type RenameTableResponse struct {
|
||||||
|
}
|
||||||
|
|
||||||
type TruncateRequest struct {
|
type TruncateRequest struct {
|
||||||
// Optional table name. Defaults to 'default'
|
|
||||||
Table string `json:"table"`
|
Table string `json:"table"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type TruncateResponse struct {
|
type TruncateResponse struct {
|
||||||
// The table truncated
|
|
||||||
Table string `json:"table"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type UpdateRequest struct {
|
type UpdateRequest struct {
|
||||||
|
|||||||
@@ -18,8 +18,10 @@ type EmailService struct {
|
|||||||
|
|
||||||
// Send an email by passing in from, to, subject, and a text or html body
|
// Send an email by passing in from, to, subject, and a text or html body
|
||||||
func (t *EmailService) Send(request *SendRequest) (*SendResponse, error) {
|
func (t *EmailService) Send(request *SendRequest) (*SendResponse, error) {
|
||||||
|
|
||||||
rsp := &SendResponse{}
|
rsp := &SendResponse{}
|
||||||
return rsp, t.client.Call("email", "Send", request, rsp)
|
return rsp, t.client.Call("email", "Send", request, rsp)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type SendRequest struct {
|
type SendRequest struct {
|
||||||
|
|||||||
@@ -18,27 +18,35 @@ type EmojiService struct {
|
|||||||
|
|
||||||
// Find an emoji by its alias e.g :beer:
|
// Find an emoji by its alias e.g :beer:
|
||||||
func (t *EmojiService) Find(request *FindRequest) (*FindResponse, error) {
|
func (t *EmojiService) Find(request *FindRequest) (*FindResponse, error) {
|
||||||
|
|
||||||
rsp := &FindResponse{}
|
rsp := &FindResponse{}
|
||||||
return rsp, t.client.Call("emoji", "Find", request, rsp)
|
return rsp, t.client.Call("emoji", "Find", request, rsp)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the flag for a country. Requires country code e.g GB for great britain
|
// Get the flag for a country. Requires country code e.g GB for great britain
|
||||||
func (t *EmojiService) Flag(request *FlagRequest) (*FlagResponse, error) {
|
func (t *EmojiService) Flag(request *FlagRequest) (*FlagResponse, error) {
|
||||||
|
|
||||||
rsp := &FlagResponse{}
|
rsp := &FlagResponse{}
|
||||||
return rsp, t.client.Call("emoji", "Flag", request, rsp)
|
return rsp, t.client.Call("emoji", "Flag", request, rsp)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print text and renders the emojis with aliases e.g
|
// Print text and renders the emojis with aliases e.g
|
||||||
// let's grab a :beer: becomes let's grab a 🍺
|
// let's grab a :beer: becomes let's grab a 🍺
|
||||||
func (t *EmojiService) Print(request *PrintRequest) (*PrintResponse, error) {
|
func (t *EmojiService) Print(request *PrintRequest) (*PrintResponse, error) {
|
||||||
|
|
||||||
rsp := &PrintResponse{}
|
rsp := &PrintResponse{}
|
||||||
return rsp, t.client.Call("emoji", "Print", request, rsp)
|
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>'
|
// 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) {
|
func (t *EmojiService) Send(request *SendRequest) (*SendResponse, error) {
|
||||||
|
|
||||||
rsp := &SendResponse{}
|
rsp := &SendResponse{}
|
||||||
return rsp, t.client.Call("emoji", "Send", request, rsp)
|
return rsp, t.client.Call("emoji", "Send", request, rsp)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type FindRequest struct {
|
type FindRequest struct {
|
||||||
|
|||||||
@@ -18,14 +18,18 @@ type EvchargersService struct {
|
|||||||
|
|
||||||
// Retrieve reference data as used by this API and in conjunction with the Search endpoint
|
// Retrieve reference data as used by this API and in conjunction with the Search endpoint
|
||||||
func (t *EvchargersService) ReferenceData(request *ReferenceDataRequest) (*ReferenceDataResponse, error) {
|
func (t *EvchargersService) ReferenceData(request *ReferenceDataRequest) (*ReferenceDataResponse, error) {
|
||||||
|
|
||||||
rsp := &ReferenceDataResponse{}
|
rsp := &ReferenceDataResponse{}
|
||||||
return rsp, t.client.Call("evchargers", "ReferenceData", request, rsp)
|
return rsp, t.client.Call("evchargers", "ReferenceData", request, rsp)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Search by giving a coordinate and a max distance, or bounding box and optional filters
|
// Search by giving a coordinate and a max distance, or bounding box and optional filters
|
||||||
func (t *EvchargersService) Search(request *SearchRequest) (*SearchResponse, error) {
|
func (t *EvchargersService) Search(request *SearchRequest) (*SearchResponse, error) {
|
||||||
|
|
||||||
rsp := &SearchResponse{}
|
rsp := &SearchResponse{}
|
||||||
return rsp, t.client.Call("evchargers", "Search", request, rsp)
|
return rsp, t.client.Call("evchargers", "Search", request, rsp)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Address struct {
|
type Address struct {
|
||||||
|
|||||||
110
event/event.go
Executable file
110
event/event.go
Executable file
@@ -0,0 +1,110 @@
|
|||||||
|
package event
|
||||||
|
|
||||||
|
import (
|
||||||
|
"go.m3o.com/client"
|
||||||
|
)
|
||||||
|
|
||||||
|
func NewEventService(token string) *EventService {
|
||||||
|
return &EventService{
|
||||||
|
client: client.NewClient(&client.Options{
|
||||||
|
Token: token,
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type EventService struct {
|
||||||
|
client *client.Client
|
||||||
|
}
|
||||||
|
|
||||||
|
// Consume events from a given topic.
|
||||||
|
func (t *EventService) Consume(request *ConsumeRequest) (*ConsumeResponseStream, error) {
|
||||||
|
stream, err := t.client.Stream("event", "Consume", request)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &ConsumeResponseStream{
|
||||||
|
stream: stream,
|
||||||
|
}, nil
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
type ConsumeResponseStream struct {
|
||||||
|
stream *client.Stream
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *ConsumeResponseStream) Recv() (*ConsumeResponse, error) {
|
||||||
|
var rsp ConsumeResponse
|
||||||
|
if err := t.stream.Recv(&rsp); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &rsp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Publish a event to the event stream.
|
||||||
|
func (t *EventService) Publish(request *PublishRequest) (*PublishResponse, error) {
|
||||||
|
|
||||||
|
rsp := &PublishResponse{}
|
||||||
|
return rsp, t.client.Call("event", "Publish", request, rsp)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read stored events
|
||||||
|
func (t *EventService) Read(request *ReadRequest) (*ReadResponse, error) {
|
||||||
|
|
||||||
|
rsp := &ReadResponse{}
|
||||||
|
return rsp, t.client.Call("event", "Read", request, rsp)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
type ConsumeRequest struct {
|
||||||
|
// Optional group for the subscription
|
||||||
|
Group string `json:"group"`
|
||||||
|
// Optional offset to read from e.g "2006-01-02T15:04:05.999Z07:00"
|
||||||
|
Offset string `json:"offset"`
|
||||||
|
// The topic to subscribe to
|
||||||
|
Topic string `json:"topic"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ConsumeResponse struct {
|
||||||
|
// Unique message id
|
||||||
|
Id string `json:"id"`
|
||||||
|
// The next json message on the topic
|
||||||
|
Message map[string]interface{} `json:"message"`
|
||||||
|
// Timestamp of publishing
|
||||||
|
Timestamp string `json:"timestamp"`
|
||||||
|
// The topic subscribed to
|
||||||
|
Topic string `json:"topic"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Ev struct {
|
||||||
|
// event id
|
||||||
|
Id string `json:"id"`
|
||||||
|
// event message
|
||||||
|
Message map[string]interface{} `json:"message"`
|
||||||
|
// event timestamp
|
||||||
|
Timestamp string `json:"timestamp"`
|
||||||
|
}
|
||||||
|
|
||||||
|
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 ReadRequest struct {
|
||||||
|
// number of events to read; default 25
|
||||||
|
Limit int32 `json:"limit"`
|
||||||
|
// offset for the events; default 0
|
||||||
|
Offset int32 `json:"offset"`
|
||||||
|
// topic to read from
|
||||||
|
Topic string `json:"topic"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ReadResponse struct {
|
||||||
|
// the events
|
||||||
|
Events []Ev `json:"events"`
|
||||||
|
}
|
||||||
@@ -29,5 +29,6 @@ func LookupPostcode() {
|
|||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
18
examples/address/lookupPostcode/lookupPostcode/main.go
Executable file
18
examples/address/lookupPostcode/lookupPostcode/main.go
Executable file
@@ -0,0 +1,18 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/address"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Lookup a list of UK addresses by postcode
|
||||||
|
func main() {
|
||||||
|
addressService := address.NewAddressService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := addressService.LookupPostcode(&address.LookupPostcodeRequest{
|
||||||
|
Postcode: "SW1A 2AA",
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
@@ -29,5 +29,6 @@ func AskAquestion() {
|
|||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
0
examples/answer/question/askAQuestion/.run
Executable file
0
examples/answer/question/askAQuestion/.run
Executable file
18
examples/answer/question/askAQuestion/main.go
Executable file
18
examples/answer/question/askAQuestion/main.go
Executable file
@@ -0,0 +1,18 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/answer"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Ask a question and receive an instant answer
|
||||||
|
func main() {
|
||||||
|
answerService := answer.NewAnswerService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := answerService.Question(&answer.QuestionRequest{
|
||||||
|
Query: "microsoft",
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
21
examples/cache/README.md
vendored
21
examples/cache/README.md
vendored
@@ -30,11 +30,12 @@ Value: "bar",
|
|||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Get
|
## Get
|
||||||
|
|
||||||
Get an item from the cache by key
|
Get an item from the cache by key. If key is not found, an empty response is returned.
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/cache/api#Get](https://m3o.com/cache/api#Get)
|
[https://m3o.com/cache/api#Get](https://m3o.com/cache/api#Get)
|
||||||
@@ -49,7 +50,7 @@ import(
|
|||||||
"go.m3o.com/cache"
|
"go.m3o.com/cache"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Get an item from the cache by key
|
// Get an item from the cache by key. If key is not found, an empty response is returned.
|
||||||
func GetAvalue() {
|
func GetAvalue() {
|
||||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := cacheService.Get(&cache.GetRequest{
|
rsp, err := cacheService.Get(&cache.GetRequest{
|
||||||
@@ -57,11 +58,12 @@ func GetAvalue() {
|
|||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Delete
|
## Delete
|
||||||
|
|
||||||
Delete a value from the cache
|
Delete a value from the cache. If key not found a success response is returned.
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/cache/api#Delete](https://m3o.com/cache/api#Delete)
|
[https://m3o.com/cache/api#Delete](https://m3o.com/cache/api#Delete)
|
||||||
@@ -76,7 +78,7 @@ import(
|
|||||||
"go.m3o.com/cache"
|
"go.m3o.com/cache"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Delete a value from the cache
|
// Delete a value from the cache. If key not found a success response is returned.
|
||||||
func DeleteAvalue() {
|
func DeleteAvalue() {
|
||||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := cacheService.Delete(&cache.DeleteRequest{
|
rsp, err := cacheService.Delete(&cache.DeleteRequest{
|
||||||
@@ -84,11 +86,12 @@ func DeleteAvalue() {
|
|||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Increment
|
## Increment
|
||||||
|
|
||||||
Increment a value (if it's a number)
|
Increment a value (if it's a number). If key not found it is equivalent to set.
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/cache/api#Increment](https://m3o.com/cache/api#Increment)
|
[https://m3o.com/cache/api#Increment](https://m3o.com/cache/api#Increment)
|
||||||
@@ -103,7 +106,7 @@ import(
|
|||||||
"go.m3o.com/cache"
|
"go.m3o.com/cache"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Increment a value (if it's a number)
|
// Increment a value (if it's a number). If key not found it is equivalent to set.
|
||||||
func IncrementAvalue() {
|
func IncrementAvalue() {
|
||||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := cacheService.Increment(&cache.IncrementRequest{
|
rsp, err := cacheService.Increment(&cache.IncrementRequest{
|
||||||
@@ -112,11 +115,12 @@ Value: 2,
|
|||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Decrement
|
## Decrement
|
||||||
|
|
||||||
Decrement a value (if it's a number)
|
Decrement a value (if it's a number). If key not found it is equivalent to set.
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/cache/api#Decrement](https://m3o.com/cache/api#Decrement)
|
[https://m3o.com/cache/api#Decrement](https://m3o.com/cache/api#Decrement)
|
||||||
@@ -131,7 +135,7 @@ import(
|
|||||||
"go.m3o.com/cache"
|
"go.m3o.com/cache"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Decrement a value (if it's a number)
|
// Decrement a value (if it's a number). If key not found it is equivalent to set.
|
||||||
func DecrementAvalue() {
|
func DecrementAvalue() {
|
||||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := cacheService.Decrement(&cache.DecrementRequest{
|
rsp, err := cacheService.Decrement(&cache.DecrementRequest{
|
||||||
@@ -140,5 +144,6 @@ Value: 2,
|
|||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
2
examples/cache/decrement/decrementAValue.go
vendored
2
examples/cache/decrement/decrementAValue.go
vendored
@@ -7,7 +7,7 @@ import (
|
|||||||
"go.m3o.com/cache"
|
"go.m3o.com/cache"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Decrement a value (if it's a number)
|
// Decrement a value (if it's a number). If key not found it is equivalent to set.
|
||||||
func DecrementAvalue() {
|
func DecrementAvalue() {
|
||||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := cacheService.Decrement(&cache.DecrementRequest{
|
rsp, err := cacheService.Decrement(&cache.DecrementRequest{
|
||||||
|
|||||||
19
examples/cache/decrement/decrementAValue/main.go
vendored
Executable file
19
examples/cache/decrement/decrementAValue/main.go
vendored
Executable file
@@ -0,0 +1,19 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/cache"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Decrement a value (if it's a number). If key not found it is equivalent to set.
|
||||||
|
func main() {
|
||||||
|
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := cacheService.Decrement(&cache.DecrementRequest{
|
||||||
|
Key: "counter",
|
||||||
|
Value: 2,
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
2
examples/cache/delete/deleteAValue.go
vendored
2
examples/cache/delete/deleteAValue.go
vendored
@@ -7,7 +7,7 @@ import (
|
|||||||
"go.m3o.com/cache"
|
"go.m3o.com/cache"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Delete a value from the cache
|
// Delete a value from the cache. If key not found a success response is returned.
|
||||||
func DeleteAvalue() {
|
func DeleteAvalue() {
|
||||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := cacheService.Delete(&cache.DeleteRequest{
|
rsp, err := cacheService.Delete(&cache.DeleteRequest{
|
||||||
|
|||||||
18
examples/cache/delete/deleteAValue/main.go
vendored
Executable file
18
examples/cache/delete/deleteAValue/main.go
vendored
Executable file
@@ -0,0 +1,18 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/cache"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Delete a value from the cache. If key not found a success response is returned.
|
||||||
|
func main() {
|
||||||
|
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := cacheService.Delete(&cache.DeleteRequest{
|
||||||
|
Key: "foo",
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
2
examples/cache/get/getAValue.go
vendored
2
examples/cache/get/getAValue.go
vendored
@@ -7,7 +7,7 @@ import (
|
|||||||
"go.m3o.com/cache"
|
"go.m3o.com/cache"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Get an item from the cache by key
|
// Get an item from the cache by key. If key is not found, an empty response is returned.
|
||||||
func GetAvalue() {
|
func GetAvalue() {
|
||||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := cacheService.Get(&cache.GetRequest{
|
rsp, err := cacheService.Get(&cache.GetRequest{
|
||||||
|
|||||||
18
examples/cache/get/getAValue/main.go
vendored
Executable file
18
examples/cache/get/getAValue/main.go
vendored
Executable file
@@ -0,0 +1,18 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/cache"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Get an item from the cache by key. If key is not found, an empty response is returned.
|
||||||
|
func main() {
|
||||||
|
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := cacheService.Get(&cache.GetRequest{
|
||||||
|
Key: "foo",
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
2
examples/cache/increment/incrementAValue.go
vendored
2
examples/cache/increment/incrementAValue.go
vendored
@@ -7,7 +7,7 @@ import (
|
|||||||
"go.m3o.com/cache"
|
"go.m3o.com/cache"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Increment a value (if it's a number)
|
// Increment a value (if it's a number). If key not found it is equivalent to set.
|
||||||
func IncrementAvalue() {
|
func IncrementAvalue() {
|
||||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := cacheService.Increment(&cache.IncrementRequest{
|
rsp, err := cacheService.Increment(&cache.IncrementRequest{
|
||||||
|
|||||||
19
examples/cache/increment/incrementAValue/main.go
vendored
Executable file
19
examples/cache/increment/incrementAValue/main.go
vendored
Executable file
@@ -0,0 +1,19 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/cache"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Increment a value (if it's a number). If key not found it is equivalent to set.
|
||||||
|
func main() {
|
||||||
|
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := cacheService.Increment(&cache.IncrementRequest{
|
||||||
|
Key: "counter",
|
||||||
|
Value: 2,
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
0
examples/cache/set/setAValue/.run
vendored
Executable file
0
examples/cache/set/setAValue/.run
vendored
Executable file
19
examples/cache/set/setAValue/main.go
vendored
Executable file
19
examples/cache/set/setAValue/main.go
vendored
Executable file
@@ -0,0 +1,19 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/cache"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Set an item in the cache. Overwrites any existing value already set.
|
||||||
|
func main() {
|
||||||
|
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := cacheService.Set(&cache.SetRequest{
|
||||||
|
Key: "foo",
|
||||||
|
Value: "bar",
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
@@ -4,60 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Crypto/api](ht
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
## News
|
|
||||||
|
|
||||||
Get news related to a currency
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/crypto/api#News](https://m3o.com/crypto/api#News)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/crypto"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Get news related to a currency
|
|
||||||
func GetCryptocurrencyNews() {
|
|
||||||
cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := cryptoService.News(&crypto.NewsRequest{
|
|
||||||
Symbol: "BTCUSD",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Price
|
|
||||||
|
|
||||||
Get the last price for a given crypto ticker
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/crypto/api#Price](https://m3o.com/crypto/api#Price)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/crypto"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Get the last price for a given crypto ticker
|
|
||||||
func GetCryptocurrencyPrice() {
|
|
||||||
cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := cryptoService.Price(&crypto.PriceRequest{
|
|
||||||
Symbol: "BTCUSD",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Quote
|
## Quote
|
||||||
|
|
||||||
Get the last quote for a given crypto ticker
|
Get the last quote for a given crypto ticker
|
||||||
@@ -83,6 +29,7 @@ func GetAcryptocurrencyQuote() {
|
|||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## History
|
## History
|
||||||
@@ -110,5 +57,62 @@ func GetPreviousClose() {
|
|||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## News
|
||||||
|
|
||||||
|
Get news related to a currency
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/crypto/api#News](https://m3o.com/crypto/api#News)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/crypto"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Get news related to a currency
|
||||||
|
func GetCryptocurrencyNews() {
|
||||||
|
cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := cryptoService.News(&crypto.NewsRequest{
|
||||||
|
Symbol: "BTCUSD",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Price
|
||||||
|
|
||||||
|
Get the last price for a given crypto ticker
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/crypto/api#Price](https://m3o.com/crypto/api#Price)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/crypto"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Get the last price for a given crypto ticker
|
||||||
|
func GetCryptocurrencyPrice() {
|
||||||
|
cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := cryptoService.Price(&crypto.PriceRequest{
|
||||||
|
Symbol: "BTCUSD",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
18
examples/crypto/history/getPreviousClose/main.go
Executable file
18
examples/crypto/history/getPreviousClose/main.go
Executable file
@@ -0,0 +1,18 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/crypto"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Returns the history for the previous close
|
||||||
|
func main() {
|
||||||
|
cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := cryptoService.History(&crypto.HistoryRequest{
|
||||||
|
Symbol: "BTCUSD",
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
18
examples/crypto/news/getCryptocurrencyNews/main.go
Executable file
18
examples/crypto/news/getCryptocurrencyNews/main.go
Executable file
@@ -0,0 +1,18 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/crypto"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Get news related to a currency
|
||||||
|
func main() {
|
||||||
|
cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := cryptoService.News(&crypto.NewsRequest{
|
||||||
|
Symbol: "BTCUSD",
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
18
examples/crypto/price/getCryptocurrencyPrice/main.go
Executable file
18
examples/crypto/price/getCryptocurrencyPrice/main.go
Executable file
@@ -0,0 +1,18 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/crypto"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Get the last price for a given crypto ticker
|
||||||
|
func main() {
|
||||||
|
cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := cryptoService.Price(&crypto.PriceRequest{
|
||||||
|
Symbol: "BTCUSD",
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
18
examples/crypto/quote/getACryptocurrencyQuote/main.go
Executable file
18
examples/crypto/quote/getACryptocurrencyQuote/main.go
Executable file
@@ -0,0 +1,18 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/crypto"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Get the last quote for a given crypto ticker
|
||||||
|
func main() {
|
||||||
|
cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := cryptoService.Quote(&crypto.QuoteRequest{
|
||||||
|
Symbol: "BTCUSD",
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
@@ -28,6 +28,7 @@ func GetSupportedCodes() {
|
|||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Rates
|
## Rates
|
||||||
@@ -55,6 +56,7 @@ func GetRatesForUsd() {
|
|||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Convert
|
## Convert
|
||||||
@@ -83,6 +85,7 @@ To: "GBP",
|
|||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Convert
|
## Convert
|
||||||
@@ -112,6 +115,7 @@ To: "GBP",
|
|||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## History
|
## History
|
||||||
@@ -140,5 +144,6 @@ Date: "2021-05-30",
|
|||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
16
examples/currency/codes/getSupportedCodes/main.go
Executable file
16
examples/currency/codes/getSupportedCodes/main.go
Executable file
@@ -0,0 +1,16 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/currency"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Codes returns the supported currency codes for the API
|
||||||
|
func main() {
|
||||||
|
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := currencyService.Codes(¤cy.CodesRequest{})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
20
examples/currency/convert/convert10UsdToGbp/main.go
Executable file
20
examples/currency/convert/convert10UsdToGbp/main.go
Executable file
@@ -0,0 +1,20 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/currency"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Convert returns the currency conversion rate between two pairs e.g USD/GBP
|
||||||
|
func main() {
|
||||||
|
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := currencyService.Convert(¤cy.ConvertRequest{
|
||||||
|
Amount: 10,
|
||||||
|
From: "USD",
|
||||||
|
To: "GBP",
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
19
examples/currency/convert/convertUsdToGbp/main.go
Executable file
19
examples/currency/convert/convertUsdToGbp/main.go
Executable file
@@ -0,0 +1,19 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/currency"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Convert returns the currency conversion rate between two pairs e.g USD/GBP
|
||||||
|
func main() {
|
||||||
|
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := currencyService.Convert(¤cy.ConvertRequest{
|
||||||
|
From: "USD",
|
||||||
|
To: "GBP",
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
19
examples/currency/history/historicRatesForACurrency/main.go
Executable file
19
examples/currency/history/historicRatesForACurrency/main.go
Executable file
@@ -0,0 +1,19 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/currency"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Returns the historic rates for a currency on a given date
|
||||||
|
func main() {
|
||||||
|
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := currencyService.History(¤cy.HistoryRequest{
|
||||||
|
Code: "USD",
|
||||||
|
Date: "2021-05-30",
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
18
examples/currency/rates/getRatesForUsd/main.go
Executable file
18
examples/currency/rates/getRatesForUsd/main.go
Executable file
@@ -0,0 +1,18 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/currency"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Rates returns the currency rates for a given code e.g USD
|
||||||
|
func main() {
|
||||||
|
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := currencyService.Rates(¤cy.RatesRequest{
|
||||||
|
Code: "USD",
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
@@ -4,6 +4,179 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Db/api](https:
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
|
## ListTables
|
||||||
|
|
||||||
|
List tables in the DB
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/db/api#ListTables](https://m3o.com/db/api#ListTables)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/db"
|
||||||
|
)
|
||||||
|
|
||||||
|
// List tables in the DB
|
||||||
|
func ListTables() {
|
||||||
|
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := dbService.ListTables(&db.ListTablesRequest{
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## RenameTable
|
||||||
|
|
||||||
|
Rename a table
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/db/api#RenameTable](https://m3o.com/db/api#RenameTable)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/db"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Rename a table
|
||||||
|
func RenameTable() {
|
||||||
|
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := dbService.RenameTable(&db.RenameTableRequest{
|
||||||
|
From: "events",
|
||||||
|
To: "events_backup",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Update
|
||||||
|
|
||||||
|
Update a record in the database. Include an "id" in the record to update.
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/db/api#Update](https://m3o.com/db/api#Update)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/db"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Update a record in the database. Include an "id" in the record to update.
|
||||||
|
func UpdateArecord() {
|
||||||
|
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := dbService.Update(&db.UpdateRequest{
|
||||||
|
Record: map[string]interface{}{
|
||||||
|
"id": "1",
|
||||||
|
"age": 43,
|
||||||
|
},
|
||||||
|
Table: "users",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Read
|
||||||
|
|
||||||
|
Read data from a table. Lookup can be by ID or via querying any field in the record.
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/db/api#Read](https://m3o.com/db/api#Read)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/db"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Read data from a table. Lookup can be by ID or via querying any field in the record.
|
||||||
|
func ReadRecords() {
|
||||||
|
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := dbService.Read(&db.ReadRequest{
|
||||||
|
Query: "age == 43",
|
||||||
|
Table: "users",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## DropTable
|
||||||
|
|
||||||
|
Drop a table in the DB
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/db/api#DropTable](https://m3o.com/db/api#DropTable)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/db"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Drop a table in the DB
|
||||||
|
func DropTable() {
|
||||||
|
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := dbService.DropTable(&db.DropTableRequest{
|
||||||
|
Table: "users",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Count
|
||||||
|
|
||||||
|
Count records in a table
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/db/api#Count](https://m3o.com/db/api#Count)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/db"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Count records in a table
|
||||||
|
func CountEntriesInAtable() {
|
||||||
|
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := dbService.Count(&db.CountRequest{
|
||||||
|
Table: "users",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
## Create
|
## Create
|
||||||
|
|
||||||
Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
|
Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
|
||||||
@@ -35,65 +208,7 @@ Table: "users",
|
|||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
}
|
|
||||||
```
|
|
||||||
## Update
|
|
||||||
|
|
||||||
Update a record in the database. Include an "id" in the record to update.
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/db/api#Update](https://m3o.com/db/api#Update)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/db"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Update a record in the database. Include an "id" in the record to update.
|
|
||||||
func UpdateArecord() {
|
|
||||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := dbService.Update(&db.UpdateRequest{
|
|
||||||
Record: map[string]interface{}{
|
|
||||||
"age": 43,
|
|
||||||
"id": "1",
|
|
||||||
},
|
|
||||||
Table: "users",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Read
|
|
||||||
|
|
||||||
Read data from a table. Lookup can be by ID or via querying any field in the record.
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/db/api#Read](https://m3o.com/db/api#Read)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/db"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Read data from a table. Lookup can be by ID or via querying any field in the record.
|
|
||||||
func ReadRecords() {
|
|
||||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := dbService.Read(&db.ReadRequest{
|
|
||||||
Query: "age == 43",
|
|
||||||
Table: "users",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Delete
|
## Delete
|
||||||
@@ -122,6 +237,7 @@ Table: "users",
|
|||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Truncate
|
## Truncate
|
||||||
@@ -149,32 +265,6 @@ func TruncateTable() {
|
|||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
}
|
|
||||||
```
|
|
||||||
## Count
|
|
||||||
|
|
||||||
Count records in a table
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/db/api#Count](https://m3o.com/db/api#Count)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/db"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Count records in a table
|
|
||||||
func CountEntriesInAtable() {
|
|
||||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := dbService.Count(&db.CountRequest{
|
|
||||||
Table: "users",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
18
examples/db/count/countEntriesInATable/main.go
Executable file
18
examples/db/count/countEntriesInATable/main.go
Executable file
@@ -0,0 +1,18 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/db"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Count records in a table
|
||||||
|
func main() {
|
||||||
|
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := dbService.Count(&db.CountRequest{
|
||||||
|
Table: "users",
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
24
examples/db/create/createARecord/main.go
Executable file
24
examples/db/create/createARecord/main.go
Executable file
@@ -0,0 +1,24 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/db"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
|
||||||
|
func main() {
|
||||||
|
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := dbService.Create(&db.CreateRequest{
|
||||||
|
Record: map[string]interface{}{
|
||||||
|
"id": "1",
|
||||||
|
"name": "Jane",
|
||||||
|
"age": 42,
|
||||||
|
"isActive": true,
|
||||||
|
},
|
||||||
|
Table: "users",
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
19
examples/db/delete/deleteARecord/main.go
Executable file
19
examples/db/delete/deleteARecord/main.go
Executable file
@@ -0,0 +1,19 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/db"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Delete a record in the database by id.
|
||||||
|
func main() {
|
||||||
|
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := dbService.Delete(&db.DeleteRequest{
|
||||||
|
Id: "1",
|
||||||
|
Table: "users",
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
18
examples/db/dropTable/dropTable/main.go
Executable file
18
examples/db/dropTable/dropTable/main.go
Executable file
@@ -0,0 +1,18 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/db"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Drop a table in the DB
|
||||||
|
func main() {
|
||||||
|
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := dbService.DropTable(&db.DropTableRequest{
|
||||||
|
Table: "users",
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
16
examples/db/listTables/listTables/main.go
Executable file
16
examples/db/listTables/listTables/main.go
Executable file
@@ -0,0 +1,16 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/db"
|
||||||
|
)
|
||||||
|
|
||||||
|
// List tables in the DB
|
||||||
|
func main() {
|
||||||
|
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := dbService.ListTables(&db.ListTablesRequest{})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
0
examples/db/read/readRecords/.run
Executable file
0
examples/db/read/readRecords/.run
Executable file
19
examples/db/read/readRecords/main.go
Executable file
19
examples/db/read/readRecords/main.go
Executable file
@@ -0,0 +1,19 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/db"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Read data from a table. Lookup can be by ID or via querying any field in the record.
|
||||||
|
func main() {
|
||||||
|
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := dbService.Read(&db.ReadRequest{
|
||||||
|
Query: "age == 43",
|
||||||
|
Table: "users",
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
19
examples/db/renameTable/renameTable/main.go
Executable file
19
examples/db/renameTable/renameTable/main.go
Executable file
@@ -0,0 +1,19 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/db"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Rename a table
|
||||||
|
func main() {
|
||||||
|
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := dbService.RenameTable(&db.RenameTableRequest{
|
||||||
|
From: "events",
|
||||||
|
To: "events_backup",
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
18
examples/db/truncate/truncateTable/main.go
Executable file
18
examples/db/truncate/truncateTable/main.go
Executable file
@@ -0,0 +1,18 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/db"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Truncate the records in a table
|
||||||
|
func main() {
|
||||||
|
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := dbService.Truncate(&db.TruncateRequest{
|
||||||
|
Table: "users",
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
22
examples/db/update/updateARecord/main.go
Executable file
22
examples/db/update/updateARecord/main.go
Executable file
@@ -0,0 +1,22 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/db"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Update a record in the database. Include an "id" in the record to update.
|
||||||
|
func main() {
|
||||||
|
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := dbService.Update(&db.UpdateRequest{
|
||||||
|
Record: map[string]interface{}{
|
||||||
|
"id": "1",
|
||||||
|
"age": 43,
|
||||||
|
},
|
||||||
|
Table: "users",
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
@@ -33,5 +33,6 @@ Please verify your email by clicking this link: $micro_verification_link`,
|
|||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
22
examples/email/send/sendEmail/main.go
Executable file
22
examples/email/send/sendEmail/main.go
Executable file
@@ -0,0 +1,22 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/email"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Send an email by passing in from, to, subject, and a text or html body
|
||||||
|
func main() {
|
||||||
|
emailService := email.NewEmailService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := emailService.Send(&email.SendRequest{
|
||||||
|
From: "Awesome Dot Com",
|
||||||
|
Subject: "Email verification",
|
||||||
|
TextBody: `Hi there,
|
||||||
|
|
||||||
|
Please verify your email by clicking this link: $micro_verification_link`,
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
@@ -4,6 +4,36 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Emoji/api](htt
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
|
## Send
|
||||||
|
|
||||||
|
Send an emoji to anyone via SMS. Messages are sent in the form '<message> Sent from <from>'
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/emoji/api#Send](https://m3o.com/emoji/api#Send)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/emoji"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Send an emoji to anyone via SMS. Messages are sent in the form '<message> Sent from <from>'
|
||||||
|
func SendAtextContainingAnEmojiToAnyoneViaSms() {
|
||||||
|
emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := emojiService.Send(&emoji.SendRequest{
|
||||||
|
From: "Alice",
|
||||||
|
Message: "let's grab a :beer:",
|
||||||
|
To: "+44782669123",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
## Find
|
## Find
|
||||||
|
|
||||||
Find an emoji by its alias e.g :beer:
|
Find an emoji by its alias e.g :beer:
|
||||||
@@ -29,6 +59,7 @@ func FindEmoji() {
|
|||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Flag
|
## Flag
|
||||||
@@ -55,6 +86,7 @@ func GetFlagByCountryCode() {
|
|||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Print
|
## Print
|
||||||
@@ -84,34 +116,6 @@ func PrintTextIncludingEmoji() {
|
|||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
}
|
|
||||||
```
|
|
||||||
## Send
|
|
||||||
|
|
||||||
Send an emoji to anyone via SMS. Messages are sent in the form '<message> Sent from <from>'
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/emoji/api#Send](https://m3o.com/emoji/api#Send)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/emoji"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Send an emoji to anyone via SMS. Messages are sent in the form '<message> Sent from <from>'
|
|
||||||
func SendAtextContainingAnEmojiToAnyoneViaSms() {
|
|
||||||
emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := emojiService.Send(&emoji.SendRequest{
|
|
||||||
From: "Alice",
|
|
||||||
Message: "let's grab a :beer:",
|
|
||||||
To: "+44782669123",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
18
examples/emoji/find/findEmoji/main.go
Executable file
18
examples/emoji/find/findEmoji/main.go
Executable file
@@ -0,0 +1,18 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/emoji"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Find an emoji by its alias e.g :beer:
|
||||||
|
func main() {
|
||||||
|
emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := emojiService.Find(&emoji.FindRequest{
|
||||||
|
Alias: ":beer:",
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
16
examples/emoji/flag/getFlagByCountryCode/main.go
Executable file
16
examples/emoji/flag/getFlagByCountryCode/main.go
Executable file
@@ -0,0 +1,16 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/emoji"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Get the flag for a country. Requires country code e.g GB for great britain
|
||||||
|
func main() {
|
||||||
|
emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := emojiService.Flag(&emoji.FlagRequest{})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
19
examples/emoji/print/printTextIncludingEmoji/main.go
Executable file
19
examples/emoji/print/printTextIncludingEmoji/main.go
Executable file
@@ -0,0 +1,19 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/emoji"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Print text and renders the emojis with aliases e.g
|
||||||
|
// let's grab a :beer: becomes let's grab a 🍺
|
||||||
|
func main() {
|
||||||
|
emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := emojiService.Print(&emoji.PrintRequest{
|
||||||
|
Text: "let's grab a :beer:",
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
20
examples/emoji/send/sendATextContainingAnEmojiToAnyoneViaSms/main.go
Executable file
20
examples/emoji/send/sendATextContainingAnEmojiToAnyoneViaSms/main.go
Executable file
@@ -0,0 +1,20 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/emoji"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Send an emoji to anyone via SMS. Messages are sent in the form '<message> Sent from <from>'
|
||||||
|
func main() {
|
||||||
|
emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := emojiService.Send(&emoji.SendRequest{
|
||||||
|
From: "Alice",
|
||||||
|
Message: "let's grab a :beer:",
|
||||||
|
To: "+44782669123",
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
@@ -33,6 +33,7 @@ Location: &evchargers.Coordinates{
|
|||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Search
|
## Search
|
||||||
@@ -61,6 +62,7 @@ func SearchByBoundingBox() {
|
|||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Search
|
## Search
|
||||||
@@ -93,6 +95,7 @@ Location: &evchargers.Coordinates{
|
|||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## ReferenceData
|
## ReferenceData
|
||||||
@@ -119,5 +122,6 @@ func GetReferenceData() {
|
|||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
16
examples/evchargers/referenceData/getReferenceData/main.go
Executable file
16
examples/evchargers/referenceData/getReferenceData/main.go
Executable file
@@ -0,0 +1,16 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/evchargers"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Retrieve reference data as used by this API and in conjunction with the Search endpoint
|
||||||
|
func main() {
|
||||||
|
evchargersService := evchargers.NewEvchargersService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := evchargersService.ReferenceData(&evchargers.ReferenceDataRequest{})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
18
examples/evchargers/search/searchByBoundingBox/main.go
Executable file
18
examples/evchargers/search/searchByBoundingBox/main.go
Executable file
@@ -0,0 +1,18 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/evchargers"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Search by giving a coordinate and a max distance, or bounding box and optional filters
|
||||||
|
func main() {
|
||||||
|
evchargersService := evchargers.NewEvchargersService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := evchargersService.Search(&evchargers.SearchRequest{
|
||||||
|
Box: &evchargers.BoundingBox{},
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
22
examples/evchargers/search/searchByLocation/main.go
Executable file
22
examples/evchargers/search/searchByLocation/main.go
Executable file
@@ -0,0 +1,22 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/evchargers"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Search by giving a coordinate and a max distance, or bounding box and optional filters
|
||||||
|
func main() {
|
||||||
|
evchargersService := evchargers.NewEvchargersService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := evchargersService.Search(&evchargers.SearchRequest{
|
||||||
|
Distance: 2000,
|
||||||
|
Location: &evchargers.Coordinates{
|
||||||
|
Latitude: 51.53336351319885,
|
||||||
|
Longitude: -0.0252,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
23
examples/evchargers/search/searchWithFiltersFastChargersOnly/main.go
Executable file
23
examples/evchargers/search/searchWithFiltersFastChargersOnly/main.go
Executable file
@@ -0,0 +1,23 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/evchargers"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Search by giving a coordinate and a max distance, or bounding box and optional filters
|
||||||
|
func main() {
|
||||||
|
evchargersService := evchargers.NewEvchargersService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := evchargersService.Search(&evchargers.SearchRequest{
|
||||||
|
Distance: 2000,
|
||||||
|
Levels: []string{"3"},
|
||||||
|
Location: &evchargers.Coordinates{
|
||||||
|
Latitude: 51.53336351319885,
|
||||||
|
Longitude: -0.0252,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
108
examples/event/README.md
Executable file
108
examples/event/README.md
Executable file
@@ -0,0 +1,108 @@
|
|||||||
|
# Event
|
||||||
|
|
||||||
|
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Event/api](https://m3o.com/Event/api).
|
||||||
|
|
||||||
|
Endpoints:
|
||||||
|
|
||||||
|
## Publish
|
||||||
|
|
||||||
|
Publish a event to the event stream.
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/event/api#Publish](https://m3o.com/event/api#Publish)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/event"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Publish a event to the event stream.
|
||||||
|
func PublishAnEvent() {
|
||||||
|
eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := eventService.Publish(&event.PublishRequest{
|
||||||
|
Message: map[string]interface{}{
|
||||||
|
"id": "1",
|
||||||
|
"type": "signup",
|
||||||
|
"user": "john",
|
||||||
|
},
|
||||||
|
Topic: "user",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Consume
|
||||||
|
|
||||||
|
Consume events from a given topic.
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/event/api#Consume](https://m3o.com/event/api#Consume)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/event"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Consume events from a given topic.
|
||||||
|
func ConsumeFromAtopic() {
|
||||||
|
eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
|
||||||
|
stream, err := eventService.Consume(&event.ConsumeRequest{
|
||||||
|
Topic: "user",
|
||||||
|
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for {
|
||||||
|
rsp, err := stream.Recv()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println(rsp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Read
|
||||||
|
|
||||||
|
Read stored events
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/event/api#Read](https://m3o.com/event/api#Read)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/event"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Read stored events
|
||||||
|
func ReadEventsOnAtopic() {
|
||||||
|
eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := eventService.Read(&event.ReadRequest{
|
||||||
|
Topic: "user",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
17
examples/event/consume/consumeFromATopic.go
Executable file
17
examples/event/consume/consumeFromATopic.go
Executable file
@@ -0,0 +1,17 @@
|
|||||||
|
package example
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/event"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Consume events from a given topic.
|
||||||
|
func ConsumeFromAtopic() {
|
||||||
|
eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := eventService.Consume(&event.ConsumeRequest{
|
||||||
|
Topic: "user",
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
}
|
||||||
31
examples/event/consume/consumeFromATopic/main.go
Executable file
31
examples/event/consume/consumeFromATopic/main.go
Executable file
@@ -0,0 +1,31 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/event"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Consume events from a given topic.
|
||||||
|
func main() {
|
||||||
|
eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
|
||||||
|
stream, err := eventService.Consume(&event.ConsumeRequest{
|
||||||
|
Topic: "user",
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for {
|
||||||
|
rsp, err := stream.Recv()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println(rsp)
|
||||||
|
}
|
||||||
|
}
|
||||||
22
examples/event/publish/publishAMessage.go
Executable file
22
examples/event/publish/publishAMessage.go
Executable file
@@ -0,0 +1,22 @@
|
|||||||
|
package example
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/event"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Publish a message to the event stream.
|
||||||
|
func PublishAmessage() {
|
||||||
|
eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := eventService.Publish(&event.PublishRequest{
|
||||||
|
Message: map[string]interface{}{
|
||||||
|
"id": "1",
|
||||||
|
"type": "signup",
|
||||||
|
"user": "john",
|
||||||
|
},
|
||||||
|
Topic: "user",
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
}
|
||||||
22
examples/event/publish/publishAnEvent.go
Executable file
22
examples/event/publish/publishAnEvent.go
Executable file
@@ -0,0 +1,22 @@
|
|||||||
|
package example
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/event"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Publish a event to the event stream.
|
||||||
|
func PublishAnEvent() {
|
||||||
|
eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := eventService.Publish(&event.PublishRequest{
|
||||||
|
Message: map[string]interface{}{
|
||||||
|
"id": "1",
|
||||||
|
"type": "signup",
|
||||||
|
"user": "john",
|
||||||
|
},
|
||||||
|
Topic: "user",
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
}
|
||||||
23
examples/event/publish/publishAnEvent/main.go
Executable file
23
examples/event/publish/publishAnEvent/main.go
Executable file
@@ -0,0 +1,23 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/event"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Publish a event to the event stream.
|
||||||
|
func main() {
|
||||||
|
eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := eventService.Publish(&event.PublishRequest{
|
||||||
|
Message: map[string]interface{}{
|
||||||
|
"user": "john",
|
||||||
|
"id": "1",
|
||||||
|
"type": "signup",
|
||||||
|
},
|
||||||
|
Topic: "user",
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
17
examples/event/read/readEventsOnATopic.go
Executable file
17
examples/event/read/readEventsOnATopic.go
Executable file
@@ -0,0 +1,17 @@
|
|||||||
|
package example
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/event"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Read stored events
|
||||||
|
func ReadEventsOnAtopic() {
|
||||||
|
eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := eventService.Read(&event.ReadRequest{
|
||||||
|
Topic: "user",
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
}
|
||||||
18
examples/event/read/readEventsOnATopic/main.go
Executable file
18
examples/event/read/readEventsOnATopic/main.go
Executable file
@@ -0,0 +1,18 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/event"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Read stored events
|
||||||
|
func main() {
|
||||||
|
eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := eventService.Read(&event.ReadRequest{
|
||||||
|
Topic: "user",
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
@@ -4,62 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/File/api](http
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
## Delete
|
|
||||||
|
|
||||||
Delete a file by project name/path
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/file/api#Delete](https://m3o.com/file/api#Delete)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/file"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Delete a file by project name/path
|
|
||||||
func DeleteFile() {
|
|
||||||
fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := fileService.Delete(&file.DeleteRequest{
|
|
||||||
Path: "/document/text-files/file.txt",
|
|
||||||
Project: "examples",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Read
|
|
||||||
|
|
||||||
Read a file by path
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/file/api#Read](https://m3o.com/file/api#Read)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/file"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Read a file by path
|
|
||||||
func ReadFile() {
|
|
||||||
fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := fileService.Read(&file.ReadRequest{
|
|
||||||
Path: "/document/text-files/file.txt",
|
|
||||||
Project: "examples",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Save
|
## Save
|
||||||
|
|
||||||
Save a file
|
Save a file
|
||||||
@@ -89,6 +33,7 @@ func SaveFile() {
|
|||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## List
|
## List
|
||||||
@@ -116,5 +61,64 @@ func ListFiles() {
|
|||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Delete
|
||||||
|
|
||||||
|
Delete a file by project name/path
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/file/api#Delete](https://m3o.com/file/api#Delete)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/file"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Delete a file by project name/path
|
||||||
|
func DeleteFile() {
|
||||||
|
fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := fileService.Delete(&file.DeleteRequest{
|
||||||
|
Path: "/document/text-files/file.txt",
|
||||||
|
Project: "examples",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Read
|
||||||
|
|
||||||
|
Read a file by path
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/file/api#Read](https://m3o.com/file/api#Read)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/file"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Read a file by path
|
||||||
|
func ReadFile() {
|
||||||
|
fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := fileService.Read(&file.ReadRequest{
|
||||||
|
Path: "/document/text-files/file.txt",
|
||||||
|
Project: "examples",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
19
examples/file/delete/deleteFile/main.go
Executable file
19
examples/file/delete/deleteFile/main.go
Executable file
@@ -0,0 +1,19 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/file"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Delete a file by project name/path
|
||||||
|
func main() {
|
||||||
|
fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := fileService.Delete(&file.DeleteRequest{
|
||||||
|
Path: "/document/text-files/file.txt",
|
||||||
|
Project: "examples",
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
0
examples/file/list/listFiles/.run
Executable file
0
examples/file/list/listFiles/.run
Executable file
18
examples/file/list/listFiles/main.go
Executable file
18
examples/file/list/listFiles/main.go
Executable file
@@ -0,0 +1,18 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/file"
|
||||||
|
)
|
||||||
|
|
||||||
|
// List files by their project and optionally a path.
|
||||||
|
func main() {
|
||||||
|
fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := fileService.List(&file.ListRequest{
|
||||||
|
Project: "examples",
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
19
examples/file/read/readFile/main.go
Executable file
19
examples/file/read/readFile/main.go
Executable file
@@ -0,0 +1,19 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/file"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Read a file by path
|
||||||
|
func main() {
|
||||||
|
fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := fileService.Read(&file.ReadRequest{
|
||||||
|
Path: "/document/text-files/file.txt",
|
||||||
|
Project: "examples",
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
22
examples/file/save/saveFile/main.go
Executable file
22
examples/file/save/saveFile/main.go
Executable file
@@ -0,0 +1,22 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/file"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Save a file
|
||||||
|
func main() {
|
||||||
|
fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := fileService.Save(&file.SaveRequest{
|
||||||
|
File: &file.Record{
|
||||||
|
Content: "file content example",
|
||||||
|
Path: "/document/text-files/file.txt",
|
||||||
|
Project: "examples",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
@@ -29,6 +29,7 @@ func GetAnFxPrice() {
|
|||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Quote
|
## Quote
|
||||||
@@ -56,6 +57,7 @@ func GetAfxQuote() {
|
|||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## History
|
## History
|
||||||
@@ -83,5 +85,6 @@ func GetPreviousClose() {
|
|||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
18
examples/forex/history/getPreviousClose/main.go
Executable file
18
examples/forex/history/getPreviousClose/main.go
Executable file
@@ -0,0 +1,18 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/forex"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Returns the data for the previous close
|
||||||
|
func main() {
|
||||||
|
forexService := forex.NewForexService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := forexService.History(&forex.HistoryRequest{
|
||||||
|
Symbol: "GBPUSD",
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
18
examples/forex/price/getAnFxPrice/main.go
Executable file
18
examples/forex/price/getAnFxPrice/main.go
Executable file
@@ -0,0 +1,18 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/forex"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Get the latest price for a given forex ticker
|
||||||
|
func main() {
|
||||||
|
forexService := forex.NewForexService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := forexService.Price(&forex.PriceRequest{
|
||||||
|
Symbol: "GBPUSD",
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
18
examples/forex/quote/getAFxQuote/main.go
Executable file
18
examples/forex/quote/getAFxQuote/main.go
Executable file
@@ -0,0 +1,18 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/forex"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Get the latest quote for the forex
|
||||||
|
func main() {
|
||||||
|
forexService := forex.NewForexService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := forexService.Quote(&forex.QuoteRequest{
|
||||||
|
Symbol: "GBPUSD",
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
@@ -4,60 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Function/api](
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
## List
|
|
||||||
|
|
||||||
List all the deployed functions
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/function/api#List](https://m3o.com/function/api#List)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/function"
|
|
||||||
)
|
|
||||||
|
|
||||||
// List all the deployed functions
|
|
||||||
func ListFunctions() {
|
|
||||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := functionService.List(&function.ListRequest{
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Delete
|
|
||||||
|
|
||||||
Delete a function by name
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/function/api#Delete](https://m3o.com/function/api#Delete)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/function"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Delete a function by name
|
|
||||||
func DeleteAfunction() {
|
|
||||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := functionService.Delete(&function.DeleteRequest{
|
|
||||||
Name: "my-first-func",
|
|
||||||
Project: "tests",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Describe
|
## Describe
|
||||||
|
|
||||||
Get the info for a deployed function
|
Get the info for a deployed function
|
||||||
@@ -84,6 +30,7 @@ Project: "tests",
|
|||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Deploy
|
## Deploy
|
||||||
@@ -115,6 +62,7 @@ Runtime: "nodejs14",
|
|||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Call
|
## Call
|
||||||
@@ -144,5 +92,62 @@ Request: map[string]interface{}{
|
|||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## List
|
||||||
|
|
||||||
|
List all the deployed functions
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/function/api#List](https://m3o.com/function/api#List)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/function"
|
||||||
|
)
|
||||||
|
|
||||||
|
// List all the deployed functions
|
||||||
|
func ListFunctions() {
|
||||||
|
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := functionService.List(&function.ListRequest{
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Delete
|
||||||
|
|
||||||
|
Delete a function by name
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/function/api#Delete](https://m3o.com/function/api#Delete)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/function"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Delete a function by name
|
||||||
|
func DeleteAfunction() {
|
||||||
|
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := functionService.Delete(&function.DeleteRequest{
|
||||||
|
Name: "my-first-func",
|
||||||
|
Project: "tests",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
19
examples/function/call/callAFunction/main.go
Executable file
19
examples/function/call/callAFunction/main.go
Executable file
@@ -0,0 +1,19 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/function"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Call a function by name
|
||||||
|
func main() {
|
||||||
|
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := functionService.Call(&function.CallRequest{
|
||||||
|
Name: "my-first-func",
|
||||||
|
Request: map[string]interface{}{},
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
19
examples/function/delete/deleteAFunction/main.go
Executable file
19
examples/function/delete/deleteAFunction/main.go
Executable file
@@ -0,0 +1,19 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/function"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Delete a function by name
|
||||||
|
func main() {
|
||||||
|
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := functionService.Delete(&function.DeleteRequest{
|
||||||
|
Name: "my-first-func",
|
||||||
|
Project: "tests",
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
22
examples/function/deploy/deployAFunction/main.go
Executable file
22
examples/function/deploy/deployAFunction/main.go
Executable file
@@ -0,0 +1,22 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/function"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Deploy a group of functions
|
||||||
|
func main() {
|
||||||
|
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := functionService.Deploy(&function.DeployRequest{
|
||||||
|
Entrypoint: "helloworld",
|
||||||
|
Name: "my-first-func",
|
||||||
|
Project: "tests",
|
||||||
|
Repo: "github.com/m3o/nodejs-function-example",
|
||||||
|
Runtime: "nodejs14",
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
19
examples/function/describe/describeFunctionStatus/main.go
Executable file
19
examples/function/describe/describeFunctionStatus/main.go
Executable file
@@ -0,0 +1,19 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/function"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Get the info for a deployed function
|
||||||
|
func main() {
|
||||||
|
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := functionService.Describe(&function.DescribeRequest{
|
||||||
|
Name: "my-first-func",
|
||||||
|
Project: "tests",
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
16
examples/function/list/listFunctions/main.go
Executable file
16
examples/function/list/listFunctions/main.go
Executable file
@@ -0,0 +1,16 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/function"
|
||||||
|
)
|
||||||
|
|
||||||
|
// List all the deployed functions
|
||||||
|
func main() {
|
||||||
|
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := functionService.List(&function.ListRequest{})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
@@ -32,6 +32,7 @@ Postcode: "wc2b",
|
|||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Reverse
|
## Reverse
|
||||||
@@ -60,5 +61,6 @@ Longitude: -0.1216235,
|
|||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
21
examples/geocoding/lookup/geocodeAnAddress/main.go
Executable file
21
examples/geocoding/lookup/geocodeAnAddress/main.go
Executable file
@@ -0,0 +1,21 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/geocoding"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Lookup returns a geocoded address including normalized address and gps coordinates. All fields are optional, provide more to get more accurate results
|
||||||
|
func main() {
|
||||||
|
geocodingService := geocoding.NewGeocodingService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := geocodingService.Lookup(&geocoding.LookupRequest{
|
||||||
|
Address: "10 russell st",
|
||||||
|
City: "london",
|
||||||
|
Country: "uk",
|
||||||
|
Postcode: "wc2b",
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
19
examples/geocoding/reverse/reverseGeocodeLocation/main.go
Executable file
19
examples/geocoding/reverse/reverseGeocodeLocation/main.go
Executable file
@@ -0,0 +1,19 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/geocoding"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Reverse lookup an address from gps coordinates
|
||||||
|
func main() {
|
||||||
|
geocodingService := geocoding.NewGeocodingService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := geocodingService.Reverse(&geocoding.ReverseRequest{
|
||||||
|
Latitude: 51.5123064,
|
||||||
|
Longitude: -0.1216235,
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
@@ -30,5 +30,6 @@ Query: "dogs",
|
|||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
19
examples/gifs/search/search/main.go
Executable file
19
examples/gifs/search/search/main.go
Executable file
@@ -0,0 +1,19 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/gifs"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Search for a GIF
|
||||||
|
func main() {
|
||||||
|
gifsService := gifs.NewGifsService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := gifsService.Search(&gifs.SearchRequest{
|
||||||
|
Limit: 2,
|
||||||
|
Query: "dogs",
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
@@ -29,5 +29,6 @@ func SearchForVideos() {
|
|||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
18
examples/google/search/searchForVideos/main.go
Executable file
18
examples/google/search/searchForVideos/main.go
Executable file
@@ -0,0 +1,18 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/google"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Search for videos on Google
|
||||||
|
func main() {
|
||||||
|
googleService := google.NewGoogleService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := googleService.Search(&google.SearchRequest{
|
||||||
|
Query: "how to make donuts",
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
@@ -4,33 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Helloworld/api
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
## Stream
|
|
||||||
|
|
||||||
Stream returns a stream of "Hello $name" responses
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/helloworld/api#Stream](https://m3o.com/helloworld/api#Stream)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/helloworld"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Stream returns a stream of "Hello $name" responses
|
|
||||||
func StreamsAreCurrentlyTemporarilyNotSupportedInClients() {
|
|
||||||
helloworldService := helloworld.NewHelloworldService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := helloworldService.Stream(&helloworld.StreamRequest{
|
|
||||||
Name: "not supported",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Call
|
## Call
|
||||||
|
|
||||||
Call returns a personalised "Hello $name" response
|
Call returns a personalised "Hello $name" response
|
||||||
@@ -56,5 +29,48 @@ func CallTheHelloworldService() {
|
|||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Stream
|
||||||
|
|
||||||
|
Stream returns a stream of "Hello $name" responses
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/helloworld/api#Stream](https://m3o.com/helloworld/api#Stream)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/helloworld"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Stream returns a stream of "Hello $name" responses
|
||||||
|
func StreamsResponsesFromTheServerUsingWebsockets() {
|
||||||
|
helloworldService := helloworld.NewHelloworldService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
|
||||||
|
stream, err := helloworldService.Stream(&helloworld.StreamRequest{
|
||||||
|
Messages: 10,
|
||||||
|
Name: "John",
|
||||||
|
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for {
|
||||||
|
rsp, err := stream.Recv()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println(rsp)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
0
examples/helloworld/call/callTheHelloworldService/.run
Executable file
0
examples/helloworld/call/callTheHelloworldService/.run
Executable file
18
examples/helloworld/call/callTheHelloworldService/main.go
Executable file
18
examples/helloworld/call/callTheHelloworldService/main.go
Executable file
@@ -0,0 +1,18 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/helloworld"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Call returns a personalised "Hello $name" response
|
||||||
|
func main() {
|
||||||
|
helloworldService := helloworld.NewHelloworldService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := helloworldService.Call(&helloworld.CallRequest{
|
||||||
|
Name: "John",
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/helloworld"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Stream returns a stream of "Hello $name" responses
|
||||||
|
func main() {
|
||||||
|
helloworldService := helloworld.NewHelloworldService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
|
||||||
|
stream, err := helloworldService.Stream(&helloworld.StreamRequest{
|
||||||
|
Name: "not supported",
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for {
|
||||||
|
rsp, err := stream.Recv()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println(rsp)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/helloworld"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Stream returns a stream of "Hello $name" responses
|
||||||
|
func main() {
|
||||||
|
helloworldService := helloworld.NewHelloworldService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
|
||||||
|
stream, err := helloworldService.Stream(&helloworld.StreamRequest{
|
||||||
|
Messages: 10,
|
||||||
|
Name: "John",
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for {
|
||||||
|
rsp, err := stream.Recv()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println(rsp)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,6 +4,33 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Holidays/api](
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
|
## Countries
|
||||||
|
|
||||||
|
Get the list of countries that are supported by this API
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/holidays/api#Countries](https://m3o.com/holidays/api#Countries)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/holidays"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Get the list of countries that are supported by this API
|
||||||
|
func ListCountries() {
|
||||||
|
holidaysService := holidays.NewHolidaysService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := holidaysService.Countries(&holidays.CountriesRequest{
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
## List
|
## List
|
||||||
|
|
||||||
List the holiday dates for a given country and year
|
List the holiday dates for a given country and year
|
||||||
@@ -29,31 +56,6 @@ func GetHolidays() {
|
|||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
}
|
|
||||||
```
|
|
||||||
## Countries
|
|
||||||
|
|
||||||
Get the list of countries that are supported by this API
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/holidays/api#Countries](https://m3o.com/holidays/api#Countries)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/holidays"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Get the list of countries that are supported by this API
|
|
||||||
func ListCountries() {
|
|
||||||
holidaysService := holidays.NewHolidaysService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := holidaysService.Countries(&holidays.CountriesRequest{
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user