mirror of
https://github.com/kevin-DL/m3o-go.git
synced 2026-01-23 15:11:36 +00:00
Compare commits
524 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6b4b4c9980 | ||
|
|
9ae25e0fec | ||
|
|
0882443a5e | ||
|
|
6910f3d25a | ||
|
|
c4eb97765e | ||
|
|
2eb4296382 | ||
|
|
418f914253 | ||
|
|
2fb26f6b55 | ||
|
|
8750a8c59f | ||
|
|
9cbd5c1988 | ||
|
|
465010411d | ||
|
|
885aa8766c | ||
|
|
c0072c24d5 | ||
|
|
041b4ef27d | ||
|
|
eeced0f4bc | ||
|
|
1373d7afea | ||
|
|
aab69f0713 | ||
|
|
6464c39046 | ||
|
|
7ddabee6b5 | ||
|
|
099b92a9b5 | ||
|
|
a14a8d234a | ||
|
|
c84610cd53 | ||
|
|
827b29d2b7 | ||
|
|
5a56ef54e7 | ||
|
|
94e2f8a5a6 | ||
|
|
544f3d2941 | ||
|
|
e8facfabd7 | ||
|
|
dadeda6bb0 | ||
|
|
2b02492525 | ||
|
|
781a433a84 | ||
|
|
a2efcefd8b | ||
|
|
bb0db592be | ||
|
|
beca62373a | ||
|
|
95340f33e9 | ||
|
|
ddef868d22 | ||
|
|
fd8353bc9c | ||
|
|
e56aeee2a7 | ||
|
|
40bb9bcdb3 | ||
|
|
21b9ece648 | ||
|
|
fa7dfe82c6 | ||
|
|
ca3f935e80 | ||
|
|
a2fd26ec51 | ||
|
|
29df5f68d5 | ||
|
|
cd0a0f4059 | ||
|
|
5b5d0b3e59 | ||
|
|
9bd086fd57 | ||
|
|
3225621041 | ||
|
|
489d94445a | ||
|
|
8cc6efd763 | ||
|
|
2485a8b887 | ||
|
|
818f632239 | ||
|
|
e20ce9d6e9 | ||
|
|
0fed9fb4ae | ||
|
|
e259f67996 | ||
|
|
41f154c15d | ||
|
|
f4364042f0 | ||
|
|
becd2f34a6 | ||
|
|
68f3df1004 | ||
|
|
af1231f0c9 | ||
|
|
3dc5ec3324 | ||
|
|
06173570da | ||
|
|
d045a9a5e4 | ||
|
|
fec8cd6c49 | ||
|
|
d935baa7b6 | ||
|
|
b6293c699c | ||
|
|
bcf8833d06 | ||
|
|
341d0e9563 | ||
|
|
8287cc7f53 | ||
|
|
bc29f092b5 | ||
|
|
38aea3724a | ||
|
|
ed46965680 | ||
|
|
c80c59c3cb | ||
|
|
a5c68cd8ab | ||
|
|
f478825008 | ||
|
|
dc93f7878d | ||
|
|
850f0f9a73 | ||
|
|
805c982135 | ||
|
|
f22a101838 | ||
|
|
70b02fb947 | ||
|
|
e9ccf5fa0f | ||
|
|
1251b49828 | ||
|
|
664e8e8299 | ||
|
|
610b0caa7a | ||
|
|
27aa74905c | ||
|
|
3a183dd2a5 | ||
|
|
daf8202a94 | ||
|
|
e3abb63e40 | ||
|
|
8cfcd5d7d2 | ||
|
|
ba33a517e5 | ||
|
|
3380a01ec6 | ||
|
|
b386520a82 | ||
|
|
41076ed778 | ||
|
|
c7e37bf0f9 | ||
|
|
1e217f2fe6 | ||
|
|
0094140173 | ||
|
|
3dace0f97c | ||
|
|
9328c78184 | ||
|
|
8607d1e6ec | ||
|
|
5a0bb20888 | ||
|
|
716229e84c | ||
|
|
9f21dbac27 | ||
|
|
bf055df06e | ||
|
|
4f9eefd72c | ||
|
|
ad465bab1b | ||
|
|
bf71e8910b | ||
|
|
7d6c343c0c | ||
|
|
006377ced4 | ||
|
|
c18890d567 | ||
|
|
d9ba4f1e81 | ||
|
|
e2c7c21f71 | ||
|
|
39bb32658f | ||
|
|
d9aa0c235b | ||
|
|
93129f6883 | ||
|
|
d976129e73 | ||
|
|
86d710f81e | ||
|
|
0638da0d21 | ||
|
|
d1352d714d | ||
|
|
9ba50816ab | ||
|
|
1d31086bec | ||
|
|
10d0a9e182 | ||
|
|
e23aea2415 | ||
|
|
fafe078c68 | ||
|
|
bab69e3059 | ||
|
|
aa05f2f678 | ||
|
|
453403a198 | ||
|
|
b580e5270e | ||
|
|
92317e7690 | ||
|
|
c737c0dd9f | ||
|
|
cf4338a959 | ||
|
|
6c61a79774 | ||
|
|
f78928459e | ||
|
|
d96ccfd958 | ||
|
|
46da6257d7 | ||
|
|
e59891fea8 | ||
|
|
0d60904f8a | ||
|
|
a6dc177797 | ||
|
|
29cb72c55b | ||
|
|
48aaa5dbad | ||
|
|
83d47cea87 | ||
|
|
ffe132871c | ||
|
|
facb2a9289 | ||
|
|
2f40c45092 | ||
|
|
c41627014b | ||
|
|
c5749cbf5c | ||
|
|
b5baad9981 | ||
|
|
ac2e4538f1 | ||
|
|
f951b8d2ac | ||
|
|
ead8d22c5f | ||
|
|
a94dc8b071 | ||
|
|
a3e13de758 | ||
|
|
ff159f4ded | ||
|
|
7a9449f921 | ||
|
|
a52e5923dd | ||
|
|
c768003af0 | ||
|
|
5f2ae98a47 | ||
|
|
2bf4cdd6b0 | ||
|
|
f1290e2b67 | ||
|
|
3c113f0f22 | ||
|
|
bdbbff7f50 | ||
|
|
ddbd0b480e | ||
|
|
aaedcafdaa | ||
|
|
90cf4567c8 | ||
|
|
7a39dbb5ad | ||
|
|
95f8372cb9 | ||
|
|
21d9e25274 | ||
|
|
47b379f500 | ||
|
|
87d036f80d | ||
|
|
5c139aa49a | ||
|
|
8f09a3e936 | ||
|
|
a54d8235d8 | ||
|
|
322e1ef7ad | ||
|
|
e56ddcffa5 | ||
|
|
219931dd30 | ||
|
|
7857517aa3 | ||
|
|
6b7892d67e | ||
|
|
60c598762d | ||
|
|
291fa0ace8 | ||
|
|
2b269fddc4 | ||
|
|
56f9de1f9b | ||
|
|
ebb5f1bad0 | ||
|
|
ce7c51dbe7 | ||
|
|
1794a54039 | ||
|
|
fc050b8ee8 | ||
|
|
e10b8ec3ae | ||
|
|
f52d0c2326 | ||
|
|
632f0d29cb | ||
|
|
d7c3704cdc | ||
|
|
5072f84abf | ||
|
|
dfe8bc8923 | ||
|
|
de9c4adf65 | ||
|
|
18e89c6aaa | ||
|
|
f710c9998f | ||
|
|
c0d318a6c8 | ||
|
|
b04245c5dd | ||
|
|
24a3fbeaad | ||
|
|
270f241c30 | ||
|
|
9218ed3365 | ||
|
|
241a2e8253 | ||
|
|
004c90663d | ||
|
|
398ddc83fb | ||
|
|
c56699c7ac | ||
|
|
5a83458f0b | ||
|
|
a2e3e070ae | ||
|
|
0394044281 | ||
|
|
815ed6c85c | ||
|
|
e5df1d2d4e | ||
|
|
c61e197ab3 | ||
|
|
326a38028d | ||
|
|
59d85ff128 | ||
|
|
1b52ade3cd | ||
|
|
7b49673d15 | ||
|
|
e2cce06b00 | ||
|
|
f109440524 | ||
|
|
f4c1fb6719 | ||
|
|
c64f6e2af6 | ||
|
|
634291e93c | ||
|
|
e2cf2d8234 | ||
|
|
8ac14a5d53 | ||
|
|
8a905ac605 | ||
|
|
c6be7b79d4 | ||
|
|
994cc15926 | ||
|
|
fbcf589c8c | ||
|
|
d4311d3010 | ||
|
|
c45c463e7c | ||
|
|
9fd476dee8 | ||
|
|
3a883ccd4d | ||
|
|
3501f9aedd | ||
|
|
a6ee280b89 | ||
|
|
6c126097a5 | ||
|
|
b5b06f2c54 | ||
|
|
8e06d54c66 | ||
|
|
8a2aa76f81 | ||
|
|
8072676eeb | ||
|
|
18283f6252 | ||
|
|
a30af6f8a8 | ||
|
|
773ca17ff5 | ||
|
|
018ae85f91 | ||
|
|
29b773ac62 | ||
|
|
97ec346c6b | ||
|
|
f8fea92773 | ||
|
|
1fd3edc2c1 | ||
|
|
24b136c46a | ||
|
|
f4da5a864d | ||
|
|
e49c2fc4f5 | ||
|
|
923f60501a | ||
|
|
f6eaea5d63 | ||
|
|
560a7f1a88 | ||
|
|
43b17fede3 | ||
|
|
f838c439a7 | ||
|
|
5f6e71b7d0 | ||
|
|
c8dfc8df56 | ||
|
|
83ac51fe95 | ||
|
|
504423439f | ||
|
|
cf0a9af833 | ||
|
|
7551ba0bd0 | ||
|
|
393a340600 | ||
|
|
6d66ae3935 | ||
|
|
1a0a40d7e1 | ||
|
|
8ba35534a1 | ||
|
|
7576f985d7 | ||
|
|
8252311ba8 | ||
|
|
1876958097 | ||
|
|
47273aa12e | ||
|
|
27de67618d | ||
|
|
8202aef808 | ||
|
|
5df737c1b8 | ||
|
|
4caeae2aa1 | ||
|
|
75c795781b | ||
|
|
ca7a123aa7 | ||
|
|
598164c362 | ||
|
|
4d7767e86a | ||
|
|
4cf3519856 | ||
|
|
8e78e3040b | ||
|
|
fc990c84ab | ||
|
|
e9229571ad | ||
|
|
b310d3e1e0 | ||
|
|
3e8a30c33a | ||
|
|
d5b9efe74e | ||
|
|
da28af7166 | ||
|
|
cceeb16d81 | ||
|
|
a25cabc9be | ||
|
|
4ca21d5561 | ||
|
|
39fcaa24c0 | ||
|
|
fc1099c437 | ||
|
|
f3af3fa1ba | ||
|
|
03a3a1bb91 | ||
|
|
1c58bf602d | ||
|
|
02fc6f735a | ||
|
|
7ea20aefbd | ||
|
|
7698310d1a | ||
|
|
9685cb5d53 | ||
|
|
63fb62a55e | ||
|
|
56cdd3c583 | ||
|
|
97accc758e | ||
|
|
7e5fdc7d77 | ||
|
|
90f27882e8 | ||
|
|
70fd591952 | ||
|
|
7add4ca16b | ||
|
|
243d779a03 | ||
|
|
6b9caa1e59 | ||
|
|
2bbe49f716 | ||
|
|
046127532d | ||
|
|
2e14a4252f | ||
|
|
d1be4f25bc | ||
|
|
f38850c259 | ||
|
|
99979e1167 | ||
|
|
d144fd0b22 | ||
|
|
75cd109929 | ||
|
|
4cd429a8b3 | ||
|
|
aef44febce | ||
|
|
6446146553 | ||
|
|
f251e45b0b | ||
|
|
01f99e0b6d | ||
|
|
d9cabd803a | ||
|
|
064734211e | ||
|
|
d0aeac6b3c | ||
|
|
eb93a5a449 | ||
|
|
78d8e2fa1e | ||
|
|
6bca5af6c5 | ||
|
|
d132d7c27c | ||
|
|
6f3a7a4dd3 | ||
|
|
a2eb34e59a | ||
|
|
709e4180ec | ||
|
|
3abd701901 | ||
|
|
ea5aa65039 | ||
|
|
1ae6969f65 | ||
|
|
9901807b67 | ||
|
|
efb35c528c | ||
|
|
a64a7a6162 | ||
|
|
c7afdd237d | ||
|
|
6f5714dc73 | ||
|
|
6ce3f89757 | ||
|
|
3e655dea52 | ||
|
|
80ca5f8229 | ||
|
|
993c0b1e1c | ||
|
|
f7c6ac50e2 | ||
|
|
1f72651636 | ||
|
|
9f65103806 | ||
|
|
fb85cd000f | ||
|
|
e78ab622d6 | ||
|
|
84a739197e | ||
|
|
83d8cd3702 | ||
|
|
a94d784928 | ||
|
|
fd3a1063b0 | ||
|
|
2b935c2eb1 | ||
|
|
2d46dc2672 | ||
|
|
06f2db6618 | ||
|
|
c0731399ee | ||
|
|
9057f09e41 | ||
|
|
b7853960a4 | ||
|
|
1d96d4517b | ||
|
|
dd282e7ab9 | ||
|
|
8f3fe3d33c | ||
|
|
7e17640b3e | ||
|
|
a46a505a9f | ||
|
|
0a690f02d9 | ||
|
|
434a7615b7 | ||
|
|
7552377ffc | ||
|
|
cdb937b2cb | ||
|
|
fbf39cc693 | ||
|
|
1729996181 | ||
|
|
5fe1678ec5 | ||
|
|
8b790bd9b9 | ||
|
|
a9bcb78aa8 | ||
|
|
b3fd38731e | ||
|
|
ad326fd0b8 | ||
|
|
3ffe702d02 | ||
|
|
27a90b388a | ||
|
|
edfebe05df | ||
|
|
13441363d5 | ||
|
|
c5d206122c | ||
|
|
909ac3d71f | ||
|
|
3e8a881233 | ||
|
|
da1038343f | ||
|
|
fe7b620e59 | ||
|
|
58278dc08b | ||
|
|
362f73dca1 | ||
|
|
3cb3b40901 | ||
|
|
0aca22c769 | ||
|
|
9547c26947 | ||
|
|
9cd82a849f | ||
|
|
f142eddbb9 | ||
|
|
81eb8a213a | ||
|
|
79a9c94139 | ||
|
|
4a6b4ddbaa | ||
|
|
4646555d94 | ||
|
|
87d4ae480a | ||
|
|
f2c03ac414 | ||
|
|
00ad5f2668 | ||
|
|
5890e989e4 | ||
|
|
e7f0fd6434 | ||
|
|
d52ecd7232 | ||
|
|
3fd0023e27 | ||
|
|
83740822e1 | ||
|
|
7a4f8f2faa | ||
|
|
5db5bff7e5 | ||
|
|
bc3256a02a | ||
|
|
d346494459 | ||
|
|
847b17a423 | ||
|
|
051b7e8db7 | ||
|
|
ef53cae138 | ||
|
|
9c5e2fc5dd | ||
|
|
fbbc6fce2b | ||
|
|
75931d518a | ||
|
|
76e85f7e0a | ||
|
|
b4f72abd73 | ||
|
|
c9ddd8776c | ||
|
|
4e9cd04448 | ||
|
|
e4472e76bc | ||
|
|
b89a529672 | ||
|
|
1c567f0eff | ||
|
|
42b9941d93 | ||
|
|
ee0f545030 | ||
|
|
59a3c3c3a8 | ||
|
|
081b4bc7dd | ||
|
|
c296523bb2 | ||
|
|
fe83bf7d18 | ||
|
|
f68c53a04d | ||
|
|
04d7bf8148 | ||
|
|
a83b25a9aa | ||
|
|
b48eab72b9 | ||
|
|
8a600b6131 | ||
|
|
8408429e9b | ||
|
|
20a3a5bfd7 | ||
|
|
f01a912eb3 | ||
|
|
eebea56166 | ||
|
|
2d8f3d735d | ||
|
|
ccc5de5cda | ||
|
|
863b60c7db | ||
|
|
5caf581eff | ||
|
|
2dda68b677 | ||
|
|
8967d7aed8 | ||
|
|
88ec3b1629 | ||
|
|
3b8973592b | ||
|
|
af71fa56b0 | ||
|
|
1a6e2f4cb5 | ||
|
|
9abf8b4e6a | ||
|
|
74d67fe903 | ||
|
|
f9a04eab0b | ||
|
|
ecbcaa1f37 | ||
|
|
fc9078369c | ||
|
|
9fb8b7249a | ||
|
|
f238a3dde3 | ||
|
|
06e0e031f0 | ||
|
|
4671615268 | ||
|
|
50abf5f044 | ||
|
|
7ebbac3eb1 | ||
|
|
cff39c86e7 | ||
|
|
200da05cf0 | ||
|
|
0a2f0eb713 | ||
|
|
0d1952d41a | ||
|
|
4eaa0d7a79 | ||
|
|
fc3cf88dd1 | ||
|
|
4029f043af | ||
|
|
768c3a7277 | ||
|
|
1b6f533cda | ||
|
|
23efeb1b54 | ||
|
|
28be83a1a3 | ||
|
|
163098f65c | ||
|
|
d75eee6adc | ||
|
|
f62afe5c72 | ||
|
|
05dcddb482 | ||
|
|
96bb1b0a89 | ||
|
|
3a49edfecc | ||
|
|
e8cd7403b7 | ||
|
|
8bba336dd3 | ||
|
|
a8b28f6b2a | ||
|
|
c919eb0016 | ||
|
|
6443d9822b | ||
|
|
cd580f41a7 | ||
|
|
f21152e1ed | ||
|
|
27e13d2b6c | ||
|
|
8561aa8205 | ||
|
|
f051277b48 | ||
|
|
1132b4809a | ||
|
|
85ff0bf56f | ||
|
|
f362f68c54 | ||
|
|
063e059d70 | ||
|
|
1773d164e4 | ||
|
|
a835eaddc4 | ||
|
|
a905d67b2c | ||
|
|
9c1ae9e4d2 | ||
|
|
5daed5e997 | ||
|
|
7c8a6f80de | ||
|
|
05097a471d | ||
|
|
3d0f9dda4b | ||
|
|
36d8023ada | ||
|
|
b135490f0e | ||
|
|
a97ced0f02 | ||
|
|
002380be31 | ||
|
|
1211b1b74e | ||
|
|
9a39681342 | ||
|
|
fd12523b0d | ||
|
|
4822495226 | ||
|
|
9cfa252f59 | ||
|
|
ab4602b369 | ||
|
|
9c97fbb4da | ||
|
|
3c853a2cbc | ||
|
|
ed1603b391 | ||
|
|
6ba5ad8ce4 | ||
|
|
24b609b070 | ||
|
|
801e983f3a | ||
|
|
c3e28cbc66 | ||
|
|
c4e0fe407e | ||
|
|
43e6f37402 | ||
|
|
9036b95fd2 | ||
|
|
937cb915ac | ||
|
|
da2b23fbab | ||
|
|
4de67b6746 | ||
|
|
75ba0d6c3a | ||
|
|
873ba7f939 | ||
|
|
a6c66fb76a | ||
|
|
292001f3f2 | ||
|
|
d7e95f687f | ||
|
|
32496fe696 | ||
|
|
86803cc1e2 | ||
|
|
3f24078efb | ||
|
|
bb753c4504 | ||
|
|
3c6466378c | ||
|
|
d921922cd9 | ||
|
|
d2230e009d | ||
|
|
536e9cfe77 | ||
|
|
c707489b7a | ||
|
|
1a28fb54f9 |
@@ -1,3 +1,11 @@
|
||||
<p align="center">
|
||||
<a href="https://discord.gg/TBR9bRjd6Z">
|
||||
<img src="https://discordapp.com/api/guilds/861917584437805127/widget.png?style=banner2" alt="Discord Banner"/>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
---
|
||||
|
||||
# M3O Go Client [](https://godoc.org/github.com/m3o/m3o-go) [](https://goreportcard.com/report/github.com/m3o/m3o-go) [](https://github.com/m3o/m3o-go/blob/master/LICENSE)
|
||||
|
||||
This is the Go client to access APIs on the M3O Platform
|
||||
|
||||
@@ -4,6 +4,10 @@ import (
|
||||
"go.m3o.com/client"
|
||||
)
|
||||
|
||||
type Address interface {
|
||||
LookupPostcode(*LookupPostcodeRequest) (*LookupPostcodeResponse, error)
|
||||
}
|
||||
|
||||
func NewAddressService(token string) *AddressService {
|
||||
return &AddressService{
|
||||
client: client.NewClient(&client.Options{
|
||||
|
||||
@@ -4,6 +4,10 @@ import (
|
||||
"go.m3o.com/client"
|
||||
)
|
||||
|
||||
type Answer interface {
|
||||
Question(*QuestionRequest) (*QuestionResponse, error)
|
||||
}
|
||||
|
||||
func NewAnswerService(token string) *AnswerService {
|
||||
return &AnswerService{
|
||||
client: client.NewClient(&client.Options{
|
||||
|
||||
17
app/app.go
17
app/app.go
@@ -4,6 +4,17 @@ import (
|
||||
"go.m3o.com/client"
|
||||
)
|
||||
|
||||
type App interface {
|
||||
Delete(*DeleteRequest) (*DeleteResponse, error)
|
||||
List(*ListRequest) (*ListResponse, error)
|
||||
Regions(*RegionsRequest) (*RegionsResponse, error)
|
||||
Reserve(*ReserveRequest) (*ReserveResponse, error)
|
||||
Resolve(*ResolveRequest) (*ResolveResponse, error)
|
||||
Run(*RunRequest) (*RunResponse, error)
|
||||
Status(*StatusRequest) (*StatusResponse, error)
|
||||
Update(*UpdateRequest) (*UpdateResponse, error)
|
||||
}
|
||||
|
||||
func NewAppService(token string) *AppService {
|
||||
return &AppService{
|
||||
client: client.NewClient(&client.Options{
|
||||
@@ -56,7 +67,7 @@ func (t *AppService) Resolve(request *ResolveRequest) (*ResolveResponse, error)
|
||||
|
||||
}
|
||||
|
||||
// Run an app from a source repo. Specify region etc.
|
||||
// Run an app from source
|
||||
func (t *AppService) Run(request *RunRequest) (*RunResponse, error) {
|
||||
|
||||
rsp := &RunResponse{}
|
||||
@@ -139,7 +150,7 @@ type ResolveResponse struct {
|
||||
type RunRequest struct {
|
||||
// branch. defaults to master
|
||||
Branch string `json:"branch"`
|
||||
// associatede env vars to pass in
|
||||
// associated env vars to pass in
|
||||
EnvVars map[string]string `json:"env_vars"`
|
||||
// name of the app
|
||||
Name string `json:"name"`
|
||||
@@ -194,6 +205,8 @@ type StatusResponse struct {
|
||||
}
|
||||
|
||||
type UpdateRequest struct {
|
||||
// Additional env vars to update
|
||||
EnvVars map[string]string `json:"env_vars"`
|
||||
// name of the app
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
@@ -4,6 +4,10 @@ import (
|
||||
"go.m3o.com/client"
|
||||
)
|
||||
|
||||
type Avatar interface {
|
||||
Generate(*GenerateRequest) (*GenerateResponse, error)
|
||||
}
|
||||
|
||||
func NewAvatarService(token string) *AvatarService {
|
||||
return &AvatarService{
|
||||
client: client.NewClient(&client.Options{
|
||||
@@ -16,7 +20,7 @@ type AvatarService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
//
|
||||
// Generate an unique avatar
|
||||
func (t *AvatarService) Generate(request *GenerateRequest) (*GenerateResponse, error) {
|
||||
|
||||
rsp := &GenerateResponse{}
|
||||
@@ -25,22 +29,21 @@ func (t *AvatarService) Generate(request *GenerateRequest) (*GenerateResponse, e
|
||||
}
|
||||
|
||||
type GenerateRequest struct {
|
||||
// encode format of avatar image, `png` or `jpeg`, default is `jpeg`
|
||||
// encode format of avatar image: `png` or `jpeg`; default is `jpeg`
|
||||
Format string `json:"format"`
|
||||
// avatar's gender, `male` or `female`, default is `male`
|
||||
// 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
|
||||
// set to true to upload to the M3O CDN and receive the 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
|
||||
// avatar's username, unique username will generate the unique avatar;
|
||||
// if empty, every request generates a random avatar;
|
||||
// if upload == true, username will be the CDN filename rather than a random uuid string
|
||||
Username string `json:"username"`
|
||||
}
|
||||
|
||||
type GenerateResponse struct {
|
||||
// base64encode string of the avatar image
|
||||
// base64 encoded string of the avatar image
|
||||
Base64 string `json:"base64"`
|
||||
// Micro's CDN url of the avatar image
|
||||
// M3O's CDN url of the avatar image
|
||||
Url string `json:"url"`
|
||||
}
|
||||
|
||||
24
cache/cache.go
vendored
24
cache/cache.go
vendored
@@ -4,6 +4,15 @@ import (
|
||||
"go.m3o.com/client"
|
||||
)
|
||||
|
||||
type Cache interface {
|
||||
Decrement(*DecrementRequest) (*DecrementResponse, error)
|
||||
Delete(*DeleteRequest) (*DeleteResponse, error)
|
||||
Get(*GetRequest) (*GetResponse, error)
|
||||
Increment(*IncrementRequest) (*IncrementResponse, error)
|
||||
ListKeys(*ListKeysRequest) (*ListKeysResponse, error)
|
||||
Set(*SetRequest) (*SetResponse, error)
|
||||
}
|
||||
|
||||
func NewCacheService(token string) *CacheService {
|
||||
return &CacheService{
|
||||
client: client.NewClient(&client.Options{
|
||||
@@ -48,6 +57,14 @@ func (t *CacheService) Increment(request *IncrementRequest) (*IncrementResponse,
|
||||
|
||||
}
|
||||
|
||||
// List all the available keys
|
||||
func (t *CacheService) ListKeys(request *ListKeysRequest) (*ListKeysResponse, error) {
|
||||
|
||||
rsp := &ListKeysResponse{}
|
||||
return rsp, t.client.Call("cache", "ListKeys", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Set an item in the cache. Overwrites any existing value already set.
|
||||
func (t *CacheService) Set(request *SetRequest) (*SetResponse, error) {
|
||||
|
||||
@@ -108,6 +125,13 @@ type IncrementResponse struct {
|
||||
Value int64 `json:"value,string"`
|
||||
}
|
||||
|
||||
type ListKeysRequest struct {
|
||||
}
|
||||
|
||||
type ListKeysResponse struct {
|
||||
Keys []string `json:"keys"`
|
||||
}
|
||||
|
||||
type SetRequest struct {
|
||||
// The key to update
|
||||
Key string `json:"key"`
|
||||
|
||||
52
carbon/carbon.go
Executable file
52
carbon/carbon.go
Executable file
@@ -0,0 +1,52 @@
|
||||
package carbon
|
||||
|
||||
import (
|
||||
"go.m3o.com/client"
|
||||
)
|
||||
|
||||
type Carbon interface {
|
||||
Offset(*OffsetRequest) (*OffsetResponse, error)
|
||||
}
|
||||
|
||||
func NewCarbonService(token string) *CarbonService {
|
||||
return &CarbonService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type CarbonService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Purchase 1KG (0.001 tonne) of carbon offsets in a single request
|
||||
func (t *CarbonService) Offset(request *OffsetRequest) (*OffsetResponse, error) {
|
||||
|
||||
rsp := &OffsetResponse{}
|
||||
return rsp, t.client.Call("carbon", "Offset", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type OffsetRequest struct {
|
||||
}
|
||||
|
||||
type OffsetResponse struct {
|
||||
// the metric used e.g KG or Tonnes
|
||||
Metric string `json:"metric"`
|
||||
// projects it was allocated to
|
||||
Projects []Project `json:"projects"`
|
||||
// number of tonnes
|
||||
Tonnes float64 `json:"tonnes"`
|
||||
// number of units purchased
|
||||
Units int32 `json:"units"`
|
||||
}
|
||||
|
||||
type Project struct {
|
||||
// name of the project
|
||||
Name string `json:"name"`
|
||||
// percentage that went to this
|
||||
Percentage float64 `json:"percentage"`
|
||||
// amount in tonnes
|
||||
Tonnes float64 `json:"tonnes"`
|
||||
}
|
||||
256
chat/chat.go
Executable file
256
chat/chat.go
Executable file
@@ -0,0 +1,256 @@
|
||||
package chat
|
||||
|
||||
import (
|
||||
"go.m3o.com/client"
|
||||
)
|
||||
|
||||
type Chat interface {
|
||||
Create(*CreateRequest) (*CreateResponse, error)
|
||||
Delete(*DeleteRequest) (*DeleteResponse, error)
|
||||
History(*HistoryRequest) (*HistoryResponse, error)
|
||||
Invite(*InviteRequest) (*InviteResponse, error)
|
||||
Join(*JoinRequest) (*JoinResponseStream, error)
|
||||
Kick(*KickRequest) (*KickResponse, error)
|
||||
Leave(*LeaveRequest) (*LeaveResponse, error)
|
||||
List(*ListRequest) (*ListResponse, error)
|
||||
Send(*SendRequest) (*SendResponse, error)
|
||||
}
|
||||
|
||||
func NewChatService(token string) *ChatService {
|
||||
return &ChatService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type ChatService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Create a new chat room
|
||||
func (t *ChatService) Create(request *CreateRequest) (*CreateResponse, error) {
|
||||
|
||||
rsp := &CreateResponse{}
|
||||
return rsp, t.client.Call("chat", "Create", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Delete a chat room
|
||||
func (t *ChatService) Delete(request *DeleteRequest) (*DeleteResponse, error) {
|
||||
|
||||
rsp := &DeleteResponse{}
|
||||
return rsp, t.client.Call("chat", "Delete", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// List the messages in a chat
|
||||
func (t *ChatService) History(request *HistoryRequest) (*HistoryResponse, error) {
|
||||
|
||||
rsp := &HistoryResponse{}
|
||||
return rsp, t.client.Call("chat", "History", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Invite a user to a chat room
|
||||
func (t *ChatService) Invite(request *InviteRequest) (*InviteResponse, error) {
|
||||
|
||||
rsp := &InviteResponse{}
|
||||
return rsp, t.client.Call("chat", "Invite", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Join a chat room
|
||||
func (t *ChatService) Join(request *JoinRequest) (*JoinResponseStream, error) {
|
||||
stream, err := t.client.Stream("chat", "Join", request)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &JoinResponseStream{
|
||||
stream: stream,
|
||||
}, nil
|
||||
|
||||
}
|
||||
|
||||
type JoinResponseStream struct {
|
||||
stream *client.Stream
|
||||
}
|
||||
|
||||
func (t *JoinResponseStream) Recv() (*JoinResponse, error) {
|
||||
var rsp JoinResponse
|
||||
if err := t.stream.Recv(&rsp); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &rsp, nil
|
||||
}
|
||||
|
||||
// Kick a user from a chat room
|
||||
func (t *ChatService) Kick(request *KickRequest) (*KickResponse, error) {
|
||||
|
||||
rsp := &KickResponse{}
|
||||
return rsp, t.client.Call("chat", "Kick", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Leave a chat room
|
||||
func (t *ChatService) Leave(request *LeaveRequest) (*LeaveResponse, error) {
|
||||
|
||||
rsp := &LeaveResponse{}
|
||||
return rsp, t.client.Call("chat", "Leave", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// List available chats
|
||||
func (t *ChatService) List(request *ListRequest) (*ListResponse, error) {
|
||||
|
||||
rsp := &ListResponse{}
|
||||
return rsp, t.client.Call("chat", "List", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Connect to a chat to receive a stream of messages
|
||||
// Send a message to a chat
|
||||
func (t *ChatService) Send(request *SendRequest) (*SendResponse, error) {
|
||||
|
||||
rsp := &SendResponse{}
|
||||
return rsp, t.client.Call("chat", "Send", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type CreateRequest struct {
|
||||
// chat description
|
||||
Description string `json:"description"`
|
||||
// name of the room
|
||||
Name string `json:"name"`
|
||||
// whether its a private room
|
||||
Private bool `json:"private"`
|
||||
// optional list of user ids
|
||||
UserIds string `json:"user_ids"`
|
||||
}
|
||||
|
||||
type CreateResponse struct {
|
||||
// the unique chat room
|
||||
Room *Room `json:"room"`
|
||||
}
|
||||
|
||||
type DeleteRequest struct {
|
||||
// the chat room id to delete
|
||||
RoomId string `json:"room_id"`
|
||||
}
|
||||
|
||||
type DeleteResponse struct {
|
||||
Room *Room `json:"room"`
|
||||
}
|
||||
|
||||
type HistoryRequest struct {
|
||||
// the chat room id to get
|
||||
RoomId string `json:"room_id"`
|
||||
}
|
||||
|
||||
type HistoryResponse struct {
|
||||
// messages in the chat room
|
||||
Messages []Message `json:"messages"`
|
||||
}
|
||||
|
||||
type InviteRequest struct {
|
||||
// the room id
|
||||
RoomId string `json:"room_id"`
|
||||
// the user id
|
||||
UserId string `json:"user_id"`
|
||||
}
|
||||
|
||||
type InviteResponse struct {
|
||||
Room *Room `json:"room"`
|
||||
}
|
||||
|
||||
type JoinRequest struct {
|
||||
// chat room to join
|
||||
RoomId string `json:"room_id"`
|
||||
// user id joining
|
||||
UserId string `json:"user_id"`
|
||||
}
|
||||
|
||||
type JoinResponse struct {
|
||||
Message *Message `json:"message"`
|
||||
}
|
||||
|
||||
type KickRequest struct {
|
||||
// the chat room id
|
||||
RoomId string `json:"room_id"`
|
||||
// the user id
|
||||
UserId string `json:"user_id"`
|
||||
}
|
||||
|
||||
type KickResponse struct {
|
||||
Room *Room `json:"room"`
|
||||
}
|
||||
|
||||
type LeaveRequest struct {
|
||||
// the chat room id
|
||||
RoomId string `json:"room_id"`
|
||||
// the user id
|
||||
UserId string `json:"user_id"`
|
||||
}
|
||||
|
||||
type LeaveResponse struct {
|
||||
Room *Room `json:"room"`
|
||||
}
|
||||
|
||||
type ListRequest struct {
|
||||
// optional user id to filter by
|
||||
UserId string `json:"user_id"`
|
||||
}
|
||||
|
||||
type ListResponse struct {
|
||||
Rooms []Room `json:"rooms"`
|
||||
}
|
||||
|
||||
type Message struct {
|
||||
// a client side id, should be validated by the server to make the request retry safe
|
||||
Client string `json:"client"`
|
||||
// id of the message, allocated by the server
|
||||
Id string `json:"id"`
|
||||
// id of the chat the message is being sent to / from
|
||||
RoomId string `json:"room_id"`
|
||||
// time the message was sent in RFC3339 format
|
||||
SentAt string `json:"sent_at"`
|
||||
// subject of the message
|
||||
Subject string `json:"subject"`
|
||||
// text of the message
|
||||
Text string `json:"text"`
|
||||
// id of the user who sent the message
|
||||
UserId string `json:"user_id"`
|
||||
}
|
||||
|
||||
type Room struct {
|
||||
// time of creation
|
||||
CreatedAt string `json:"created_at"`
|
||||
// description of the that
|
||||
Description string `json:"description"`
|
||||
// unique room id
|
||||
Id string `json:"id"`
|
||||
// name of the chat
|
||||
Name string `json:"name"`
|
||||
// whether its a private room
|
||||
Private bool `json:"private"`
|
||||
// list of users
|
||||
UserIds string `json:"user_ids"`
|
||||
}
|
||||
|
||||
type SendRequest struct {
|
||||
// a client side id, should be validated by the server to make the request retry safe
|
||||
Client string `json:"client"`
|
||||
// id of the chat room the message is being sent to / from
|
||||
RoomId string `json:"room_id"`
|
||||
// subject of the message
|
||||
Subject string `json:"subject"`
|
||||
// text of the message
|
||||
Text string `json:"text"`
|
||||
// id of the user who sent the message
|
||||
UserId string `json:"user_id"`
|
||||
}
|
||||
|
||||
type SendResponse struct {
|
||||
// the message which was created
|
||||
Message *Message `json:"message"`
|
||||
}
|
||||
162
comments/comments.go
Executable file
162
comments/comments.go
Executable file
@@ -0,0 +1,162 @@
|
||||
package comments
|
||||
|
||||
import (
|
||||
"go.m3o.com/client"
|
||||
)
|
||||
|
||||
type Comments interface {
|
||||
Create(*CreateRequest) (*CreateResponse, error)
|
||||
Delete(*DeleteRequest) (*DeleteResponse, error)
|
||||
Events(*EventsRequest) (*EventsResponseStream, error)
|
||||
List(*ListRequest) (*ListResponse, error)
|
||||
Read(*ReadRequest) (*ReadResponse, error)
|
||||
Update(*UpdateRequest) (*UpdateResponse, error)
|
||||
}
|
||||
|
||||
func NewCommentsService(token string) *CommentsService {
|
||||
return &CommentsService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type CommentsService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Create a new comment
|
||||
func (t *CommentsService) Create(request *CreateRequest) (*CreateResponse, error) {
|
||||
|
||||
rsp := &CreateResponse{}
|
||||
return rsp, t.client.Call("comments", "Create", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Delete a comment
|
||||
func (t *CommentsService) Delete(request *DeleteRequest) (*DeleteResponse, error) {
|
||||
|
||||
rsp := &DeleteResponse{}
|
||||
return rsp, t.client.Call("comments", "Delete", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Subscribe to comments events
|
||||
func (t *CommentsService) Events(request *EventsRequest) (*EventsResponseStream, error) {
|
||||
stream, err := t.client.Stream("comments", "Events", request)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &EventsResponseStream{
|
||||
stream: stream,
|
||||
}, nil
|
||||
|
||||
}
|
||||
|
||||
type EventsResponseStream struct {
|
||||
stream *client.Stream
|
||||
}
|
||||
|
||||
func (t *EventsResponseStream) Recv() (*EventsResponse, error) {
|
||||
var rsp EventsResponse
|
||||
if err := t.stream.Recv(&rsp); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &rsp, nil
|
||||
}
|
||||
|
||||
// List all the comments
|
||||
func (t *CommentsService) List(request *ListRequest) (*ListResponse, error) {
|
||||
|
||||
rsp := &ListResponse{}
|
||||
return rsp, t.client.Call("comments", "List", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Read a comment
|
||||
func (t *CommentsService) Read(request *ReadRequest) (*ReadResponse, error) {
|
||||
|
||||
rsp := &ReadResponse{}
|
||||
return rsp, t.client.Call("comments", "Read", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Update a comment
|
||||
func (t *CommentsService) Update(request *UpdateRequest) (*UpdateResponse, error) {
|
||||
|
||||
rsp := &UpdateResponse{}
|
||||
return rsp, t.client.Call("comments", "Update", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type Comment struct {
|
||||
// time at which the comment was created
|
||||
Created string `json:"created"`
|
||||
// unique id for the comment, generated if not specified
|
||||
Id string `json:"id"`
|
||||
// subject of the comment
|
||||
Subject string `json:"subject"`
|
||||
// text of the comment
|
||||
Text string `json:"text"`
|
||||
// time at which the comment was updated
|
||||
Updated string `json:"updated"`
|
||||
}
|
||||
|
||||
type CreateRequest struct {
|
||||
// comment subject
|
||||
Subject string `json:"subject"`
|
||||
// comment items
|
||||
Text string `json:"text"`
|
||||
}
|
||||
|
||||
type CreateResponse struct {
|
||||
// The created comment
|
||||
Comment *Comment `json:"comment"`
|
||||
}
|
||||
|
||||
type DeleteRequest struct {
|
||||
// specify the id of the comment
|
||||
Id string `json:"id"`
|
||||
}
|
||||
|
||||
type DeleteResponse struct {
|
||||
Comment *Comment `json:"comment"`
|
||||
}
|
||||
|
||||
type EventsRequest struct {
|
||||
// optionally specify a comment id
|
||||
Id string `json:"id"`
|
||||
}
|
||||
|
||||
type EventsResponse struct {
|
||||
// the comment which the operation occured on
|
||||
Comment *Comment `json:"comment"`
|
||||
// the event which occured; create, delete, update
|
||||
Event string `json:"event"`
|
||||
}
|
||||
|
||||
type ListRequest struct {
|
||||
}
|
||||
|
||||
type ListResponse struct {
|
||||
// the comment of comments
|
||||
Comments []Comment `json:"comments"`
|
||||
}
|
||||
|
||||
type ReadRequest struct {
|
||||
// the comment id
|
||||
Id string `json:"id"`
|
||||
}
|
||||
|
||||
type ReadResponse struct {
|
||||
// The comment
|
||||
Comment *Comment `json:"comment"`
|
||||
}
|
||||
|
||||
type UpdateRequest struct {
|
||||
Comment *Comment `json:"comment"`
|
||||
}
|
||||
|
||||
type UpdateResponse struct {
|
||||
Comment *Comment `json:"comment"`
|
||||
}
|
||||
200
contact/contact.go
Executable file
200
contact/contact.go
Executable file
@@ -0,0 +1,200 @@
|
||||
package contact
|
||||
|
||||
import (
|
||||
"go.m3o.com/client"
|
||||
)
|
||||
|
||||
type Contact interface {
|
||||
Create(*CreateRequest) (*CreateResponse, error)
|
||||
Delete(*DeleteRequest) (*DeleteResponse, error)
|
||||
List(*ListRequest) (*ListResponse, error)
|
||||
Read(*ReadRequest) (*ReadResponse, error)
|
||||
Update(*UpdateRequest) (*UpdateResponse, error)
|
||||
}
|
||||
|
||||
func NewContactService(token string) *ContactService {
|
||||
return &ContactService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type ContactService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Create a contact
|
||||
func (t *ContactService) Create(request *CreateRequest) (*CreateResponse, error) {
|
||||
|
||||
rsp := &CreateResponse{}
|
||||
return rsp, t.client.Call("contact", "Create", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Delete a contact
|
||||
func (t *ContactService) Delete(request *DeleteRequest) (*DeleteResponse, error) {
|
||||
|
||||
rsp := &DeleteResponse{}
|
||||
return rsp, t.client.Call("contact", "Delete", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// List contacts
|
||||
func (t *ContactService) List(request *ListRequest) (*ListResponse, error) {
|
||||
|
||||
rsp := &ListResponse{}
|
||||
return rsp, t.client.Call("contact", "List", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Read contact details
|
||||
func (t *ContactService) Read(request *ReadRequest) (*ReadResponse, error) {
|
||||
|
||||
rsp := &ReadResponse{}
|
||||
return rsp, t.client.Call("contact", "Read", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Update a contact
|
||||
func (t *ContactService) Update(request *UpdateRequest) (*UpdateResponse, error) {
|
||||
|
||||
rsp := &UpdateResponse{}
|
||||
return rsp, t.client.Call("contact", "Update", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type Address struct {
|
||||
// the label of the address
|
||||
Label string `json:"label"`
|
||||
// the address location
|
||||
Location string `json:"location"`
|
||||
}
|
||||
|
||||
type ContactInfo struct {
|
||||
// the address
|
||||
Addresses []Address `json:"addresses"`
|
||||
// the birthday
|
||||
Birthday string `json:"birthday"`
|
||||
// create date string in RFC3339
|
||||
CreatedAt string `json:"created_at"`
|
||||
// the emails
|
||||
Emails []Email `json:"emails"`
|
||||
// contact id
|
||||
Id string `json:"id"`
|
||||
// the contact links
|
||||
Links []Link `json:"links"`
|
||||
// the contact name
|
||||
Name string `json:"name"`
|
||||
// note of the contact
|
||||
Note string `json:"note"`
|
||||
// the phone numbers
|
||||
Phones []Phone `json:"phones"`
|
||||
// the social media username
|
||||
SocialMedias *SocialMedia `json:"social_medias"`
|
||||
// update date string in RFC3339
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
}
|
||||
|
||||
type CreateRequest struct {
|
||||
// optional, location
|
||||
Addresses []Address `json:"addresses"`
|
||||
// optional, birthday
|
||||
Birthday string `json:"birthday"`
|
||||
// optional, emails
|
||||
Emails []Email `json:"emails"`
|
||||
// optional, links
|
||||
Links []Link `json:"links"`
|
||||
// required, the name of the contact
|
||||
Name string `json:"name"`
|
||||
// optional, note of the contact
|
||||
Note string `json:"note"`
|
||||
// optional, phone numbers
|
||||
Phones []Phone `json:"phones"`
|
||||
// optional, social media
|
||||
SocialMedias *SocialMedia `json:"social_medias"`
|
||||
}
|
||||
|
||||
type CreateResponse struct {
|
||||
Contact *ContactInfo `json:"contact"`
|
||||
}
|
||||
|
||||
type DeleteRequest struct {
|
||||
// the id of the contact
|
||||
Id string `json:"id"`
|
||||
}
|
||||
|
||||
type DeleteResponse struct {
|
||||
}
|
||||
|
||||
type Email struct {
|
||||
// the email address
|
||||
Address string `json:"address"`
|
||||
// the label of the email
|
||||
Label string `json:"label"`
|
||||
}
|
||||
|
||||
type Link struct {
|
||||
// the label of the link
|
||||
Label string `json:"label"`
|
||||
// the url of the contact
|
||||
Url string `json:"url"`
|
||||
}
|
||||
|
||||
type ListRequest struct {
|
||||
// optional, default is 30
|
||||
Limit int32 `json:"limit"`
|
||||
// optional
|
||||
Offset int32 `json:"offset"`
|
||||
}
|
||||
|
||||
type ListResponse struct {
|
||||
Contacts []ContactInfo `json:"contacts"`
|
||||
}
|
||||
|
||||
type Phone struct {
|
||||
// the label of the phone number
|
||||
Label string `json:"label"`
|
||||
// phone number
|
||||
Number string `json:"number"`
|
||||
}
|
||||
|
||||
type ReadRequest struct {
|
||||
Id string `json:"id"`
|
||||
}
|
||||
|
||||
type ReadResponse struct {
|
||||
Contact *ContactInfo `json:"contact"`
|
||||
}
|
||||
|
||||
type SocialMedia struct {
|
||||
// the label of the social
|
||||
Label string `json:"label"`
|
||||
// the username of social media
|
||||
Username string `json:"username"`
|
||||
}
|
||||
|
||||
type UpdateRequest struct {
|
||||
// optional, addresses
|
||||
Addresses []Address `json:"addresses"`
|
||||
// optional, birthday
|
||||
Birthday string `json:"birthday"`
|
||||
// optional, emails
|
||||
Emails []Email `json:"emails"`
|
||||
// required, the contact id
|
||||
Id string `json:"id"`
|
||||
// optional, links
|
||||
Links []Link `json:"links"`
|
||||
// required, the name
|
||||
Name string `json:"name"`
|
||||
// optional, note
|
||||
Note string `json:"note"`
|
||||
// optional, phone number
|
||||
Phones []Phone `json:"phones"`
|
||||
// optional, social media
|
||||
SocialMedias *SocialMedia `json:"social_medias"`
|
||||
}
|
||||
|
||||
type UpdateResponse struct {
|
||||
Contact *ContactInfo `json:"contact"`
|
||||
}
|
||||
@@ -4,6 +4,14 @@ import (
|
||||
"go.m3o.com/client"
|
||||
)
|
||||
|
||||
type Crypto interface {
|
||||
History(*HistoryRequest) (*HistoryResponse, error)
|
||||
News(*NewsRequest) (*NewsResponse, error)
|
||||
Price(*PriceRequest) (*PriceResponse, error)
|
||||
Quote(*QuoteRequest) (*QuoteResponse, error)
|
||||
Symbols(*SymbolsRequest) (*SymbolsResponse, error)
|
||||
}
|
||||
|
||||
func NewCryptoService(token string) *CryptoService {
|
||||
return &CryptoService{
|
||||
client: client.NewClient(&client.Options{
|
||||
@@ -48,6 +56,14 @@ func (t *CryptoService) Quote(request *QuoteRequest) (*QuoteResponse, error) {
|
||||
|
||||
}
|
||||
|
||||
// Returns the full list of supported symbols
|
||||
func (t *CryptoService) Symbols(request *SymbolsRequest) (*SymbolsResponse, error) {
|
||||
|
||||
rsp := &SymbolsResponse{}
|
||||
return rsp, t.client.Call("crypto", "Symbols", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type Article struct {
|
||||
// the date published
|
||||
Date string `json:"date"`
|
||||
@@ -126,3 +142,15 @@ type QuoteResponse struct {
|
||||
// the UTC timestamp of the quote
|
||||
Timestamp string `json:"timestamp"`
|
||||
}
|
||||
|
||||
type Symbol struct {
|
||||
Name string `json:"name"`
|
||||
Symbol string `json:"symbol"`
|
||||
}
|
||||
|
||||
type SymbolsRequest struct {
|
||||
}
|
||||
|
||||
type SymbolsResponse struct {
|
||||
Symbols []Symbol `json:"symbols"`
|
||||
}
|
||||
|
||||
@@ -4,6 +4,13 @@ import (
|
||||
"go.m3o.com/client"
|
||||
)
|
||||
|
||||
type Currency interface {
|
||||
Codes(*CodesRequest) (*CodesResponse, error)
|
||||
Convert(*ConvertRequest) (*ConvertResponse, error)
|
||||
History(*HistoryRequest) (*HistoryResponse, error)
|
||||
Rates(*RatesRequest) (*RatesResponse, error)
|
||||
}
|
||||
|
||||
func NewCurrencyService(token string) *CurrencyService {
|
||||
return &CurrencyService{
|
||||
client: client.NewClient(&client.Options{
|
||||
|
||||
12
db/db.go
12
db/db.go
@@ -4,6 +4,18 @@ import (
|
||||
"go.m3o.com/client"
|
||||
)
|
||||
|
||||
type Db interface {
|
||||
Count(*CountRequest) (*CountResponse, error)
|
||||
Create(*CreateRequest) (*CreateResponse, error)
|
||||
Delete(*DeleteRequest) (*DeleteResponse, error)
|
||||
DropTable(*DropTableRequest) (*DropTableResponse, error)
|
||||
ListTables(*ListTablesRequest) (*ListTablesResponse, error)
|
||||
Read(*ReadRequest) (*ReadResponse, error)
|
||||
RenameTable(*RenameTableRequest) (*RenameTableResponse, error)
|
||||
Truncate(*TruncateRequest) (*TruncateResponse, error)
|
||||
Update(*UpdateRequest) (*UpdateResponse, error)
|
||||
}
|
||||
|
||||
func NewDbService(token string) *DbService {
|
||||
return &DbService{
|
||||
client: client.NewClient(&client.Options{
|
||||
|
||||
@@ -4,6 +4,12 @@ import (
|
||||
"go.m3o.com/client"
|
||||
)
|
||||
|
||||
type Email interface {
|
||||
Parse(*ParseRequest) (*ParseResponse, error)
|
||||
Send(*SendRequest) (*SendResponse, error)
|
||||
Validate(*ValidateRequest) (*ValidateResponse, error)
|
||||
}
|
||||
|
||||
func NewEmailService(token string) *EmailService {
|
||||
return &EmailService{
|
||||
client: client.NewClient(&client.Options{
|
||||
@@ -16,6 +22,14 @@ type EmailService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Parse an RFC5322 address e.g "Joe Blogs <joe@example.com>"
|
||||
func (t *EmailService) Parse(request *ParseRequest) (*ParseResponse, error) {
|
||||
|
||||
rsp := &ParseResponse{}
|
||||
return rsp, t.client.Call("email", "Parse", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Send an email by passing in from, to, subject, and a text or html body
|
||||
func (t *EmailService) Send(request *SendRequest) (*SendResponse, error) {
|
||||
|
||||
@@ -24,6 +38,26 @@ func (t *EmailService) Send(request *SendRequest) (*SendResponse, error) {
|
||||
|
||||
}
|
||||
|
||||
// Validate an email address format
|
||||
func (t *EmailService) Validate(request *ValidateRequest) (*ValidateResponse, error) {
|
||||
|
||||
rsp := &ValidateResponse{}
|
||||
return rsp, t.client.Call("email", "Validate", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type ParseRequest struct {
|
||||
// The address to parse. Can be of the format "Joe Blogs <joe@example.com>" or "joe@example.com"
|
||||
Address string `json:"address"`
|
||||
}
|
||||
|
||||
type ParseResponse struct {
|
||||
// the email address
|
||||
Address string `json:"address"`
|
||||
// associated name e.g Joe Blogs
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type SendRequest struct {
|
||||
// the display name of the sender
|
||||
From string `json:"from"`
|
||||
@@ -41,3 +75,11 @@ type SendRequest struct {
|
||||
|
||||
type SendResponse struct {
|
||||
}
|
||||
|
||||
type ValidateRequest struct {
|
||||
Address string `json:"address"`
|
||||
}
|
||||
|
||||
type ValidateResponse struct {
|
||||
IsValid bool `json:"is_valid"`
|
||||
}
|
||||
|
||||
@@ -4,6 +4,12 @@ import (
|
||||
"go.m3o.com/client"
|
||||
)
|
||||
|
||||
type Emoji interface {
|
||||
Find(*FindRequest) (*FindResponse, error)
|
||||
Flag(*FlagRequest) (*FlagResponse, error)
|
||||
Print(*PrintRequest) (*PrintResponse, error)
|
||||
}
|
||||
|
||||
func NewEmojiService(token string) *EmojiService {
|
||||
return &EmojiService{
|
||||
client: client.NewClient(&client.Options{
|
||||
@@ -41,14 +47,6 @@ func (t *EmojiService) Print(request *PrintRequest) (*PrintResponse, error) {
|
||||
|
||||
}
|
||||
|
||||
// Send an emoji to anyone via SMS. Messages are sent in the form '<message> Sent from <from>'
|
||||
func (t *EmojiService) Send(request *SendRequest) (*SendResponse, error) {
|
||||
|
||||
rsp := &SendResponse{}
|
||||
return rsp, t.client.Call("emoji", "Send", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type FindRequest struct {
|
||||
// the alias code e.g :beer:
|
||||
Alias string `json:"alias"`
|
||||
@@ -78,17 +76,3 @@ type PrintResponse struct {
|
||||
// text with rendered emojis
|
||||
Text string `json:"text"`
|
||||
}
|
||||
|
||||
type SendRequest struct {
|
||||
// the name of the sender from e.g Alice
|
||||
From string `json:"from"`
|
||||
// message to send including emoji aliases
|
||||
Message string `json:"message"`
|
||||
// phone number to send to (including international dialing code)
|
||||
To string `json:"to"`
|
||||
}
|
||||
|
||||
type SendResponse struct {
|
||||
// whether or not it succeeded
|
||||
Success bool `json:"success"`
|
||||
}
|
||||
|
||||
@@ -4,6 +4,11 @@ import (
|
||||
"go.m3o.com/client"
|
||||
)
|
||||
|
||||
type Evchargers interface {
|
||||
ReferenceData(*ReferenceDataRequest) (*ReferenceDataResponse, error)
|
||||
Search(*SearchRequest) (*SearchResponse, error)
|
||||
}
|
||||
|
||||
func NewEvchargersService(token string) *EvchargersService {
|
||||
return &EvchargersService{
|
||||
client: client.NewClient(&client.Options{
|
||||
|
||||
@@ -4,6 +4,12 @@ import (
|
||||
"go.m3o.com/client"
|
||||
)
|
||||
|
||||
type Event interface {
|
||||
Consume(*ConsumeRequest) (*ConsumeResponseStream, error)
|
||||
Publish(*PublishRequest) (*PublishResponse, error)
|
||||
Read(*ReadRequest) (*ReadResponse, error)
|
||||
}
|
||||
|
||||
func NewEventService(token string) *EventService {
|
||||
return &EventService{
|
||||
client: client.NewClient(&client.Options{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Address
|
||||
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Address/api](https://m3o.com/Address/api).
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/address/api](https://m3o.com/address/api).
|
||||
|
||||
Endpoints:
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Answer
|
||||
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Answer/api](https://m3o.com/Answer/api).
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/answer/api](https://m3o.com/answer/api).
|
||||
|
||||
Endpoints:
|
||||
|
||||
|
||||
@@ -1,9 +1,37 @@
|
||||
# App
|
||||
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/App/api](https://m3o.com/App/api).
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/app/api](https://m3o.com/app/api).
|
||||
|
||||
Endpoints:
|
||||
|
||||
## 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)
|
||||
|
||||
}
|
||||
```
|
||||
## Update
|
||||
|
||||
Update the app. The latest source code will be downloaded, built and deployed.
|
||||
@@ -117,7 +145,7 @@ func ListTheApps() {
|
||||
```
|
||||
## Run
|
||||
|
||||
Run an app from a source repo. Specify region etc.
|
||||
Run an app from source
|
||||
|
||||
|
||||
[https://m3o.com/app/api#Run](https://m3o.com/app/api#Run)
|
||||
@@ -132,7 +160,7 @@ import(
|
||||
"go.m3o.com/app"
|
||||
)
|
||||
|
||||
// Run an app from a source repo. Specify region etc.
|
||||
// Run an app from source
|
||||
func RunAnApp() {
|
||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := appService.Run(&app.RunRequest{
|
||||
@@ -202,31 +230,3 @@ func GetTheStatusOfAnApp() {
|
||||
|
||||
}
|
||||
```
|
||||
## 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)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"go.m3o.com/app"
|
||||
)
|
||||
|
||||
// Run an app from a source repo. Specify region etc.
|
||||
// Run an app from source
|
||||
func main() {
|
||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := appService.Run(&app.RunRequest{
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
# Avatar
|
||||
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Avatar/api](https://m3o.com/Avatar/api).
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/avatar/api](https://m3o.com/avatar/api).
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Generate
|
||||
|
||||
|
||||
Generate an unique avatar
|
||||
|
||||
|
||||
[https://m3o.com/avatar/api#Generate](https://m3o.com/avatar/api#Generate)
|
||||
@@ -21,39 +21,8 @@ import(
|
||||
"go.m3o.com/avatar"
|
||||
)
|
||||
|
||||
//
|
||||
// Generate an unique 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",
|
||||
@@ -66,3 +35,34 @@ Username: "",
|
||||
|
||||
}
|
||||
```
|
||||
## Generate
|
||||
|
||||
Generate an unique avatar
|
||||
|
||||
|
||||
[https://m3o.com/avatar/api#Generate](https://m3o.com/avatar/api#Generate)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/avatar"
|
||||
)
|
||||
|
||||
// Generate an unique avatar
|
||||
func GenerateAnAvatarAndUploadTheAvatarToMicrosCdn() {
|
||||
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)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -7,13 +7,13 @@ import (
|
||||
"go.m3o.com/avatar"
|
||||
)
|
||||
|
||||
//
|
||||
// Generate an unique avatar
|
||||
func main() {
|
||||
avatarService := avatar.NewAvatarService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := avatarService.Generate(&avatar.GenerateRequest{
|
||||
Format: "jpeg",
|
||||
Format: "png",
|
||||
Gender: "female",
|
||||
Upload: false,
|
||||
Upload: true,
|
||||
Username: "",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
@@ -7,13 +7,13 @@ import (
|
||||
"go.m3o.com/avatar"
|
||||
)
|
||||
|
||||
//
|
||||
// Generate an unique avatar
|
||||
func main() {
|
||||
avatarService := avatar.NewAvatarService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := avatarService.Generate(&avatar.GenerateRequest{
|
||||
Format: "png",
|
||||
Format: "jpeg",
|
||||
Gender: "female",
|
||||
Upload: true,
|
||||
Upload: false,
|
||||
Username: "",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
87
examples/cache/README.md
vendored
87
examples/cache/README.md
vendored
@@ -1,9 +1,65 @@
|
||||
# Cache
|
||||
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Cache/api](https://m3o.com/Cache/api).
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/cache/api](https://m3o.com/cache/api).
|
||||
|
||||
Endpoints:
|
||||
|
||||
## 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)
|
||||
|
||||
}
|
||||
```
|
||||
## ListKeys
|
||||
|
||||
List all the available keys
|
||||
|
||||
|
||||
[https://m3o.com/cache/api#ListKeys](https://m3o.com/cache/api#ListKeys)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/cache"
|
||||
)
|
||||
|
||||
// List all the available keys
|
||||
func ListTheKeys() {
|
||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := cacheService.ListKeys(&cache.ListKeysRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Set
|
||||
|
||||
Set an item in the cache. Overwrites any existing value already set.
|
||||
@@ -118,32 +174,3 @@ Value: 2,
|
||||
|
||||
}
|
||||
```
|
||||
## 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)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
15
examples/cache/listKeys/listTheKeys/main.go
vendored
Executable file
15
examples/cache/listKeys/listTheKeys/main.go
vendored
Executable file
@@ -0,0 +1,15 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/cache"
|
||||
)
|
||||
|
||||
// List all the available keys
|
||||
func main() {
|
||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := cacheService.ListKeys(&cache.ListKeysRequest{})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
33
examples/carbon/README.md
Executable file
33
examples/carbon/README.md
Executable file
@@ -0,0 +1,33 @@
|
||||
# Carbon
|
||||
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/carbon/api](https://m3o.com/carbon/api).
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Offset
|
||||
|
||||
Purchase 1KG (0.001 tonne) of carbon offsets in a single request
|
||||
|
||||
|
||||
[https://m3o.com/carbon/api#Offset](https://m3o.com/carbon/api#Offset)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/carbon"
|
||||
)
|
||||
|
||||
// Purchase 1KG (0.001 tonne) of carbon offsets in a single request
|
||||
func OffsetCarbon() {
|
||||
carbonService := carbon.NewCarbonService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := carbonService.Offset(&carbon.OffsetRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
15
examples/carbon/offset/offsetCarbon/main.go
Executable file
15
examples/carbon/offset/offsetCarbon/main.go
Executable file
@@ -0,0 +1,15 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/carbon"
|
||||
)
|
||||
|
||||
// Purchase 1KG (0.001 tonne) of carbon offsets in a single request
|
||||
func main() {
|
||||
carbonService := carbon.NewCarbonService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := carbonService.Offset(&carbon.OffsetRequest{})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
269
examples/chat/README.md
Executable file
269
examples/chat/README.md
Executable file
@@ -0,0 +1,269 @@
|
||||
# Chat
|
||||
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/chat/api](https://m3o.com/chat/api).
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Create
|
||||
|
||||
Create a new chat room
|
||||
|
||||
|
||||
[https://m3o.com/chat/api#Create](https://m3o.com/chat/api#Create)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/chat"
|
||||
)
|
||||
|
||||
// Create a new chat room
|
||||
func CreateAnewChat() {
|
||||
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := chatService.Create(&chat.CreateRequest{
|
||||
Description: "The general chat room",
|
||||
Name: "general",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Invite
|
||||
|
||||
Invite a user to a chat room
|
||||
|
||||
|
||||
[https://m3o.com/chat/api#Invite](https://m3o.com/chat/api#Invite)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/chat"
|
||||
)
|
||||
|
||||
// Invite a user to a chat room
|
||||
func InviteAuser() {
|
||||
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := chatService.Invite(&chat.InviteRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Send
|
||||
|
||||
Connect to a chat to receive a stream of messages
|
||||
Send a message to a chat
|
||||
|
||||
|
||||
[https://m3o.com/chat/api#Send](https://m3o.com/chat/api#Send)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/chat"
|
||||
)
|
||||
|
||||
// Connect to a chat to receive a stream of messages
|
||||
// Send a message to a chat
|
||||
func SendAmessage() {
|
||||
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := chatService.Send(&chat.SendRequest{
|
||||
Client: "web",
|
||||
Subject: "Random",
|
||||
Text: "Hey whats up?",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## History
|
||||
|
||||
List the messages in a chat
|
||||
|
||||
|
||||
[https://m3o.com/chat/api#History](https://m3o.com/chat/api#History)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/chat"
|
||||
)
|
||||
|
||||
// List the messages in a chat
|
||||
func GetChatHistory() {
|
||||
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := chatService.History(&chat.HistoryRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Join
|
||||
|
||||
Join a chat room
|
||||
|
||||
|
||||
[https://m3o.com/chat/api#Join](https://m3o.com/chat/api#Join)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/chat"
|
||||
)
|
||||
|
||||
// Join a chat room
|
||||
func JoinAroom() {
|
||||
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
||||
|
||||
stream, err := chatService.Join(&chat.JoinRequest{
|
||||
|
||||
})
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
for {
|
||||
rsp, err := stream.Recv()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println(rsp)
|
||||
}
|
||||
}
|
||||
```
|
||||
## Kick
|
||||
|
||||
Kick a user from a chat room
|
||||
|
||||
|
||||
[https://m3o.com/chat/api#Kick](https://m3o.com/chat/api#Kick)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/chat"
|
||||
)
|
||||
|
||||
// Kick a user from a chat room
|
||||
func KickAuserFromAroom() {
|
||||
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := chatService.Kick(&chat.KickRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Leave
|
||||
|
||||
Leave a chat room
|
||||
|
||||
|
||||
[https://m3o.com/chat/api#Leave](https://m3o.com/chat/api#Leave)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/chat"
|
||||
)
|
||||
|
||||
// Leave a chat room
|
||||
func LeaveAroom() {
|
||||
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := chatService.Leave(&chat.LeaveRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## List
|
||||
|
||||
List available chats
|
||||
|
||||
|
||||
[https://m3o.com/chat/api#List](https://m3o.com/chat/api#List)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/chat"
|
||||
)
|
||||
|
||||
// List available chats
|
||||
func ListChatRooms() {
|
||||
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := chatService.List(&chat.ListRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Delete
|
||||
|
||||
Delete a chat room
|
||||
|
||||
|
||||
[https://m3o.com/chat/api#Delete](https://m3o.com/chat/api#Delete)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/chat"
|
||||
)
|
||||
|
||||
// Delete a chat room
|
||||
func DeleteAchat() {
|
||||
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := chatService.Delete(&chat.DeleteRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
18
examples/chat/create/createANewChat/main.go
Executable file
18
examples/chat/create/createANewChat/main.go
Executable file
@@ -0,0 +1,18 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/chat"
|
||||
)
|
||||
|
||||
// Create a new chat room
|
||||
func main() {
|
||||
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := chatService.Create(&chat.CreateRequest{
|
||||
Description: "The general chat room",
|
||||
Name: "general",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
15
examples/chat/delete/deleteAChat/main.go
Executable file
15
examples/chat/delete/deleteAChat/main.go
Executable file
@@ -0,0 +1,15 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/chat"
|
||||
)
|
||||
|
||||
// Delete a chat room
|
||||
func main() {
|
||||
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := chatService.Delete(&chat.DeleteRequest{})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
15
examples/chat/history/getChatHistory/main.go
Executable file
15
examples/chat/history/getChatHistory/main.go
Executable file
@@ -0,0 +1,15 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/chat"
|
||||
)
|
||||
|
||||
// List the messages in a chat
|
||||
func main() {
|
||||
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := chatService.History(&chat.HistoryRequest{})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
15
examples/chat/invite/inviteAUser/main.go
Executable file
15
examples/chat/invite/inviteAUser/main.go
Executable file
@@ -0,0 +1,15 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/chat"
|
||||
)
|
||||
|
||||
// Invite a user to a chat room
|
||||
func main() {
|
||||
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := chatService.Invite(&chat.InviteRequest{})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
28
examples/chat/join/joinARoom/main.go
Executable file
28
examples/chat/join/joinARoom/main.go
Executable file
@@ -0,0 +1,28 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/chat"
|
||||
)
|
||||
|
||||
// Join a chat room
|
||||
func main() {
|
||||
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
||||
stream, err := chatService.Join(&chat.JoinRequest{})
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
for {
|
||||
rsp, err := stream.Recv()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println(rsp)
|
||||
}
|
||||
}
|
||||
15
examples/chat/kick/kickAUserFromARoom/main.go
Executable file
15
examples/chat/kick/kickAUserFromARoom/main.go
Executable file
@@ -0,0 +1,15 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/chat"
|
||||
)
|
||||
|
||||
// Kick a user from a chat room
|
||||
func main() {
|
||||
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := chatService.Kick(&chat.KickRequest{})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
15
examples/chat/leave/leaveARoom/main.go
Executable file
15
examples/chat/leave/leaveARoom/main.go
Executable file
@@ -0,0 +1,15 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/chat"
|
||||
)
|
||||
|
||||
// Leave a chat room
|
||||
func main() {
|
||||
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := chatService.Leave(&chat.LeaveRequest{})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
15
examples/chat/list/listChatRooms/main.go
Executable file
15
examples/chat/list/listChatRooms/main.go
Executable file
@@ -0,0 +1,15 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/chat"
|
||||
)
|
||||
|
||||
// List available chats
|
||||
func main() {
|
||||
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := chatService.List(&chat.ListRequest{})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
20
examples/chat/send/sendAMessage/main.go
Executable file
20
examples/chat/send/sendAMessage/main.go
Executable file
@@ -0,0 +1,20 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/chat"
|
||||
)
|
||||
|
||||
// Connect to a chat to receive a stream of messages
|
||||
// Send a message to a chat
|
||||
func main() {
|
||||
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := chatService.Send(&chat.SendRequest{
|
||||
Client: "web",
|
||||
Subject: "Random",
|
||||
Text: "Hey whats up?",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
190
examples/comments/README.md
Executable file
190
examples/comments/README.md
Executable file
@@ -0,0 +1,190 @@
|
||||
# Comments
|
||||
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/comments/api](https://m3o.com/comments/api).
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Create
|
||||
|
||||
Create a new comment
|
||||
|
||||
|
||||
[https://m3o.com/comments/api#Create](https://m3o.com/comments/api#Create)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/comments"
|
||||
)
|
||||
|
||||
// Create a new comment
|
||||
func CreateAcomment() {
|
||||
commentsService := comments.NewCommentsService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := commentsService.Create(&comments.CreateRequest{
|
||||
Text: "This is my comment",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Read
|
||||
|
||||
Read a comment
|
||||
|
||||
|
||||
[https://m3o.com/comments/api#Read](https://m3o.com/comments/api#Read)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/comments"
|
||||
)
|
||||
|
||||
// Read a comment
|
||||
func ReadAcomment() {
|
||||
commentsService := comments.NewCommentsService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := commentsService.Read(&comments.ReadRequest{
|
||||
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## List
|
||||
|
||||
List all the comments
|
||||
|
||||
|
||||
[https://m3o.com/comments/api#List](https://m3o.com/comments/api#List)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/comments"
|
||||
)
|
||||
|
||||
// List all the comments
|
||||
func ListAllComments() {
|
||||
commentsService := comments.NewCommentsService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := commentsService.List(&comments.ListRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Update
|
||||
|
||||
Update a comment
|
||||
|
||||
|
||||
[https://m3o.com/comments/api#Update](https://m3o.com/comments/api#Update)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/comments"
|
||||
)
|
||||
|
||||
// Update a comment
|
||||
func UpdateAcomment() {
|
||||
commentsService := comments.NewCommentsService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := commentsService.Update(&comments.UpdateRequest{
|
||||
Comment: &comments.Comment{
|
||||
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
|
||||
Subject: "Update Comment",
|
||||
Text: "Updated comment text",
|
||||
},
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Delete
|
||||
|
||||
Delete a comment
|
||||
|
||||
|
||||
[https://m3o.com/comments/api#Delete](https://m3o.com/comments/api#Delete)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/comments"
|
||||
)
|
||||
|
||||
// Delete a comment
|
||||
func DeleteAcomment() {
|
||||
commentsService := comments.NewCommentsService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := commentsService.Delete(&comments.DeleteRequest{
|
||||
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Events
|
||||
|
||||
Subscribe to comments events
|
||||
|
||||
|
||||
[https://m3o.com/comments/api#Events](https://m3o.com/comments/api#Events)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/comments"
|
||||
)
|
||||
|
||||
// Subscribe to comments events
|
||||
func SubscribeToEvents() {
|
||||
commentsService := comments.NewCommentsService(os.Getenv("M3O_API_TOKEN"))
|
||||
|
||||
stream, err := commentsService.Events(&comments.EventsRequest{
|
||||
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
|
||||
|
||||
})
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
for {
|
||||
rsp, err := stream.Recv()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println(rsp)
|
||||
}
|
||||
}
|
||||
```
|
||||
17
examples/comments/create/createAComment/main.go
Executable file
17
examples/comments/create/createAComment/main.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/comments"
|
||||
)
|
||||
|
||||
// Create a new comment
|
||||
func main() {
|
||||
commentsService := comments.NewCommentsService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := commentsService.Create(&comments.CreateRequest{
|
||||
Text: "This is my comment",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
17
examples/comments/delete/deleteAComment/main.go
Executable file
17
examples/comments/delete/deleteAComment/main.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/comments"
|
||||
)
|
||||
|
||||
// Delete a comment
|
||||
func main() {
|
||||
commentsService := comments.NewCommentsService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := commentsService.Delete(&comments.DeleteRequest{
|
||||
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
30
examples/comments/events/subscribeToEvents/main.go
Executable file
30
examples/comments/events/subscribeToEvents/main.go
Executable file
@@ -0,0 +1,30 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/comments"
|
||||
)
|
||||
|
||||
// Subscribe to comments events
|
||||
func main() {
|
||||
commentsService := comments.NewCommentsService(os.Getenv("M3O_API_TOKEN"))
|
||||
stream, err := commentsService.Events(&comments.EventsRequest{
|
||||
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
|
||||
})
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
for {
|
||||
rsp, err := stream.Recv()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println(rsp)
|
||||
}
|
||||
}
|
||||
15
examples/comments/list/listAllComments/main.go
Executable file
15
examples/comments/list/listAllComments/main.go
Executable file
@@ -0,0 +1,15 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/comments"
|
||||
)
|
||||
|
||||
// List all the comments
|
||||
func main() {
|
||||
commentsService := comments.NewCommentsService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := commentsService.List(&comments.ListRequest{})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
17
examples/comments/read/readAComment/main.go
Executable file
17
examples/comments/read/readAComment/main.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/comments"
|
||||
)
|
||||
|
||||
// Read a comment
|
||||
func main() {
|
||||
commentsService := comments.NewCommentsService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := commentsService.Read(&comments.ReadRequest{
|
||||
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
21
examples/comments/update/updateAComment/main.go
Executable file
21
examples/comments/update/updateAComment/main.go
Executable file
@@ -0,0 +1,21 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/comments"
|
||||
)
|
||||
|
||||
// Update a comment
|
||||
func main() {
|
||||
commentsService := comments.NewCommentsService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := commentsService.Update(&comments.UpdateRequest{
|
||||
Comment: &comments.Comment{
|
||||
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
|
||||
Subject: "Update Comment",
|
||||
Text: "Updated comment text",
|
||||
},
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
219
examples/contact/README.md
Executable file
219
examples/contact/README.md
Executable file
@@ -0,0 +1,219 @@
|
||||
# Contact
|
||||
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/contact/api](https://m3o.com/contact/api).
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Delete
|
||||
|
||||
Delete a contact
|
||||
|
||||
|
||||
[https://m3o.com/contact/api#Delete](https://m3o.com/contact/api#Delete)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/contact"
|
||||
)
|
||||
|
||||
// Delete a contact
|
||||
func DeleteAcontact() {
|
||||
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := contactService.Delete(&contact.DeleteRequest{
|
||||
Id: "42e48a3c-6221-11ec-96d2-acde48001122",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## List
|
||||
|
||||
List contacts
|
||||
|
||||
|
||||
[https://m3o.com/contact/api#List](https://m3o.com/contact/api#List)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/contact"
|
||||
)
|
||||
|
||||
// List contacts
|
||||
func ListContactsWithDefaultOffsetAndLimitDefaultLimitIs20() {
|
||||
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := contactService.List(&contact.ListRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## List
|
||||
|
||||
List contacts
|
||||
|
||||
|
||||
[https://m3o.com/contact/api#List](https://m3o.com/contact/api#List)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/contact"
|
||||
)
|
||||
|
||||
// List contacts
|
||||
func ListContactsWithSpecificOffsetAndLimit() {
|
||||
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := contactService.List(&contact.ListRequest{
|
||||
Limit: 1,
|
||||
Offset: 1,
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Create
|
||||
|
||||
Create a contact
|
||||
|
||||
|
||||
[https://m3o.com/contact/api#Create](https://m3o.com/contact/api#Create)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/contact"
|
||||
)
|
||||
|
||||
// Create a contact
|
||||
func CreateAcontact() {
|
||||
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := contactService.Create(&contact.CreateRequest{
|
||||
Addresses: []contact.Address{
|
||||
contact.Address{
|
||||
Label: "company address",
|
||||
Location: "123 street address",
|
||||
}},
|
||||
Birthday: "1995-01-01",
|
||||
Emails: []contact.Email{
|
||||
contact.Email{
|
||||
Address: "home@example.com",
|
||||
Label: "home",
|
||||
}},
|
||||
Links: []contact.Link{
|
||||
contact.Link{
|
||||
Label: "blog",
|
||||
Url: "https://blog.joe.me",
|
||||
}},
|
||||
Name: "joe",
|
||||
Note: "this person is very important",
|
||||
Phones: []contact.Phone{
|
||||
contact.Phone{
|
||||
Label: "home",
|
||||
Number: "010-12345678",
|
||||
}},
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Update
|
||||
|
||||
Update a contact
|
||||
|
||||
|
||||
[https://m3o.com/contact/api#Update](https://m3o.com/contact/api#Update)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/contact"
|
||||
)
|
||||
|
||||
// Update a contact
|
||||
func UpdateAcontact() {
|
||||
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := contactService.Update(&contact.UpdateRequest{
|
||||
Addresses: []contact.Address{
|
||||
contact.Address{
|
||||
Label: "company address",
|
||||
Location: "123 street address",
|
||||
}},
|
||||
Birthday: "1995-01-01",
|
||||
Emails: []contact.Email{
|
||||
contact.Email{
|
||||
Address: "home@example.com",
|
||||
Label: "home",
|
||||
}},
|
||||
Id: "42e48a3c-6221-11ec-96d2-acde48001122",
|
||||
Links: []contact.Link{
|
||||
contact.Link{
|
||||
Label: "blog",
|
||||
Url: "https://blog.joe.me",
|
||||
}},
|
||||
Name: "joe",
|
||||
Note: "this person is very important",
|
||||
Phones: []contact.Phone{
|
||||
contact.Phone{
|
||||
Label: "home",
|
||||
Number: "010-12345678",
|
||||
}},
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Read
|
||||
|
||||
Read contact details
|
||||
|
||||
|
||||
[https://m3o.com/contact/api#Read](https://m3o.com/contact/api#Read)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/contact"
|
||||
)
|
||||
|
||||
// Read contact details
|
||||
func GetAcontact() {
|
||||
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := contactService.Read(&contact.ReadRequest{
|
||||
Id: "42e48a3c-6221-11ec-96d2-acde48001122",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
39
examples/contact/create/createAContact/main.go
Executable file
39
examples/contact/create/createAContact/main.go
Executable file
@@ -0,0 +1,39 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/contact"
|
||||
)
|
||||
|
||||
// Create a contact
|
||||
func main() {
|
||||
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := contactService.Create(&contact.CreateRequest{
|
||||
Addresses: []contact.Address{
|
||||
contact.Address{
|
||||
Label: "company address",
|
||||
Location: "123 street address",
|
||||
}},
|
||||
Birthday: "1995-01-01",
|
||||
Emails: []contact.Email{
|
||||
contact.Email{
|
||||
Address: "home@example.com",
|
||||
Label: "home",
|
||||
}},
|
||||
Links: []contact.Link{
|
||||
contact.Link{
|
||||
Label: "blog",
|
||||
Url: "https://blog.joe.me",
|
||||
}},
|
||||
Name: "joe",
|
||||
Note: "this person is very important",
|
||||
Phones: []contact.Phone{
|
||||
contact.Phone{
|
||||
Label: "home",
|
||||
Number: "010-12345678",
|
||||
}},
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
17
examples/contact/delete/deleteAContact/main.go
Executable file
17
examples/contact/delete/deleteAContact/main.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/contact"
|
||||
)
|
||||
|
||||
// Delete a contact
|
||||
func main() {
|
||||
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := contactService.Delete(&contact.DeleteRequest{
|
||||
Id: "42e48a3c-6221-11ec-96d2-acde48001122",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/contact"
|
||||
)
|
||||
|
||||
// List contacts
|
||||
func main() {
|
||||
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := contactService.List(&contact.ListRequest{})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
18
examples/contact/list/listContactsWithSpecificOffsetAndLimit/main.go
Executable file
18
examples/contact/list/listContactsWithSpecificOffsetAndLimit/main.go
Executable file
@@ -0,0 +1,18 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/contact"
|
||||
)
|
||||
|
||||
// List contacts
|
||||
func main() {
|
||||
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := contactService.List(&contact.ListRequest{
|
||||
Limit: 1,
|
||||
Offset: 1,
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
17
examples/contact/read/getAContact/main.go
Executable file
17
examples/contact/read/getAContact/main.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/contact"
|
||||
)
|
||||
|
||||
// Read contact details
|
||||
func main() {
|
||||
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := contactService.Read(&contact.ReadRequest{
|
||||
Id: "42e48a3c-6221-11ec-96d2-acde48001122",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
40
examples/contact/update/updateAContact/main.go
Executable file
40
examples/contact/update/updateAContact/main.go
Executable file
@@ -0,0 +1,40 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/contact"
|
||||
)
|
||||
|
||||
// Update a contact
|
||||
func main() {
|
||||
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := contactService.Update(&contact.UpdateRequest{
|
||||
Addresses: []contact.Address{
|
||||
contact.Address{
|
||||
Label: "company address",
|
||||
Location: "123 street address",
|
||||
}},
|
||||
Birthday: "1995-01-01",
|
||||
Emails: []contact.Email{
|
||||
contact.Email{
|
||||
Address: "home@example.com",
|
||||
Label: "home",
|
||||
}},
|
||||
Id: "42e48a3c-6221-11ec-96d2-acde48001122",
|
||||
Links: []contact.Link{
|
||||
contact.Link{
|
||||
Label: "blog",
|
||||
Url: "https://blog.joe.me",
|
||||
}},
|
||||
Name: "joe",
|
||||
Note: "this person is very important",
|
||||
Phones: []contact.Phone{
|
||||
contact.Phone{
|
||||
Label: "home",
|
||||
Number: "010-12345678",
|
||||
}},
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
# Crypto
|
||||
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Crypto/api](https://m3o.com/Crypto/api).
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/crypto/api](https://m3o.com/crypto/api).
|
||||
|
||||
Endpoints:
|
||||
|
||||
@@ -116,3 +116,30 @@ func GetPreviousClose() {
|
||||
|
||||
}
|
||||
```
|
||||
## Symbols
|
||||
|
||||
Returns the full list of supported symbols
|
||||
|
||||
|
||||
[https://m3o.com/crypto/api#Symbols](https://m3o.com/crypto/api#Symbols)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/crypto"
|
||||
)
|
||||
|
||||
// Returns the full list of supported symbols
|
||||
func GetListOfAllSupportedSymbols() {
|
||||
cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := cryptoService.Symbols(&crypto.SymbolsRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
15
examples/crypto/symbols/getListOfAllSupportedSymbols/main.go
Executable file
15
examples/crypto/symbols/getListOfAllSupportedSymbols/main.go
Executable file
@@ -0,0 +1,15 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/crypto"
|
||||
)
|
||||
|
||||
// Returns the full list of supported symbols
|
||||
func main() {
|
||||
cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := cryptoService.Symbols(&crypto.SymbolsRequest{})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
@@ -1,38 +1,9 @@
|
||||
# Currency
|
||||
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Currency/api](https://m3o.com/Currency/api).
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/currency/api](https://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
|
||||
@@ -147,3 +118,32 @@ To: "GBP",
|
||||
|
||||
}
|
||||
```
|
||||
## 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)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -1,178 +1,9 @@
|
||||
# Db
|
||||
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Db/api](https://m3o.com/Db/api).
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/db/api](https://m3o.com/db/api).
|
||||
|
||||
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
|
||||
|
||||
|
||||
[https://m3o.com/db/api#Truncate](https://m3o.com/db/api#Truncate)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/db"
|
||||
)
|
||||
|
||||
// Truncate the records in a table
|
||||
func TruncateTable() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.Truncate(&db.TruncateRequest{
|
||||
Table: "example",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Count
|
||||
|
||||
Count records in a table
|
||||
|
||||
|
||||
[https://m3o.com/db/api#Count](https://m3o.com/db/api#Count)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/db"
|
||||
)
|
||||
|
||||
// Count records in a table
|
||||
func CountEntriesInAtable() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.Count(&db.CountRequest{
|
||||
Table: "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
|
||||
|
||||
Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
|
||||
@@ -268,3 +99,172 @@ Table: "example",
|
||||
|
||||
}
|
||||
```
|
||||
## Count
|
||||
|
||||
Count records in a table
|
||||
|
||||
|
||||
[https://m3o.com/db/api#Count](https://m3o.com/db/api#Count)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/db"
|
||||
)
|
||||
|
||||
// Count records in a table
|
||||
func CountEntriesInAtable() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.Count(&db.CountRequest{
|
||||
Table: "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: "example",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Truncate
|
||||
|
||||
Truncate the records in a table
|
||||
|
||||
|
||||
[https://m3o.com/db/api#Truncate](https://m3o.com/db/api#Truncate)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/db"
|
||||
)
|
||||
|
||||
// Truncate the records in a table
|
||||
func TruncateTable() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.Truncate(&db.TruncateRequest{
|
||||
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)
|
||||
|
||||
}
|
||||
```
|
||||
## ListTables
|
||||
|
||||
List tables in the DB
|
||||
|
||||
|
||||
[https://m3o.com/db/api#ListTables](https://m3o.com/db/api#ListTables)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/db"
|
||||
)
|
||||
|
||||
// List tables in the DB
|
||||
func ListTables() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.ListTables(&db.ListTablesRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## RenameTable
|
||||
|
||||
Rename a table
|
||||
|
||||
|
||||
[https://m3o.com/db/api#RenameTable](https://m3o.com/db/api#RenameTable)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/db"
|
||||
)
|
||||
|
||||
// Rename a table
|
||||
func RenameTable() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.RenameTable(&db.RenameTableRequest{
|
||||
From: "examples2",
|
||||
To: "examples3",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -12,8 +12,8 @@ func main() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.Update(&db.UpdateRequest{
|
||||
Record: map[string]interface{}{
|
||||
"id": "1",
|
||||
"age": 43,
|
||||
"id": "1",
|
||||
},
|
||||
Table: "example",
|
||||
})
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Email
|
||||
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Email/api](https://m3o.com/Email/api).
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/email/api](https://m3o.com/email/api).
|
||||
|
||||
Endpoints:
|
||||
|
||||
@@ -36,3 +36,59 @@ Please verify your email by clicking this link: $micro_verification_link`,
|
||||
|
||||
}
|
||||
```
|
||||
## Parse
|
||||
|
||||
Parse an RFC5322 address e.g "Joe Blogs <joe@example.com>"
|
||||
|
||||
|
||||
[https://m3o.com/email/api#Parse](https://m3o.com/email/api#Parse)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/email"
|
||||
)
|
||||
|
||||
// Parse an RFC5322 address e.g "Joe Blogs <joe@example.com>"
|
||||
func ParseEmail() {
|
||||
emailService := email.NewEmailService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := emailService.Parse(&email.ParseRequest{
|
||||
Address: "Joe Blogs <joe@example.com>",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Validate
|
||||
|
||||
Validate an email address format
|
||||
|
||||
|
||||
[https://m3o.com/email/api#Validate](https://m3o.com/email/api#Validate)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/email"
|
||||
)
|
||||
|
||||
// Validate an email address format
|
||||
func ValidateEmail() {
|
||||
emailService := email.NewEmailService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := emailService.Validate(&email.ValidateRequest{
|
||||
Address: "joe@example.com",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
17
examples/email/parse/parseEmail/main.go
Executable file
17
examples/email/parse/parseEmail/main.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/email"
|
||||
)
|
||||
|
||||
// Parse an RFC5322 address e.g "Joe Blogs <joe@example.com>"
|
||||
func main() {
|
||||
emailService := email.NewEmailService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := emailService.Parse(&email.ParseRequest{
|
||||
Address: "Joe Blogs <joe@example.com>",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
17
examples/email/validate/validateEmail/main.go
Executable file
17
examples/email/validate/validateEmail/main.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/email"
|
||||
)
|
||||
|
||||
// Validate an email address format
|
||||
func main() {
|
||||
emailService := email.NewEmailService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := emailService.Validate(&email.ValidateRequest{
|
||||
Address: "joe@example.com",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
# Emoji
|
||||
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Emoji/api](https://m3o.com/Emoji/api).
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/emoji/api](https://m3o.com/emoji/api).
|
||||
|
||||
Endpoints:
|
||||
|
||||
@@ -89,33 +89,3 @@ func PrintTextIncludingEmoji() {
|
||||
|
||||
}
|
||||
```
|
||||
## Send
|
||||
|
||||
Send an emoji to anyone via SMS. Messages are sent in the form '<message> Sent from <from>'
|
||||
|
||||
|
||||
[https://m3o.com/emoji/api#Send](https://m3o.com/emoji/api#Send)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/emoji"
|
||||
)
|
||||
|
||||
// Send an emoji to anyone via SMS. Messages are sent in the form '<message> Sent from <from>'
|
||||
func SendAtextContainingAnEmojiToAnyoneViaSms() {
|
||||
emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := emojiService.Send(&emoji.SendRequest{
|
||||
From: "Alice",
|
||||
Message: "let's grab a :beer:",
|
||||
To: "+44782669123",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/emoji"
|
||||
)
|
||||
|
||||
// Send an emoji to anyone via SMS. Messages are sent in the form '<message> Sent from <from>'
|
||||
func SendAtextContainingAnEmojiToAnyoneViaSms() {
|
||||
emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := emojiService.Send(&emoji.SendRequest{
|
||||
From: "Alice",
|
||||
Message: "let's grab a :beer:",
|
||||
To: "+44782669123",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
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)
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
# Evchargers
|
||||
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Evchargers/api](https://m3o.com/Evchargers/api).
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/evchargers/api](https://m3o.com/evchargers/api).
|
||||
|
||||
Endpoints:
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Event
|
||||
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Event/api](https://m3o.com/Event/api).
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/event/api](https://m3o.com/event/api).
|
||||
|
||||
Endpoints:
|
||||
|
||||
|
||||
@@ -12,9 +12,9 @@ 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",
|
||||
"user": "john",
|
||||
},
|
||||
Topic: "user",
|
||||
})
|
||||
|
||||
@@ -1,67 +1,9 @@
|
||||
# File
|
||||
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/File/api](https://m3o.com/File/api).
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/file/api](https://m3o.com/file/api).
|
||||
|
||||
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
|
||||
@@ -122,3 +64,61 @@ func ListFiles() {
|
||||
|
||||
}
|
||||
```
|
||||
## 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)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Forex
|
||||
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Forex/api](https://m3o.com/Forex/api).
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/forex/api](https://m3o.com/forex/api).
|
||||
|
||||
Endpoints:
|
||||
|
||||
|
||||
@@ -1,9 +1,37 @@
|
||||
# Function
|
||||
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Function/api](https://m3o.com/Function/api).
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/function/api](https://m3o.com/function/api).
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Proxy
|
||||
|
||||
Return the backend url for proxying
|
||||
|
||||
|
||||
[https://m3o.com/function/api#Proxy](https://m3o.com/function/api#Proxy)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/function"
|
||||
)
|
||||
|
||||
// Return the backend url for proxying
|
||||
func ProxyUrl() {
|
||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := functionService.Proxy(&function.ProxyRequest{
|
||||
Id: "helloworld",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Deploy
|
||||
|
||||
Deploy a group of functions
|
||||
@@ -25,98 +53,13 @@ import(
|
||||
func DeployAfunction() {
|
||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := functionService.Deploy(&function.DeployRequest{
|
||||
Entrypoint: "helloworld",
|
||||
Branch: "main",
|
||||
Entrypoint: "Helloworld",
|
||||
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
|
||||
|
||||
Call a function by name
|
||||
|
||||
|
||||
[https://m3o.com/function/api#Call](https://m3o.com/function/api#Call)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/function"
|
||||
)
|
||||
|
||||
// Call a function by name
|
||||
func CallAfunction() {
|
||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := functionService.Call(&function.CallRequest{
|
||||
Name: "helloworld",
|
||||
Request: map[string]interface{}{
|
||||
},
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## List
|
||||
|
||||
List all the deployed functions
|
||||
|
||||
|
||||
[https://m3o.com/function/api#List](https://m3o.com/function/api#List)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/function"
|
||||
)
|
||||
|
||||
// List all the deployed functions
|
||||
func ListFunctions() {
|
||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := functionService.List(&function.ListRequest{
|
||||
Region: "europe-west1",
|
||||
Repo: "https://github.com/m3o/m3o",
|
||||
Runtime: "go116",
|
||||
Subfolder: "examples/go-function",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
@@ -149,6 +92,174 @@ func DeleteAfunction() {
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Reserve
|
||||
|
||||
Reserve function names and resources beyond free quota
|
||||
|
||||
|
||||
[https://m3o.com/function/api#Reserve](https://m3o.com/function/api#Reserve)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/function"
|
||||
)
|
||||
|
||||
// Reserve function names and resources beyond free quota
|
||||
func ReserveAfunction() {
|
||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := functionService.Reserve(&function.ReserveRequest{
|
||||
Name: "helloworld",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Runtimes
|
||||
|
||||
Return a list of supported runtimes
|
||||
|
||||
|
||||
[https://m3o.com/function/api#Runtimes](https://m3o.com/function/api#Runtimes)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/function"
|
||||
)
|
||||
|
||||
// Return a list of supported runtimes
|
||||
func ListRuntimes() {
|
||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := functionService.Runtimes(&function.RuntimesRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Regions
|
||||
|
||||
Return a list of supported regions
|
||||
|
||||
|
||||
[https://m3o.com/function/api#Regions](https://m3o.com/function/api#Regions)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/function"
|
||||
)
|
||||
|
||||
// Return a list of supported regions
|
||||
func ListRegions() {
|
||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := functionService.Regions(&function.RegionsRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Update
|
||||
|
||||
Update a function. Downloads the source, builds and redeploys
|
||||
|
||||
|
||||
[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. Downloads the source, builds and redeploys
|
||||
func UpdateAfunction() {
|
||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := functionService.Update(&function.UpdateRequest{
|
||||
Name: "helloworld",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Call
|
||||
|
||||
Call a function by name
|
||||
|
||||
|
||||
[https://m3o.com/function/api#Call](https://m3o.com/function/api#Call)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/function"
|
||||
)
|
||||
|
||||
// Call a function by name
|
||||
func CallAfunction() {
|
||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := functionService.Call(&function.CallRequest{
|
||||
Name: "helloworld",
|
||||
Request: map[string]interface{}{
|
||||
"name": "Alice",
|
||||
},
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## List
|
||||
|
||||
List all the deployed functions
|
||||
|
||||
|
||||
[https://m3o.com/function/api#List](https://m3o.com/function/api#List)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/function"
|
||||
)
|
||||
|
||||
// List all the deployed functions
|
||||
func ListFunctions() {
|
||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := functionService.List(&function.ListRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Describe
|
||||
|
||||
@@ -12,7 +12,9 @@ func main() {
|
||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := functionService.Call(&function.CallRequest{
|
||||
Name: "helloworld",
|
||||
Request: map[string]interface{}{},
|
||||
Request: map[string]interface{}{
|
||||
"name": "Alice",
|
||||
},
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ func DeleteAfunction() {
|
||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := functionService.Delete(&function.DeleteRequest{
|
||||
Name: "my-first-func",
|
||||
Project: "tests",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ func DeployAfunction() {
|
||||
rsp, err := functionService.Deploy(&function.DeployRequest{
|
||||
Entrypoint: "helloworld",
|
||||
Name: "my-first-func",
|
||||
Project: "tests",
|
||||
Repo: "github.com/m3o/nodejs-function-example",
|
||||
Runtime: "nodejs14",
|
||||
})
|
||||
|
||||
@@ -11,10 +11,13 @@ import (
|
||||
func main() {
|
||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := functionService.Deploy(&function.DeployRequest{
|
||||
Entrypoint: "helloworld",
|
||||
Branch: "main",
|
||||
Entrypoint: "Helloworld",
|
||||
Name: "helloworld",
|
||||
Repo: "github.com/m3o/nodejs-function-example",
|
||||
Runtime: "nodejs14",
|
||||
Region: "europe-west1",
|
||||
Repo: "https://github.com/m3o/m3o",
|
||||
Runtime: "go116",
|
||||
Subfolder: "examples/go-function",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ func DescribeFunctionStatus() {
|
||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := functionService.Describe(&function.DescribeRequest{
|
||||
Name: "my-first-func",
|
||||
Project: "tests",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
|
||||
17
examples/function/proxy/proxyUrl/main.go
Executable file
17
examples/function/proxy/proxyUrl/main.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/function"
|
||||
)
|
||||
|
||||
// Return the backend url for proxying
|
||||
func main() {
|
||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := functionService.Proxy(&function.ProxyRequest{
|
||||
Id: "helloworld",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
15
examples/function/regions/listRegions/main.go
Executable file
15
examples/function/regions/listRegions/main.go
Executable file
@@ -0,0 +1,15 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/function"
|
||||
)
|
||||
|
||||
// Return a list of supported regions
|
||||
func main() {
|
||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := functionService.Regions(&function.RegionsRequest{})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
17
examples/function/reserve/reserveAFunction/main.go
Executable file
17
examples/function/reserve/reserveAFunction/main.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/function"
|
||||
)
|
||||
|
||||
// Reserve function names and resources beyond free quota
|
||||
func main() {
|
||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := functionService.Reserve(&function.ReserveRequest{
|
||||
Name: "helloworld",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
15
examples/function/runtimes/listRuntimes/main.go
Executable file
15
examples/function/runtimes/listRuntimes/main.go
Executable file
@@ -0,0 +1,15 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/function"
|
||||
)
|
||||
|
||||
// Return a list of supported runtimes
|
||||
func main() {
|
||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := functionService.Runtimes(&function.RuntimesRequest{})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
@@ -7,14 +7,11 @@ import (
|
||||
"go.m3o.com/function"
|
||||
)
|
||||
|
||||
// Update a function
|
||||
// Update a function. Downloads the source, builds and redeploys
|
||||
func main() {
|
||||
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)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Geocoding
|
||||
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Geocoding/api](https://m3o.com/Geocoding/api).
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/geocoding/api](https://m3o.com/geocoding/api).
|
||||
|
||||
Endpoints:
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Gifs
|
||||
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Gifs/api](https://m3o.com/Gifs/api).
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/gifs/api](https://m3o.com/gifs/api).
|
||||
|
||||
Endpoints:
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Google
|
||||
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Google/api](https://m3o.com/Google/api).
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/google/api](https://m3o.com/google/api).
|
||||
|
||||
Endpoints:
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Helloworld
|
||||
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Helloworld/api](https://m3o.com/Helloworld/api).
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/helloworld/api](https://m3o.com/helloworld/api).
|
||||
|
||||
Endpoints:
|
||||
|
||||
@@ -22,7 +22,7 @@ import(
|
||||
)
|
||||
|
||||
// Call returns a personalised "Hello $name" response
|
||||
func CallTheHelloworldService() {
|
||||
func CallHelloworld() {
|
||||
helloworldService := helloworld.NewHelloworldService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := helloworldService.Call(&helloworld.CallRequest{
|
||||
Name: "John",
|
||||
@@ -50,7 +50,7 @@ import(
|
||||
)
|
||||
|
||||
// Stream returns a stream of "Hello $name" responses
|
||||
func StreamsResponsesFromTheServerUsingWebsockets() {
|
||||
func StreamHelloworld() {
|
||||
helloworldService := helloworld.NewHelloworldService(os.Getenv("M3O_API_TOKEN"))
|
||||
|
||||
stream, err := helloworldService.Stream(&helloworld.StreamRequest{
|
||||
|
||||
0
examples/helloworld/call/callHelloworld/.run
Executable file
0
examples/helloworld/call/callHelloworld/.run
Executable file
17
examples/helloworld/call/callHelloworld/main.go
Executable file
17
examples/helloworld/call/callHelloworld/main.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/helloworld"
|
||||
)
|
||||
|
||||
// Call returns a personalised "Hello $name" response
|
||||
func main() {
|
||||
helloworldService := helloworld.NewHelloworldService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := helloworldService.Call(&helloworld.CallRequest{
|
||||
Name: "John",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
0
examples/helloworld/stream/streamHelloworld/.run
Executable file
0
examples/helloworld/stream/streamHelloworld/.run
Executable file
31
examples/helloworld/stream/streamHelloworld/main.go
Executable file
31
examples/helloworld/stream/streamHelloworld/main.go
Executable file
@@ -0,0 +1,31 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/helloworld"
|
||||
)
|
||||
|
||||
// Stream returns a stream of "Hello $name" responses
|
||||
func main() {
|
||||
helloworldService := helloworld.NewHelloworldService(os.Getenv("M3O_API_TOKEN"))
|
||||
stream, err := helloworldService.Stream(&helloworld.StreamRequest{
|
||||
Messages: 10,
|
||||
Name: "John",
|
||||
})
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
for {
|
||||
rsp, err := stream.Recv()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println(rsp)
|
||||
}
|
||||
}
|
||||
@@ -1,36 +1,9 @@
|
||||
# Holidays
|
||||
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Holidays/api](https://m3o.com/Holidays/api).
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/holidays/api](https://m3o.com/holidays/api).
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Countries
|
||||
|
||||
Get the list of countries that are supported by this API
|
||||
|
||||
|
||||
[https://m3o.com/holidays/api#Countries](https://m3o.com/holidays/api#Countries)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/holidays"
|
||||
)
|
||||
|
||||
// Get the list of countries that are supported by this API
|
||||
func ListCountries() {
|
||||
holidaysService := holidays.NewHolidaysService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := holidaysService.Countries(&holidays.CountriesRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## List
|
||||
|
||||
List the holiday dates for a given country and year
|
||||
@@ -59,3 +32,30 @@ func GetHolidays() {
|
||||
|
||||
}
|
||||
```
|
||||
## Countries
|
||||
|
||||
Get the list of countries that are supported by this API
|
||||
|
||||
|
||||
[https://m3o.com/holidays/api#Countries](https://m3o.com/holidays/api#Countries)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/holidays"
|
||||
)
|
||||
|
||||
// Get the list of countries that are supported by this API
|
||||
func ListCountries() {
|
||||
holidaysService := holidays.NewHolidaysService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := holidaysService.Countries(&holidays.CountriesRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -1,36 +1,9 @@
|
||||
# Id
|
||||
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Id/api](https://m3o.com/Id/api).
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/id/api](https://m3o.com/id/api).
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Types
|
||||
|
||||
List the types of IDs available. No query params needed.
|
||||
|
||||
|
||||
[https://m3o.com/id/api#Types](https://m3o.com/id/api#Types)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/id"
|
||||
)
|
||||
|
||||
// List the types of IDs available. No query params needed.
|
||||
func ListTheTypesOfIdsAvailable() {
|
||||
idService := id.NewIdService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := idService.Types(&id.TypesRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Generate
|
||||
|
||||
Generate a unique ID. Defaults to uuid.
|
||||
@@ -143,3 +116,30 @@ func GenerateAbigflakeId() {
|
||||
|
||||
}
|
||||
```
|
||||
## Types
|
||||
|
||||
List the types of IDs available. No query params needed.
|
||||
|
||||
|
||||
[https://m3o.com/id/api#Types](https://m3o.com/id/api#Types)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/id"
|
||||
)
|
||||
|
||||
// List the types of IDs available. No query params needed.
|
||||
func ListTheTypesOfIdsAvailable() {
|
||||
idService := id.NewIdService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := idService.Types(&id.TypesRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -1,37 +1,9 @@
|
||||
# Image
|
||||
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Image/api](https://m3o.com/Image/api).
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/image/api](https://m3o.com/image/api).
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Delete
|
||||
|
||||
Delete an image previously uploaded.
|
||||
|
||||
|
||||
[https://m3o.com/image/api#Delete](https://m3o.com/image/api#Delete)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/image"
|
||||
)
|
||||
|
||||
// Delete an image previously uploaded.
|
||||
func DeleteAnUploadedImage() {
|
||||
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := imageService.Delete(&image.DeleteRequest{
|
||||
Url: "https://cdn.m3ocontent.com/micro/images/micro/41e23b39-48dd-42b6-9738-79a313414bb8/cat.png",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Resize
|
||||
|
||||
Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters.
|
||||
@@ -256,3 +228,31 @@ Url: "somewebsite.com/cat.png",
|
||||
|
||||
}
|
||||
```
|
||||
## Delete
|
||||
|
||||
Delete an image previously uploaded.
|
||||
|
||||
|
||||
[https://m3o.com/image/api#Delete](https://m3o.com/image/api#Delete)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/image"
|
||||
)
|
||||
|
||||
// Delete an image previously uploaded.
|
||||
func DeleteAnUploadedImage() {
|
||||
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := imageService.Delete(&image.DeleteRequest{
|
||||
Url: "https://cdn.m3ocontent.com/micro/images/micro/41e23b39-48dd-42b6-9738-79a313414bb8/cat.png",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Ip
|
||||
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Ip/api](https://m3o.com/Ip/api).
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/ip/api](https://m3o.com/ip/api).
|
||||
|
||||
Endpoints:
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Joke
|
||||
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Joke/api](https://m3o.com/Joke/api).
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/joke/api](https://m3o.com/joke/api).
|
||||
|
||||
Endpoints:
|
||||
|
||||
|
||||
187
examples/lists/README.md
Executable file
187
examples/lists/README.md
Executable file
@@ -0,0 +1,187 @@
|
||||
# Lists
|
||||
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/lists/api](https://m3o.com/lists/api).
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Create
|
||||
|
||||
Create a new list
|
||||
|
||||
|
||||
[https://m3o.com/lists/api#Create](https://m3o.com/lists/api#Create)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/lists"
|
||||
)
|
||||
|
||||
// Create a new list
|
||||
func CreateAlist() {
|
||||
listsService := lists.NewListsService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := listsService.Create(&lists.CreateRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Read
|
||||
|
||||
Read a list
|
||||
|
||||
|
||||
[https://m3o.com/lists/api#Read](https://m3o.com/lists/api#Read)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/lists"
|
||||
)
|
||||
|
||||
// Read a list
|
||||
func ReadAlist() {
|
||||
listsService := lists.NewListsService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := listsService.Read(&lists.ReadRequest{
|
||||
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## List
|
||||
|
||||
List all the lists
|
||||
|
||||
|
||||
[https://m3o.com/lists/api#List](https://m3o.com/lists/api#List)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/lists"
|
||||
)
|
||||
|
||||
// List all the lists
|
||||
func ListAllLists() {
|
||||
listsService := lists.NewListsService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := listsService.List(&lists.ListRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Update
|
||||
|
||||
Update a list
|
||||
|
||||
|
||||
[https://m3o.com/lists/api#Update](https://m3o.com/lists/api#Update)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/lists"
|
||||
)
|
||||
|
||||
// Update a list
|
||||
func UpdateAlist() {
|
||||
listsService := lists.NewListsService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := listsService.Update(&lists.UpdateRequest{
|
||||
List: &lists.List{
|
||||
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
|
||||
},
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Delete
|
||||
|
||||
Delete a list
|
||||
|
||||
|
||||
[https://m3o.com/lists/api#Delete](https://m3o.com/lists/api#Delete)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/lists"
|
||||
)
|
||||
|
||||
// Delete a list
|
||||
func DeleteAlist() {
|
||||
listsService := lists.NewListsService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := listsService.Delete(&lists.DeleteRequest{
|
||||
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Events
|
||||
|
||||
Subscribe to lists events
|
||||
|
||||
|
||||
[https://m3o.com/lists/api#Events](https://m3o.com/lists/api#Events)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/lists"
|
||||
)
|
||||
|
||||
// Subscribe to lists events
|
||||
func SubscribeToEvents() {
|
||||
listsService := lists.NewListsService(os.Getenv("M3O_API_TOKEN"))
|
||||
|
||||
stream, err := listsService.Events(&lists.EventsRequest{
|
||||
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
|
||||
|
||||
})
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
for {
|
||||
rsp, err := stream.Recv()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println(rsp)
|
||||
}
|
||||
}
|
||||
```
|
||||
15
examples/lists/create/createAList/main.go
Executable file
15
examples/lists/create/createAList/main.go
Executable file
@@ -0,0 +1,15 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/lists"
|
||||
)
|
||||
|
||||
// Create a new list
|
||||
func main() {
|
||||
listsService := lists.NewListsService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := listsService.Create(&lists.CreateRequest{})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
17
examples/lists/delete/deleteAList/main.go
Executable file
17
examples/lists/delete/deleteAList/main.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/lists"
|
||||
)
|
||||
|
||||
// Delete a list
|
||||
func main() {
|
||||
listsService := lists.NewListsService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := listsService.Delete(&lists.DeleteRequest{
|
||||
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
30
examples/lists/events/subscribeToEvents/main.go
Executable file
30
examples/lists/events/subscribeToEvents/main.go
Executable file
@@ -0,0 +1,30 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/lists"
|
||||
)
|
||||
|
||||
// Subscribe to lists events
|
||||
func main() {
|
||||
listsService := lists.NewListsService(os.Getenv("M3O_API_TOKEN"))
|
||||
stream, err := listsService.Events(&lists.EventsRequest{
|
||||
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
|
||||
})
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
for {
|
||||
rsp, err := stream.Recv()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println(rsp)
|
||||
}
|
||||
}
|
||||
15
examples/lists/list/listAllLists/main.go
Executable file
15
examples/lists/list/listAllLists/main.go
Executable file
@@ -0,0 +1,15 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/lists"
|
||||
)
|
||||
|
||||
// List all the lists
|
||||
func main() {
|
||||
listsService := lists.NewListsService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := listsService.List(&lists.ListRequest{})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
17
examples/lists/read/readAList/main.go
Executable file
17
examples/lists/read/readAList/main.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/lists"
|
||||
)
|
||||
|
||||
// Read a list
|
||||
func main() {
|
||||
listsService := lists.NewListsService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := listsService.Read(&lists.ReadRequest{
|
||||
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
19
examples/lists/update/updateAList/main.go
Executable file
19
examples/lists/update/updateAList/main.go
Executable file
@@ -0,0 +1,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/lists"
|
||||
)
|
||||
|
||||
// Update a list
|
||||
func main() {
|
||||
listsService := lists.NewListsService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := listsService.Update(&lists.UpdateRequest{
|
||||
List: &lists.List{
|
||||
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
|
||||
},
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
@@ -1,45 +1,9 @@
|
||||
# Location
|
||||
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Location/api](https://m3o.com/Location/api).
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/location/api](https://m3o.com/location/api).
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Save
|
||||
|
||||
Save an entity's current position
|
||||
|
||||
|
||||
[https://m3o.com/location/api#Save](https://m3o.com/location/api#Save)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/location"
|
||||
)
|
||||
|
||||
// Save an entity's current position
|
||||
func SaveAnEntity() {
|
||||
locationService := location.NewLocationService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := locationService.Save(&location.SaveRequest{
|
||||
Entity: &location.Entity{
|
||||
Id: "1",
|
||||
Location: &location.Point{
|
||||
Latitude: 51.511061,
|
||||
Longitude: -0.120022,
|
||||
Timestamp: 1622802761,
|
||||
},
|
||||
Type: "bike",
|
||||
},
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Read
|
||||
|
||||
Read an entity by its ID
|
||||
@@ -102,3 +66,39 @@ Type: "bike",
|
||||
|
||||
}
|
||||
```
|
||||
## Save
|
||||
|
||||
Save an entity's current position
|
||||
|
||||
|
||||
[https://m3o.com/location/api#Save](https://m3o.com/location/api#Save)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/location"
|
||||
)
|
||||
|
||||
// Save an entity's current position
|
||||
func SaveAnEntity() {
|
||||
locationService := location.NewLocationService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := locationService.Save(&location.SaveRequest{
|
||||
Entity: &location.Entity{
|
||||
Id: "1",
|
||||
Location: &location.Point{
|
||||
Latitude: 51.511061,
|
||||
Longitude: -0.120022,
|
||||
Timestamp: 1622802761,
|
||||
},
|
||||
Type: "bike",
|
||||
},
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user