mirror of
https://github.com/kevin-DL/m3o-go.git
synced 2026-01-24 07:25:35 +00:00
Compare commits
471 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 |
@@ -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)
|
# 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
|
This is the Go client to access APIs on the M3O Platform
|
||||||
|
|||||||
@@ -67,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) {
|
func (t *AppService) Run(request *RunRequest) (*RunResponse, error) {
|
||||||
|
|
||||||
rsp := &RunResponse{}
|
rsp := &RunResponse{}
|
||||||
@@ -150,7 +150,7 @@ type ResolveResponse struct {
|
|||||||
type RunRequest struct {
|
type RunRequest struct {
|
||||||
// branch. defaults to master
|
// branch. defaults to master
|
||||||
Branch string `json:"branch"`
|
Branch string `json:"branch"`
|
||||||
// associatede env vars to pass in
|
// associated env vars to pass in
|
||||||
EnvVars map[string]string `json:"env_vars"`
|
EnvVars map[string]string `json:"env_vars"`
|
||||||
// name of the app
|
// name of the app
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
@@ -205,6 +205,8 @@ type StatusResponse struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type UpdateRequest struct {
|
type UpdateRequest struct {
|
||||||
|
// Additional env vars to update
|
||||||
|
EnvVars map[string]string `json:"env_vars"`
|
||||||
// name of the app
|
// name of the app
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ type AvatarService struct {
|
|||||||
client *client.Client
|
client *client.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
// Generate an unique avatar
|
||||||
func (t *AvatarService) Generate(request *GenerateRequest) (*GenerateResponse, error) {
|
func (t *AvatarService) Generate(request *GenerateRequest) (*GenerateResponse, error) {
|
||||||
|
|
||||||
rsp := &GenerateResponse{}
|
rsp := &GenerateResponse{}
|
||||||
@@ -29,22 +29,21 @@ func (t *AvatarService) Generate(request *GenerateRequest) (*GenerateResponse, e
|
|||||||
}
|
}
|
||||||
|
|
||||||
type GenerateRequest struct {
|
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"`
|
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"`
|
Gender string `json:"gender"`
|
||||||
// if upload to m3o CDN, default is `false`
|
// set to true to upload to the M3O CDN and receive the url
|
||||||
// if update = true, then it'll return the CDN url
|
|
||||||
Upload bool `json:"upload"`
|
Upload bool `json:"upload"`
|
||||||
// avatar's username, unique username will generates the unique avatar;
|
// avatar's username, unique username will generate the unique avatar;
|
||||||
// if username == "", will generate a random avatar in every request
|
// if empty, every request generates a random avatar;
|
||||||
// if upload == true, username will be used as CDN filename rather than a random uuid string
|
// if upload == true, username will be the CDN filename rather than a random uuid string
|
||||||
Username string `json:"username"`
|
Username string `json:"username"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GenerateResponse struct {
|
type GenerateResponse struct {
|
||||||
// base64encode string of the avatar image
|
// base64 encoded string of the avatar image
|
||||||
Base64 string `json:"base64"`
|
Base64 string `json:"base64"`
|
||||||
// Micro's CDN url of the avatar image
|
// M3O's CDN url of the avatar image
|
||||||
Url string `json:"url"`
|
Url string `json:"url"`
|
||||||
}
|
}
|
||||||
|
|||||||
16
cache/cache.go
vendored
16
cache/cache.go
vendored
@@ -9,6 +9,7 @@ type Cache interface {
|
|||||||
Delete(*DeleteRequest) (*DeleteResponse, error)
|
Delete(*DeleteRequest) (*DeleteResponse, error)
|
||||||
Get(*GetRequest) (*GetResponse, error)
|
Get(*GetRequest) (*GetResponse, error)
|
||||||
Increment(*IncrementRequest) (*IncrementResponse, error)
|
Increment(*IncrementRequest) (*IncrementResponse, error)
|
||||||
|
ListKeys(*ListKeysRequest) (*ListKeysResponse, error)
|
||||||
Set(*SetRequest) (*SetResponse, error)
|
Set(*SetRequest) (*SetResponse, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,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.
|
// Set an item in the cache. Overwrites any existing value already set.
|
||||||
func (t *CacheService) Set(request *SetRequest) (*SetResponse, error) {
|
func (t *CacheService) Set(request *SetRequest) (*SetResponse, error) {
|
||||||
|
|
||||||
@@ -116,6 +125,13 @@ type IncrementResponse struct {
|
|||||||
Value int64 `json:"value,string"`
|
Value int64 `json:"value,string"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ListKeysRequest struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
type ListKeysResponse struct {
|
||||||
|
Keys []string `json:"keys"`
|
||||||
|
}
|
||||||
|
|
||||||
type SetRequest struct {
|
type SetRequest struct {
|
||||||
// The key to update
|
// The key to update
|
||||||
Key string `json:"key"`
|
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"`
|
||||||
|
}
|
||||||
@@ -24,7 +24,7 @@ type ContactService struct {
|
|||||||
client *client.Client
|
client *client.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
// Create a contact
|
||||||
func (t *ContactService) Create(request *CreateRequest) (*CreateResponse, error) {
|
func (t *ContactService) Create(request *CreateRequest) (*CreateResponse, error) {
|
||||||
|
|
||||||
rsp := &CreateResponse{}
|
rsp := &CreateResponse{}
|
||||||
@@ -32,7 +32,7 @@ func (t *ContactService) Create(request *CreateRequest) (*CreateResponse, error)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
// Delete a contact
|
||||||
func (t *ContactService) Delete(request *DeleteRequest) (*DeleteResponse, error) {
|
func (t *ContactService) Delete(request *DeleteRequest) (*DeleteResponse, error) {
|
||||||
|
|
||||||
rsp := &DeleteResponse{}
|
rsp := &DeleteResponse{}
|
||||||
@@ -40,7 +40,7 @@ func (t *ContactService) Delete(request *DeleteRequest) (*DeleteResponse, error)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
// List contacts
|
||||||
func (t *ContactService) List(request *ListRequest) (*ListResponse, error) {
|
func (t *ContactService) List(request *ListRequest) (*ListResponse, error) {
|
||||||
|
|
||||||
rsp := &ListResponse{}
|
rsp := &ListResponse{}
|
||||||
@@ -48,7 +48,7 @@ func (t *ContactService) List(request *ListRequest) (*ListResponse, error) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
// Read contact details
|
||||||
func (t *ContactService) Read(request *ReadRequest) (*ReadResponse, error) {
|
func (t *ContactService) Read(request *ReadRequest) (*ReadResponse, error) {
|
||||||
|
|
||||||
rsp := &ReadResponse{}
|
rsp := &ReadResponse{}
|
||||||
@@ -56,7 +56,7 @@ func (t *ContactService) Read(request *ReadRequest) (*ReadResponse, error) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
// Update a contact
|
||||||
func (t *ContactService) Update(request *UpdateRequest) (*UpdateResponse, error) {
|
func (t *ContactService) Update(request *UpdateRequest) (*UpdateResponse, error) {
|
||||||
|
|
||||||
rsp := &UpdateResponse{}
|
rsp := &UpdateResponse{}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ type Crypto interface {
|
|||||||
News(*NewsRequest) (*NewsResponse, error)
|
News(*NewsRequest) (*NewsResponse, error)
|
||||||
Price(*PriceRequest) (*PriceResponse, error)
|
Price(*PriceRequest) (*PriceResponse, error)
|
||||||
Quote(*QuoteRequest) (*QuoteResponse, error)
|
Quote(*QuoteRequest) (*QuoteResponse, error)
|
||||||
|
Symbols(*SymbolsRequest) (*SymbolsResponse, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewCryptoService(token string) *CryptoService {
|
func NewCryptoService(token string) *CryptoService {
|
||||||
@@ -55,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 {
|
type Article struct {
|
||||||
// the date published
|
// the date published
|
||||||
Date string `json:"date"`
|
Date string `json:"date"`
|
||||||
@@ -133,3 +142,15 @@ type QuoteResponse struct {
|
|||||||
// the UTC timestamp of the quote
|
// the UTC timestamp of the quote
|
||||||
Timestamp string `json:"timestamp"`
|
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"`
|
||||||
|
}
|
||||||
|
|||||||
@@ -5,7 +5,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Email interface {
|
type Email interface {
|
||||||
|
Parse(*ParseRequest) (*ParseResponse, error)
|
||||||
Send(*SendRequest) (*SendResponse, error)
|
Send(*SendRequest) (*SendResponse, error)
|
||||||
|
Validate(*ValidateRequest) (*ValidateResponse, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewEmailService(token string) *EmailService {
|
func NewEmailService(token string) *EmailService {
|
||||||
@@ -20,6 +22,14 @@ type EmailService struct {
|
|||||||
client *client.Client
|
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
|
// Send an email by passing in from, to, subject, and a text or html body
|
||||||
func (t *EmailService) Send(request *SendRequest) (*SendResponse, error) {
|
func (t *EmailService) Send(request *SendRequest) (*SendResponse, error) {
|
||||||
|
|
||||||
@@ -28,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 {
|
type SendRequest struct {
|
||||||
// the display name of the sender
|
// the display name of the sender
|
||||||
From string `json:"from"`
|
From string `json:"from"`
|
||||||
@@ -45,3 +75,11 @@ type SendRequest struct {
|
|||||||
|
|
||||||
type SendResponse struct {
|
type SendResponse struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ValidateRequest struct {
|
||||||
|
Address string `json:"address"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ValidateResponse struct {
|
||||||
|
IsValid bool `json:"is_valid"`
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ type Emoji interface {
|
|||||||
Find(*FindRequest) (*FindResponse, error)
|
Find(*FindRequest) (*FindResponse, error)
|
||||||
Flag(*FlagRequest) (*FlagResponse, error)
|
Flag(*FlagRequest) (*FlagResponse, error)
|
||||||
Print(*PrintRequest) (*PrintResponse, error)
|
Print(*PrintRequest) (*PrintResponse, error)
|
||||||
Send(*SendRequest) (*SendResponse, error)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewEmojiService(token string) *EmojiService {
|
func NewEmojiService(token string) *EmojiService {
|
||||||
@@ -48,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 {
|
type FindRequest struct {
|
||||||
// the alias code e.g :beer:
|
// the alias code e.g :beer:
|
||||||
Alias string `json:"alias"`
|
Alias string `json:"alias"`
|
||||||
@@ -85,17 +76,3 @@ type PrintResponse struct {
|
|||||||
// text with rendered emojis
|
// text with rendered emojis
|
||||||
Text string `json:"text"`
|
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"`
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# Address
|
# 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:
|
Endpoints:
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# Answer
|
# 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:
|
Endpoints:
|
||||||
|
|
||||||
|
|||||||
@@ -1,37 +1,9 @@
|
|||||||
# App
|
# 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:
|
Endpoints:
|
||||||
|
|
||||||
## Status
|
|
||||||
|
|
||||||
Get the status of an app
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/app/api#Status](https://m3o.com/app/api#Status)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/app"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Get the status of an app
|
|
||||||
func GetTheStatusOfAnApp() {
|
|
||||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := appService.Status(&app.StatusRequest{
|
|
||||||
Name: "helloworld",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Resolve
|
## Resolve
|
||||||
|
|
||||||
Resolve an app by id to its raw backend endpoint
|
Resolve an app by id to its raw backend endpoint
|
||||||
@@ -173,7 +145,7 @@ func ListTheApps() {
|
|||||||
```
|
```
|
||||||
## Run
|
## 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)
|
[https://m3o.com/app/api#Run](https://m3o.com/app/api#Run)
|
||||||
@@ -188,7 +160,7 @@ import(
|
|||||||
"go.m3o.com/app"
|
"go.m3o.com/app"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Run an app from a source repo. Specify region etc.
|
// Run an app from source
|
||||||
func RunAnApp() {
|
func RunAnApp() {
|
||||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := appService.Run(&app.RunRequest{
|
rsp, err := appService.Run(&app.RunRequest{
|
||||||
@@ -230,3 +202,31 @@ func ListRegions() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
## Status
|
||||||
|
|
||||||
|
Get the status of an app
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/app/api#Status](https://m3o.com/app/api#Status)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/app"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Get the status of an app
|
||||||
|
func GetTheStatusOfAnApp() {
|
||||||
|
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := appService.Status(&app.StatusRequest{
|
||||||
|
Name: "helloworld",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
"go.m3o.com/app"
|
"go.m3o.com/app"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Run an app from a source repo. Specify region etc.
|
// Run an app from source
|
||||||
func main() {
|
func main() {
|
||||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := appService.Run(&app.RunRequest{
|
rsp, err := appService.Run(&app.RunRequest{
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
# Avatar
|
# 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:
|
Endpoints:
|
||||||
|
|
||||||
## Generate
|
## Generate
|
||||||
|
|
||||||
|
Generate an unique avatar
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/avatar/api#Generate](https://m3o.com/avatar/api#Generate)
|
[https://m3o.com/avatar/api#Generate](https://m3o.com/avatar/api#Generate)
|
||||||
@@ -21,39 +21,8 @@ import(
|
|||||||
"go.m3o.com/avatar"
|
"go.m3o.com/avatar"
|
||||||
)
|
)
|
||||||
|
|
||||||
//
|
// Generate an unique avatar
|
||||||
func GenerateAvatarAndReturnBase64stringOfTheAvatar() {
|
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"))
|
avatarService := avatar.NewAvatarService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := avatarService.Generate(&avatar.GenerateRequest{
|
rsp, err := avatarService.Generate(&avatar.GenerateRequest{
|
||||||
Format: "jpeg",
|
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"
|
"go.m3o.com/avatar"
|
||||||
)
|
)
|
||||||
|
|
||||||
//
|
// Generate an unique avatar
|
||||||
func main() {
|
func main() {
|
||||||
avatarService := avatar.NewAvatarService(os.Getenv("M3O_API_TOKEN"))
|
avatarService := avatar.NewAvatarService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := avatarService.Generate(&avatar.GenerateRequest{
|
rsp, err := avatarService.Generate(&avatar.GenerateRequest{
|
||||||
Format: "jpeg",
|
Format: "png",
|
||||||
Gender: "female",
|
Gender: "female",
|
||||||
Upload: false,
|
Upload: true,
|
||||||
Username: "",
|
Username: "",
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|||||||
@@ -7,13 +7,13 @@ import (
|
|||||||
"go.m3o.com/avatar"
|
"go.m3o.com/avatar"
|
||||||
)
|
)
|
||||||
|
|
||||||
//
|
// Generate an unique avatar
|
||||||
func main() {
|
func main() {
|
||||||
avatarService := avatar.NewAvatarService(os.Getenv("M3O_API_TOKEN"))
|
avatarService := avatar.NewAvatarService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := avatarService.Generate(&avatar.GenerateRequest{
|
rsp, err := avatarService.Generate(&avatar.GenerateRequest{
|
||||||
Format: "png",
|
Format: "jpeg",
|
||||||
Gender: "female",
|
Gender: "female",
|
||||||
Upload: true,
|
Upload: false,
|
||||||
Username: "",
|
Username: "",
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|||||||
87
examples/cache/README.md
vendored
87
examples/cache/README.md
vendored
@@ -1,9 +1,65 @@
|
|||||||
# Cache
|
# 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:
|
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
|
||||||
|
|
||||||
Set an item in the cache. Overwrites any existing value already 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)
|
||||||
|
}
|
||||||
@@ -1,12 +1,96 @@
|
|||||||
# Contact
|
# Contact
|
||||||
|
|
||||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Contact/api](https://m3o.com/Contact/api).
|
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/contact/api](https://m3o.com/contact/api).
|
||||||
|
|
||||||
Endpoints:
|
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
|
||||||
|
|
||||||
|
Create a contact
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/contact/api#Create](https://m3o.com/contact/api#Create)
|
[https://m3o.com/contact/api#Create](https://m3o.com/contact/api#Create)
|
||||||
@@ -21,7 +105,7 @@ import(
|
|||||||
"go.m3o.com/contact"
|
"go.m3o.com/contact"
|
||||||
)
|
)
|
||||||
|
|
||||||
//
|
// Create a contact
|
||||||
func CreateAcontact() {
|
func CreateAcontact() {
|
||||||
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := contactService.Create(&contact.CreateRequest{
|
rsp, err := contactService.Create(&contact.CreateRequest{
|
||||||
@@ -56,7 +140,7 @@ contact.Phone{
|
|||||||
```
|
```
|
||||||
## Update
|
## Update
|
||||||
|
|
||||||
|
Update a contact
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/contact/api#Update](https://m3o.com/contact/api#Update)
|
[https://m3o.com/contact/api#Update](https://m3o.com/contact/api#Update)
|
||||||
@@ -71,7 +155,7 @@ import(
|
|||||||
"go.m3o.com/contact"
|
"go.m3o.com/contact"
|
||||||
)
|
)
|
||||||
|
|
||||||
//
|
// Update a contact
|
||||||
func UpdateAcontact() {
|
func UpdateAcontact() {
|
||||||
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := contactService.Update(&contact.UpdateRequest{
|
rsp, err := contactService.Update(&contact.UpdateRequest{
|
||||||
@@ -107,7 +191,7 @@ contact.Phone{
|
|||||||
```
|
```
|
||||||
## Read
|
## Read
|
||||||
|
|
||||||
|
Read contact details
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/contact/api#Read](https://m3o.com/contact/api#Read)
|
[https://m3o.com/contact/api#Read](https://m3o.com/contact/api#Read)
|
||||||
@@ -122,7 +206,7 @@ import(
|
|||||||
"go.m3o.com/contact"
|
"go.m3o.com/contact"
|
||||||
)
|
)
|
||||||
|
|
||||||
//
|
// Read contact details
|
||||||
func GetAcontact() {
|
func GetAcontact() {
|
||||||
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := contactService.Read(&contact.ReadRequest{
|
rsp, err := contactService.Read(&contact.ReadRequest{
|
||||||
@@ -133,87 +217,3 @@ func GetAcontact() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Delete
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/contact/api#Delete](https://m3o.com/contact/api#Delete)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/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
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/contact/api#List](https://m3o.com/contact/api#List)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/contact"
|
|
||||||
)
|
|
||||||
|
|
||||||
//
|
|
||||||
func ListContactsWithDefaultOffsetAndLimitDefaultLimitIs20() {
|
|
||||||
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := contactService.List(&contact.ListRequest{
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## List
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/contact/api#List](https://m3o.com/contact/api#List)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/contact"
|
|
||||||
)
|
|
||||||
|
|
||||||
//
|
|
||||||
func ListContactsWithSpecificOffsetAndLimit() {
|
|
||||||
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := contactService.List(&contact.ListRequest{
|
|
||||||
Limit: 1,
|
|
||||||
Offset: 1,
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
"go.m3o.com/contact"
|
"go.m3o.com/contact"
|
||||||
)
|
)
|
||||||
|
|
||||||
//
|
// Create a contact
|
||||||
func main() {
|
func main() {
|
||||||
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := contactService.Create(&contact.CreateRequest{
|
rsp, err := contactService.Create(&contact.CreateRequest{
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
"go.m3o.com/contact"
|
"go.m3o.com/contact"
|
||||||
)
|
)
|
||||||
|
|
||||||
//
|
// Delete a contact
|
||||||
func main() {
|
func main() {
|
||||||
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := contactService.Delete(&contact.DeleteRequest{
|
rsp, err := contactService.Delete(&contact.DeleteRequest{
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
"go.m3o.com/contact"
|
"go.m3o.com/contact"
|
||||||
)
|
)
|
||||||
|
|
||||||
//
|
// List contacts
|
||||||
func main() {
|
func main() {
|
||||||
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := contactService.List(&contact.ListRequest{})
|
rsp, err := contactService.List(&contact.ListRequest{})
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
"go.m3o.com/contact"
|
"go.m3o.com/contact"
|
||||||
)
|
)
|
||||||
|
|
||||||
//
|
// List contacts
|
||||||
func main() {
|
func main() {
|
||||||
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := contactService.List(&contact.ListRequest{
|
rsp, err := contactService.List(&contact.ListRequest{
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
"go.m3o.com/contact"
|
"go.m3o.com/contact"
|
||||||
)
|
)
|
||||||
|
|
||||||
//
|
// Read contact details
|
||||||
func main() {
|
func main() {
|
||||||
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := contactService.Read(&contact.ReadRequest{
|
rsp, err := contactService.Read(&contact.ReadRequest{
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
"go.m3o.com/contact"
|
"go.m3o.com/contact"
|
||||||
)
|
)
|
||||||
|
|
||||||
//
|
// Update a contact
|
||||||
func main() {
|
func main() {
|
||||||
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := contactService.Update(&contact.UpdateRequest{
|
rsp, err := contactService.Update(&contact.UpdateRequest{
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# Crypto
|
# 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:
|
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,6 +1,6 @@
|
|||||||
# Currency
|
# 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:
|
Endpoints:
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
# Db
|
# 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:
|
Endpoints:
|
||||||
|
|
||||||
## Delete
|
## Create
|
||||||
|
|
||||||
Delete a record in the database by id.
|
Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/db/api#Delete](https://m3o.com/db/api#Delete)
|
[https://m3o.com/db/api#Create](https://m3o.com/db/api#Create)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
package example
|
package example
|
||||||
@@ -21,11 +21,16 @@ import(
|
|||||||
"go.m3o.com/db"
|
"go.m3o.com/db"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Delete a record in the database by id.
|
// Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
|
||||||
func DeleteArecord() {
|
func CreateArecord() {
|
||||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := dbService.Delete(&db.DeleteRequest{
|
rsp, err := dbService.Create(&db.CreateRequest{
|
||||||
Id: "1",
|
Record: map[string]interface{}{
|
||||||
|
"isActive": true,
|
||||||
|
"id": "1",
|
||||||
|
"name": "Jane",
|
||||||
|
"age": 42,
|
||||||
|
},
|
||||||
Table: "example",
|
Table: "example",
|
||||||
|
|
||||||
})
|
})
|
||||||
@@ -63,6 +68,63 @@ Table: "example",
|
|||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Delete
|
||||||
|
|
||||||
|
Delete a record in the database by id.
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/db/api#Delete](https://m3o.com/db/api#Delete)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/db"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Delete a record in the database by id.
|
||||||
|
func DeleteArecord() {
|
||||||
|
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := dbService.Delete(&db.DeleteRequest{
|
||||||
|
Id: "1",
|
||||||
|
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)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Read
|
## Read
|
||||||
@@ -148,34 +210,6 @@ func DropTable() {
|
|||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Count
|
|
||||||
|
|
||||||
Count records in a table
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/db/api#Count](https://m3o.com/db/api#Count)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/db"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Count records in a table
|
|
||||||
func CountEntriesInAtable() {
|
|
||||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := dbService.Count(&db.CountRequest{
|
|
||||||
Table: "example",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## ListTables
|
## ListTables
|
||||||
@@ -234,37 +268,3 @@ To: "examples3",
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Create
|
|
||||||
|
|
||||||
Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/db/api#Create](https://m3o.com/db/api#Create)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/db"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
|
|
||||||
func CreateArecord() {
|
|
||||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := dbService.Create(&db.CreateRequest{
|
|
||||||
Record: map[string]interface{}{
|
|
||||||
"id": "1",
|
|
||||||
"name": "Jane",
|
|
||||||
"age": 42,
|
|
||||||
"isActive": true,
|
|
||||||
},
|
|
||||||
Table: "example",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ func main() {
|
|||||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := dbService.Update(&db.UpdateRequest{
|
rsp, err := dbService.Update(&db.UpdateRequest{
|
||||||
Record: map[string]interface{}{
|
Record: map[string]interface{}{
|
||||||
"id": "1",
|
|
||||||
"age": 43,
|
"age": 43,
|
||||||
|
"id": "1",
|
||||||
},
|
},
|
||||||
Table: "example",
|
Table: "example",
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# Email
|
# 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:
|
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
|
# 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:
|
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
|
# 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:
|
Endpoints:
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# Event
|
# 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:
|
Endpoints:
|
||||||
|
|
||||||
|
|||||||
@@ -1,38 +1,9 @@
|
|||||||
# File
|
# 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:
|
Endpoints:
|
||||||
|
|
||||||
## Delete
|
|
||||||
|
|
||||||
Delete a file by project name/path
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/file/api#Delete](https://m3o.com/file/api#Delete)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/file"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Delete a file by project name/path
|
|
||||||
func DeleteFile() {
|
|
||||||
fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := fileService.Delete(&file.DeleteRequest{
|
|
||||||
Path: "/document/text-files/file.txt",
|
|
||||||
Project: "examples",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Save
|
## Save
|
||||||
|
|
||||||
Save a file
|
Save a file
|
||||||
@@ -122,3 +93,32 @@ Project: "examples",
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
## 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
|
# 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:
|
Endpoints:
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,181 @@
|
|||||||
# Function
|
# 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:
|
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
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/function/api#Deploy](https://m3o.com/function/api#Deploy)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/function"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Deploy a group of functions
|
||||||
|
func DeployAfunction() {
|
||||||
|
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := functionService.Deploy(&function.DeployRequest{
|
||||||
|
Branch: "main",
|
||||||
|
Entrypoint: "Helloworld",
|
||||||
|
Name: "helloworld",
|
||||||
|
Region: "europe-west1",
|
||||||
|
Repo: "https://github.com/m3o/m3o",
|
||||||
|
Runtime: "go116",
|
||||||
|
Subfolder: "examples/go-function",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Delete
|
||||||
|
|
||||||
|
Delete a function by name
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/function/api#Delete](https://m3o.com/function/api#Delete)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/function"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Delete a function by name
|
||||||
|
func DeleteAfunction() {
|
||||||
|
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := functionService.Delete(&function.DeleteRequest{
|
||||||
|
Name: "helloworld",
|
||||||
|
|
||||||
|
})
|
||||||
|
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
|
||||||
|
|
||||||
Update a function. Downloads the source, builds and redeploys
|
Update a function. Downloads the source, builds and redeploys
|
||||||
@@ -88,95 +260,6 @@ func ListFunctions() {
|
|||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
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)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Deploy
|
|
||||||
|
|
||||||
Deploy a group of functions
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/function/api#Deploy](https://m3o.com/function/api#Deploy)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/function"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Deploy a group of functions
|
|
||||||
func DeployAfunction() {
|
|
||||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := functionService.Deploy(&function.DeployRequest{
|
|
||||||
Branch: "main",
|
|
||||||
Entrypoint: "Helloworld",
|
|
||||||
Name: "helloworld",
|
|
||||||
Region: "europe-west1",
|
|
||||||
Repo: "https://github.com/m3o/m3o",
|
|
||||||
Runtime: "go116",
|
|
||||||
Subfolder: "examples/go-function",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Delete
|
|
||||||
|
|
||||||
Delete a function by name
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/function/api#Delete](https://m3o.com/function/api#Delete)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/function"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Delete a function by name
|
|
||||||
func DeleteAfunction() {
|
|
||||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := functionService.Delete(&function.DeleteRequest{
|
|
||||||
Name: "helloworld",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Describe
|
## Describe
|
||||||
@@ -207,59 +290,3 @@ func DescribeFunctionStatus() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## 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)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## 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)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|||||||
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)
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
# Geocoding
|
# 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:
|
Endpoints:
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# Gifs
|
# 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:
|
Endpoints:
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# Google
|
# 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:
|
Endpoints:
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# Helloworld
|
# 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:
|
Endpoints:
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@ import(
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Call returns a personalised "Hello $name" response
|
// Call returns a personalised "Hello $name" response
|
||||||
func CallTheHelloworldService() {
|
func CallHelloworld() {
|
||||||
helloworldService := helloworld.NewHelloworldService(os.Getenv("M3O_API_TOKEN"))
|
helloworldService := helloworld.NewHelloworldService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := helloworldService.Call(&helloworld.CallRequest{
|
rsp, err := helloworldService.Call(&helloworld.CallRequest{
|
||||||
Name: "John",
|
Name: "John",
|
||||||
@@ -50,7 +50,7 @@ import(
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Stream returns a stream of "Hello $name" responses
|
// Stream returns a stream of "Hello $name" responses
|
||||||
func StreamsResponsesFromTheServerUsingWebsockets() {
|
func StreamHelloworld() {
|
||||||
helloworldService := helloworld.NewHelloworldService(os.Getenv("M3O_API_TOKEN"))
|
helloworldService := helloworld.NewHelloworldService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
|
||||||
stream, err := helloworldService.Stream(&helloworld.StreamRequest{
|
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
|
# 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:
|
Endpoints:
|
||||||
|
|
||||||
## Countries
|
|
||||||
|
|
||||||
Get the list of countries that are supported by this API
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/holidays/api#Countries](https://m3o.com/holidays/api#Countries)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/holidays"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Get the list of countries that are supported by this API
|
|
||||||
func ListCountries() {
|
|
||||||
holidaysService := holidays.NewHolidaysService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := holidaysService.Countries(&holidays.CountriesRequest{
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## List
|
## List
|
||||||
|
|
||||||
List the holiday dates for a given country and year
|
List the holiday dates for a given country and year
|
||||||
@@ -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,6 +1,6 @@
|
|||||||
# Id
|
# 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:
|
Endpoints:
|
||||||
|
|
||||||
|
|||||||
@@ -1,107 +1,9 @@
|
|||||||
# Image
|
# 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:
|
Endpoints:
|
||||||
|
|
||||||
## Upload
|
|
||||||
|
|
||||||
Upload an image by either sending a base64 encoded image to this endpoint or a URL.
|
|
||||||
To resize an image before uploading, see the Resize endpoint.
|
|
||||||
To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
|
|
||||||
with each parameter as a form field.
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/image/api#Upload](https://m3o.com/image/api#Upload)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/image"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Upload an image by either sending a base64 encoded image to this endpoint or a URL.
|
|
||||||
// To resize an image before uploading, see the Resize endpoint.
|
|
||||||
// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
|
|
||||||
// with each parameter as a form field.
|
|
||||||
func UploadAbase64imageToMicrosCdn() {
|
|
||||||
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := imageService.Upload(&image.UploadRequest{
|
|
||||||
Base64: "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAx0lEQVR4nOzaMaoDMQyE4ZHj+x82vVdhwQoTkzKQEcwP5r0ihT7sbjUTeAJ4HCegXQJYfOYefOyjDuBiz3yjwJBoCIl6QZOeUjTC1Ix1IxEJXF9+0KWsf2bD4bn37OO/c/wuQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9Sa/NG94Tf3j4WBdaxudMEkn4IM2rZBA0wBrvo7aOcpj2emXvLeVt0IGm0GVXUj91mvAAAA//+V2CZl+4AKXwAAAABJRU5ErkJggg==",
|
|
||||||
Name: "cat.jpeg",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Upload
|
|
||||||
|
|
||||||
Upload an image by either sending a base64 encoded image to this endpoint or a URL.
|
|
||||||
To resize an image before uploading, see the Resize endpoint.
|
|
||||||
To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
|
|
||||||
with each parameter as a form field.
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/image/api#Upload](https://m3o.com/image/api#Upload)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/image"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Upload an image by either sending a base64 encoded image to this endpoint or a URL.
|
|
||||||
// To resize an image before uploading, see the Resize endpoint.
|
|
||||||
// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
|
|
||||||
// with each parameter as a form field.
|
|
||||||
func UploadAnImageFromAurlToMicrosCdn() {
|
|
||||||
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := imageService.Upload(&image.UploadRequest{
|
|
||||||
Name: "cat.jpeg",
|
|
||||||
Url: "somewebsite.com/cat.png",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## 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
|
||||||
|
|
||||||
Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters.
|
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 +158,101 @@ Url: "somewebsite.com/cat.png",
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
## Upload
|
||||||
|
|
||||||
|
Upload an image by either sending a base64 encoded image to this endpoint or a URL.
|
||||||
|
To resize an image before uploading, see the Resize endpoint.
|
||||||
|
To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
|
||||||
|
with each parameter as a form field.
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/image/api#Upload](https://m3o.com/image/api#Upload)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/image"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Upload an image by either sending a base64 encoded image to this endpoint or a URL.
|
||||||
|
// To resize an image before uploading, see the Resize endpoint.
|
||||||
|
// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
|
||||||
|
// with each parameter as a form field.
|
||||||
|
func UploadAbase64imageToMicrosCdn() {
|
||||||
|
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := imageService.Upload(&image.UploadRequest{
|
||||||
|
Base64: "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAx0lEQVR4nOzaMaoDMQyE4ZHj+x82vVdhwQoTkzKQEcwP5r0ihT7sbjUTeAJ4HCegXQJYfOYefOyjDuBiz3yjwJBoCIl6QZOeUjTC1Ix1IxEJXF9+0KWsf2bD4bn37OO/c/wuQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9Sa/NG94Tf3j4WBdaxudMEkn4IM2rZBA0wBrvo7aOcpj2emXvLeVt0IGm0GVXUj91mvAAAA//+V2CZl+4AKXwAAAABJRU5ErkJggg==",
|
||||||
|
Name: "cat.jpeg",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Upload
|
||||||
|
|
||||||
|
Upload an image by either sending a base64 encoded image to this endpoint or a URL.
|
||||||
|
To resize an image before uploading, see the Resize endpoint.
|
||||||
|
To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
|
||||||
|
with each parameter as a form field.
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/image/api#Upload](https://m3o.com/image/api#Upload)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/image"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Upload an image by either sending a base64 encoded image to this endpoint or a URL.
|
||||||
|
// To resize an image before uploading, see the Resize endpoint.
|
||||||
|
// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
|
||||||
|
// with each parameter as a form field.
|
||||||
|
func UploadAnImageFromAurlToMicrosCdn() {
|
||||||
|
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := imageService.Upload(&image.UploadRequest{
|
||||||
|
Name: "cat.jpeg",
|
||||||
|
Url: "somewebsite.com/cat.png",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## 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
|
# 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:
|
Endpoints:
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# Joke
|
# 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:
|
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
|
# 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:
|
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
|
||||||
|
|
||||||
Read an entity by its ID
|
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)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
61
examples/meme/README.md
Executable file
61
examples/meme/README.md
Executable file
@@ -0,0 +1,61 @@
|
|||||||
|
# Meme
|
||||||
|
|
||||||
|
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/meme/api](https://m3o.com/meme/api).
|
||||||
|
|
||||||
|
Endpoints:
|
||||||
|
|
||||||
|
## Templates
|
||||||
|
|
||||||
|
List the available templates
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/meme/api#Templates](https://m3o.com/meme/api#Templates)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/meme"
|
||||||
|
)
|
||||||
|
|
||||||
|
// List the available templates
|
||||||
|
func MemeTemplates() {
|
||||||
|
memeService := meme.NewMemeService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := memeService.Templates(&meme.TemplatesRequest{
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Generate
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/meme/api#Generate](https://m3o.com/meme/api#Generate)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/meme"
|
||||||
|
)
|
||||||
|
|
||||||
|
//
|
||||||
|
func GenerateAmeme() {
|
||||||
|
memeService := meme.NewMemeService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := memeService.Generate(&meme.GenerateRequest{
|
||||||
|
Id: "444501",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
17
examples/meme/generate/generateAMeme/main.go
Executable file
17
examples/meme/generate/generateAMeme/main.go
Executable file
@@ -0,0 +1,17 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/meme"
|
||||||
|
)
|
||||||
|
|
||||||
|
//
|
||||||
|
func main() {
|
||||||
|
memeService := meme.NewMemeService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := memeService.Generate(&meme.GenerateRequest{
|
||||||
|
Id: "444501",
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
}
|
||||||
15
examples/meme/templates/memeTemplates/main.go
Executable file
15
examples/meme/templates/memeTemplates/main.go
Executable file
@@ -0,0 +1,15 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/meme"
|
||||||
|
)
|
||||||
|
|
||||||
|
// List the available templates
|
||||||
|
func main() {
|
||||||
|
memeService := meme.NewMemeService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := memeService.Templates(&meme.TemplatesRequest{})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
}
|
||||||
61
examples/memegen/README.md
Executable file
61
examples/memegen/README.md
Executable file
@@ -0,0 +1,61 @@
|
|||||||
|
# Memegen
|
||||||
|
|
||||||
|
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/memegen/api](https://m3o.com/memegen/api).
|
||||||
|
|
||||||
|
Endpoints:
|
||||||
|
|
||||||
|
## Templates
|
||||||
|
|
||||||
|
List the available templates
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/memegen/api#Templates](https://m3o.com/memegen/api#Templates)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/memegen"
|
||||||
|
)
|
||||||
|
|
||||||
|
// List the available templates
|
||||||
|
func MemeTemplates() {
|
||||||
|
memegenService := memegen.NewMemegenService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := memegenService.Templates(&memegen.TemplatesRequest{
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Generate
|
||||||
|
|
||||||
|
Generate a meme using a template
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/memegen/api#Generate](https://m3o.com/memegen/api#Generate)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/memegen"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Generate a meme using a template
|
||||||
|
func GenerateAmeme() {
|
||||||
|
memegenService := memegen.NewMemegenService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := memegenService.Generate(&memegen.GenerateRequest{
|
||||||
|
Id: "444501",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
17
examples/memegen/generate/generateAMeme/main.go
Executable file
17
examples/memegen/generate/generateAMeme/main.go
Executable file
@@ -0,0 +1,17 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/memegen"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Generate a meme using a template
|
||||||
|
func main() {
|
||||||
|
memegenService := memegen.NewMemegenService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := memegenService.Generate(&memegen.GenerateRequest{
|
||||||
|
Id: "444501",
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
}
|
||||||
15
examples/memegen/templates/memeTemplates/main.go
Executable file
15
examples/memegen/templates/memeTemplates/main.go
Executable file
@@ -0,0 +1,15 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/memegen"
|
||||||
|
)
|
||||||
|
|
||||||
|
// List the available templates
|
||||||
|
func main() {
|
||||||
|
memegenService := memegen.NewMemegenService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := memegenService.Templates(&memegen.TemplatesRequest{})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
}
|
||||||
34
examples/minecraft/README.md
Executable file
34
examples/minecraft/README.md
Executable file
@@ -0,0 +1,34 @@
|
|||||||
|
# Minecraft
|
||||||
|
|
||||||
|
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/minecraft/api](https://m3o.com/minecraft/api).
|
||||||
|
|
||||||
|
Endpoints:
|
||||||
|
|
||||||
|
## Ping
|
||||||
|
|
||||||
|
Ping a minecraft server
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/minecraft/api#Ping](https://m3o.com/minecraft/api#Ping)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/minecraft"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Ping a minecraft server
|
||||||
|
func PingAminecraftServer() {
|
||||||
|
minecraftService := minecraft.NewMinecraftService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := minecraftService.Ping(&minecraft.PingRequest{
|
||||||
|
Address: "funcraft.net",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
17
examples/minecraft/ping/pingAMinecraftServer/main.go
Executable file
17
examples/minecraft/ping/pingAMinecraftServer/main.go
Executable file
@@ -0,0 +1,17 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/minecraft"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Ping a minecraft server
|
||||||
|
func main() {
|
||||||
|
minecraftService := minecraft.NewMinecraftService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := minecraftService.Ping(&minecraft.PingRequest{
|
||||||
|
Address: "funcraft.net",
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
# Movie
|
# Movie
|
||||||
|
|
||||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Movie/api](https://m3o.com/Movie/api).
|
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/movie/api](https://m3o.com/movie/api).
|
||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# Mq
|
# Mq
|
||||||
|
|
||||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Mq/api](https://m3o.com/Mq/api).
|
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/mq/api](https://m3o.com/mq/api).
|
||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# News
|
# News
|
||||||
|
|
||||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/News/api](https://m3o.com/News/api).
|
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/news/api](https://m3o.com/news/api).
|
||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,64 @@
|
|||||||
# Nft
|
# Nft
|
||||||
|
|
||||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Nft/api](https://m3o.com/Nft/api).
|
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/nft/api](https://m3o.com/nft/api).
|
||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
|
## Asset
|
||||||
|
|
||||||
|
Get a single asset by the contract
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/nft/api#Asset](https://m3o.com/nft/api#Asset)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/nft"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Get a single asset by the contract
|
||||||
|
func GetAsingleAsset() {
|
||||||
|
nftService := nft.NewNftService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := nftService.Asset(&nft.AssetRequest{
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Collection
|
||||||
|
|
||||||
|
Get a collection by its slug
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/nft/api#Collection](https://m3o.com/nft/api#Collection)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/nft"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Get a collection by its slug
|
||||||
|
func GetAsingleCollection() {
|
||||||
|
nftService := nft.NewNftService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := nftService.Collection(&nft.CollectionRequest{
|
||||||
|
Slug: "doodles-official",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
## Assets
|
## Assets
|
||||||
|
|
||||||
Return a list of assets
|
Return a list of assets
|
||||||
|
|||||||
15
examples/nft/asset/getASingleAsset/main.go
Executable file
15
examples/nft/asset/getASingleAsset/main.go
Executable file
@@ -0,0 +1,15 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/nft"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Get a single asset by the contract
|
||||||
|
func main() {
|
||||||
|
nftService := nft.NewNftService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := nftService.Asset(&nft.AssetRequest{})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
}
|
||||||
17
examples/nft/collection/getASingleCollection/main.go
Executable file
17
examples/nft/collection/getASingleCollection/main.go
Executable file
@@ -0,0 +1,17 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/nft"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Get a collection by its slug
|
||||||
|
func main() {
|
||||||
|
nftService := nft.NewNftService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := nftService.Collection(&nft.CollectionRequest{
|
||||||
|
Slug: "doodles-official",
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
}
|
||||||
@@ -1,93 +1,9 @@
|
|||||||
# Notes
|
# Notes
|
||||||
|
|
||||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Notes/api](https://m3o.com/Notes/api).
|
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/notes/api](https://m3o.com/notes/api).
|
||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
## Create
|
|
||||||
|
|
||||||
Create a new note
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/notes/api#Create](https://m3o.com/notes/api#Create)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/notes"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Create a new note
|
|
||||||
func CreateAnote() {
|
|
||||||
notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := notesService.Create(¬es.CreateRequest{
|
|
||||||
Text: "This is my note",
|
|
||||||
Title: "New Note",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Read
|
|
||||||
|
|
||||||
Read a note
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/notes/api#Read](https://m3o.com/notes/api#Read)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/notes"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Read a note
|
|
||||||
func ReadAnote() {
|
|
||||||
notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := notesService.Read(¬es.ReadRequest{
|
|
||||||
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## List
|
|
||||||
|
|
||||||
List all the notes
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/notes/api#List](https://m3o.com/notes/api#List)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/notes"
|
|
||||||
)
|
|
||||||
|
|
||||||
// List all the notes
|
|
||||||
func ListAllNotes() {
|
|
||||||
notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := notesService.List(¬es.ListRequest{
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Update
|
## Update
|
||||||
|
|
||||||
Update a note
|
Update a note
|
||||||
@@ -189,3 +105,87 @@ func SubscribeToEvents() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
## Create
|
||||||
|
|
||||||
|
Create a new note
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/notes/api#Create](https://m3o.com/notes/api#Create)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/notes"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Create a new note
|
||||||
|
func CreateAnote() {
|
||||||
|
notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := notesService.Create(¬es.CreateRequest{
|
||||||
|
Text: "This is my note",
|
||||||
|
Title: "New Note",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Read
|
||||||
|
|
||||||
|
Read a note
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/notes/api#Read](https://m3o.com/notes/api#Read)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/notes"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Read a note
|
||||||
|
func ReadAnote() {
|
||||||
|
notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := notesService.Read(¬es.ReadRequest{
|
||||||
|
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## List
|
||||||
|
|
||||||
|
List all the notes
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/notes/api#List](https://m3o.com/notes/api#List)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/notes"
|
||||||
|
)
|
||||||
|
|
||||||
|
// List all the notes
|
||||||
|
func ListAllNotes() {
|
||||||
|
notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := notesService.List(¬es.ListRequest{
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# Otp
|
# Otp
|
||||||
|
|
||||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Otp/api](https://m3o.com/Otp/api).
|
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/otp/api](https://m3o.com/otp/api).
|
||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user