mirror of
https://github.com/kevin-DL/m3o-go.git
synced 2026-01-24 07:25:35 +00:00
Compare commits
510 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d9525396cf | ||
|
|
4ba7d514de | ||
|
|
6f19fa6c21 | ||
|
|
9e9cdea93c | ||
|
|
b15338a487 | ||
|
|
0dcf091fcd | ||
|
|
0b51a95007 | ||
|
|
45911a9514 | ||
|
|
e1e192f018 | ||
|
|
27a864147e | ||
|
|
c1b77789fa | ||
|
|
4620490768 | ||
|
|
114a758381 | ||
|
|
56f6f1b226 | ||
|
|
669c89d2ce | ||
|
|
1ba6f0112e | ||
|
|
683ed620f6 | ||
|
|
f456c792e3 | ||
|
|
501ad85d89 | ||
|
|
f5ac2484b1 | ||
|
|
ffe83a0e6b | ||
|
|
a27ae23ef5 | ||
|
|
3268e8b833 | ||
|
|
f4d0b1d660 | ||
|
|
ed69c094ef | ||
|
|
f98122a9dd | ||
|
|
ec54c879cb | ||
|
|
44073d45ca | ||
|
|
06105ec3b9 | ||
|
|
0c476e33bd | ||
|
|
8241c345fb | ||
|
|
0eb39e2461 | ||
|
|
8ce3354f04 | ||
|
|
f5475a5170 | ||
|
|
90e94ef592 | ||
|
|
03c04de4f0 | ||
|
|
06389f6ad6 | ||
|
|
7a11bb07da | ||
|
|
aa8a17a47c | ||
|
|
0310b8e3df | ||
|
|
e6a0e215ab | ||
|
|
e649f76975 | ||
|
|
2b8e5d7870 | ||
|
|
23de678eeb | ||
|
|
9a662c1dcc | ||
|
|
8a940fae02 | ||
|
|
fdcfcfd347 | ||
|
|
65df1a1342 | ||
|
|
93e6f9f01d | ||
|
|
b84d5933b9 | ||
|
|
f8e430b5a7 | ||
|
|
244d46bb05 | ||
|
|
6e4709f6fc | ||
|
|
4a6f0939d7 | ||
|
|
d287d1f1bd | ||
|
|
7fadd2533d | ||
|
|
ea14846c46 | ||
|
|
f6e156bc79 | ||
|
|
e5a5c4e65b | ||
|
|
792375ce99 | ||
|
|
f199e7ce48 | ||
|
|
72e5d61a4f | ||
|
|
01c65269af | ||
|
|
cde5ee4b4a | ||
|
|
a803ac6cb2 | ||
|
|
4bf0f8117b | ||
|
|
83576d7c80 | ||
|
|
72d0bf6e92 | ||
|
|
f3af48b74a | ||
|
|
a411a0357f | ||
|
|
1768e5a808 | ||
|
|
c0d2552cbd | ||
|
|
768b2ff48a | ||
|
|
5b868b14a1 | ||
|
|
05bd1cc019 | ||
|
|
d43cef6a73 | ||
|
|
d553a75980 | ||
|
|
075ce9c66d | ||
|
|
14f8578107 | ||
|
|
ee1e2f343f | ||
|
|
d1d2e772b1 | ||
|
|
39c260aa7d | ||
|
|
df2e3791f8 | ||
|
|
b438949b74 | ||
|
|
522d1cfddf | ||
|
|
99dd48cf66 | ||
|
|
17032521e6 | ||
|
|
641305066b | ||
|
|
05f5fd60de | ||
|
|
9b6b287efd | ||
|
|
fb17d4eeb8 | ||
|
|
9e505ad6fd | ||
|
|
c9f71d2779 | ||
|
|
d792a8407f | ||
|
|
f55142f3fd | ||
|
|
77e5eeb9d0 | ||
|
|
6e56e7fb79 | ||
|
|
4cfcb489f5 | ||
|
|
fbd3cc92b8 | ||
|
|
d31537fab5 | ||
|
|
3b138131a9 | ||
|
|
620ee63c4f | ||
|
|
6a2dd1866b | ||
|
|
71c5bb6e03 | ||
|
|
3b8a75307d | ||
|
|
43846051bf | ||
|
|
84a5ed29c6 | ||
|
|
0d54e22630 | ||
|
|
8fd93d33a8 | ||
|
|
633b2dc986 | ||
|
|
9726537930 | ||
|
|
a7335378e5 | ||
|
|
11ea4be31e | ||
|
|
cbee5fbe46 | ||
|
|
87645bef95 | ||
|
|
fbb3b8b37f | ||
|
|
c578c665fb | ||
|
|
192963e19e | ||
|
|
f6a6c065b1 | ||
|
|
92edd2c7df | ||
|
|
6f04af332e | ||
|
|
e6a4ba7a6a | ||
|
|
8245cf14ad | ||
|
|
d310afaf59 | ||
|
|
ead8a52c00 | ||
|
|
44959a42ae | ||
|
|
9400bd92ed | ||
|
|
f3ad0d0a31 | ||
|
|
c85190845b | ||
|
|
f3960b5942 | ||
|
|
14bf65c01b | ||
|
|
c246e99019 | ||
|
|
945dd22f3f | ||
|
|
9f36bc2691 | ||
|
|
eca42fbc54 | ||
|
|
ba04dfd77e | ||
|
|
af45cd2894 | ||
|
|
0a74e37b3d | ||
|
|
3e76b80858 | ||
|
|
40fb1aabc2 | ||
|
|
2166a3322f | ||
|
|
f7d1a4e72a | ||
|
|
717896adeb | ||
|
|
614e6f96d5 | ||
|
|
884146ef30 | ||
|
|
041d77e930 | ||
|
|
2148ec979a | ||
|
|
6ebb0a6fc0 | ||
|
|
a2297b4940 | ||
|
|
54ac1d7b5e | ||
|
|
5d4497ce02 | ||
|
|
5cf1b55904 | ||
|
|
4b1ca7d2cf | ||
|
|
18f89d3897 | ||
|
|
e56ccf9c5a | ||
|
|
21d79de877 | ||
|
|
99efab9e84 | ||
|
|
17969ed728 | ||
|
|
18bb483c19 | ||
|
|
2df19f48f9 | ||
|
|
1fd95a1ba2 | ||
|
|
d561c13a96 | ||
|
|
a40743588f | ||
|
|
ba5525397e | ||
|
|
8cb1bd3b0e | ||
|
|
bb37bc2303 | ||
|
|
952eefa075 | ||
|
|
ce4bf96d24 | ||
|
|
38ca628ece | ||
|
|
f18524b9be | ||
|
|
440ace2ff1 | ||
|
|
e8b0af2e55 | ||
|
|
0b38412bf3 | ||
|
|
b9768eb8b7 | ||
|
|
e7e04b4dc6 | ||
|
|
699b61e7c0 | ||
|
|
4cb3a27308 | ||
|
|
0f075f596c | ||
|
|
e474140446 | ||
|
|
455cc584c1 | ||
|
|
f2720472ef | ||
|
|
e4d135221e | ||
|
|
ab6fda2a88 | ||
|
|
949f7358ae | ||
|
|
e92b8761e4 | ||
|
|
e480f7b75e | ||
|
|
f72459c80c | ||
|
|
4eaec6494d | ||
|
|
ff8579bd7b | ||
|
|
d7a2a7192c | ||
|
|
9484560933 | ||
|
|
4d9f2537b3 | ||
|
|
4ad39a9390 | ||
|
|
6e90e55833 | ||
|
|
e0df52d52d | ||
|
|
85d2609a1a | ||
|
|
9daed33d8c | ||
|
|
381437bc3e | ||
|
|
aebe1be645 | ||
|
|
7c4b2d3be8 | ||
|
|
dc4ea3ec58 | ||
|
|
59088be869 | ||
|
|
5c417658ba | ||
|
|
6635c69668 | ||
|
|
d37db98b30 | ||
|
|
470af2ef62 | ||
|
|
f80a59c744 | ||
|
|
c93f6ca3f8 | ||
|
|
fb09d21ee3 | ||
|
|
c72af16e84 | ||
|
|
82aff73527 | ||
|
|
f5a9559dd5 | ||
|
|
b74cd32327 | ||
|
|
f2acce6472 | ||
|
|
ca487399c4 | ||
|
|
804c7c268f | ||
|
|
7f887c0e5c | ||
|
|
5280b7371d | ||
|
|
ef81a4f249 | ||
|
|
c07c3d2c56 | ||
|
|
b7d260f835 | ||
|
|
244317372a | ||
|
|
e155efc8bc | ||
|
|
170212b863 | ||
|
|
981643b54e | ||
|
|
49b020b77d | ||
|
|
a0c2f0e902 | ||
|
|
ecd3cd917e | ||
|
|
cc85c6fecb | ||
|
|
214ee72d62 | ||
|
|
0c5b55927a | ||
|
|
b33cea5122 | ||
|
|
f3206ed31c | ||
|
|
149807a75c | ||
|
|
612fc2de62 | ||
|
|
9b283db5fe | ||
|
|
042289cc6f | ||
|
|
4db6e7b4ba | ||
|
|
322b0a4106 | ||
|
|
3f4c3f86df | ||
|
|
eda3404230 | ||
|
|
ec4c8a74bb | ||
|
|
21b52c415d | ||
|
|
762c2c0fe1 | ||
|
|
96a4f54d29 | ||
|
|
85b2a409d1 | ||
|
|
0f3166d4e8 | ||
|
|
d814c2acf7 | ||
|
|
8c56ab81dc | ||
|
|
f5c0e5528e | ||
|
|
672f12a626 | ||
|
|
bb625c5e27 | ||
|
|
dceb4a3d15 | ||
|
|
0989ba261d | ||
|
|
a22808668d | ||
|
|
678101a8c1 | ||
|
|
272b9b9ec4 | ||
|
|
ede720bbcc | ||
|
|
b581d55bab | ||
|
|
1232a8904f | ||
|
|
81c307da6f | ||
|
|
dac0425b2a | ||
|
|
06ef8db313 | ||
|
|
5b47bd8d20 | ||
|
|
8b220a4f84 | ||
|
|
87630a4bfd | ||
|
|
8e682f8359 | ||
|
|
6506023057 | ||
|
|
c531597f93 | ||
|
|
0547d347c4 | ||
|
|
1084761795 | ||
|
|
6ce71d618e | ||
|
|
8ba89dded0 | ||
|
|
7448f9c556 | ||
|
|
15b0ea2d2c | ||
|
|
04883e7c8c | ||
|
|
9e1a6baeb8 | ||
|
|
c680a1c055 | ||
|
|
36b779de0d | ||
|
|
0c995edf26 | ||
|
|
8d7ad0b58b | ||
|
|
321c5b9f6f | ||
|
|
3f9e5d8723 | ||
|
|
faf22546b7 | ||
|
|
a083415879 | ||
|
|
cd45d400fb | ||
|
|
bb36584e1a | ||
|
|
894cd4e923 | ||
|
|
39f8d5f3fb | ||
|
|
54c8f9dcb6 | ||
|
|
a51bd71f2d | ||
|
|
3ea8266db8 | ||
|
|
230e477ceb | ||
|
|
5575045afe | ||
|
|
538c015b32 | ||
|
|
f799ac0771 | ||
|
|
2de1245364 | ||
|
|
6ab7deb939 | ||
|
|
82e3f11c72 | ||
|
|
7a74865089 | ||
|
|
0231fe345f | ||
|
|
96d7eb54ed | ||
|
|
65ce64530e | ||
|
|
dd6aa87548 | ||
|
|
ee8da57912 | ||
|
|
0096558263 | ||
|
|
ed691ec515 | ||
|
|
c2fb06ae73 | ||
|
|
3d54b046da | ||
|
|
d33dbbf317 | ||
|
|
77a58e78bd | ||
|
|
c18f47ca4c | ||
|
|
33398d3eb8 | ||
|
|
bb46995e2f | ||
|
|
9c534ced3d | ||
|
|
15c55dec36 | ||
|
|
fb13c684fd | ||
|
|
65c906fbdc | ||
|
|
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 |
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
|
||||
func (t *AddressService) LookupPostcode(request *LookupPostcodeRequest) (*LookupPostcodeResponse, error) {
|
||||
|
||||
rsp := &LookupPostcodeResponse{}
|
||||
return rsp, t.client.Call("address", "LookupPostcode", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type LookupPostcodeRequest struct {
|
||||
@@ -33,13 +35,13 @@ type LookupPostcodeResponse struct {
|
||||
|
||||
type Record struct {
|
||||
// building name
|
||||
BuildingName string `json:"buildingName"`
|
||||
BuildingName string `json:"building_name"`
|
||||
// the county
|
||||
County string `json:"county"`
|
||||
// line one of address
|
||||
LineOne string `json:"lineOne"`
|
||||
LineOne string `json:"line_one"`
|
||||
// line two of address
|
||||
LineTwo string `json:"lineTwo"`
|
||||
LineTwo string `json:"line_two"`
|
||||
// dependent locality
|
||||
Locality string `json:"locality"`
|
||||
// organisation if present
|
||||
|
||||
@@ -18,8 +18,10 @@ type AnswerService struct {
|
||||
|
||||
// Ask a question and receive an instant answer
|
||||
func (t *AnswerService) Question(request *QuestionRequest) (*QuestionResponse, error) {
|
||||
|
||||
rsp := &QuestionResponse{}
|
||||
return rsp, t.client.Call("answer", "Question", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type QuestionRequest struct {
|
||||
|
||||
202
app/app.go
Executable file
202
app/app.go
Executable file
@@ -0,0 +1,202 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"go.m3o.com/client"
|
||||
)
|
||||
|
||||
func NewAppService(token string) *AppService {
|
||||
return &AppService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type AppService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Delete an app
|
||||
func (t *AppService) Delete(request *DeleteRequest) (*DeleteResponse, error) {
|
||||
|
||||
rsp := &DeleteResponse{}
|
||||
return rsp, t.client.Call("app", "Delete", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// List all the apps
|
||||
func (t *AppService) List(request *ListRequest) (*ListResponse, error) {
|
||||
|
||||
rsp := &ListResponse{}
|
||||
return rsp, t.client.Call("app", "List", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Return the support regions
|
||||
func (t *AppService) Regions(request *RegionsRequest) (*RegionsResponse, error) {
|
||||
|
||||
rsp := &RegionsResponse{}
|
||||
return rsp, t.client.Call("app", "Regions", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Reserve apps beyond the free quota. Call Run after.
|
||||
func (t *AppService) Reserve(request *ReserveRequest) (*ReserveResponse, error) {
|
||||
|
||||
rsp := &ReserveResponse{}
|
||||
return rsp, t.client.Call("app", "Reserve", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Resolve an app by id to its raw backend endpoint
|
||||
func (t *AppService) Resolve(request *ResolveRequest) (*ResolveResponse, error) {
|
||||
|
||||
rsp := &ResolveResponse{}
|
||||
return rsp, t.client.Call("app", "Resolve", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Run an app from a source repo. Specify region etc.
|
||||
func (t *AppService) Run(request *RunRequest) (*RunResponse, error) {
|
||||
|
||||
rsp := &RunResponse{}
|
||||
return rsp, t.client.Call("app", "Run", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Get the status of an app
|
||||
func (t *AppService) Status(request *StatusRequest) (*StatusResponse, error) {
|
||||
|
||||
rsp := &StatusResponse{}
|
||||
return rsp, t.client.Call("app", "Status", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Update the app. The latest source code will be downloaded, built and deployed.
|
||||
func (t *AppService) Update(request *UpdateRequest) (*UpdateResponse, error) {
|
||||
|
||||
rsp := &UpdateResponse{}
|
||||
return rsp, t.client.Call("app", "Update", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type DeleteRequest struct {
|
||||
// name of the app
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type DeleteResponse struct {
|
||||
}
|
||||
|
||||
type ListRequest struct {
|
||||
}
|
||||
|
||||
type ListResponse struct {
|
||||
// all the apps
|
||||
Services []Service `json:"services"`
|
||||
}
|
||||
|
||||
type RegionsRequest struct {
|
||||
}
|
||||
|
||||
type RegionsResponse struct {
|
||||
Regions []string `json:"regions"`
|
||||
}
|
||||
|
||||
type Reservation struct {
|
||||
// time of reservation
|
||||
Created string `json:"created"`
|
||||
// time reservation expires
|
||||
Expires string `json:"expires"`
|
||||
// name of the app
|
||||
Name string `json:"name"`
|
||||
// owner id
|
||||
Owner string `json:"owner"`
|
||||
// associated token
|
||||
Token string `json:"token"`
|
||||
}
|
||||
|
||||
type ReserveRequest struct {
|
||||
// name of your app e.g helloworld
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type ReserveResponse struct {
|
||||
// The app reservation
|
||||
Reservation *Reservation `json:"reservation"`
|
||||
}
|
||||
|
||||
type ResolveRequest struct {
|
||||
// the service id
|
||||
Id string `json:"id"`
|
||||
}
|
||||
|
||||
type ResolveResponse struct {
|
||||
// the end provider url
|
||||
Url string `json:"url"`
|
||||
}
|
||||
|
||||
type RunRequest struct {
|
||||
// branch. defaults to master
|
||||
Branch string `json:"branch"`
|
||||
// associatede env vars to pass in
|
||||
EnvVars map[string]string `json:"env_vars"`
|
||||
// name of the app
|
||||
Name string `json:"name"`
|
||||
// port to run on
|
||||
Port int32 `json:"port"`
|
||||
// region to run in
|
||||
Region string `json:"region"`
|
||||
// source repository
|
||||
Repo string `json:"repo"`
|
||||
}
|
||||
|
||||
type RunResponse struct {
|
||||
// The running service
|
||||
Service *Service `json:"service"`
|
||||
}
|
||||
|
||||
type Service struct {
|
||||
// branch of code
|
||||
Branch string `json:"branch"`
|
||||
// time of creation
|
||||
Created string `json:"created"`
|
||||
// custom domains
|
||||
CustomDomains string `json:"custom_domains"`
|
||||
// associated env vars
|
||||
EnvVars map[string]string `json:"env_vars"`
|
||||
// unique id
|
||||
Id string `json:"id"`
|
||||
// name of the app
|
||||
Name string `json:"name"`
|
||||
// port running on
|
||||
Port int32 `json:"port"`
|
||||
// region running in
|
||||
Region string `json:"region"`
|
||||
// source repository
|
||||
Repo string `json:"repo"`
|
||||
// status of the app
|
||||
Status string `json:"status"`
|
||||
// last updated
|
||||
Updated string `json:"updated"`
|
||||
// app url
|
||||
Url string `json:"url"`
|
||||
}
|
||||
|
||||
type StatusRequest struct {
|
||||
// name of the app
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type StatusResponse struct {
|
||||
// running service info
|
||||
Service *Service `json:"service"`
|
||||
}
|
||||
|
||||
type UpdateRequest struct {
|
||||
// name of the app
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type UpdateResponse struct {
|
||||
}
|
||||
46
avatar/avatar.go
Executable file
46
avatar/avatar.go
Executable file
@@ -0,0 +1,46 @@
|
||||
package avatar
|
||||
|
||||
import (
|
||||
"go.m3o.com/client"
|
||||
)
|
||||
|
||||
func NewAvatarService(token string) *AvatarService {
|
||||
return &AvatarService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type AvatarService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
//
|
||||
func (t *AvatarService) Generate(request *GenerateRequest) (*GenerateResponse, error) {
|
||||
|
||||
rsp := &GenerateResponse{}
|
||||
return rsp, t.client.Call("avatar", "Generate", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type GenerateRequest struct {
|
||||
// encode format of avatar image, `png` or `jpeg`, default is `jpeg`
|
||||
Format string `json:"format"`
|
||||
// avatar's gender, `male` or `female`, default is `male`
|
||||
Gender string `json:"gender"`
|
||||
// if upload to m3o CDN, default is `false`
|
||||
// if update = true, then it'll return the CDN url
|
||||
Upload bool `json:"upload"`
|
||||
// avatar's username, unique username will generates the unique avatar;
|
||||
// if username == "", will generate a random avatar in every request
|
||||
// if upload == true, username will be used as CDN filename rather than a random uuid string
|
||||
Username string `json:"username"`
|
||||
}
|
||||
|
||||
type GenerateResponse struct {
|
||||
// base64encode string of the avatar image
|
||||
Base64 string `json:"base64"`
|
||||
// Micro's CDN url of the avatar image
|
||||
Url string `json:"url"`
|
||||
}
|
||||
18
cache/cache.go
vendored
18
cache/cache.go
vendored
@@ -16,34 +16,44 @@ type CacheService struct {
|
||||
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) {
|
||||
|
||||
rsp := &DecrementResponse{}
|
||||
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) {
|
||||
|
||||
rsp := &DeleteResponse{}
|
||||
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) {
|
||||
|
||||
rsp := &GetResponse{}
|
||||
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) {
|
||||
|
||||
rsp := &IncrementResponse{}
|
||||
return rsp, t.client.Call("cache", "Increment", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Set an item in the cache. Overwrites any existing value already set.
|
||||
func (t *CacheService) Set(request *SetRequest) (*SetResponse, error) {
|
||||
|
||||
rsp := &SetResponse{}
|
||||
return rsp, t.client.Call("cache", "Set", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type DecrementRequest struct {
|
||||
|
||||
@@ -6,6 +6,10 @@ import (
|
||||
)
|
||||
|
||||
func TestBasicCall(t *testing.T) {
|
||||
if v := os.Getenv("IN_TRAVIS"); v == "yes" {
|
||||
return
|
||||
}
|
||||
|
||||
response := map[string]interface{}{}
|
||||
if err := NewClient(&Options{
|
||||
Token: os.Getenv("TOKEN"),
|
||||
|
||||
@@ -18,26 +18,34 @@ type CryptoService struct {
|
||||
|
||||
// Returns the history for the previous close
|
||||
func (t *CryptoService) History(request *HistoryRequest) (*HistoryResponse, error) {
|
||||
|
||||
rsp := &HistoryResponse{}
|
||||
return rsp, t.client.Call("crypto", "History", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Get news related to a currency
|
||||
func (t *CryptoService) News(request *NewsRequest) (*NewsResponse, error) {
|
||||
|
||||
rsp := &NewsResponse{}
|
||||
return rsp, t.client.Call("crypto", "News", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Get the last price for a given crypto ticker
|
||||
func (t *CryptoService) Price(request *PriceRequest) (*PriceResponse, error) {
|
||||
|
||||
rsp := &PriceResponse{}
|
||||
return rsp, t.client.Call("crypto", "Price", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Get the last quote for a given crypto ticker
|
||||
func (t *CryptoService) Quote(request *QuoteRequest) (*QuoteResponse, error) {
|
||||
|
||||
rsp := &QuoteResponse{}
|
||||
return rsp, t.client.Call("crypto", "Quote", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type Article struct {
|
||||
@@ -106,13 +114,13 @@ type QuoteRequest struct {
|
||||
|
||||
type QuoteResponse struct {
|
||||
// the asking price
|
||||
AskPrice float64 `json:"askPrice"`
|
||||
AskPrice float64 `json:"ask_price"`
|
||||
// the ask size
|
||||
AskSize float64 `json:"askSize"`
|
||||
AskSize float64 `json:"ask_size"`
|
||||
// the bidding price
|
||||
BidPrice float64 `json:"bidPrice"`
|
||||
BidPrice float64 `json:"bid_price"`
|
||||
// the bid size
|
||||
BidSize float64 `json:"bidSize"`
|
||||
BidSize float64 `json:"bid_size"`
|
||||
// the crypto symbol
|
||||
Symbol string `json:"symbol"`
|
||||
// the UTC timestamp of the quote
|
||||
|
||||
@@ -18,26 +18,34 @@ type CurrencyService struct {
|
||||
|
||||
// Codes returns the supported currency codes for the API
|
||||
func (t *CurrencyService) Codes(request *CodesRequest) (*CodesResponse, error) {
|
||||
|
||||
rsp := &CodesResponse{}
|
||||
return rsp, t.client.Call("currency", "Codes", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Convert returns the currency conversion rate between two pairs e.g USD/GBP
|
||||
func (t *CurrencyService) Convert(request *ConvertRequest) (*ConvertResponse, error) {
|
||||
|
||||
rsp := &ConvertResponse{}
|
||||
return rsp, t.client.Call("currency", "Convert", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Returns the historic rates for a currency on a given date
|
||||
func (t *CurrencyService) History(request *HistoryRequest) (*HistoryResponse, error) {
|
||||
|
||||
rsp := &HistoryResponse{}
|
||||
return rsp, t.client.Call("currency", "History", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Rates returns the currency rates for a given code e.g USD
|
||||
func (t *CurrencyService) Rates(request *RatesRequest) (*RatesResponse, error) {
|
||||
|
||||
rsp := &RatesResponse{}
|
||||
return rsp, t.client.Call("currency", "Rates", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type Code struct {
|
||||
|
||||
66
db/db.go
66
db/db.go
@@ -18,38 +18,74 @@ type DbService struct {
|
||||
|
||||
// Count records in a table
|
||||
func (t *DbService) Count(request *CountRequest) (*CountResponse, error) {
|
||||
|
||||
rsp := &CountResponse{}
|
||||
return rsp, t.client.Call("db", "Count", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
|
||||
func (t *DbService) Create(request *CreateRequest) (*CreateResponse, error) {
|
||||
|
||||
rsp := &CreateResponse{}
|
||||
return rsp, t.client.Call("db", "Create", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Delete a record in the database by id.
|
||||
func (t *DbService) Delete(request *DeleteRequest) (*DeleteResponse, error) {
|
||||
|
||||
rsp := &DeleteResponse{}
|
||||
return rsp, t.client.Call("db", "Delete", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// 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.
|
||||
func (t *DbService) Read(request *ReadRequest) (*ReadResponse, error) {
|
||||
|
||||
rsp := &ReadResponse{}
|
||||
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
|
||||
func (t *DbService) Truncate(request *TruncateRequest) (*TruncateResponse, error) {
|
||||
|
||||
rsp := &TruncateResponse{}
|
||||
return rsp, t.client.Call("db", "Truncate", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Update a record in the database. Include an "id" in the record to update.
|
||||
func (t *DbService) Update(request *UpdateRequest) (*UpdateResponse, error) {
|
||||
|
||||
rsp := &UpdateResponse{}
|
||||
return rsp, t.client.Call("db", "Update", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type CountRequest struct {
|
||||
@@ -63,6 +99,8 @@ type CountResponse struct {
|
||||
}
|
||||
|
||||
type CreateRequest struct {
|
||||
// optional record id to use
|
||||
Id string `json:"id"`
|
||||
// JSON encoded record or records (can be array or object)
|
||||
Record map[string]interface{} `json:"record"`
|
||||
// Optional table name. Defaults to 'default'
|
||||
@@ -84,6 +122,21 @@ type DeleteRequest 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 {
|
||||
// Read by id. Equivalent to 'id == "your-id"'
|
||||
Id string `json:"id"`
|
||||
@@ -110,14 +163,21 @@ type ReadResponse struct {
|
||||
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 {
|
||||
// Optional table name. Defaults to 'default'
|
||||
Table string `json:"table"`
|
||||
}
|
||||
|
||||
type TruncateResponse struct {
|
||||
// The table truncated
|
||||
Table string `json:"table"`
|
||||
}
|
||||
|
||||
type UpdateRequest struct {
|
||||
|
||||
@@ -18,21 +18,23 @@ type EmailService struct {
|
||||
|
||||
// Send an email by passing in from, to, subject, and a text or html body
|
||||
func (t *EmailService) Send(request *SendRequest) (*SendResponse, error) {
|
||||
|
||||
rsp := &SendResponse{}
|
||||
return rsp, t.client.Call("email", "Send", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type SendRequest struct {
|
||||
// the display name of the sender
|
||||
From string `json:"from"`
|
||||
// the html body
|
||||
HtmlBody string `json:"htmlBody"`
|
||||
HtmlBody string `json:"html_body"`
|
||||
// an optional reply to email address
|
||||
ReplyTo string `json:"replyTo"`
|
||||
ReplyTo string `json:"reply_to"`
|
||||
// the email subject
|
||||
Subject string `json:"subject"`
|
||||
// the text body
|
||||
TextBody string `json:"textBody"`
|
||||
TextBody string `json:"text_body"`
|
||||
// the email address of the recipient
|
||||
To string `json:"to"`
|
||||
}
|
||||
|
||||
@@ -18,27 +18,35 @@ type EmojiService struct {
|
||||
|
||||
// Find an emoji by its alias e.g :beer:
|
||||
func (t *EmojiService) Find(request *FindRequest) (*FindResponse, error) {
|
||||
|
||||
rsp := &FindResponse{}
|
||||
return rsp, t.client.Call("emoji", "Find", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Get the flag for a country. Requires country code e.g GB for great britain
|
||||
func (t *EmojiService) Flag(request *FlagRequest) (*FlagResponse, error) {
|
||||
|
||||
rsp := &FlagResponse{}
|
||||
return rsp, t.client.Call("emoji", "Flag", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Print text and renders the emojis with aliases e.g
|
||||
// let's grab a :beer: becomes let's grab a 🍺
|
||||
func (t *EmojiService) Print(request *PrintRequest) (*PrintResponse, error) {
|
||||
|
||||
rsp := &PrintResponse{}
|
||||
return rsp, t.client.Call("emoji", "Print", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Send an emoji to anyone via SMS. Messages are sent in the form '<message> Sent from <from>'
|
||||
func (t *EmojiService) Send(request *SendRequest) (*SendResponse, error) {
|
||||
|
||||
rsp := &SendResponse{}
|
||||
return rsp, t.client.Call("emoji", "Send", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type FindRequest struct {
|
||||
|
||||
@@ -18,62 +18,66 @@ type EvchargersService struct {
|
||||
|
||||
// Retrieve reference data as used by this API and in conjunction with the Search endpoint
|
||||
func (t *EvchargersService) ReferenceData(request *ReferenceDataRequest) (*ReferenceDataResponse, error) {
|
||||
|
||||
rsp := &ReferenceDataResponse{}
|
||||
return rsp, t.client.Call("evchargers", "ReferenceData", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Search by giving a coordinate and a max distance, or bounding box and optional filters
|
||||
func (t *EvchargersService) Search(request *SearchRequest) (*SearchResponse, error) {
|
||||
|
||||
rsp := &SearchResponse{}
|
||||
return rsp, t.client.Call("evchargers", "Search", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type Address struct {
|
||||
// Any comments about how to access the charger
|
||||
AccessComments string `json:"accessComments"`
|
||||
AddressLine1 string `json:"addressLine1"`
|
||||
AddressLine2 string `json:"addressLine2"`
|
||||
AccessComments string `json:"access_comments"`
|
||||
AddressLine1 string `json:"address_line_1"`
|
||||
AddressLine2 string `json:"address_line_2"`
|
||||
Country *Country `json:"country"`
|
||||
CountryId string `json:"countryId"`
|
||||
LatLng string `json:"latLng"`
|
||||
CountryId string `json:"country_id"`
|
||||
LatLng string `json:"lat_lng"`
|
||||
Location *Coordinates `json:"location"`
|
||||
Postcode string `json:"postcode"`
|
||||
StateOrProvince string `json:"stateOrProvince"`
|
||||
StateOrProvince string `json:"state_or_province"`
|
||||
Title string `json:"title"`
|
||||
Town string `json:"town"`
|
||||
}
|
||||
|
||||
type BoundingBox struct {
|
||||
BottomLeft *Coordinates `json:"bottomLeft"`
|
||||
TopRight *Coordinates `json:"topRight"`
|
||||
BottomLeft *Coordinates `json:"bottom_left"`
|
||||
TopRight *Coordinates `json:"top_right"`
|
||||
}
|
||||
|
||||
type ChargerType struct {
|
||||
Comments string `json:"comments"`
|
||||
Id string `json:"id"`
|
||||
// Is this 40KW+
|
||||
IsFastChargeCapable bool `json:"isFastChargeCapable"`
|
||||
IsFastChargeCapable bool `json:"is_fast_charge_capable"`
|
||||
Title string `json:"title"`
|
||||
}
|
||||
|
||||
type CheckinStatusType struct {
|
||||
Id string `json:"id"`
|
||||
IsAutomated bool `json:"isAutomated"`
|
||||
IsPositive bool `json:"isPositive"`
|
||||
IsAutomated bool `json:"is_automated"`
|
||||
IsPositive bool `json:"is_positive"`
|
||||
Title string `json:"title"`
|
||||
}
|
||||
|
||||
type Connection struct {
|
||||
// The amps offered
|
||||
Amps float64 `json:"amps"`
|
||||
ConnectionType *ConnectionType `json:"connectionType"`
|
||||
ConnectionType *ConnectionType `json:"connection_type"`
|
||||
// The ID of the connection type
|
||||
ConnectionTypeId string `json:"connectionTypeId"`
|
||||
ConnectionTypeId string `json:"connection_type_id"`
|
||||
// The current
|
||||
Current string `json:"current"`
|
||||
Level *ChargerType `json:"level"`
|
||||
// The level of charging power available
|
||||
LevelId string `json:"levelId"`
|
||||
LevelId string `json:"level_id"`
|
||||
// The power in KW
|
||||
Power float64 `json:"power"`
|
||||
Reference string `json:"reference"`
|
||||
@@ -82,10 +86,10 @@ type Connection struct {
|
||||
}
|
||||
|
||||
type ConnectionType struct {
|
||||
FormalName string `json:"formalName"`
|
||||
FormalName string `json:"formal_name"`
|
||||
Id string `json:"id"`
|
||||
IsDiscontinued bool `json:"isDiscontinued"`
|
||||
IsObsolete bool `json:"isObsolete"`
|
||||
IsDiscontinued bool `json:"is_discontinued"`
|
||||
IsObsolete bool `json:"is_obsolete"`
|
||||
Title string `json:"title"`
|
||||
}
|
||||
|
||||
@@ -95,9 +99,9 @@ type Coordinates struct {
|
||||
}
|
||||
|
||||
type Country struct {
|
||||
ContinentCode string `json:"continentCode"`
|
||||
ContinentCode string `json:"continent_code"`
|
||||
Id string `json:"id"`
|
||||
IsoCode string `json:"isoCode"`
|
||||
IsoCode string `json:"iso_code"`
|
||||
Title string `json:"title"`
|
||||
}
|
||||
|
||||
@@ -109,7 +113,7 @@ type CurrentType struct {
|
||||
|
||||
type DataProvider struct {
|
||||
Comments string `json:"comments"`
|
||||
DataProviderStatusType *DataProviderStatusType `json:"dataProviderStatusType"`
|
||||
DataProviderStatusType *DataProviderStatusType `json:"data_provider_status_type"`
|
||||
Id string `json:"id"`
|
||||
// How is this data licensed
|
||||
License string `json:"license"`
|
||||
@@ -119,19 +123,19 @@ type DataProvider struct {
|
||||
|
||||
type DataProviderStatusType struct {
|
||||
Id string `json:"id"`
|
||||
IsProviderEnabled bool `json:"isProviderEnabled"`
|
||||
IsProviderEnabled bool `json:"is_provider_enabled"`
|
||||
Title string `json:"title"`
|
||||
}
|
||||
|
||||
type Operator struct {
|
||||
Comments string `json:"comments"`
|
||||
ContactEmail string `json:"contactEmail"`
|
||||
FaultReportEmail string `json:"faultReportEmail"`
|
||||
ContactEmail string `json:"contact_email"`
|
||||
FaultReportEmail string `json:"fault_report_email"`
|
||||
Id string `json:"id"`
|
||||
// Is this operator a private individual vs a company
|
||||
IsPrivateIndividual bool `json:"isPrivateIndividual"`
|
||||
PhonePrimary string `json:"phonePrimary"`
|
||||
PhoneSecondary string `json:"phoneSecondary"`
|
||||
IsPrivateIndividual bool `json:"is_private_individual"`
|
||||
PhonePrimary string `json:"phone_primary"`
|
||||
PhoneSecondary string `json:"phone_secondary"`
|
||||
Title string `json:"title"`
|
||||
Website string `json:"website"`
|
||||
}
|
||||
@@ -144,19 +148,19 @@ type Poi struct {
|
||||
// The cost of charging
|
||||
Cost string `json:"cost"`
|
||||
// The ID of the data provider
|
||||
DataProviderId string `json:"dataProviderId"`
|
||||
DataProviderId string `json:"data_provider_id"`
|
||||
// The ID of the charger
|
||||
Id string `json:"id"`
|
||||
// The number of charging points
|
||||
NumPoints int64 `json:"numPoints,string"`
|
||||
NumPoints int64 `json:"num_points,string"`
|
||||
// The operator
|
||||
Operator *Operator `json:"operator"`
|
||||
// The ID of the operator of the charger
|
||||
OperatorId string `json:"operatorId"`
|
||||
OperatorId string `json:"operator_id"`
|
||||
// The type of usage
|
||||
UsageType *UsageType `json:"usageType"`
|
||||
UsageType *UsageType `json:"usage_type"`
|
||||
// The type of usage for this charger point (is it public, membership required, etc)
|
||||
UsageTypeId string `json:"usageTypeId"`
|
||||
UsageTypeId string `json:"usage_type_id"`
|
||||
}
|
||||
|
||||
type ReferenceDataRequest struct {
|
||||
@@ -164,36 +168,36 @@ type ReferenceDataRequest struct {
|
||||
|
||||
type ReferenceDataResponse struct {
|
||||
// The types of charger
|
||||
ChargerTypes *ChargerType `json:"chargerTypes"`
|
||||
ChargerTypes *ChargerType `json:"charger_types"`
|
||||
// The types of checkin status
|
||||
CheckinStatusTypes *CheckinStatusType `json:"checkinStatusTypes"`
|
||||
CheckinStatusTypes *CheckinStatusType `json:"checkin_status_types"`
|
||||
// The types of connection
|
||||
ConnectionTypes *ConnectionType `json:"connectionTypes"`
|
||||
ConnectionTypes *ConnectionType `json:"connection_types"`
|
||||
// The countries
|
||||
Countries []Country `json:"countries"`
|
||||
// The types of current
|
||||
CurrentTypes *CurrentType `json:"currentTypes"`
|
||||
CurrentTypes *CurrentType `json:"current_types"`
|
||||
// The providers of the charger data
|
||||
DataProviders *DataProvider `json:"dataProviders"`
|
||||
DataProviders *DataProvider `json:"data_providers"`
|
||||
// The companies operating the chargers
|
||||
Operators []Operator `json:"operators"`
|
||||
// The status of the charger
|
||||
StatusTypes *StatusType `json:"statusTypes"`
|
||||
StatusTypes *StatusType `json:"status_types"`
|
||||
// The status of a submission
|
||||
SubmissionStatusTypes *SubmissionStatusType `json:"submissionStatusTypes"`
|
||||
SubmissionStatusTypes *SubmissionStatusType `json:"submission_status_types"`
|
||||
// The different types of usage
|
||||
UsageTypes *UsageType `json:"usageTypes"`
|
||||
UsageTypes *UsageType `json:"usage_types"`
|
||||
// The types of user comment
|
||||
UserCommentTypes *UserCommentType `json:"userCommentTypes"`
|
||||
UserCommentTypes *UserCommentType `json:"user_comment_types"`
|
||||
}
|
||||
|
||||
type SearchRequest struct {
|
||||
// Bounding box to search within (top left and bottom right coordinates)
|
||||
Box *BoundingBox `json:"box"`
|
||||
// IDs of the connection type
|
||||
ConnectionTypes string `json:"connectionTypes"`
|
||||
ConnectionTypes string `json:"connection_types"`
|
||||
// Country ID
|
||||
CountryId string `json:"countryId"`
|
||||
CountryId string `json:"country_id"`
|
||||
// Search distance from point in metres, defaults to 5000m
|
||||
Distance int64 `json:"distance,string"`
|
||||
// Supported charging levels
|
||||
@@ -201,13 +205,13 @@ type SearchRequest struct {
|
||||
// Coordinates from which to begin search
|
||||
Location *Coordinates `json:"location"`
|
||||
// Maximum number of results to return, defaults to 100
|
||||
MaxResults int64 `json:"maxResults,string"`
|
||||
MaxResults int64 `json:"max_results,string"`
|
||||
// Minimum power in KW. Note: data not available for many chargers
|
||||
MinPower int64 `json:"minPower,string"`
|
||||
MinPower int64 `json:"min_power,string"`
|
||||
// IDs of the the EV charger operator
|
||||
Operators []string `json:"operators"`
|
||||
// Usage of the charge point (is it public, membership required, etc)
|
||||
UsageTypes string `json:"usageTypes"`
|
||||
UsageTypes string `json:"usage_types"`
|
||||
}
|
||||
|
||||
type SearchResponse struct {
|
||||
@@ -216,21 +220,21 @@ type SearchResponse struct {
|
||||
|
||||
type StatusType struct {
|
||||
Id string `json:"id"`
|
||||
IsOperational bool `json:"isOperational"`
|
||||
IsOperational bool `json:"is_operational"`
|
||||
Title string `json:"title"`
|
||||
}
|
||||
|
||||
type SubmissionStatusType struct {
|
||||
Id string `json:"id"`
|
||||
IsLive bool `json:"isLive"`
|
||||
IsLive bool `json:"is_live"`
|
||||
Title string `json:"title"`
|
||||
}
|
||||
|
||||
type UsageType struct {
|
||||
Id string `json:"id"`
|
||||
IsAccessKeyRequired bool `json:"isAccessKeyRequired"`
|
||||
IsMembershipRequired bool `json:"isMembershipRequired"`
|
||||
IsPayAtLocation bool `json:"isPayAtLocation"`
|
||||
IsAccessKeyRequired bool `json:"is_access_key_required"`
|
||||
IsMembershipRequired bool `json:"is_membership_required"`
|
||||
IsPayAtLocation bool `json:"is_pay_at_location"`
|
||||
Title string `json:"title"`
|
||||
}
|
||||
|
||||
|
||||
@@ -16,16 +16,73 @@ type EventService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Publish a message to the event stream.
|
||||
func (t *EventService) Publish(request *PublishRequest) (*PublishResponse, error) {
|
||||
rsp := &PublishResponse{}
|
||||
return rsp, t.client.Call("event", "Publish", request, rsp)
|
||||
// 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
|
||||
|
||||
}
|
||||
|
||||
// Subscribe to messages for a given topic.
|
||||
func (t *EventService) Subscribe(request *SubscribeRequest) (*SubscribeResponse, error) {
|
||||
rsp := &SubscribeResponse{}
|
||||
return rsp, t.client.Call("event", "Subscribe", request, rsp)
|
||||
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 {
|
||||
@@ -38,16 +95,16 @@ type PublishRequest struct {
|
||||
type PublishResponse struct {
|
||||
}
|
||||
|
||||
type SubscribeRequest struct {
|
||||
// Optional group for the subscription
|
||||
Group string `json:"group"`
|
||||
// The topic to subscribe to
|
||||
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 SubscribeResponse struct {
|
||||
// The next json message on the topic
|
||||
Message map[string]interface{} `json:"message"`
|
||||
// The topic subscribed to
|
||||
Topic string `json:"topic"`
|
||||
type ReadResponse struct {
|
||||
// the events
|
||||
Events []Ev `json:"events"`
|
||||
}
|
||||
|
||||
@@ -29,5 +29,6 @@ func LookupPostcode() {
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
17
examples/address/lookupPostcode/lookupPostcode/main.go
Executable file
17
examples/address/lookupPostcode/lookupPostcode/main.go
Executable file
@@ -0,0 +1,17 @@
|
||||
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)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
0
examples/answer/question/askAQuestion/.run
Executable file
0
examples/answer/question/askAQuestion/.run
Executable file
17
examples/answer/question/askAQuestion/main.go
Executable file
17
examples/answer/question/askAQuestion/main.go
Executable file
@@ -0,0 +1,17 @@
|
||||
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)
|
||||
}
|
||||
232
examples/app/README.md
Executable file
232
examples/app/README.md
Executable file
@@ -0,0 +1,232 @@
|
||||
# App
|
||||
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/App/api](https://m3o.com/App/api).
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Update
|
||||
|
||||
Update the app. The latest source code will be downloaded, built and deployed.
|
||||
|
||||
|
||||
[https://m3o.com/app/api#Update](https://m3o.com/app/api#Update)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/app"
|
||||
)
|
||||
|
||||
// Update the app. The latest source code will be downloaded, built and deployed.
|
||||
func UpdateAnApp() {
|
||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := appService.Update(&app.UpdateRequest{
|
||||
Name: "helloworld",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Delete
|
||||
|
||||
Delete an app
|
||||
|
||||
|
||||
[https://m3o.com/app/api#Delete](https://m3o.com/app/api#Delete)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/app"
|
||||
)
|
||||
|
||||
// Delete an app
|
||||
func DeleteAnApp() {
|
||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := appService.Delete(&app.DeleteRequest{
|
||||
Name: "helloworld",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Reserve
|
||||
|
||||
Reserve apps beyond the free quota. Call Run after.
|
||||
|
||||
|
||||
[https://m3o.com/app/api#Reserve](https://m3o.com/app/api#Reserve)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/app"
|
||||
)
|
||||
|
||||
// Reserve apps beyond the free quota. Call Run after.
|
||||
func ReserveAppName() {
|
||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := appService.Reserve(&app.ReserveRequest{
|
||||
Name: "helloworld",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## List
|
||||
|
||||
List all the apps
|
||||
|
||||
|
||||
[https://m3o.com/app/api#List](https://m3o.com/app/api#List)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/app"
|
||||
)
|
||||
|
||||
// List all the apps
|
||||
func ListTheApps() {
|
||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := appService.List(&app.ListRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Run
|
||||
|
||||
Run an app from a source repo. Specify region etc.
|
||||
|
||||
|
||||
[https://m3o.com/app/api#Run](https://m3o.com/app/api#Run)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/app"
|
||||
)
|
||||
|
||||
// Run an app from a source repo. Specify region etc.
|
||||
func RunAnApp() {
|
||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := appService.Run(&app.RunRequest{
|
||||
Branch: "master",
|
||||
Name: "helloworld",
|
||||
Port: 8080,
|
||||
Region: "europe-west1",
|
||||
Repo: "github.com/asim/helloworld",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Regions
|
||||
|
||||
Return the support regions
|
||||
|
||||
|
||||
[https://m3o.com/app/api#Regions](https://m3o.com/app/api#Regions)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/app"
|
||||
)
|
||||
|
||||
// Return the support regions
|
||||
func ListRegions() {
|
||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := appService.Regions(&app.RegionsRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Status
|
||||
|
||||
Get the status of an app
|
||||
|
||||
|
||||
[https://m3o.com/app/api#Status](https://m3o.com/app/api#Status)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/app"
|
||||
)
|
||||
|
||||
// Get the status of an app
|
||||
func GetTheStatusOfAnApp() {
|
||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := appService.Status(&app.StatusRequest{
|
||||
Name: "helloworld",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Resolve
|
||||
|
||||
Resolve an app by id to its raw backend endpoint
|
||||
|
||||
|
||||
[https://m3o.com/app/api#Resolve](https://m3o.com/app/api#Resolve)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/app"
|
||||
)
|
||||
|
||||
// Resolve an app by id to its raw backend endpoint
|
||||
func ResolveAppById() {
|
||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := appService.Resolve(&app.ResolveRequest{
|
||||
Id: "helloworld",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
17
examples/app/delete/deleteAnApp/main.go
Executable file
17
examples/app/delete/deleteAnApp/main.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/app"
|
||||
)
|
||||
|
||||
// Delete an app
|
||||
func main() {
|
||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := appService.Delete(&app.DeleteRequest{
|
||||
Name: "helloworld",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
15
examples/app/list/listTheApps/main.go
Executable file
15
examples/app/list/listTheApps/main.go
Executable file
@@ -0,0 +1,15 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/app"
|
||||
)
|
||||
|
||||
// List all the apps
|
||||
func main() {
|
||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := appService.List(&app.ListRequest{})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
15
examples/app/regions/listRegions/main.go
Executable file
15
examples/app/regions/listRegions/main.go
Executable file
@@ -0,0 +1,15 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/app"
|
||||
)
|
||||
|
||||
// Return the support regions
|
||||
func main() {
|
||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := appService.Regions(&app.RegionsRequest{})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
17
examples/app/reserve/reserveAppName/main.go
Executable file
17
examples/app/reserve/reserveAppName/main.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/app"
|
||||
)
|
||||
|
||||
// Reserve apps beyond the free quota. Call Run after.
|
||||
func main() {
|
||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := appService.Reserve(&app.ReserveRequest{
|
||||
Name: "helloworld",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
17
examples/app/resolve/resolveAppById/main.go
Executable file
17
examples/app/resolve/resolveAppById/main.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/app"
|
||||
)
|
||||
|
||||
// Resolve an app by id to its raw backend endpoint
|
||||
func main() {
|
||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := appService.Resolve(&app.ResolveRequest{
|
||||
Id: "helloworld",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
21
examples/app/run/runAnApp/main.go
Executable file
21
examples/app/run/runAnApp/main.go
Executable file
@@ -0,0 +1,21 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/app"
|
||||
)
|
||||
|
||||
// Run an app from a source repo. Specify region etc.
|
||||
func main() {
|
||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := appService.Run(&app.RunRequest{
|
||||
Branch: "master",
|
||||
Name: "helloworld",
|
||||
Port: 8080,
|
||||
Region: "europe-west1",
|
||||
Repo: "github.com/asim/helloworld",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
17
examples/app/status/getTheStatusOfAnApp/main.go
Executable file
17
examples/app/status/getTheStatusOfAnApp/main.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/app"
|
||||
)
|
||||
|
||||
// Get the status of an app
|
||||
func main() {
|
||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := appService.Status(&app.StatusRequest{
|
||||
Name: "helloworld",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
17
examples/app/update/updateAnApp/main.go
Executable file
17
examples/app/update/updateAnApp/main.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/app"
|
||||
)
|
||||
|
||||
// Update the app. The latest source code will be downloaded, built and deployed.
|
||||
func main() {
|
||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := appService.Update(&app.UpdateRequest{
|
||||
Name: "helloworld",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
68
examples/avatar/README.md
Executable file
68
examples/avatar/README.md
Executable file
@@ -0,0 +1,68 @@
|
||||
# Avatar
|
||||
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Avatar/api](https://m3o.com/Avatar/api).
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Generate
|
||||
|
||||
|
||||
|
||||
|
||||
[https://m3o.com/avatar/api#Generate](https://m3o.com/avatar/api#Generate)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/avatar"
|
||||
)
|
||||
|
||||
//
|
||||
func GenerateAvatarAndReturnBase64stringOfTheAvatar() {
|
||||
avatarService := avatar.NewAvatarService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := avatarService.Generate(&avatar.GenerateRequest{
|
||||
Format: "png",
|
||||
Gender: "female",
|
||||
Upload: true,
|
||||
Username: "",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Generate
|
||||
|
||||
|
||||
|
||||
|
||||
[https://m3o.com/avatar/api#Generate](https://m3o.com/avatar/api#Generate)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/avatar"
|
||||
)
|
||||
|
||||
//
|
||||
func GenerateAnAvatarAndUploadTheAvatarToMicrosCdn() {
|
||||
avatarService := avatar.NewAvatarService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := avatarService.Generate(&avatar.GenerateRequest{
|
||||
Format: "jpeg",
|
||||
Gender: "female",
|
||||
Upload: false,
|
||||
Username: "",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
@@ -0,0 +1,20 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/avatar"
|
||||
)
|
||||
|
||||
//
|
||||
func main() {
|
||||
avatarService := avatar.NewAvatarService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := avatarService.Generate(&avatar.GenerateRequest{
|
||||
Format: "jpeg",
|
||||
Gender: "female",
|
||||
Upload: false,
|
||||
Username: "",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/avatar"
|
||||
)
|
||||
|
||||
//
|
||||
func main() {
|
||||
avatarService := avatar.NewAvatarService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := avatarService.Generate(&avatar.GenerateRequest{
|
||||
Format: "png",
|
||||
Gender: "female",
|
||||
Upload: true,
|
||||
Username: "",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
125
examples/cache/README.md
vendored
125
examples/cache/README.md
vendored
@@ -4,62 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Cache/api](htt
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Increment
|
||||
|
||||
Increment a value (if it's a number)
|
||||
|
||||
|
||||
[https://m3o.com/cache/api#Increment](https://m3o.com/cache/api#Increment)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/cache"
|
||||
)
|
||||
|
||||
// Increment a value (if it's a number)
|
||||
func IncrementAvalue() {
|
||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := cacheService.Increment(&cache.IncrementRequest{
|
||||
Key: "counter",
|
||||
Value: 2,
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## Decrement
|
||||
|
||||
Decrement a value (if it's a number)
|
||||
|
||||
|
||||
[https://m3o.com/cache/api#Decrement](https://m3o.com/cache/api#Decrement)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/cache"
|
||||
)
|
||||
|
||||
// Decrement a value (if it's a number)
|
||||
func DecrementAvalue() {
|
||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := cacheService.Decrement(&cache.DecrementRequest{
|
||||
Key: "counter",
|
||||
Value: 2,
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## Set
|
||||
|
||||
Set an item in the cache. Overwrites any existing value already set.
|
||||
@@ -86,11 +30,12 @@ Value: "bar",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## 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)
|
||||
@@ -105,7 +50,7 @@ import(
|
||||
"go.m3o.com/cache"
|
||||
)
|
||||
|
||||
// Get an item from the cache by key
|
||||
// Get an item from the cache by key. If key is not found, an empty response is returned.
|
||||
func GetAvalue() {
|
||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := cacheService.Get(&cache.GetRequest{
|
||||
@@ -113,11 +58,12 @@ func GetAvalue() {
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## 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)
|
||||
@@ -132,7 +78,7 @@ import(
|
||||
"go.m3o.com/cache"
|
||||
)
|
||||
|
||||
// Delete a value from the cache
|
||||
// Delete a value from the cache. If key not found a success response is returned.
|
||||
func DeleteAvalue() {
|
||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := cacheService.Delete(&cache.DeleteRequest{
|
||||
@@ -140,5 +86,64 @@ func DeleteAvalue() {
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Increment
|
||||
|
||||
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)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
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 IncrementAvalue() {
|
||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := cacheService.Increment(&cache.IncrementRequest{
|
||||
Key: "counter",
|
||||
Value: 2,
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Decrement
|
||||
|
||||
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)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
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 DecrementAvalue() {
|
||||
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/decrement/decrementAValue.go
vendored
2
examples/cache/decrement/decrementAValue.go
vendored
@@ -7,7 +7,7 @@ import (
|
||||
"go.m3o.com/cache"
|
||||
)
|
||||
|
||||
// Decrement a value (if it's a number)
|
||||
// Decrement a value (if it's a number). If key not found it is equivalent to set.
|
||||
func DecrementAvalue() {
|
||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := cacheService.Decrement(&cache.DecrementRequest{
|
||||
|
||||
18
examples/cache/decrement/decrementAValue/main.go
vendored
Executable file
18
examples/cache/decrement/decrementAValue/main.go
vendored
Executable file
@@ -0,0 +1,18 @@
|
||||
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"
|
||||
)
|
||||
|
||||
// Delete a value from the cache
|
||||
// Delete a value from the cache. If key not found a success response is returned.
|
||||
func DeleteAvalue() {
|
||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := cacheService.Delete(&cache.DeleteRequest{
|
||||
|
||||
17
examples/cache/delete/deleteAValue/main.go
vendored
Executable file
17
examples/cache/delete/deleteAValue/main.go
vendored
Executable file
@@ -0,0 +1,17 @@
|
||||
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"
|
||||
)
|
||||
|
||||
// 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() {
|
||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := cacheService.Get(&cache.GetRequest{
|
||||
|
||||
17
examples/cache/get/getAValue/main.go
vendored
Executable file
17
examples/cache/get/getAValue/main.go
vendored
Executable file
@@ -0,0 +1,17 @@
|
||||
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"
|
||||
)
|
||||
|
||||
// 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() {
|
||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := cacheService.Increment(&cache.IncrementRequest{
|
||||
|
||||
18
examples/cache/increment/incrementAValue/main.go
vendored
Executable file
18
examples/cache/increment/incrementAValue/main.go
vendored
Executable file
@@ -0,0 +1,18 @@
|
||||
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
18
examples/cache/set/setAValue/main.go
vendored
Executable file
18
examples/cache/set/setAValue/main.go
vendored
Executable file
@@ -0,0 +1,18 @@
|
||||
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)
|
||||
}
|
||||
@@ -29,6 +29,7 @@ func GetCryptocurrencyNews() {
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Price
|
||||
@@ -56,6 +57,7 @@ func GetCryptocurrencyPrice() {
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Quote
|
||||
@@ -83,6 +85,7 @@ func GetAcryptocurrencyQuote() {
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## History
|
||||
@@ -110,5 +113,6 @@ func GetPreviousClose() {
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
17
examples/crypto/history/getPreviousClose/main.go
Executable file
17
examples/crypto/history/getPreviousClose/main.go
Executable file
@@ -0,0 +1,17 @@
|
||||
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)
|
||||
}
|
||||
17
examples/crypto/news/getCryptocurrencyNews/main.go
Executable file
17
examples/crypto/news/getCryptocurrencyNews/main.go
Executable file
@@ -0,0 +1,17 @@
|
||||
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)
|
||||
}
|
||||
17
examples/crypto/price/getCryptocurrencyPrice/main.go
Executable file
17
examples/crypto/price/getCryptocurrencyPrice/main.go
Executable file
@@ -0,0 +1,17 @@
|
||||
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)
|
||||
}
|
||||
17
examples/crypto/quote/getACryptocurrencyQuote/main.go
Executable file
17
examples/crypto/quote/getACryptocurrencyQuote/main.go
Executable file
@@ -0,0 +1,17 @@
|
||||
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)
|
||||
}
|
||||
@@ -4,6 +4,90 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Currency/api](
|
||||
|
||||
Endpoints:
|
||||
|
||||
## History
|
||||
|
||||
Returns the historic rates for a currency on a given date
|
||||
|
||||
|
||||
[https://m3o.com/currency/api#History](https://m3o.com/currency/api#History)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/currency"
|
||||
)
|
||||
|
||||
// Returns the historic rates for a currency on a given date
|
||||
func HistoricRatesForAcurrency() {
|
||||
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := currencyService.History(¤cy.HistoryRequest{
|
||||
Code: "USD",
|
||||
Date: "2021-05-30",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Codes
|
||||
|
||||
Codes returns the supported currency codes for the API
|
||||
|
||||
|
||||
[https://m3o.com/currency/api#Codes](https://m3o.com/currency/api#Codes)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/currency"
|
||||
)
|
||||
|
||||
// Codes returns the supported currency codes for the API
|
||||
func GetSupportedCodes() {
|
||||
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := currencyService.Codes(¤cy.CodesRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Rates
|
||||
|
||||
Rates returns the currency rates for a given code e.g USD
|
||||
|
||||
|
||||
[https://m3o.com/currency/api#Rates](https://m3o.com/currency/api#Rates)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/currency"
|
||||
)
|
||||
|
||||
// Rates returns the currency rates for a given code e.g USD
|
||||
func GetRatesForUsd() {
|
||||
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := currencyService.Rates(¤cy.RatesRequest{
|
||||
Code: "USD",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Convert
|
||||
|
||||
Convert returns the currency conversion rate between two pairs e.g USD/GBP
|
||||
@@ -30,6 +114,7 @@ To: "GBP",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Convert
|
||||
@@ -59,86 +144,6 @@ To: "GBP",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## History
|
||||
|
||||
Returns the historic rates for a currency on a given date
|
||||
|
||||
|
||||
[https://m3o.com/currency/api#History](https://m3o.com/currency/api#History)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/currency"
|
||||
)
|
||||
|
||||
// Returns the historic rates for a currency on a given date
|
||||
func HistoricRatesForAcurrency() {
|
||||
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := currencyService.History(¤cy.HistoryRequest{
|
||||
Code: "USD",
|
||||
Date: "2021-05-30",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## Codes
|
||||
|
||||
Codes returns the supported currency codes for the API
|
||||
|
||||
|
||||
[https://m3o.com/currency/api#Codes](https://m3o.com/currency/api#Codes)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/currency"
|
||||
)
|
||||
|
||||
// Codes returns the supported currency codes for the API
|
||||
func GetSupportedCodes() {
|
||||
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := currencyService.Codes(¤cy.CodesRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## Rates
|
||||
|
||||
Rates returns the currency rates for a given code e.g USD
|
||||
|
||||
|
||||
[https://m3o.com/currency/api#Rates](https://m3o.com/currency/api#Rates)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/currency"
|
||||
)
|
||||
|
||||
// Rates returns the currency rates for a given code e.g USD
|
||||
func GetRatesForUsd() {
|
||||
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := currencyService.Rates(¤cy.RatesRequest{
|
||||
Code: "USD",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
15
examples/currency/codes/getSupportedCodes/main.go
Executable file
15
examples/currency/codes/getSupportedCodes/main.go
Executable file
@@ -0,0 +1,15 @@
|
||||
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)
|
||||
}
|
||||
19
examples/currency/convert/convert10UsdToGbp/main.go
Executable file
19
examples/currency/convert/convert10UsdToGbp/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{
|
||||
Amount: 10,
|
||||
From: "USD",
|
||||
To: "GBP",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
18
examples/currency/convert/convertUsdToGbp/main.go
Executable file
18
examples/currency/convert/convertUsdToGbp/main.go
Executable file
@@ -0,0 +1,18 @@
|
||||
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)
|
||||
}
|
||||
18
examples/currency/history/historicRatesForACurrency/main.go
Executable file
18
examples/currency/history/historicRatesForACurrency/main.go
Executable file
@@ -0,0 +1,18 @@
|
||||
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)
|
||||
}
|
||||
17
examples/currency/rates/getRatesForUsd/main.go
Executable file
17
examples/currency/rates/getRatesForUsd/main.go
Executable file
@@ -0,0 +1,17 @@
|
||||
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,92 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Db/api](https:
|
||||
|
||||
Endpoints:
|
||||
|
||||
## 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: "example",
|
||||
|
||||
})
|
||||
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: "example",
|
||||
|
||||
})
|
||||
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: "examples2",
|
||||
To: "examples3",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Truncate
|
||||
|
||||
Truncate the records in a table
|
||||
@@ -25,10 +111,11 @@ import(
|
||||
func TruncateTable() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.Truncate(&db.TruncateRequest{
|
||||
Table: "users",
|
||||
Table: "example",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Count
|
||||
@@ -52,10 +139,38 @@ import(
|
||||
func CountEntriesInAtable() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.Count(&db.CountRequest{
|
||||
Table: "users",
|
||||
Table: "example",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## 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)
|
||||
|
||||
}
|
||||
```
|
||||
## Create
|
||||
@@ -80,15 +195,16 @@ func CreateArecord() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.Create(&db.CreateRequest{
|
||||
Record: map[string]interface{}{
|
||||
"name": "Jane",
|
||||
"age": 42,
|
||||
"isActive": true,
|
||||
"id": "1",
|
||||
"name": "Jane",
|
||||
"age": 42,
|
||||
},
|
||||
Table: "users",
|
||||
Table: "example",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Update
|
||||
@@ -116,38 +232,11 @@ func UpdateArecord() {
|
||||
"id": "1",
|
||||
"age": 43,
|
||||
},
|
||||
Table: "users",
|
||||
Table: "example",
|
||||
|
||||
})
|
||||
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
|
||||
@@ -172,9 +261,10 @@ func DeleteArecord() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.Delete(&db.DeleteRequest{
|
||||
Id: "1",
|
||||
Table: "users",
|
||||
Table: "example",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
17
examples/db/count/countEntriesInATable/main.go
Executable file
17
examples/db/count/countEntriesInATable/main.go
Executable file
@@ -0,0 +1,17 @@
|
||||
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: "example",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
@@ -12,10 +12,10 @@ func CreateArecord() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.Create(&db.CreateRequest{
|
||||
Record: map[string]interface{}{
|
||||
"isActive": true,
|
||||
"id": "1",
|
||||
"name": "Jane",
|
||||
"age": 42,
|
||||
"isActive": true,
|
||||
},
|
||||
Table: "users",
|
||||
})
|
||||
|
||||
23
examples/db/create/createARecord/main.go
Executable file
23
examples/db/create/createARecord/main.go
Executable file
@@ -0,0 +1,23 @@
|
||||
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: "example",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
18
examples/db/delete/deleteARecord/main.go
Executable file
18
examples/db/delete/deleteARecord/main.go
Executable file
@@ -0,0 +1,18 @@
|
||||
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: "example",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
17
examples/db/dropTable/dropTable/main.go
Executable file
17
examples/db/dropTable/dropTable/main.go
Executable file
@@ -0,0 +1,17 @@
|
||||
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: "example",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
15
examples/db/listTables/listTables/main.go
Executable file
15
examples/db/listTables/listTables/main.go
Executable file
@@ -0,0 +1,15 @@
|
||||
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
18
examples/db/read/readRecords/main.go
Executable file
18
examples/db/read/readRecords/main.go
Executable file
@@ -0,0 +1,18 @@
|
||||
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: "example",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
18
examples/db/renameTable/renameTable/main.go
Executable file
18
examples/db/renameTable/renameTable/main.go
Executable file
@@ -0,0 +1,18 @@
|
||||
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: "examples2",
|
||||
To: "examples3",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
17
examples/db/truncate/truncateTable/main.go
Executable file
17
examples/db/truncate/truncateTable/main.go
Executable file
@@ -0,0 +1,17 @@
|
||||
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: "example",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
@@ -12,8 +12,8 @@ func UpdateArecord() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.Update(&db.UpdateRequest{
|
||||
Record: map[string]interface{}{
|
||||
"age": 43,
|
||||
"id": "1",
|
||||
"age": 43,
|
||||
},
|
||||
Table: "users",
|
||||
})
|
||||
|
||||
21
examples/db/update/updateARecord/main.go
Executable file
21
examples/db/update/updateARecord/main.go
Executable file
@@ -0,0 +1,21 @@
|
||||
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: "example",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
@@ -33,5 +33,6 @@ Please verify your email by clicking this link: $micro_verification_link`,
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
21
examples/email/send/sendEmail/main.go
Executable file
21
examples/email/send/sendEmail/main.go
Executable file
@@ -0,0 +1,21 @@
|
||||
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)
|
||||
}
|
||||
@@ -29,6 +29,7 @@ func FindEmoji() {
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Flag
|
||||
@@ -55,6 +56,7 @@ func GetFlagByCountryCode() {
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Print
|
||||
@@ -84,6 +86,7 @@ func PrintTextIncludingEmoji() {
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Send
|
||||
@@ -113,5 +116,6 @@ To: "+44782669123",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
17
examples/emoji/find/findEmoji/main.go
Executable file
17
examples/emoji/find/findEmoji/main.go
Executable file
@@ -0,0 +1,17 @@
|
||||
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)
|
||||
}
|
||||
15
examples/emoji/flag/getFlagByCountryCode/main.go
Executable file
15
examples/emoji/flag/getFlagByCountryCode/main.go
Executable file
@@ -0,0 +1,15 @@
|
||||
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)
|
||||
}
|
||||
18
examples/emoji/print/printTextIncludingEmoji/main.go
Executable file
18
examples/emoji/print/printTextIncludingEmoji/main.go
Executable file
@@ -0,0 +1,18 @@
|
||||
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)
|
||||
}
|
||||
19
examples/emoji/send/sendATextContainingAnEmojiToAnyoneViaSms/main.go
Executable file
19
examples/emoji/send/sendATextContainingAnEmojiToAnyoneViaSms/main.go
Executable file
@@ -0,0 +1,19 @@
|
||||
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)
|
||||
|
||||
}
|
||||
```
|
||||
## Search
|
||||
@@ -61,6 +62,7 @@ func SearchByBoundingBox() {
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Search
|
||||
@@ -93,6 +95,7 @@ Location: &evchargers.Coordinates{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## ReferenceData
|
||||
@@ -119,5 +122,6 @@ func GetReferenceData() {
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
15
examples/evchargers/referenceData/getReferenceData/main.go
Executable file
15
examples/evchargers/referenceData/getReferenceData/main.go
Executable file
@@ -0,0 +1,15 @@
|
||||
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)
|
||||
}
|
||||
17
examples/evchargers/search/searchByBoundingBox/main.go
Executable file
17
examples/evchargers/search/searchByBoundingBox/main.go
Executable file
@@ -0,0 +1,17 @@
|
||||
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)
|
||||
}
|
||||
21
examples/evchargers/search/searchByLocation/main.go
Executable file
21
examples/evchargers/search/searchByLocation/main.go
Executable file
@@ -0,0 +1,21 @@
|
||||
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)
|
||||
}
|
||||
22
examples/evchargers/search/searchWithFiltersFastChargersOnly/main.go
Executable file
22
examples/evchargers/search/searchWithFiltersFastChargersOnly/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,
|
||||
Levels: []string{"3"},
|
||||
Location: &evchargers.Coordinates{
|
||||
Latitude: 51.53336351319885,
|
||||
Longitude: -0.0252,
|
||||
},
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
@@ -6,7 +6,7 @@ Endpoints:
|
||||
|
||||
## Publish
|
||||
|
||||
Publish a message to the event stream.
|
||||
Publish a event to the event stream.
|
||||
|
||||
|
||||
[https://m3o.com/event/api#Publish](https://m3o.com/event/api#Publish)
|
||||
@@ -21,27 +21,28 @@ import(
|
||||
"go.m3o.com/event"
|
||||
)
|
||||
|
||||
// Publish a message to the event stream.
|
||||
func PublishAmessage() {
|
||||
// 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{}{
|
||||
"user": "john",
|
||||
"id": "1",
|
||||
"type": "signup",
|
||||
"user": "john",
|
||||
},
|
||||
Topic: "user",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Subscribe
|
||||
## Consume
|
||||
|
||||
Subscribe to messages for a given topic.
|
||||
Consume events from a given topic.
|
||||
|
||||
|
||||
[https://m3o.com/event/api#Subscribe](https://m3o.com/event/api#Subscribe)
|
||||
[https://m3o.com/event/api#Consume](https://m3o.com/event/api#Consume)
|
||||
|
||||
```go
|
||||
package example
|
||||
@@ -53,13 +54,55 @@ import(
|
||||
"go.m3o.com/event"
|
||||
)
|
||||
|
||||
// Subscribe to messages for a given topic.
|
||||
func SubscribeToAtopic() {
|
||||
// Consume events from a given topic.
|
||||
func ConsumeFromAtopic() {
|
||||
eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := eventService.Subscribe(&event.SubscribeRequest{
|
||||
|
||||
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)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -7,10 +7,10 @@ import (
|
||||
"go.m3o.com/event"
|
||||
)
|
||||
|
||||
// Subscribe to messages for a given topic.
|
||||
func SubscribeToAtopic() {
|
||||
// Consume events from a given topic.
|
||||
func ConsumeFromAtopic() {
|
||||
eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := eventService.Subscribe(&event.SubscribeRequest{
|
||||
rsp, err := eventService.Consume(&event.ConsumeRequest{
|
||||
Topic: "user",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
30
examples/event/consume/consumeFromATopic/main.go
Executable file
30
examples/event/consume/consumeFromATopic/main.go
Executable file
@@ -0,0 +1,30 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
@@ -12,9 +12,9 @@ func PublishAmessage() {
|
||||
eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := eventService.Publish(&event.PublishRequest{
|
||||
Message: map[string]interface{}{
|
||||
"user": "john",
|
||||
"id": "1",
|
||||
"type": "signup",
|
||||
"user": "john",
|
||||
},
|
||||
Topic: "user",
|
||||
})
|
||||
|
||||
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)
|
||||
}
|
||||
22
examples/event/publish/publishAnEvent/main.go
Executable file
22
examples/event/publish/publishAnEvent/main.go
Executable file
@@ -0,0 +1,22 @@
|
||||
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)
|
||||
}
|
||||
17
examples/event/read/readEventsOnATopic/main.go
Executable file
17
examples/event/read/readEventsOnATopic/main.go
Executable file
@@ -0,0 +1,17 @@
|
||||
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,6 +4,64 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/File/api](http
|
||||
|
||||
Endpoints:
|
||||
|
||||
## 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)
|
||||
|
||||
}
|
||||
```
|
||||
## 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)
|
||||
|
||||
}
|
||||
```
|
||||
## Save
|
||||
|
||||
Save a file
|
||||
@@ -33,6 +91,7 @@ func SaveFile() {
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## List
|
||||
@@ -60,61 +119,6 @@ func ListFiles() {
|
||||
|
||||
})
|
||||
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)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
18
examples/file/delete/deleteFile/main.go
Executable file
18
examples/file/delete/deleteFile/main.go
Executable file
@@ -0,0 +1,18 @@
|
||||
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
17
examples/file/list/listFiles/main.go
Executable file
17
examples/file/list/listFiles/main.go
Executable file
@@ -0,0 +1,17 @@
|
||||
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)
|
||||
}
|
||||
18
examples/file/read/readFile/main.go
Executable file
18
examples/file/read/readFile/main.go
Executable file
@@ -0,0 +1,18 @@
|
||||
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)
|
||||
}
|
||||
21
examples/file/save/saveFile/main.go
Executable file
21
examples/file/save/saveFile/main.go
Executable file
@@ -0,0 +1,21 @@
|
||||
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)
|
||||
}
|
||||
@@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Forex/api](htt
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Price
|
||||
|
||||
Get the latest price for a given forex ticker
|
||||
|
||||
|
||||
[https://m3o.com/forex/api#Price](https://m3o.com/forex/api#Price)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/forex"
|
||||
)
|
||||
|
||||
// Get the latest price for a given forex ticker
|
||||
func GetAnFxPrice() {
|
||||
forexService := forex.NewForexService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := forexService.Price(&forex.PriceRequest{
|
||||
Symbol: "GBPUSD",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Quote
|
||||
|
||||
Get the latest quote for the forex
|
||||
@@ -29,6 +57,7 @@ func GetAfxQuote() {
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## History
|
||||
@@ -56,32 +85,6 @@ func GetPreviousClose() {
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## Price
|
||||
|
||||
Get the latest price for a given forex ticker
|
||||
|
||||
|
||||
[https://m3o.com/forex/api#Price](https://m3o.com/forex/api#Price)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/forex"
|
||||
)
|
||||
|
||||
// Get the latest price for a given forex ticker
|
||||
func GetAnFxPrice() {
|
||||
forexService := forex.NewForexService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := forexService.Price(&forex.PriceRequest{
|
||||
Symbol: "GBPUSD",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
17
examples/forex/history/getPreviousClose/main.go
Executable file
17
examples/forex/history/getPreviousClose/main.go
Executable file
@@ -0,0 +1,17 @@
|
||||
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)
|
||||
}
|
||||
17
examples/forex/price/getAnFxPrice/main.go
Executable file
17
examples/forex/price/getAnFxPrice/main.go
Executable file
@@ -0,0 +1,17 @@
|
||||
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)
|
||||
}
|
||||
17
examples/forex/quote/getAFxQuote/main.go
Executable file
17
examples/forex/quote/getAFxQuote/main.go
Executable file
@@ -0,0 +1,17 @@
|
||||
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)
|
||||
}
|
||||
@@ -26,13 +26,44 @@ func DeployAfunction() {
|
||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := functionService.Deploy(&function.DeployRequest{
|
||||
Entrypoint: "helloworld",
|
||||
Name: "my-first-func",
|
||||
Project: "tests",
|
||||
Name: "helloworld",
|
||||
Repo: "github.com/m3o/nodejs-function-example",
|
||||
Runtime: "nodejs14",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Update
|
||||
|
||||
Update a function
|
||||
|
||||
|
||||
[https://m3o.com/function/api#Update](https://m3o.com/function/api#Update)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/function"
|
||||
)
|
||||
|
||||
// Update a function
|
||||
func UpdateAfunction() {
|
||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := functionService.Update(&function.UpdateRequest{
|
||||
Entrypoint: "helloworld",
|
||||
Name: "helloworld",
|
||||
Repo: "github.com/m3o/nodejs-function-example",
|
||||
Runtime: "nodejs14",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Call
|
||||
@@ -56,12 +87,13 @@ import(
|
||||
func CallAfunction() {
|
||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := functionService.Call(&function.CallRequest{
|
||||
Name: "my-first-func",
|
||||
Name: "helloworld",
|
||||
Request: map[string]interface{}{
|
||||
},
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## List
|
||||
@@ -88,6 +120,7 @@ func ListFunctions() {
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Delete
|
||||
@@ -111,11 +144,11 @@ import(
|
||||
func DeleteAfunction() {
|
||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := functionService.Delete(&function.DeleteRequest{
|
||||
Name: "my-first-func",
|
||||
Project: "tests",
|
||||
Name: "helloworld",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Describe
|
||||
@@ -139,10 +172,10 @@ import(
|
||||
func DescribeFunctionStatus() {
|
||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := functionService.Describe(&function.DescribeRequest{
|
||||
Name: "my-first-func",
|
||||
Project: "tests",
|
||||
Name: "helloworld",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
18
examples/function/call/callAFunction/main.go
Executable file
18
examples/function/call/callAFunction/main.go
Executable file
@@ -0,0 +1,18 @@
|
||||
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: "helloworld",
|
||||
Request: map[string]interface{}{},
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
17
examples/function/delete/deleteAFunction/main.go
Executable file
17
examples/function/delete/deleteAFunction/main.go
Executable file
@@ -0,0 +1,17 @@
|
||||
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: "helloworld",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
20
examples/function/deploy/deployAFunction/main.go
Executable file
20
examples/function/deploy/deployAFunction/main.go
Executable file
@@ -0,0 +1,20 @@
|
||||
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: "helloworld",
|
||||
Repo: "github.com/m3o/nodejs-function-example",
|
||||
Runtime: "nodejs14",
|
||||
})
|
||||
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