mirror of
https://github.com/kevin-DL/m3o-go.git
synced 2026-01-24 07:25:35 +00:00
Compare commits
273 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 |
@@ -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
|
||||||
|
|||||||
@@ -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"`
|
||||||
}
|
}
|
||||||
|
|||||||
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"`
|
||||||
|
}
|
||||||
|
|||||||
@@ -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"`
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -4,6 +4,118 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/app/api](https
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
|
## Resolve
|
||||||
|
|
||||||
|
Resolve an app by id to its raw backend endpoint
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/app/api#Resolve](https://m3o.com/app/api#Resolve)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/app"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Resolve an app by id to its raw backend endpoint
|
||||||
|
func ResolveAppById() {
|
||||||
|
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := appService.Resolve(&app.ResolveRequest{
|
||||||
|
Id: "helloworld",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Update
|
||||||
|
|
||||||
|
Update the app. The latest source code will be downloaded, built and deployed.
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/app/api#Update](https://m3o.com/app/api#Update)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/app"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Update the app. The latest source code will be downloaded, built and deployed.
|
||||||
|
func UpdateAnApp() {
|
||||||
|
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := appService.Update(&app.UpdateRequest{
|
||||||
|
Name: "helloworld",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Delete
|
||||||
|
|
||||||
|
Delete an app
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/app/api#Delete](https://m3o.com/app/api#Delete)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/app"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Delete an app
|
||||||
|
func DeleteAnApp() {
|
||||||
|
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := appService.Delete(&app.DeleteRequest{
|
||||||
|
Name: "helloworld",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Reserve
|
||||||
|
|
||||||
|
Reserve apps beyond the free quota. Call Run after.
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/app/api#Reserve](https://m3o.com/app/api#Reserve)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/app"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Reserve apps beyond the free quota. Call Run after.
|
||||||
|
func ReserveAppName() {
|
||||||
|
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := appService.Reserve(&app.ReserveRequest{
|
||||||
|
Name: "helloworld",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
## List
|
## List
|
||||||
|
|
||||||
List all the apps
|
List all the apps
|
||||||
@@ -118,115 +230,3 @@ func GetTheStatusOfAnApp() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Resolve
|
|
||||||
|
|
||||||
Resolve an app by id to its raw backend endpoint
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/app/api#Resolve](https://m3o.com/app/api#Resolve)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/app"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Resolve an app by id to its raw backend endpoint
|
|
||||||
func ResolveAppById() {
|
|
||||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := appService.Resolve(&app.ResolveRequest{
|
|
||||||
Id: "helloworld",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Update
|
|
||||||
|
|
||||||
Update the app. The latest source code will be downloaded, built and deployed.
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/app/api#Update](https://m3o.com/app/api#Update)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/app"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Update the app. The latest source code will be downloaded, built and deployed.
|
|
||||||
func UpdateAnApp() {
|
|
||||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := appService.Update(&app.UpdateRequest{
|
|
||||||
Name: "helloworld",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Delete
|
|
||||||
|
|
||||||
Delete an app
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/app/api#Delete](https://m3o.com/app/api#Delete)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/app"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Delete an app
|
|
||||||
func DeleteAnApp() {
|
|
||||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := appService.Delete(&app.DeleteRequest{
|
|
||||||
Name: "helloworld",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Reserve
|
|
||||||
|
|
||||||
Reserve apps beyond the free quota. Call Run after.
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/app/api#Reserve](https://m3o.com/app/api#Reserve)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/app"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Reserve apps beyond the free quota. Call Run after.
|
|
||||||
func ReserveAppName() {
|
|
||||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := appService.Reserve(&app.ReserveRequest{
|
|
||||||
Name: "helloworld",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ 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,7 +21,7 @@ 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"))
|
avatarService := avatar.NewAvatarService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := avatarService.Generate(&avatar.GenerateRequest{
|
rsp, err := avatarService.Generate(&avatar.GenerateRequest{
|
||||||
@@ -37,7 +37,7 @@ Username: "",
|
|||||||
```
|
```
|
||||||
## 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)
|
||||||
@@ -52,7 +52,7 @@ import(
|
|||||||
"go.m3o.com/avatar"
|
"go.m3o.com/avatar"
|
||||||
)
|
)
|
||||||
|
|
||||||
//
|
// Generate an unique avatar
|
||||||
func GenerateAnAvatarAndUploadTheAvatarToMicrosCdn() {
|
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{
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ 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{
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ 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{
|
||||||
|
|||||||
58
examples/cache/README.md
vendored
58
examples/cache/README.md
vendored
@@ -4,35 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/cache/api](htt
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
## Increment
|
|
||||||
|
|
||||||
Increment a value (if it's a number). If key not found it is equivalent to set.
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/cache/api#Increment](https://m3o.com/cache/api#Increment)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/cache"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Increment a value (if it's a number). If key not found it is equivalent to set.
|
|
||||||
func IncrementAvalue() {
|
|
||||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := cacheService.Increment(&cache.IncrementRequest{
|
|
||||||
Key: "counter",
|
|
||||||
Value: 2,
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Decrement
|
## Decrement
|
||||||
|
|
||||||
Decrement a value (if it's a number). If key not found it is equivalent to set.
|
Decrement a value (if it's a number). If key not found it is equivalent to set.
|
||||||
@@ -174,3 +145,32 @@ func DeleteAvalue() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
## Increment
|
||||||
|
|
||||||
|
Increment a value (if it's a number). If key not found it is equivalent to set.
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/cache/api#Increment](https://m3o.com/cache/api#Increment)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/cache"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Increment a value (if it's a number). If key not found it is equivalent to set.
|
||||||
|
func IncrementAvalue() {
|
||||||
|
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := cacheService.Increment(&cache.IncrementRequest{
|
||||||
|
Key: "counter",
|
||||||
|
Value: 2,
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
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)
|
||||||
|
}
|
||||||
@@ -6,7 +6,7 @@ Endpoints:
|
|||||||
|
|
||||||
## Delete
|
## Delete
|
||||||
|
|
||||||
|
Delete a contact
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/contact/api#Delete](https://m3o.com/contact/api#Delete)
|
[https://m3o.com/contact/api#Delete](https://m3o.com/contact/api#Delete)
|
||||||
@@ -21,7 +21,7 @@ import(
|
|||||||
"go.m3o.com/contact"
|
"go.m3o.com/contact"
|
||||||
)
|
)
|
||||||
|
|
||||||
//
|
// Delete a contact
|
||||||
func DeleteAcontact() {
|
func DeleteAcontact() {
|
||||||
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{
|
||||||
@@ -34,7 +34,7 @@ func DeleteAcontact() {
|
|||||||
```
|
```
|
||||||
## List
|
## List
|
||||||
|
|
||||||
|
List contacts
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/contact/api#List](https://m3o.com/contact/api#List)
|
[https://m3o.com/contact/api#List](https://m3o.com/contact/api#List)
|
||||||
@@ -49,7 +49,7 @@ import(
|
|||||||
"go.m3o.com/contact"
|
"go.m3o.com/contact"
|
||||||
)
|
)
|
||||||
|
|
||||||
//
|
// List contacts
|
||||||
func ListContactsWithDefaultOffsetAndLimitDefaultLimitIs20() {
|
func ListContactsWithDefaultOffsetAndLimitDefaultLimitIs20() {
|
||||||
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{
|
||||||
@@ -61,7 +61,7 @@ func ListContactsWithDefaultOffsetAndLimitDefaultLimitIs20() {
|
|||||||
```
|
```
|
||||||
## List
|
## List
|
||||||
|
|
||||||
|
List contacts
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/contact/api#List](https://m3o.com/contact/api#List)
|
[https://m3o.com/contact/api#List](https://m3o.com/contact/api#List)
|
||||||
@@ -76,7 +76,7 @@ import(
|
|||||||
"go.m3o.com/contact"
|
"go.m3o.com/contact"
|
||||||
)
|
)
|
||||||
|
|
||||||
//
|
// List contacts
|
||||||
func ListContactsWithSpecificOffsetAndLimit() {
|
func ListContactsWithSpecificOffsetAndLimit() {
|
||||||
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{
|
||||||
@@ -90,7 +90,7 @@ Offset: 1,
|
|||||||
```
|
```
|
||||||
## 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)
|
||||||
@@ -105,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{
|
||||||
@@ -140,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)
|
||||||
@@ -155,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{
|
||||||
@@ -191,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)
|
||||||
@@ -206,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{
|
||||||
|
|||||||
@@ -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{
|
||||||
|
|||||||
@@ -4,62 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/crypto/api](ht
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
## Quote
|
|
||||||
|
|
||||||
Get the last quote for a given crypto ticker
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/crypto/api#Quote](https://m3o.com/crypto/api#Quote)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/crypto"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Get the last quote for a given crypto ticker
|
|
||||||
func GetAcryptocurrencyQuote() {
|
|
||||||
cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := cryptoService.Quote(&crypto.QuoteRequest{
|
|
||||||
Symbol: "BTCUSD",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## History
|
|
||||||
|
|
||||||
Returns the history for the previous close
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/crypto/api#History](https://m3o.com/crypto/api#History)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/crypto"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Returns the history for the previous close
|
|
||||||
func GetPreviousClose() {
|
|
||||||
cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := cryptoService.History(&crypto.HistoryRequest{
|
|
||||||
Symbol: "BTCUSD",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## News
|
## News
|
||||||
|
|
||||||
Get news related to a currency
|
Get news related to a currency
|
||||||
@@ -116,3 +60,86 @@ func GetCryptocurrencyPrice() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
## Quote
|
||||||
|
|
||||||
|
Get the last quote for a given crypto ticker
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/crypto/api#Quote](https://m3o.com/crypto/api#Quote)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/crypto"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Get the last quote for a given crypto ticker
|
||||||
|
func GetAcryptocurrencyQuote() {
|
||||||
|
cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := cryptoService.Quote(&crypto.QuoteRequest{
|
||||||
|
Symbol: "BTCUSD",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## History
|
||||||
|
|
||||||
|
Returns the history for the previous close
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/crypto/api#History](https://m3o.com/crypto/api#History)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/crypto"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Returns the history for the previous close
|
||||||
|
func GetPreviousClose() {
|
||||||
|
cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := cryptoService.History(&crypto.HistoryRequest{
|
||||||
|
Symbol: "BTCUSD",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## 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)
|
||||||
|
}
|
||||||
@@ -4,12 +4,12 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/db/api](https:
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
## RenameTable
|
## Create
|
||||||
|
|
||||||
Rename a table
|
Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/db/api#RenameTable](https://m3o.com/db/api#RenameTable)
|
[https://m3o.com/db/api#Create](https://m3o.com/db/api#Create)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
package example
|
package example
|
||||||
@@ -21,12 +21,49 @@ import(
|
|||||||
"go.m3o.com/db"
|
"go.m3o.com/db"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Rename a table
|
// Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
|
||||||
func RenameTable() {
|
func CreateArecord() {
|
||||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := dbService.RenameTable(&db.RenameTableRequest{
|
rsp, err := dbService.Create(&db.CreateRequest{
|
||||||
From: "examples2",
|
Record: map[string]interface{}{
|
||||||
To: "examples3",
|
"isActive": true,
|
||||||
|
"id": "1",
|
||||||
|
"name": "Jane",
|
||||||
|
"age": 42,
|
||||||
|
},
|
||||||
|
Table: "example",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Update
|
||||||
|
|
||||||
|
Update a record in the database. Include an "id" in the record to update.
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/db/api#Update](https://m3o.com/db/api#Update)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/db"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Update a record in the database. Include an "id" in the record to update.
|
||||||
|
func UpdateArecord() {
|
||||||
|
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := dbService.Update(&db.UpdateRequest{
|
||||||
|
Record: map[string]interface{}{
|
||||||
|
"id": "1",
|
||||||
|
"age": 43,
|
||||||
|
},
|
||||||
|
Table: "example",
|
||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
@@ -62,12 +99,12 @@ Table: "example",
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## ListTables
|
## Count
|
||||||
|
|
||||||
List tables in the DB
|
Count records in a table
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/db/api#ListTables](https://m3o.com/db/api#ListTables)
|
[https://m3o.com/db/api#Count](https://m3o.com/db/api#Count)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
package example
|
package example
|
||||||
@@ -79,10 +116,11 @@ import(
|
|||||||
"go.m3o.com/db"
|
"go.m3o.com/db"
|
||||||
)
|
)
|
||||||
|
|
||||||
// List tables in the DB
|
// Count records in a table
|
||||||
func ListTables() {
|
func CountEntriesInAtable() {
|
||||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := dbService.ListTables(&db.ListTablesRequest{
|
rsp, err := dbService.Count(&db.CountRequest{
|
||||||
|
Table: "example",
|
||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
@@ -174,12 +212,12 @@ func DropTable() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Count
|
## ListTables
|
||||||
|
|
||||||
Count records in a table
|
List tables in the DB
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/db/api#Count](https://m3o.com/db/api#Count)
|
[https://m3o.com/db/api#ListTables](https://m3o.com/db/api#ListTables)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
package example
|
package example
|
||||||
@@ -191,23 +229,22 @@ import(
|
|||||||
"go.m3o.com/db"
|
"go.m3o.com/db"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Count records in a table
|
// List tables in the DB
|
||||||
func CountEntriesInAtable() {
|
func ListTables() {
|
||||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := dbService.Count(&db.CountRequest{
|
rsp, err := dbService.ListTables(&db.ListTablesRequest{
|
||||||
Table: "example",
|
|
||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Create
|
## RenameTable
|
||||||
|
|
||||||
Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
|
Rename a table
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/db/api#Create](https://m3o.com/db/api#Create)
|
[https://m3o.com/db/api#RenameTable](https://m3o.com/db/api#RenameTable)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
package example
|
package example
|
||||||
@@ -219,49 +256,12 @@ import(
|
|||||||
"go.m3o.com/db"
|
"go.m3o.com/db"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
|
// Rename a table
|
||||||
func CreateArecord() {
|
func RenameTable() {
|
||||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := dbService.Create(&db.CreateRequest{
|
rsp, err := dbService.RenameTable(&db.RenameTableRequest{
|
||||||
Record: map[string]interface{}{
|
From: "examples2",
|
||||||
"id": "1",
|
To: "examples3",
|
||||||
"name": "Jane",
|
|
||||||
"age": 42,
|
|
||||||
"isActive": true,
|
|
||||||
},
|
|
||||||
Table: "example",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Update
|
|
||||||
|
|
||||||
Update a record in the database. Include an "id" in the record to update.
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/db/api#Update](https://m3o.com/db/api#Update)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/db"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Update a record in the database. Include an "id" in the record to update.
|
|
||||||
func UpdateArecord() {
|
|
||||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := dbService.Update(&db.UpdateRequest{
|
|
||||||
Record: map[string]interface{}{
|
|
||||||
"id": "1",
|
|
||||||
"age": 43,
|
|
||||||
},
|
|
||||||
Table: "example",
|
|
||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|||||||
@@ -4,6 +4,38 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/email/api](htt
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
|
## Send
|
||||||
|
|
||||||
|
Send an email by passing in from, to, subject, and a text or html body
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/email/api#Send](https://m3o.com/email/api#Send)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/email"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Send an email by passing in from, to, subject, and a text or html body
|
||||||
|
func SendEmail() {
|
||||||
|
emailService := email.NewEmailService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := emailService.Send(&email.SendRequest{
|
||||||
|
From: "Awesome Dot Com",
|
||||||
|
Subject: "Email verification",
|
||||||
|
TextBody: `Hi there,
|
||||||
|
|
||||||
|
Please verify your email by clicking this link: $micro_verification_link`,
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
## Parse
|
## Parse
|
||||||
|
|
||||||
Parse an RFC5322 address e.g "Joe Blogs <joe@example.com>"
|
Parse an RFC5322 address e.g "Joe Blogs <joe@example.com>"
|
||||||
@@ -60,35 +92,3 @@ func ValidateEmail() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Send
|
|
||||||
|
|
||||||
Send an email by passing in from, to, subject, and a text or html body
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/email/api#Send](https://m3o.com/email/api#Send)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/email"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Send an email by passing in from, to, subject, and a text or html body
|
|
||||||
func SendEmail() {
|
|
||||||
emailService := email.NewEmailService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := emailService.Send(&email.SendRequest{
|
|
||||||
From: "Awesome Dot Com",
|
|
||||||
Subject: "Email verification",
|
|
||||||
TextBody: `Hi there,
|
|
||||||
|
|
||||||
Please verify your email by clicking this link: $micro_verification_link`,
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|||||||
@@ -4,36 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/emoji/api](htt
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
## Send
|
|
||||||
|
|
||||||
Send an emoji to anyone via SMS. Messages are sent in the form '<message> Sent from <from>'
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/emoji/api#Send](https://m3o.com/emoji/api#Send)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/emoji"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Send an emoji to anyone via SMS. Messages are sent in the form '<message> Sent from <from>'
|
|
||||||
func SendAtextContainingAnEmojiToAnyoneViaSms() {
|
|
||||||
emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := emojiService.Send(&emoji.SendRequest{
|
|
||||||
From: "Alice",
|
|
||||||
Message: "let's grab a :beer:",
|
|
||||||
To: "+44782669123",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Find
|
## Find
|
||||||
|
|
||||||
Find an emoji by its alias e.g :beer:
|
Find an emoji by its alias e.g :beer:
|
||||||
|
|||||||
@@ -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)
|
|
||||||
}
|
|
||||||
@@ -4,61 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/function/api](
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
## List
|
|
||||||
|
|
||||||
List all the deployed functions
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/function/api#List](https://m3o.com/function/api#List)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/function"
|
|
||||||
)
|
|
||||||
|
|
||||||
// List all the deployed functions
|
|
||||||
func ListFunctions() {
|
|
||||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := functionService.List(&function.ListRequest{
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## 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
|
## Proxy
|
||||||
|
|
||||||
Return the backend url for proxying
|
Return the backend url for proxying
|
||||||
@@ -119,37 +64,6 @@ Subfolder: "examples/go-function",
|
|||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Call
|
|
||||||
|
|
||||||
Call a function by name
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/function/api#Call](https://m3o.com/function/api#Call)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/function"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Call a function by name
|
|
||||||
func CallAfunction() {
|
|
||||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := functionService.Call(&function.CallRequest{
|
|
||||||
Name: "helloworld",
|
|
||||||
Request: map[string]interface{}{
|
|
||||||
"name": "Alice",
|
|
||||||
},
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Delete
|
## Delete
|
||||||
@@ -180,12 +94,12 @@ func DeleteAfunction() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Describe
|
## Reserve
|
||||||
|
|
||||||
Get the info for a deployed function
|
Reserve function names and resources beyond free quota
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/function/api#Describe](https://m3o.com/function/api#Describe)
|
[https://m3o.com/function/api#Reserve](https://m3o.com/function/api#Reserve)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
package example
|
package example
|
||||||
@@ -197,15 +111,42 @@ import(
|
|||||||
"go.m3o.com/function"
|
"go.m3o.com/function"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Get the info for a deployed function
|
// Reserve function names and resources beyond free quota
|
||||||
func DescribeFunctionStatus() {
|
func ReserveAfunction() {
|
||||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := functionService.Describe(&function.DescribeRequest{
|
rsp, err := functionService.Reserve(&function.ReserveRequest{
|
||||||
Name: "helloworld",
|
Name: "helloworld",
|
||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
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
|
## Regions
|
||||||
@@ -263,3 +204,89 @@ func UpdateAfunction() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
## Call
|
||||||
|
|
||||||
|
Call a function by name
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/function/api#Call](https://m3o.com/function/api#Call)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/function"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Call a function by name
|
||||||
|
func CallAfunction() {
|
||||||
|
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := functionService.Call(&function.CallRequest{
|
||||||
|
Name: "helloworld",
|
||||||
|
Request: map[string]interface{}{
|
||||||
|
"name": "Alice",
|
||||||
|
},
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## List
|
||||||
|
|
||||||
|
List all the deployed functions
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/function/api#List](https://m3o.com/function/api#List)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/function"
|
||||||
|
)
|
||||||
|
|
||||||
|
// List all the deployed functions
|
||||||
|
func ListFunctions() {
|
||||||
|
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := functionService.List(&function.ListRequest{
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Describe
|
||||||
|
|
||||||
|
Get the info for a deployed function
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/function/api#Describe](https://m3o.com/function/api#Describe)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/function"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Get the info for a deployed function
|
||||||
|
func DescribeFunctionStatus() {
|
||||||
|
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := functionService.Describe(&function.DescribeRequest{
|
||||||
|
Name: "helloworld",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
15
examples/function/runtimes/listRuntimes/main.go
Executable file
15
examples/function/runtimes/listRuntimes/main.go
Executable file
@@ -0,0 +1,15 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/function"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Return a list of supported runtimes
|
||||||
|
func main() {
|
||||||
|
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := functionService.Runtimes(&function.RuntimesRequest{})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
}
|
||||||
@@ -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)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,33 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/holidays/api](
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
## Countries
|
|
||||||
|
|
||||||
Get the list of countries that are supported by this API
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/holidays/api#Countries](https://m3o.com/holidays/api#Countries)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/holidays"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Get the list of countries that are supported by this API
|
|
||||||
func ListCountries() {
|
|
||||||
holidaysService := holidays.NewHolidaysService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := holidaysService.Countries(&holidays.CountriesRequest{
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## List
|
## List
|
||||||
|
|
||||||
List the holiday dates for a given country and year
|
List the holiday dates for a given country and year
|
||||||
@@ -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)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
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)
|
||||||
|
}
|
||||||
@@ -4,42 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [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)
|
||||||
|
}
|
||||||
@@ -12,9 +12,9 @@ func main() {
|
|||||||
mqService := mq.NewMqService(os.Getenv("M3O_API_TOKEN"))
|
mqService := mq.NewMqService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := mqService.Publish(&mq.PublishRequest{
|
rsp, err := mqService.Publish(&mq.PublishRequest{
|
||||||
Message: map[string]interface{}{
|
Message: map[string]interface{}{
|
||||||
|
"user": "john",
|
||||||
"id": "1",
|
"id": "1",
|
||||||
"type": "signup",
|
"type": "signup",
|
||||||
"user": "john",
|
|
||||||
},
|
},
|
||||||
Topic: "events",
|
Topic: "events",
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -4,6 +4,61 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/nft/api](https
|
|||||||
|
|
||||||
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)
|
||||||
|
}
|
||||||
@@ -4,90 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/notes/api](htt
|
|||||||
|
|
||||||
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)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
66
examples/password/README.md
Executable file
66
examples/password/README.md
Executable file
@@ -0,0 +1,66 @@
|
|||||||
|
# Password
|
||||||
|
|
||||||
|
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/password/api](https://m3o.com/password/api).
|
||||||
|
|
||||||
|
Endpoints:
|
||||||
|
|
||||||
|
## Generate
|
||||||
|
|
||||||
|
Generate a strong random password. Use the switches to control which character types are included, defaults to using all of them
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/password/api#Generate](https://m3o.com/password/api#Generate)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/password"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Generate a strong random password. Use the switches to control which character types are included, defaults to using all of them
|
||||||
|
func GeneratePassword() {
|
||||||
|
passwordService := password.NewPasswordService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := passwordService.Generate(&password.GenerateRequest{
|
||||||
|
Length: 16,
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Generate
|
||||||
|
|
||||||
|
Generate a strong random password. Use the switches to control which character types are included, defaults to using all of them
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/password/api#Generate](https://m3o.com/password/api#Generate)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/password"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Generate a strong random password. Use the switches to control which character types are included, defaults to using all of them
|
||||||
|
func GeneratePasswordWithoutSpecialCharacters() {
|
||||||
|
passwordService := password.NewPasswordService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := passwordService.Generate(&password.GenerateRequest{
|
||||||
|
Length: 16,
|
||||||
|
Lowercase: true,
|
||||||
|
Numbers: true,
|
||||||
|
Special: false,
|
||||||
|
Uppercase: true,
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
17
examples/password/generate/generatePassword/main.go
Executable file
17
examples/password/generate/generatePassword/main.go
Executable file
@@ -0,0 +1,17 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/password"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Generate a strong random password. Use the switches to control which character types are included, defaults to using all of them
|
||||||
|
func main() {
|
||||||
|
passwordService := password.NewPasswordService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := passwordService.Generate(&password.GenerateRequest{
|
||||||
|
Length: 16,
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
}
|
||||||
21
examples/password/generate/generatePasswordWithoutSpecialCharacters/main.go
Executable file
21
examples/password/generate/generatePasswordWithoutSpecialCharacters/main.go
Executable file
@@ -0,0 +1,21 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/password"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Generate a strong random password. Use the switches to control which character types are included, defaults to using all of them
|
||||||
|
func main() {
|
||||||
|
passwordService := password.NewPasswordService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := passwordService.Generate(&password.GenerateRequest{
|
||||||
|
Length: 16,
|
||||||
|
Lowercase: true,
|
||||||
|
Numbers: true,
|
||||||
|
Special: false,
|
||||||
|
Uppercase: true,
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
}
|
||||||
@@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/ping/api](http
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
|
## Ip
|
||||||
|
|
||||||
|
Ping an IP address
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/ping/api#Ip](https://m3o.com/ping/api#Ip)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/ping"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Ping an IP address
|
||||||
|
func PingAnIp() {
|
||||||
|
pingService := ping.NewPingService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := pingService.Ip(&ping.IpRequest{
|
||||||
|
Address: "google.com",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
## Tcp
|
## Tcp
|
||||||
|
|
||||||
Ping a TCP port is open
|
Ping a TCP port is open
|
||||||
@@ -60,31 +88,3 @@ func CheckAurl() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Ip
|
|
||||||
|
|
||||||
Ping an IP address
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/ping/api#Ip](https://m3o.com/ping/api#Ip)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/ping"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Ping an IP address
|
|
||||||
func PingAnIp() {
|
|
||||||
pingService := ping.NewPingService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := pingService.Ip(&ping.IpRequest{
|
|
||||||
Address: "google.com",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|||||||
@@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/quran/api](htt
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
## Chapters
|
|
||||||
|
|
||||||
List the Chapters (surahs) of the Quran
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/quran/api#Chapters](https://m3o.com/quran/api#Chapters)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/quran"
|
|
||||||
)
|
|
||||||
|
|
||||||
// List the Chapters (surahs) of the Quran
|
|
||||||
func ListChapters() {
|
|
||||||
quranService := quran.NewQuranService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := quranService.Chapters(&quran.ChaptersRequest{
|
|
||||||
Language: "en",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Summary
|
## Summary
|
||||||
|
|
||||||
Get a summary for a given chapter (surah)
|
Get a summary for a given chapter (surah)
|
||||||
@@ -120,3 +92,31 @@ func SearchTheQuran() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
## Chapters
|
||||||
|
|
||||||
|
List the Chapters (surahs) of the Quran
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/quran/api#Chapters](https://m3o.com/quran/api#Chapters)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/quran"
|
||||||
|
)
|
||||||
|
|
||||||
|
// List the Chapters (surahs) of the Quran
|
||||||
|
func ListChapters() {
|
||||||
|
quranService := quran.NewQuranService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := quranService.Chapters(&quran.ChaptersRequest{
|
||||||
|
Language: "en",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
@@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/rss/api](https
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
|
## Remove
|
||||||
|
|
||||||
|
Remove an RSS feed by name
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/rss/api#Remove](https://m3o.com/rss/api#Remove)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/rss"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Remove an RSS feed by name
|
||||||
|
func RemoveAfeed() {
|
||||||
|
rssService := rss.NewRssService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := rssService.Remove(&rss.RemoveRequest{
|
||||||
|
Name: "bbc",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
## Add
|
## Add
|
||||||
|
|
||||||
Add a new RSS feed with a name, url, and category
|
Add a new RSS feed with a name, url, and category
|
||||||
@@ -89,31 +117,3 @@ func ListRssFeeds() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Remove
|
|
||||||
|
|
||||||
Remove an RSS feed by name
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/rss/api#Remove](https://m3o.com/rss/api#Remove)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/rss"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Remove an RSS feed by name
|
|
||||||
func RemoveAfeed() {
|
|
||||||
rssService := rss.NewRssService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := rssService.Remove(&rss.RemoveRequest{
|
|
||||||
Name: "bbc",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|||||||
@@ -4,9 +4,129 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/search/api](ht
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
|
## Index
|
||||||
|
|
||||||
|
Index a record i.e. insert a document to search for.
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/search/api#Index](https://m3o.com/search/api#Index)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/search"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Index a record i.e. insert a document to search for.
|
||||||
|
func IndexArecord() {
|
||||||
|
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := searchService.Index(&search.IndexRequest{
|
||||||
|
Data: map[string]interface{}{
|
||||||
|
"starsign": "Leo",
|
||||||
|
"name": "John Doe",
|
||||||
|
"age": 37,
|
||||||
|
},
|
||||||
|
Index: "customers",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Search
|
||||||
|
|
||||||
|
Search for records in a given in index
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/search/api#Search](https://m3o.com/search/api#Search)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/search"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Search for records in a given in index
|
||||||
|
func SearchForArecord() {
|
||||||
|
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := searchService.Search(&search.SearchRequest{
|
||||||
|
Index: "customers",
|
||||||
|
Query: "name == 'John'",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Search
|
||||||
|
|
||||||
|
Search for records in a given in index
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/search/api#Search](https://m3o.com/search/api#Search)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/search"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Search for records in a given in index
|
||||||
|
func SearchOnMultipleFieldsand() {
|
||||||
|
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := searchService.Search(&search.SearchRequest{
|
||||||
|
Index: "customers",
|
||||||
|
Query: "name == 'John' AND starsign == 'Leo'",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Search
|
||||||
|
|
||||||
|
Search for records in a given in index
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/search/api#Search](https://m3o.com/search/api#Search)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/search"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Search for records in a given in index
|
||||||
|
func SearchOnMultipleFieldsor() {
|
||||||
|
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := searchService.Search(&search.SearchRequest{
|
||||||
|
Index: "customers",
|
||||||
|
Query: "name == 'John' OR name == 'Jane'",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
## Delete
|
## Delete
|
||||||
|
|
||||||
Delete a document given its ID
|
Delete a record given its ID
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/search/api#Delete](https://m3o.com/search/api#Delete)
|
[https://m3o.com/search/api#Delete](https://m3o.com/search/api#Delete)
|
||||||
@@ -21,8 +141,8 @@ import(
|
|||||||
"go.m3o.com/search"
|
"go.m3o.com/search"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Delete a document given its ID
|
// Delete a record given its ID
|
||||||
func DeleteAdocument() {
|
func DeleteArecord() {
|
||||||
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
|
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := searchService.Delete(&search.DeleteRequest{
|
rsp, err := searchService.Delete(&search.DeleteRequest{
|
||||||
Id: "1234",
|
Id: "1234",
|
||||||
@@ -89,126 +209,3 @@ func DeleteAnIndex() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Index
|
|
||||||
|
|
||||||
Index a document i.e. insert a document to search for.
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/search/api#Index](https://m3o.com/search/api#Index)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/search"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Index a document i.e. insert a document to search for.
|
|
||||||
func IndexAdocument() {
|
|
||||||
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := searchService.Index(&search.IndexRequest{
|
|
||||||
Document: &search.Document{
|
|
||||||
Contents: map[string]interface{}{
|
|
||||||
"name": "John Doe",
|
|
||||||
"age": 37,
|
|
||||||
"starsign": "Leo",
|
|
||||||
},
|
|
||||||
Id: "1234",
|
|
||||||
},
|
|
||||||
Index: "customers",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Search
|
|
||||||
|
|
||||||
Search for documents in a given in index
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/search/api#Search](https://m3o.com/search/api#Search)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/search"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Search for documents in a given in index
|
|
||||||
func SearchForAdocument() {
|
|
||||||
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := searchService.Search(&search.SearchRequest{
|
|
||||||
Index: "customers",
|
|
||||||
Query: "name == 'John'",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Search
|
|
||||||
|
|
||||||
Search for documents in a given in index
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/search/api#Search](https://m3o.com/search/api#Search)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/search"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Search for documents in a given in index
|
|
||||||
func SearchOnMultipleFieldsand() {
|
|
||||||
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := searchService.Search(&search.SearchRequest{
|
|
||||||
Index: "customers",
|
|
||||||
Query: "name == 'John' AND starsign == 'Leo'",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Search
|
|
||||||
|
|
||||||
Search for documents in a given in index
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/search/api#Search](https://m3o.com/search/api#Search)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/search"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Search for documents in a given in index
|
|
||||||
func SearchOnMultipleFieldsor() {
|
|
||||||
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := searchService.Search(&search.SearchRequest{
|
|
||||||
Index: "customers",
|
|
||||||
Query: "name == 'John' OR name == 'Jane'",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|||||||
18
examples/search/delete/deleteARecord/main.go
Executable file
18
examples/search/delete/deleteARecord/main.go
Executable file
@@ -0,0 +1,18 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/search"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Delete a record given its ID
|
||||||
|
func main() {
|
||||||
|
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := searchService.Delete(&search.DeleteRequest{
|
||||||
|
Id: "1234",
|
||||||
|
Index: "customers",
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
}
|
||||||
@@ -7,17 +7,14 @@ import (
|
|||||||
"go.m3o.com/search"
|
"go.m3o.com/search"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Index a document i.e. insert a document to search for.
|
// Index a record i.e. insert a document to search for.
|
||||||
func main() {
|
func main() {
|
||||||
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
|
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := searchService.Index(&search.IndexRequest{
|
rsp, err := searchService.Index(&search.IndexRequest{
|
||||||
Document: &search.Document{
|
Data: map[string]interface{}{
|
||||||
Contents: map[string]interface{}{
|
"starsign": "Leo",
|
||||||
"age": 37,
|
"name": "John Doe",
|
||||||
"starsign": "Leo",
|
"age": 37,
|
||||||
"name": "John Doe",
|
|
||||||
},
|
|
||||||
Id: "1234",
|
|
||||||
},
|
},
|
||||||
Index: "customers",
|
Index: "customers",
|
||||||
})
|
})
|
||||||
18
examples/search/search/searchForARecord/main.go
Executable file
18
examples/search/search/searchForARecord/main.go
Executable file
@@ -0,0 +1,18 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/search"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Search for records in a given in index
|
||||||
|
func main() {
|
||||||
|
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := searchService.Search(&search.SearchRequest{
|
||||||
|
Index: "customers",
|
||||||
|
Query: "name == 'John'",
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
}
|
||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
"go.m3o.com/search"
|
"go.m3o.com/search"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Search for documents in a given in index
|
// Search for records in a given in index
|
||||||
func main() {
|
func main() {
|
||||||
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
|
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := searchService.Search(&search.SearchRequest{
|
rsp, err := searchService.Search(&search.SearchRequest{
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
"go.m3o.com/search"
|
"go.m3o.com/search"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Search for documents in a given in index
|
// Search for records in a given in index
|
||||||
func main() {
|
func main() {
|
||||||
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
|
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := searchService.Search(&search.SearchRequest{
|
rsp, err := searchService.Search(&search.SearchRequest{
|
||||||
|
|||||||
@@ -4,120 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/space/api](htt
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
## Update
|
|
||||||
|
|
||||||
Update an object. If an object with this name does not exist, creates a new one.
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/space/api#Update](https://m3o.com/space/api#Update)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/space"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Update an object. If an object with this name does not exist, creates a new one.
|
|
||||||
func UpdateAnObject() {
|
|
||||||
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := spaceService.Update(&space.UpdateRequest{
|
|
||||||
Name: "images/file.jpg",
|
|
||||||
Object: "<file bytes>",
|
|
||||||
Visibility: "public",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Delete
|
|
||||||
|
|
||||||
Delete an object from space
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/space/api#Delete](https://m3o.com/space/api#Delete)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/space"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Delete an object from space
|
|
||||||
func DeleteAnObject() {
|
|
||||||
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := spaceService.Delete(&space.DeleteRequest{
|
|
||||||
Name: "images/file.jpg",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## List
|
|
||||||
|
|
||||||
List the objects in space
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/space/api#List](https://m3o.com/space/api#List)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/space"
|
|
||||||
)
|
|
||||||
|
|
||||||
// List the objects in space
|
|
||||||
func ListObjectsWithPrefix() {
|
|
||||||
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := spaceService.List(&space.ListRequest{
|
|
||||||
Prefix: "images/",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Head
|
|
||||||
|
|
||||||
Retrieve meta information about an object
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/space/api#Head](https://m3o.com/space/api#Head)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/space"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Retrieve meta information about an object
|
|
||||||
func HeadAnObject() {
|
|
||||||
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := spaceService.Head(&space.HeadRequest{
|
|
||||||
Name: "images/file.jpg",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Read
|
## Read
|
||||||
|
|
||||||
Read an object in space
|
Read an object in space
|
||||||
@@ -232,3 +118,117 @@ Visibility: "public",
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
## Update
|
||||||
|
|
||||||
|
Update an object. If an object with this name does not exist, creates a new one.
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/space/api#Update](https://m3o.com/space/api#Update)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/space"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Update an object. If an object with this name does not exist, creates a new one.
|
||||||
|
func UpdateAnObject() {
|
||||||
|
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := spaceService.Update(&space.UpdateRequest{
|
||||||
|
Name: "images/file.jpg",
|
||||||
|
Object: "<file bytes>",
|
||||||
|
Visibility: "public",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Delete
|
||||||
|
|
||||||
|
Delete an object from space
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/space/api#Delete](https://m3o.com/space/api#Delete)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/space"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Delete an object from space
|
||||||
|
func DeleteAnObject() {
|
||||||
|
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := spaceService.Delete(&space.DeleteRequest{
|
||||||
|
Name: "images/file.jpg",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## List
|
||||||
|
|
||||||
|
List the objects in space
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/space/api#List](https://m3o.com/space/api#List)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/space"
|
||||||
|
)
|
||||||
|
|
||||||
|
// List the objects in space
|
||||||
|
func ListObjectsWithPrefix() {
|
||||||
|
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := spaceService.List(&space.ListRequest{
|
||||||
|
Prefix: "images/",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Head
|
||||||
|
|
||||||
|
Retrieve meta information about an object
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/space/api#Head](https://m3o.com/space/api#Head)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/space"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Retrieve meta information about an object
|
||||||
|
func HeadAnObject() {
|
||||||
|
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := spaceService.Head(&space.HeadRequest{
|
||||||
|
Name: "images/file.jpg",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
@@ -4,35 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/sunnah/api](ht
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
## Chapters
|
|
||||||
|
|
||||||
Get all the chapters of a given book within a collection.
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/sunnah/api#Chapters](https://m3o.com/sunnah/api#Chapters)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/sunnah"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Get all the chapters of a given book within a collection.
|
|
||||||
func ListTheChaptersInAbook() {
|
|
||||||
sunnahService := sunnah.NewSunnahService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := sunnahService.Chapters(&sunnah.ChaptersRequest{
|
|
||||||
Book: 1,
|
|
||||||
Collection: "bukhari",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Hadiths
|
## Hadiths
|
||||||
|
|
||||||
Hadiths returns a list of hadiths and their corresponding text for a
|
Hadiths returns a list of hadiths and their corresponding text for a
|
||||||
@@ -123,3 +94,32 @@ func GetTheBooksWithinAcollection() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
## Chapters
|
||||||
|
|
||||||
|
Get all the chapters of a given book within a collection.
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/sunnah/api#Chapters](https://m3o.com/sunnah/api#Chapters)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/sunnah"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Get all the chapters of a given book within a collection.
|
||||||
|
func ListTheChaptersInAbook() {
|
||||||
|
sunnahService := sunnah.NewSunnahService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := sunnahService.Chapters(&sunnah.ChaptersRequest{
|
||||||
|
Book: 1,
|
||||||
|
Collection: "bukhari",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
@@ -4,6 +4,326 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/user/api](http
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
|
## VerifyToken
|
||||||
|
|
||||||
|
Check whether the token attached to MagicLink is valid or not.
|
||||||
|
Ideally, you need to call this endpoint from your http request
|
||||||
|
handler that handles the endpoint which is specified in the
|
||||||
|
SendMagicLink request.
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/user/api#VerifyToken](https://m3o.com/user/api#VerifyToken)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/user"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Check whether the token attached to MagicLink is valid or not.
|
||||||
|
// Ideally, you need to call this endpoint from your http request
|
||||||
|
// handler that handles the endpoint which is specified in the
|
||||||
|
// SendMagicLink request.
|
||||||
|
func VerifyAtoken() {
|
||||||
|
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := userService.VerifyToken(&user.VerifyTokenRequest{
|
||||||
|
Token: "EdsUiidouJJJLldjlloofUiorkojflsWWdld",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## SendVerificationEmail
|
||||||
|
|
||||||
|
Send a verification email to a user.
|
||||||
|
Email "from" will be 'noreply@email.m3ocontent.com'.
|
||||||
|
The verification link will be injected in the email
|
||||||
|
as a template variable, $micro_verification_link e.g
|
||||||
|
'Welcome to M3O! Use the link below to verify your email: $micro_verification_link'
|
||||||
|
The variable will be replaced with a url similar to:
|
||||||
|
'https://user.m3o.com/user/verify?token=a-verification-token&redirectUrl=your-redir-url'
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/user/api#SendVerificationEmail](https://m3o.com/user/api#SendVerificationEmail)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/user"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Send a verification email to a user.
|
||||||
|
// Email "from" will be 'noreply@email.m3ocontent.com'.
|
||||||
|
// The verification link will be injected in the email
|
||||||
|
// as a template variable, $micro_verification_link e.g
|
||||||
|
// 'Welcome to M3O! Use the link below to verify your email: $micro_verification_link'
|
||||||
|
// The variable will be replaced with a url similar to:
|
||||||
|
// 'https://user.m3o.com/user/verify?token=a-verification-token&redirectUrl=your-redir-url'
|
||||||
|
func SendVerificationEmail() {
|
||||||
|
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := userService.SendVerificationEmail(&user.SendVerificationEmailRequest{
|
||||||
|
Email: "joe@example.com",
|
||||||
|
FailureRedirectUrl: "https://m3o.com/verification-failed",
|
||||||
|
FromName: "Awesome Dot Com",
|
||||||
|
RedirectUrl: "https://m3o.com",
|
||||||
|
Subject: "Email verification",
|
||||||
|
TextContent: `Hi there,
|
||||||
|
|
||||||
|
Please verify your email by clicking this link: $micro_verification_link`,
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## VerifyEmail
|
||||||
|
|
||||||
|
Verify the email address of an account from a token sent in an email to the user.
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/user/api#VerifyEmail](https://m3o.com/user/api#VerifyEmail)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/user"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Verify the email address of an account from a token sent in an email to the user.
|
||||||
|
func VerifyEmail() {
|
||||||
|
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := userService.VerifyEmail(&user.VerifyEmailRequest{
|
||||||
|
Token: "012345",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## List
|
||||||
|
|
||||||
|
List all users. Returns a paged list of results
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/user/api#List](https://m3o.com/user/api#List)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/user"
|
||||||
|
)
|
||||||
|
|
||||||
|
// List all users. Returns a paged list of results
|
||||||
|
func ListAllUsers() {
|
||||||
|
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := userService.List(&user.ListRequest{
|
||||||
|
Limit: 100,
|
||||||
|
Offset: 0,
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## SendPasswordResetEmail
|
||||||
|
|
||||||
|
Send an email with a verification code to reset password.
|
||||||
|
Call "ResetPassword" endpoint once user provides the code.
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/user/api#SendPasswordResetEmail](https://m3o.com/user/api#SendPasswordResetEmail)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/user"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Send an email with a verification code to reset password.
|
||||||
|
// Call "ResetPassword" endpoint once user provides the code.
|
||||||
|
func SendPasswordResetEmail() {
|
||||||
|
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := userService.SendPasswordResetEmail(&user.SendPasswordResetEmailRequest{
|
||||||
|
Email: "joe@example.com",
|
||||||
|
FromName: "Awesome Dot Com",
|
||||||
|
Subject: "Password reset",
|
||||||
|
TextContent: `Hi there,
|
||||||
|
click here to reset your password: myapp.com/reset/code?=$code`,
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Login
|
||||||
|
|
||||||
|
Login using username or email. The response will return a new session for successful login,
|
||||||
|
401 in the case of login failure and 500 for any other error
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/user/api#Login](https://m3o.com/user/api#Login)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/user"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Login using username or email. The response will return a new session for successful login,
|
||||||
|
// 401 in the case of login failure and 500 for any other error
|
||||||
|
func LogAuserIn() {
|
||||||
|
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := userService.Login(&user.LoginRequest{
|
||||||
|
Email: "joe@example.com",
|
||||||
|
Password: "Password1",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Logout
|
||||||
|
|
||||||
|
Logout a user account
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/user/api#Logout](https://m3o.com/user/api#Logout)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/user"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Logout a user account
|
||||||
|
func LogAuserOut() {
|
||||||
|
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := userService.Logout(&user.LogoutRequest{
|
||||||
|
SessionId: "df91a612-5b24-4634-99ff-240220ab8f55",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## ReadSession
|
||||||
|
|
||||||
|
Read a session by the session id. In the event it has expired or is not found and error is returned.
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/user/api#ReadSession](https://m3o.com/user/api#ReadSession)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/user"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Read a session by the session id. In the event it has expired or is not found and error is returned.
|
||||||
|
func ReadAsessionByTheSessionId() {
|
||||||
|
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := userService.ReadSession(&user.ReadSessionRequest{
|
||||||
|
SessionId: "df91a612-5b24-4634-99ff-240220ab8f55",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Update
|
||||||
|
|
||||||
|
Update the account username or email
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/user/api#Update](https://m3o.com/user/api#Update)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/user"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Update the account username or email
|
||||||
|
func UpdateAnAccount() {
|
||||||
|
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := userService.Update(&user.UpdateRequest{
|
||||||
|
Email: "joe+2@example.com",
|
||||||
|
Id: "user-1",
|
||||||
|
Username: "joe",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## ResetPassword
|
||||||
|
|
||||||
|
Reset password with the code sent by the "SendPasswordResetEmail" endpoint.
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/user/api#ResetPassword](https://m3o.com/user/api#ResetPassword)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/user"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Reset password with the code sent by the "SendPasswordResetEmail" endpoint.
|
||||||
|
func ResetPassword() {
|
||||||
|
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := userService.ResetPassword(&user.ResetPasswordRequest{
|
||||||
|
Code: "012345",
|
||||||
|
ConfirmPassword: "NewPassword1",
|
||||||
|
Email: "joe@example.com",
|
||||||
|
NewPassword: "NewPassword1",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
## Delete
|
## Delete
|
||||||
|
|
||||||
Delete an account by id
|
Delete an account by id
|
||||||
@@ -67,18 +387,12 @@ Click here to access your account $micro_verification_link`,
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## SendVerificationEmail
|
## Create
|
||||||
|
|
||||||
Send a verification email to a user.
|
Create a new user account. The email address and username for the account must be unique.
|
||||||
Email "from" will be 'noreply@email.m3ocontent.com'.
|
|
||||||
The verification link will be injected in the email
|
|
||||||
as a template variable, $micro_verification_link e.g
|
|
||||||
'Welcome to M3O! Use the link below to verify your email: $micro_verification_link'
|
|
||||||
The variable will be replaced with a url similar to:
|
|
||||||
'https://user.m3o.com/user/verify?token=a-verification-token&redirectUrl=your-redir-url'
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/user/api#SendVerificationEmail](https://m3o.com/user/api#SendVerificationEmail)
|
[https://m3o.com/user/api#Create](https://m3o.com/user/api#Create)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
package example
|
package example
|
||||||
@@ -90,24 +404,45 @@ import(
|
|||||||
"go.m3o.com/user"
|
"go.m3o.com/user"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Send a verification email to a user.
|
// Create a new user account. The email address and username for the account must be unique.
|
||||||
// Email "from" will be 'noreply@email.m3ocontent.com'.
|
func CreateAnAccount() {
|
||||||
// The verification link will be injected in the email
|
|
||||||
// as a template variable, $micro_verification_link e.g
|
|
||||||
// 'Welcome to M3O! Use the link below to verify your email: $micro_verification_link'
|
|
||||||
// The variable will be replaced with a url similar to:
|
|
||||||
// 'https://user.m3o.com/user/verify?token=a-verification-token&redirectUrl=your-redir-url'
|
|
||||||
func SendVerificationEmail() {
|
|
||||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := userService.SendVerificationEmail(&user.SendVerificationEmailRequest{
|
rsp, err := userService.Create(&user.CreateRequest{
|
||||||
Email: "joe@example.com",
|
Email: "joe@example.com",
|
||||||
FailureRedirectUrl: "https://m3o.com/verification-failed",
|
Id: "user-1",
|
||||||
FromName: "Awesome Dot Com",
|
Password: "Password1",
|
||||||
RedirectUrl: "https://m3o.com",
|
Username: "joe",
|
||||||
Subject: "Email verification",
|
|
||||||
TextContent: `Hi there,
|
|
||||||
|
|
||||||
Please verify your email by clicking this link: $micro_verification_link`,
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## UpdatePassword
|
||||||
|
|
||||||
|
Update the account password
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/user/api#UpdatePassword](https://m3o.com/user/api#UpdatePassword)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/user"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Update the account password
|
||||||
|
func UpdateTheAccountPassword() {
|
||||||
|
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := userService.UpdatePassword(&user.UpdatePasswordRequest{
|
||||||
|
ConfirmPassword: "Password2",
|
||||||
|
NewPassword: "Password2",
|
||||||
|
OldPassword: "Password1",
|
||||||
|
UserId: "user-1",
|
||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
@@ -198,337 +533,3 @@ func ReadAccountByEmail() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## UpdatePassword
|
|
||||||
|
|
||||||
Update the account password
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/user/api#UpdatePassword](https://m3o.com/user/api#UpdatePassword)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/user"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Update the account password
|
|
||||||
func UpdateTheAccountPassword() {
|
|
||||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := userService.UpdatePassword(&user.UpdatePasswordRequest{
|
|
||||||
ConfirmPassword: "Password2",
|
|
||||||
NewPassword: "Password2",
|
|
||||||
OldPassword: "Password1",
|
|
||||||
UserId: "user-1",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## SendPasswordResetEmail
|
|
||||||
|
|
||||||
Send an email with a verification code to reset password.
|
|
||||||
Call "ResetPassword" endpoint once user provides the code.
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/user/api#SendPasswordResetEmail](https://m3o.com/user/api#SendPasswordResetEmail)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/user"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Send an email with a verification code to reset password.
|
|
||||||
// Call "ResetPassword" endpoint once user provides the code.
|
|
||||||
func SendPasswordResetEmail() {
|
|
||||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := userService.SendPasswordResetEmail(&user.SendPasswordResetEmailRequest{
|
|
||||||
Email: "joe@example.com",
|
|
||||||
FromName: "Awesome Dot Com",
|
|
||||||
Subject: "Password reset",
|
|
||||||
TextContent: `Hi there,
|
|
||||||
click here to reset your password: myapp.com/reset/code?=$code`,
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## VerifyEmail
|
|
||||||
|
|
||||||
Verify the email address of an account from a token sent in an email to the user.
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/user/api#VerifyEmail](https://m3o.com/user/api#VerifyEmail)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/user"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Verify the email address of an account from a token sent in an email to the user.
|
|
||||||
func VerifyEmail() {
|
|
||||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := userService.VerifyEmail(&user.VerifyEmailRequest{
|
|
||||||
Token: "012345",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## ReadSession
|
|
||||||
|
|
||||||
Read a session by the session id. In the event it has expired or is not found and error is returned.
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/user/api#ReadSession](https://m3o.com/user/api#ReadSession)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/user"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Read a session by the session id. In the event it has expired or is not found and error is returned.
|
|
||||||
func ReadAsessionByTheSessionId() {
|
|
||||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := userService.ReadSession(&user.ReadSessionRequest{
|
|
||||||
SessionId: "df91a612-5b24-4634-99ff-240220ab8f55",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## List
|
|
||||||
|
|
||||||
List all users. Returns a paged list of results
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/user/api#List](https://m3o.com/user/api#List)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/user"
|
|
||||||
)
|
|
||||||
|
|
||||||
// List all users. Returns a paged list of results
|
|
||||||
func ListAllUsers() {
|
|
||||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := userService.List(&user.ListRequest{
|
|
||||||
Limit: 100,
|
|
||||||
Offset: 0,
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## VerifyToken
|
|
||||||
|
|
||||||
Check whether the token attached to MagicLink is valid or not.
|
|
||||||
Ideally, you need to call this endpoint from your http request
|
|
||||||
handler that handles the endpoint which is specified in the
|
|
||||||
SendMagicLink request.
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/user/api#VerifyToken](https://m3o.com/user/api#VerifyToken)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/user"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Check whether the token attached to MagicLink is valid or not.
|
|
||||||
// Ideally, you need to call this endpoint from your http request
|
|
||||||
// handler that handles the endpoint which is specified in the
|
|
||||||
// SendMagicLink request.
|
|
||||||
func VerifyAtoken() {
|
|
||||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := userService.VerifyToken(&user.VerifyTokenRequest{
|
|
||||||
Token: "EdsUiidouJJJLldjlloofUiorkojflsWWdld",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Create
|
|
||||||
|
|
||||||
Create a new user account. The email address and username for the account must be unique.
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/user/api#Create](https://m3o.com/user/api#Create)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/user"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Create a new user account. The email address and username for the account must be unique.
|
|
||||||
func CreateAnAccount() {
|
|
||||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := userService.Create(&user.CreateRequest{
|
|
||||||
Email: "joe@example.com",
|
|
||||||
Id: "user-1",
|
|
||||||
Password: "Password1",
|
|
||||||
Username: "joe",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## ResetPassword
|
|
||||||
|
|
||||||
Reset password with the code sent by the "SendPasswordResetEmail" endoint.
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/user/api#ResetPassword](https://m3o.com/user/api#ResetPassword)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/user"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Reset password with the code sent by the "SendPasswordResetEmail" endoint.
|
|
||||||
func ResetPassword() {
|
|
||||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := userService.ResetPassword(&user.ResetPasswordRequest{
|
|
||||||
Code: "012345",
|
|
||||||
ConfirmPassword: "NewPassword1",
|
|
||||||
Email: "joe@example.com",
|
|
||||||
NewPassword: "NewPassword1",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Login
|
|
||||||
|
|
||||||
Login using username or email. The response will return a new session for successful login,
|
|
||||||
401 in the case of login failure and 500 for any other error
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/user/api#Login](https://m3o.com/user/api#Login)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/user"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Login using username or email. The response will return a new session for successful login,
|
|
||||||
// 401 in the case of login failure and 500 for any other error
|
|
||||||
func LogAuserIn() {
|
|
||||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := userService.Login(&user.LoginRequest{
|
|
||||||
Email: "joe@example.com",
|
|
||||||
Password: "Password1",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Logout
|
|
||||||
|
|
||||||
Logout a user account
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/user/api#Logout](https://m3o.com/user/api#Logout)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/user"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Logout a user account
|
|
||||||
func LogAuserOut() {
|
|
||||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := userService.Logout(&user.LogoutRequest{
|
|
||||||
SessionId: "df91a612-5b24-4634-99ff-240220ab8f55",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Update
|
|
||||||
|
|
||||||
Update the account username or email
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/user/api#Update](https://m3o.com/user/api#Update)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/user"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Update the account username or email
|
|
||||||
func UpdateAnAccount() {
|
|
||||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := userService.Update(&user.UpdateRequest{
|
|
||||||
Email: "joe+2@example.com",
|
|
||||||
Id: "user-1",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
"go.m3o.com/user"
|
"go.m3o.com/user"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Reset password with the code sent by the "SendPasswordResetEmail" endoint.
|
// Reset password with the code sent by the "SendPasswordResetEmail" endpoint.
|
||||||
func main() {
|
func main() {
|
||||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := userService.ResetPassword(&user.ResetPasswordRequest{
|
rsp, err := userService.ResetPassword(&user.ResetPasswordRequest{
|
||||||
|
|||||||
@@ -11,8 +11,9 @@ import (
|
|||||||
func main() {
|
func main() {
|
||||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := userService.Update(&user.UpdateRequest{
|
rsp, err := userService.Update(&user.UpdateRequest{
|
||||||
Email: "joe+2@example.com",
|
Email: "joe+2@example.com",
|
||||||
Id: "user-1",
|
Id: "user-1",
|
||||||
|
Username: "joe",
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/youtube/api](h
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
## Search
|
|
||||||
|
|
||||||
Search for videos on YouTube
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/youtube/api#Search](https://m3o.com/youtube/api#Search)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/youtube"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Search for videos on YouTube
|
|
||||||
func SearchForVideos() {
|
|
||||||
youtubeService := youtube.NewYoutubeService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := youtubeService.Search(&youtube.SearchRequest{
|
|
||||||
Query: "donuts",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Embed
|
## Embed
|
||||||
|
|
||||||
Embed a YouTube video
|
Embed a YouTube video
|
||||||
@@ -60,3 +32,31 @@ func EmbedAyoutubeVideo() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
## Search
|
||||||
|
|
||||||
|
Search for videos on YouTube
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/youtube/api#Search](https://m3o.com/youtube/api#Search)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/youtube"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Search for videos on YouTube
|
||||||
|
func SearchForVideos() {
|
||||||
|
youtubeService := youtube.NewYoutubeService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := youtubeService.Search(&youtube.SearchRequest{
|
||||||
|
Query: "donuts",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ type Function interface {
|
|||||||
Proxy(*ProxyRequest) (*ProxyResponse, error)
|
Proxy(*ProxyRequest) (*ProxyResponse, error)
|
||||||
Regions(*RegionsRequest) (*RegionsResponse, error)
|
Regions(*RegionsRequest) (*RegionsResponse, error)
|
||||||
Reserve(*ReserveRequest) (*ReserveResponse, error)
|
Reserve(*ReserveRequest) (*ReserveResponse, error)
|
||||||
|
Runtimes(*RuntimesRequest) (*RuntimesResponse, error)
|
||||||
Update(*UpdateRequest) (*UpdateResponse, error)
|
Update(*UpdateRequest) (*UpdateResponse, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,6 +93,14 @@ func (t *FunctionService) Reserve(request *ReserveRequest) (*ReserveResponse, er
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return a list of supported runtimes
|
||||||
|
func (t *FunctionService) Runtimes(request *RuntimesRequest) (*RuntimesResponse, error) {
|
||||||
|
|
||||||
|
rsp := &RuntimesResponse{}
|
||||||
|
return rsp, t.client.Call("function", "Runtimes", request, rsp)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Update a function. Downloads the source, builds and redeploys
|
// Update a function. Downloads the source, builds and redeploys
|
||||||
func (t *FunctionService) Update(request *UpdateRequest) (*UpdateResponse, error) {
|
func (t *FunctionService) Update(request *UpdateRequest) (*UpdateResponse, error) {
|
||||||
|
|
||||||
@@ -132,13 +141,15 @@ type DeployRequest struct {
|
|||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
// region to deploy in. defaults to europe-west1
|
// region to deploy in. defaults to europe-west1
|
||||||
Region string `json:"region"`
|
Region string `json:"region"`
|
||||||
// github url to repo
|
// github url for a repo
|
||||||
Repo string `json:"repo"`
|
Repo string `json:"repo"`
|
||||||
// runtime/lanaguage of the function e.g php74,
|
// runtime/lanaguage of the function e.g php74,
|
||||||
// nodejs6, nodejs8, nodejs10, nodejs12, nodejs14, nodejs16,
|
// nodejs6, nodejs8, nodejs10, nodejs12, nodejs14, nodejs16,
|
||||||
// dotnet3, java11, ruby26, ruby27, go111, go113, go116,
|
// dotnet3, java11, ruby26, ruby27, go111, go113, go116,
|
||||||
// python37, python38, python39
|
// python37, python38, python39
|
||||||
Runtime string `json:"runtime"`
|
Runtime string `json:"runtime"`
|
||||||
|
// inline source code
|
||||||
|
Source string `json:"source"`
|
||||||
// optional subfolder path
|
// optional subfolder path
|
||||||
Subfolder string `json:"subfolder"`
|
Subfolder string `json:"subfolder"`
|
||||||
}
|
}
|
||||||
@@ -180,6 +191,8 @@ type Func struct {
|
|||||||
// dotnet3, java11, ruby26, ruby27, go111, go113, go116,
|
// dotnet3, java11, ruby26, ruby27, go111, go113, go116,
|
||||||
// python37, python38, python39
|
// python37, python38, python39
|
||||||
Runtime string `json:"runtime"`
|
Runtime string `json:"runtime"`
|
||||||
|
// the source code
|
||||||
|
Source string `json:"source"`
|
||||||
// eg. ACTIVE, DEPLOY_IN_PROGRESS, OFFLINE etc
|
// eg. ACTIVE, DEPLOY_IN_PROGRESS, OFFLINE etc
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
// subfolder path to entrypoint
|
// subfolder path to entrypoint
|
||||||
@@ -238,9 +251,18 @@ type ReserveResponse struct {
|
|||||||
Reservation *Reservation `json:"reservation"`
|
Reservation *Reservation `json:"reservation"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type RuntimesRequest struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
type RuntimesResponse struct {
|
||||||
|
Runtimes []string `json:"runtimes"`
|
||||||
|
}
|
||||||
|
|
||||||
type UpdateRequest struct {
|
type UpdateRequest struct {
|
||||||
// function name
|
// function name
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
|
// inline source code
|
||||||
|
Source string `json:"source"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type UpdateResponse struct {
|
type UpdateResponse struct {
|
||||||
|
|||||||
162
lists/lists.go
Executable file
162
lists/lists.go
Executable file
@@ -0,0 +1,162 @@
|
|||||||
|
package lists
|
||||||
|
|
||||||
|
import (
|
||||||
|
"go.m3o.com/client"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Lists 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 NewListsService(token string) *ListsService {
|
||||||
|
return &ListsService{
|
||||||
|
client: client.NewClient(&client.Options{
|
||||||
|
Token: token,
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type ListsService struct {
|
||||||
|
client *client.Client
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a new list
|
||||||
|
func (t *ListsService) Create(request *CreateRequest) (*CreateResponse, error) {
|
||||||
|
|
||||||
|
rsp := &CreateResponse{}
|
||||||
|
return rsp, t.client.Call("lists", "Create", request, rsp)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete a list
|
||||||
|
func (t *ListsService) Delete(request *DeleteRequest) (*DeleteResponse, error) {
|
||||||
|
|
||||||
|
rsp := &DeleteResponse{}
|
||||||
|
return rsp, t.client.Call("lists", "Delete", request, rsp)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Subscribe to lists events
|
||||||
|
func (t *ListsService) Events(request *EventsRequest) (*EventsResponseStream, error) {
|
||||||
|
stream, err := t.client.Stream("lists", "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 lists
|
||||||
|
func (t *ListsService) List(request *ListRequest) (*ListResponse, error) {
|
||||||
|
|
||||||
|
rsp := &ListResponse{}
|
||||||
|
return rsp, t.client.Call("lists", "List", request, rsp)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read a list
|
||||||
|
func (t *ListsService) Read(request *ReadRequest) (*ReadResponse, error) {
|
||||||
|
|
||||||
|
rsp := &ReadResponse{}
|
||||||
|
return rsp, t.client.Call("lists", "Read", request, rsp)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update a list
|
||||||
|
func (t *ListsService) Update(request *UpdateRequest) (*UpdateResponse, error) {
|
||||||
|
|
||||||
|
rsp := &UpdateResponse{}
|
||||||
|
return rsp, t.client.Call("lists", "Update", request, rsp)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
type CreateRequest struct {
|
||||||
|
// list items
|
||||||
|
Items []string `json:"items"`
|
||||||
|
// list name
|
||||||
|
Name string `json:"name"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CreateResponse struct {
|
||||||
|
// The created list
|
||||||
|
List *List `json:"list"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type DeleteRequest struct {
|
||||||
|
// specify the id of the list
|
||||||
|
Id string `json:"id"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type DeleteResponse struct {
|
||||||
|
List *List `json:"list"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type EventsRequest struct {
|
||||||
|
// optionally specify a list id
|
||||||
|
Id string `json:"id"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type EventsResponse struct {
|
||||||
|
// the event which occured; create, delete, update
|
||||||
|
Event string `json:"event"`
|
||||||
|
// the list which the operation occured on
|
||||||
|
List *List `json:"list"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type List struct {
|
||||||
|
// time at which the list was created
|
||||||
|
Created string `json:"created"`
|
||||||
|
// unique id for the list, generated if not specified
|
||||||
|
Id string `json:"id"`
|
||||||
|
// items within the list
|
||||||
|
Items []string `json:"items"`
|
||||||
|
// name of the list
|
||||||
|
Name string `json:"name"`
|
||||||
|
// time at which the list was updated
|
||||||
|
Updated string `json:"updated"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ListRequest struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
type ListResponse struct {
|
||||||
|
// the list of lists
|
||||||
|
Lists []List `json:"lists"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ReadRequest struct {
|
||||||
|
// the list id
|
||||||
|
Id string `json:"id"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ReadResponse struct {
|
||||||
|
// The list
|
||||||
|
List *List `json:"list"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type UpdateRequest struct {
|
||||||
|
List *List `json:"list"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type UpdateResponse struct {
|
||||||
|
List *List `json:"list"`
|
||||||
|
}
|
||||||
251
m3o.go
251
m3o.go
@@ -7,6 +7,8 @@ import (
|
|||||||
"go.m3o.com/avatar"
|
"go.m3o.com/avatar"
|
||||||
"go.m3o.com/cache"
|
"go.m3o.com/cache"
|
||||||
"go.m3o.com/carbon"
|
"go.m3o.com/carbon"
|
||||||
|
"go.m3o.com/chat"
|
||||||
|
"go.m3o.com/comments"
|
||||||
"go.m3o.com/contact"
|
"go.m3o.com/contact"
|
||||||
"go.m3o.com/crypto"
|
"go.m3o.com/crypto"
|
||||||
"go.m3o.com/currency"
|
"go.m3o.com/currency"
|
||||||
@@ -27,7 +29,9 @@ import (
|
|||||||
"go.m3o.com/image"
|
"go.m3o.com/image"
|
||||||
"go.m3o.com/ip"
|
"go.m3o.com/ip"
|
||||||
"go.m3o.com/joke"
|
"go.m3o.com/joke"
|
||||||
|
"go.m3o.com/lists"
|
||||||
"go.m3o.com/location"
|
"go.m3o.com/location"
|
||||||
|
"go.m3o.com/memegen"
|
||||||
"go.m3o.com/minecraft"
|
"go.m3o.com/minecraft"
|
||||||
"go.m3o.com/movie"
|
"go.m3o.com/movie"
|
||||||
"go.m3o.com/mq"
|
"go.m3o.com/mq"
|
||||||
@@ -35,6 +39,7 @@ import (
|
|||||||
"go.m3o.com/nft"
|
"go.m3o.com/nft"
|
||||||
"go.m3o.com/notes"
|
"go.m3o.com/notes"
|
||||||
"go.m3o.com/otp"
|
"go.m3o.com/otp"
|
||||||
|
"go.m3o.com/password"
|
||||||
"go.m3o.com/ping"
|
"go.m3o.com/ping"
|
||||||
"go.m3o.com/place"
|
"go.m3o.com/place"
|
||||||
"go.m3o.com/postcode"
|
"go.m3o.com/postcode"
|
||||||
@@ -66,128 +71,138 @@ func NewClient(token string) *Client {
|
|||||||
return &Client{
|
return &Client{
|
||||||
token: token,
|
token: token,
|
||||||
|
|
||||||
AddressService: address.NewAddressService(token),
|
Address: address.NewAddressService(token),
|
||||||
AnswerService: answer.NewAnswerService(token),
|
Answer: answer.NewAnswerService(token),
|
||||||
AppService: app.NewAppService(token),
|
App: app.NewAppService(token),
|
||||||
AvatarService: avatar.NewAvatarService(token),
|
Avatar: avatar.NewAvatarService(token),
|
||||||
CacheService: cache.NewCacheService(token),
|
Cache: cache.NewCacheService(token),
|
||||||
CarbonService: carbon.NewCarbonService(token),
|
Carbon: carbon.NewCarbonService(token),
|
||||||
ContactService: contact.NewContactService(token),
|
Chat: chat.NewChatService(token),
|
||||||
CryptoService: crypto.NewCryptoService(token),
|
Comments: comments.NewCommentsService(token),
|
||||||
CurrencyService: currency.NewCurrencyService(token),
|
Contact: contact.NewContactService(token),
|
||||||
DbService: db.NewDbService(token),
|
Crypto: crypto.NewCryptoService(token),
|
||||||
EmailService: email.NewEmailService(token),
|
Currency: currency.NewCurrencyService(token),
|
||||||
EmojiService: emoji.NewEmojiService(token),
|
Db: db.NewDbService(token),
|
||||||
EvchargersService: evchargers.NewEvchargersService(token),
|
Email: email.NewEmailService(token),
|
||||||
EventService: event.NewEventService(token),
|
Emoji: emoji.NewEmojiService(token),
|
||||||
FileService: file.NewFileService(token),
|
Evchargers: evchargers.NewEvchargersService(token),
|
||||||
ForexService: forex.NewForexService(token),
|
Event: event.NewEventService(token),
|
||||||
FunctionService: function.NewFunctionService(token),
|
File: file.NewFileService(token),
|
||||||
GeocodingService: geocoding.NewGeocodingService(token),
|
Forex: forex.NewForexService(token),
|
||||||
GifsService: gifs.NewGifsService(token),
|
Function: function.NewFunctionService(token),
|
||||||
GoogleService: google.NewGoogleService(token),
|
Geocoding: geocoding.NewGeocodingService(token),
|
||||||
HelloworldService: helloworld.NewHelloworldService(token),
|
Gifs: gifs.NewGifsService(token),
|
||||||
HolidaysService: holidays.NewHolidaysService(token),
|
Google: google.NewGoogleService(token),
|
||||||
IdService: id.NewIdService(token),
|
Helloworld: helloworld.NewHelloworldService(token),
|
||||||
ImageService: image.NewImageService(token),
|
Holidays: holidays.NewHolidaysService(token),
|
||||||
IpService: ip.NewIpService(token),
|
Id: id.NewIdService(token),
|
||||||
JokeService: joke.NewJokeService(token),
|
Image: image.NewImageService(token),
|
||||||
LocationService: location.NewLocationService(token),
|
Ip: ip.NewIpService(token),
|
||||||
MinecraftService: minecraft.NewMinecraftService(token),
|
Joke: joke.NewJokeService(token),
|
||||||
MovieService: movie.NewMovieService(token),
|
Lists: lists.NewListsService(token),
|
||||||
MqService: mq.NewMqService(token),
|
Location: location.NewLocationService(token),
|
||||||
NewsService: news.NewNewsService(token),
|
Memegen: memegen.NewMemegenService(token),
|
||||||
NftService: nft.NewNftService(token),
|
Minecraft: minecraft.NewMinecraftService(token),
|
||||||
NotesService: notes.NewNotesService(token),
|
Movie: movie.NewMovieService(token),
|
||||||
OtpService: otp.NewOtpService(token),
|
Mq: mq.NewMqService(token),
|
||||||
PingService: ping.NewPingService(token),
|
News: news.NewNewsService(token),
|
||||||
PlaceService: place.NewPlaceService(token),
|
Nft: nft.NewNftService(token),
|
||||||
PostcodeService: postcode.NewPostcodeService(token),
|
Notes: notes.NewNotesService(token),
|
||||||
PrayerService: prayer.NewPrayerService(token),
|
Otp: otp.NewOtpService(token),
|
||||||
QrService: qr.NewQrService(token),
|
Password: password.NewPasswordService(token),
|
||||||
QuranService: quran.NewQuranService(token),
|
Ping: ping.NewPingService(token),
|
||||||
RoutingService: routing.NewRoutingService(token),
|
Place: place.NewPlaceService(token),
|
||||||
RssService: rss.NewRssService(token),
|
Postcode: postcode.NewPostcodeService(token),
|
||||||
SearchService: search.NewSearchService(token),
|
Prayer: prayer.NewPrayerService(token),
|
||||||
SentimentService: sentiment.NewSentimentService(token),
|
Qr: qr.NewQrService(token),
|
||||||
SmsService: sms.NewSmsService(token),
|
Quran: quran.NewQuranService(token),
|
||||||
SpaceService: space.NewSpaceService(token),
|
Routing: routing.NewRoutingService(token),
|
||||||
SpamService: spam.NewSpamService(token),
|
Rss: rss.NewRssService(token),
|
||||||
StockService: stock.NewStockService(token),
|
Search: search.NewSearchService(token),
|
||||||
StreamService: stream.NewStreamService(token),
|
Sentiment: sentiment.NewSentimentService(token),
|
||||||
SunnahService: sunnah.NewSunnahService(token),
|
Sms: sms.NewSmsService(token),
|
||||||
ThumbnailService: thumbnail.NewThumbnailService(token),
|
Space: space.NewSpaceService(token),
|
||||||
TimeService: time.NewTimeService(token),
|
Spam: spam.NewSpamService(token),
|
||||||
TranslateService: translate.NewTranslateService(token),
|
Stock: stock.NewStockService(token),
|
||||||
TwitterService: twitter.NewTwitterService(token),
|
Stream: stream.NewStreamService(token),
|
||||||
UrlService: url.NewUrlService(token),
|
Sunnah: sunnah.NewSunnahService(token),
|
||||||
UserService: user.NewUserService(token),
|
Thumbnail: thumbnail.NewThumbnailService(token),
|
||||||
VehicleService: vehicle.NewVehicleService(token),
|
Time: time.NewTimeService(token),
|
||||||
WeatherService: weather.NewWeatherService(token),
|
Translate: translate.NewTranslateService(token),
|
||||||
YoutubeService: youtube.NewYoutubeService(token),
|
Twitter: twitter.NewTwitterService(token),
|
||||||
|
Url: url.NewUrlService(token),
|
||||||
|
User: user.NewUserService(token),
|
||||||
|
Vehicle: vehicle.NewVehicleService(token),
|
||||||
|
Weather: weather.NewWeatherService(token),
|
||||||
|
Youtube: youtube.NewYoutubeService(token),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type Client struct {
|
type Client struct {
|
||||||
token string
|
token string
|
||||||
|
|
||||||
AddressService *address.AddressService
|
Address address.Address
|
||||||
AnswerService *answer.AnswerService
|
Answer answer.Answer
|
||||||
AppService *app.AppService
|
App app.App
|
||||||
AvatarService *avatar.AvatarService
|
Avatar avatar.Avatar
|
||||||
CacheService *cache.CacheService
|
Cache cache.Cache
|
||||||
CarbonService *carbon.CarbonService
|
Carbon carbon.Carbon
|
||||||
ContactService *contact.ContactService
|
Chat chat.Chat
|
||||||
CryptoService *crypto.CryptoService
|
Comments comments.Comments
|
||||||
CurrencyService *currency.CurrencyService
|
Contact contact.Contact
|
||||||
DbService *db.DbService
|
Crypto crypto.Crypto
|
||||||
EmailService *email.EmailService
|
Currency currency.Currency
|
||||||
EmojiService *emoji.EmojiService
|
Db db.Db
|
||||||
EvchargersService *evchargers.EvchargersService
|
Email email.Email
|
||||||
EventService *event.EventService
|
Emoji emoji.Emoji
|
||||||
FileService *file.FileService
|
Evchargers evchargers.Evchargers
|
||||||
ForexService *forex.ForexService
|
Event event.Event
|
||||||
FunctionService *function.FunctionService
|
File file.File
|
||||||
GeocodingService *geocoding.GeocodingService
|
Forex forex.Forex
|
||||||
GifsService *gifs.GifsService
|
Function function.Function
|
||||||
GoogleService *google.GoogleService
|
Geocoding geocoding.Geocoding
|
||||||
HelloworldService *helloworld.HelloworldService
|
Gifs gifs.Gifs
|
||||||
HolidaysService *holidays.HolidaysService
|
Google google.Google
|
||||||
IdService *id.IdService
|
Helloworld helloworld.Helloworld
|
||||||
ImageService *image.ImageService
|
Holidays holidays.Holidays
|
||||||
IpService *ip.IpService
|
Id id.Id
|
||||||
JokeService *joke.JokeService
|
Image image.Image
|
||||||
LocationService *location.LocationService
|
Ip ip.Ip
|
||||||
MinecraftService *minecraft.MinecraftService
|
Joke joke.Joke
|
||||||
MovieService *movie.MovieService
|
Lists lists.Lists
|
||||||
MqService *mq.MqService
|
Location location.Location
|
||||||
NewsService *news.NewsService
|
Memegen memegen.Memegen
|
||||||
NftService *nft.NftService
|
Minecraft minecraft.Minecraft
|
||||||
NotesService *notes.NotesService
|
Movie movie.Movie
|
||||||
OtpService *otp.OtpService
|
Mq mq.Mq
|
||||||
PingService *ping.PingService
|
News news.News
|
||||||
PlaceService *place.PlaceService
|
Nft nft.Nft
|
||||||
PostcodeService *postcode.PostcodeService
|
Notes notes.Notes
|
||||||
PrayerService *prayer.PrayerService
|
Otp otp.Otp
|
||||||
QrService *qr.QrService
|
Password password.Password
|
||||||
QuranService *quran.QuranService
|
Ping ping.Ping
|
||||||
RoutingService *routing.RoutingService
|
Place place.Place
|
||||||
RssService *rss.RssService
|
Postcode postcode.Postcode
|
||||||
SearchService *search.SearchService
|
Prayer prayer.Prayer
|
||||||
SentimentService *sentiment.SentimentService
|
Qr qr.Qr
|
||||||
SmsService *sms.SmsService
|
Quran quran.Quran
|
||||||
SpaceService *space.SpaceService
|
Routing routing.Routing
|
||||||
SpamService *spam.SpamService
|
Rss rss.Rss
|
||||||
StockService *stock.StockService
|
Search search.Search
|
||||||
StreamService *stream.StreamService
|
Sentiment sentiment.Sentiment
|
||||||
SunnahService *sunnah.SunnahService
|
Sms sms.Sms
|
||||||
ThumbnailService *thumbnail.ThumbnailService
|
Space space.Space
|
||||||
TimeService *time.TimeService
|
Spam spam.Spam
|
||||||
TranslateService *translate.TranslateService
|
Stock stock.Stock
|
||||||
TwitterService *twitter.TwitterService
|
Stream stream.Stream
|
||||||
UrlService *url.UrlService
|
Sunnah sunnah.Sunnah
|
||||||
UserService *user.UserService
|
Thumbnail thumbnail.Thumbnail
|
||||||
VehicleService *vehicle.VehicleService
|
Time time.Time
|
||||||
WeatherService *weather.WeatherService
|
Translate translate.Translate
|
||||||
YoutubeService *youtube.YoutubeService
|
Twitter twitter.Twitter
|
||||||
|
Url url.Url
|
||||||
|
User user.User
|
||||||
|
Vehicle vehicle.Vehicle
|
||||||
|
Weather weather.Weather
|
||||||
|
Youtube youtube.Youtube
|
||||||
}
|
}
|
||||||
|
|||||||
95
meme/meme.go
Executable file
95
meme/meme.go
Executable file
@@ -0,0 +1,95 @@
|
|||||||
|
package meme
|
||||||
|
|
||||||
|
import (
|
||||||
|
"go.m3o.com/client"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Meme interface {
|
||||||
|
Generate(*GenerateRequest) (*GenerateResponse, error)
|
||||||
|
Templates(*TemplatesRequest) (*TemplatesResponse, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewMemeService(token string) *MemeService {
|
||||||
|
return &MemeService{
|
||||||
|
client: client.NewClient(&client.Options{
|
||||||
|
Token: token,
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type MemeService struct {
|
||||||
|
client *client.Client
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
func (t *MemeService) Generate(request *GenerateRequest) (*GenerateResponse, error) {
|
||||||
|
|
||||||
|
rsp := &GenerateResponse{}
|
||||||
|
return rsp, t.client.Call("meme", "Generate", request, rsp)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// List the available templates
|
||||||
|
func (t *MemeService) Templates(request *TemplatesRequest) (*TemplatesResponse, error) {
|
||||||
|
|
||||||
|
rsp := &TemplatesResponse{}
|
||||||
|
return rsp, t.client.Call("meme", "Templates", request, rsp)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
type Box struct {
|
||||||
|
// colour hex code
|
||||||
|
Color string `json:"color"`
|
||||||
|
// height in pixels
|
||||||
|
Height int32 `json:"height"`
|
||||||
|
// outline color hex code
|
||||||
|
Outline string `json:"outline"`
|
||||||
|
// text to display
|
||||||
|
Text string `json:"text"`
|
||||||
|
// width in pixels
|
||||||
|
Width int32 `json:"width"`
|
||||||
|
// x axis position
|
||||||
|
X int32 `json:"x"`
|
||||||
|
// y axis position
|
||||||
|
Y int32 `json:"y"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type GenerateRequest struct {
|
||||||
|
// bottom text
|
||||||
|
BottomText string `json:"bottom_text"`
|
||||||
|
// font: arial or impact
|
||||||
|
Font string `json:"font"`
|
||||||
|
// the template id to use
|
||||||
|
Id string `json:"id"`
|
||||||
|
// font size; defaults to 50px
|
||||||
|
MaxFontSize string `json:"max_font_size"`
|
||||||
|
// top text
|
||||||
|
TopText string `json:"top_text"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type GenerateResponse struct {
|
||||||
|
// url of the meme
|
||||||
|
Url string `json:"url"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Template struct {
|
||||||
|
// number of boxes used
|
||||||
|
BoxCount int32 `json:"box_count"`
|
||||||
|
// height in pixels
|
||||||
|
Height int32 `json:"height"`
|
||||||
|
// id of the meme
|
||||||
|
Id string `json:"id"`
|
||||||
|
// name of the meme
|
||||||
|
Name string `json:"name"`
|
||||||
|
// url of the meme
|
||||||
|
Url string `json:"url"`
|
||||||
|
// width in pixels
|
||||||
|
Width int32 `json:"width"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type TemplatesRequest struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
type TemplatesResponse struct {
|
||||||
|
Templates []Template `json:"templates"`
|
||||||
|
}
|
||||||
95
memegen/memegen.go
Executable file
95
memegen/memegen.go
Executable file
@@ -0,0 +1,95 @@
|
|||||||
|
package memegen
|
||||||
|
|
||||||
|
import (
|
||||||
|
"go.m3o.com/client"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Memegen interface {
|
||||||
|
Generate(*GenerateRequest) (*GenerateResponse, error)
|
||||||
|
Templates(*TemplatesRequest) (*TemplatesResponse, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewMemegenService(token string) *MemegenService {
|
||||||
|
return &MemegenService{
|
||||||
|
client: client.NewClient(&client.Options{
|
||||||
|
Token: token,
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type MemegenService struct {
|
||||||
|
client *client.Client
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate a meme using a template
|
||||||
|
func (t *MemegenService) Generate(request *GenerateRequest) (*GenerateResponse, error) {
|
||||||
|
|
||||||
|
rsp := &GenerateResponse{}
|
||||||
|
return rsp, t.client.Call("memegen", "Generate", request, rsp)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// List the available templates
|
||||||
|
func (t *MemegenService) Templates(request *TemplatesRequest) (*TemplatesResponse, error) {
|
||||||
|
|
||||||
|
rsp := &TemplatesResponse{}
|
||||||
|
return rsp, t.client.Call("memegen", "Templates", request, rsp)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
type Box struct {
|
||||||
|
// colour hex code
|
||||||
|
Color string `json:"color"`
|
||||||
|
// height in pixels
|
||||||
|
Height int32 `json:"height"`
|
||||||
|
// outline color hex code
|
||||||
|
Outline string `json:"outline"`
|
||||||
|
// text to display
|
||||||
|
Text string `json:"text"`
|
||||||
|
// width in pixels
|
||||||
|
Width int32 `json:"width"`
|
||||||
|
// x axis position
|
||||||
|
X int32 `json:"x"`
|
||||||
|
// y axis position
|
||||||
|
Y int32 `json:"y"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type GenerateRequest struct {
|
||||||
|
// bottom text
|
||||||
|
BottomText string `json:"bottom_text"`
|
||||||
|
// font: arial or impact
|
||||||
|
Font string `json:"font"`
|
||||||
|
// the template id to use
|
||||||
|
Id string `json:"id"`
|
||||||
|
// font size; defaults to 50px
|
||||||
|
MaxFontSize string `json:"max_font_size"`
|
||||||
|
// top text
|
||||||
|
TopText string `json:"top_text"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type GenerateResponse struct {
|
||||||
|
// url of the memegen
|
||||||
|
Url string `json:"url"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Template struct {
|
||||||
|
// number of boxes used
|
||||||
|
BoxCount int32 `json:"box_count"`
|
||||||
|
// height in pixels
|
||||||
|
Height int32 `json:"height"`
|
||||||
|
// id of the memegen
|
||||||
|
Id string `json:"id"`
|
||||||
|
// name of the memegen
|
||||||
|
Name string `json:"name"`
|
||||||
|
// url of the memegen
|
||||||
|
Url string `json:"url"`
|
||||||
|
// width in pixels
|
||||||
|
Width int32 `json:"width"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type TemplatesRequest struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
type TemplatesResponse struct {
|
||||||
|
Templates []Template `json:"templates"`
|
||||||
|
}
|
||||||
79
nft/nft.go
79
nft/nft.go
@@ -5,7 +5,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Nft interface {
|
type Nft interface {
|
||||||
|
Asset(*AssetRequest) (*AssetResponse, error)
|
||||||
Assets(*AssetsRequest) (*AssetsResponse, error)
|
Assets(*AssetsRequest) (*AssetsResponse, error)
|
||||||
|
Collection(*CollectionRequest) (*CollectionResponse, error)
|
||||||
Collections(*CollectionsRequest) (*CollectionsResponse, error)
|
Collections(*CollectionsRequest) (*CollectionsResponse, error)
|
||||||
Create(*CreateRequest) (*CreateResponse, error)
|
Create(*CreateRequest) (*CreateResponse, error)
|
||||||
}
|
}
|
||||||
@@ -22,6 +24,14 @@ type NftService struct {
|
|||||||
client *client.Client
|
client *client.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get a single asset by the contract
|
||||||
|
func (t *NftService) Asset(request *AssetRequest) (*AssetResponse, error) {
|
||||||
|
|
||||||
|
rsp := &AssetResponse{}
|
||||||
|
return rsp, t.client.Call("nft", "Asset", request, rsp)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Return a list of assets
|
// Return a list of assets
|
||||||
func (t *NftService) Assets(request *AssetsRequest) (*AssetsResponse, error) {
|
func (t *NftService) Assets(request *AssetsRequest) (*AssetsResponse, error) {
|
||||||
|
|
||||||
@@ -30,6 +40,14 @@ func (t *NftService) Assets(request *AssetsRequest) (*AssetsResponse, error) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get a collection by its slug
|
||||||
|
func (t *NftService) Collection(request *CollectionRequest) (*CollectionResponse, error) {
|
||||||
|
|
||||||
|
rsp := &CollectionResponse{}
|
||||||
|
return rsp, t.client.Call("nft", "Collection", request, rsp)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Get a list of collections
|
// Get a list of collections
|
||||||
func (t *NftService) Collections(request *CollectionsRequest) (*CollectionsResponse, error) {
|
func (t *NftService) Collections(request *CollectionsRequest) (*CollectionsResponse, error) {
|
||||||
|
|
||||||
@@ -75,14 +93,27 @@ type Asset struct {
|
|||||||
Sales int32 `json:"sales"`
|
Sales int32 `json:"sales"`
|
||||||
// the token id
|
// the token id
|
||||||
TokenId string `json:"token_id"`
|
TokenId string `json:"token_id"`
|
||||||
|
// traits associated with the item
|
||||||
|
Traits []map[string]interface{} `json:"traits"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type AssetRequest struct {
|
||||||
|
ContractAddress string `json:"contract_address"`
|
||||||
|
TokenId string `json:"token_id"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type AssetResponse struct {
|
||||||
|
Asset *Asset `json:"asset"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AssetsRequest struct {
|
type AssetsRequest struct {
|
||||||
// limit to members of a collection by slug name (case sensitive)
|
// limit to members of a collection by slug name (case sensitive)
|
||||||
Collection string `json:"collection"`
|
Collection string `json:"collection"`
|
||||||
|
// A cursor pointing to the page to retrieve
|
||||||
|
Cursor string `json:"cursor"`
|
||||||
// limit returned assets
|
// limit returned assets
|
||||||
Limit int32 `json:"limit"`
|
Limit int32 `json:"limit"`
|
||||||
// offset for pagination
|
// DEPRECATED offset for pagination, please use cursor instead
|
||||||
Offset int32 `json:"offset"`
|
Offset int32 `json:"offset"`
|
||||||
// order "asc" or "desc"
|
// order "asc" or "desc"
|
||||||
Order string `json:"order"`
|
Order string `json:"order"`
|
||||||
@@ -93,15 +124,51 @@ type AssetsRequest struct {
|
|||||||
type AssetsResponse struct {
|
type AssetsResponse struct {
|
||||||
// list of assets
|
// list of assets
|
||||||
Assets []Asset `json:"assets"`
|
Assets []Asset `json:"assets"`
|
||||||
|
// A cursor to be supplied to retrieve the next page of results
|
||||||
|
Next string `json:"next"`
|
||||||
|
// A cursor to be supplied to retrieve the previous page of results
|
||||||
|
Previous string `json:"previous"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Collection struct {
|
type Collection struct {
|
||||||
CreatedAt string `json:"created_at"`
|
// image used in the banner for the collection
|
||||||
Description string `json:"description"`
|
BannerImageUrl string `json:"banner_image_url"`
|
||||||
ImageUrl string `json:"image_url"`
|
// creation time
|
||||||
Name string `json:"name"`
|
CreatedAt string `json:"created_at"`
|
||||||
|
// description of the collection
|
||||||
|
Description string `json:"description"`
|
||||||
|
// approved editors for this collection
|
||||||
|
Editors []string `json:"editors"`
|
||||||
|
// external link to the original website for the collection
|
||||||
|
ExternalLink string `json:"external_link"`
|
||||||
|
// an image for the collection
|
||||||
|
ImageUrl string `json:"image_url"`
|
||||||
|
// name of the collection
|
||||||
|
Name string `json:"name"`
|
||||||
|
// the payment tokens accepted for this collection
|
||||||
|
PaymentTokens *Token `json:"payment_tokens"`
|
||||||
|
// payout address for the collection's royalties
|
||||||
PayoutAddress string `json:"payout_address"`
|
PayoutAddress string `json:"payout_address"`
|
||||||
Slug string `json:"slug"`
|
// a list of the contracts associated with this collection
|
||||||
|
PrimaryAssetContracts *Contract `json:"primary_asset_contracts"`
|
||||||
|
// the collection's approval status on OpenSea
|
||||||
|
SafelistRequestStatus string `json:"safelist_request_status"`
|
||||||
|
// the fees that get paid out when a sale is made
|
||||||
|
SellerFees string `json:"seller_fees"`
|
||||||
|
// collection slug
|
||||||
|
Slug string `json:"slug"`
|
||||||
|
// sales statistics associated with the collection
|
||||||
|
Stats map[string]interface{} `json:"stats"`
|
||||||
|
// listing of all the trait types available within this collection
|
||||||
|
Traits map[string]interface{} `json:"traits"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CollectionRequest struct {
|
||||||
|
Slug string `json:"slug"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CollectionResponse struct {
|
||||||
|
Collection *Collection `json:"collection"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type CollectionsRequest struct {
|
type CollectionsRequest struct {
|
||||||
|
|||||||
47
password/password.go
Executable file
47
password/password.go
Executable file
@@ -0,0 +1,47 @@
|
|||||||
|
package password
|
||||||
|
|
||||||
|
import (
|
||||||
|
"go.m3o.com/client"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Password interface {
|
||||||
|
Generate(*GenerateRequest) (*GenerateResponse, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewPasswordService(token string) *PasswordService {
|
||||||
|
return &PasswordService{
|
||||||
|
client: client.NewClient(&client.Options{
|
||||||
|
Token: token,
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type PasswordService struct {
|
||||||
|
client *client.Client
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate a strong random password. Use the switches to control which character types are included, defaults to using all of them
|
||||||
|
func (t *PasswordService) Generate(request *GenerateRequest) (*GenerateResponse, error) {
|
||||||
|
|
||||||
|
rsp := &GenerateResponse{}
|
||||||
|
return rsp, t.client.Call("password", "Generate", request, rsp)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
type GenerateRequest struct {
|
||||||
|
// password length; defaults to 8 chars
|
||||||
|
Length int32 `json:"length"`
|
||||||
|
// include lowercase letters
|
||||||
|
Lowercase bool `json:"lowercase"`
|
||||||
|
// include numbers
|
||||||
|
Numbers bool `json:"numbers"`
|
||||||
|
// include special characters (!@#$%&*)
|
||||||
|
Special bool `json:"special"`
|
||||||
|
// include uppercase letters
|
||||||
|
Uppercase bool `json:"uppercase"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type GenerateResponse struct {
|
||||||
|
// The generated password
|
||||||
|
Password string `json:"password"`
|
||||||
|
}
|
||||||
@@ -40,7 +40,7 @@ func (t *SearchService) DeleteIndex(request *DeleteIndexRequest) (*DeleteIndexRe
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete a document given its ID
|
// Delete a record given its ID
|
||||||
func (t *SearchService) Delete(request *DeleteRequest) (*DeleteResponse, error) {
|
func (t *SearchService) Delete(request *DeleteRequest) (*DeleteResponse, error) {
|
||||||
|
|
||||||
rsp := &DeleteResponse{}
|
rsp := &DeleteResponse{}
|
||||||
@@ -48,7 +48,7 @@ func (t *SearchService) Delete(request *DeleteRequest) (*DeleteResponse, error)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Index a document i.e. insert a document to search for.
|
// Index a record i.e. insert a document to search for.
|
||||||
func (t *SearchService) Index(request *IndexRequest) (*IndexResponse, error) {
|
func (t *SearchService) Index(request *IndexRequest) (*IndexResponse, error) {
|
||||||
|
|
||||||
rsp := &IndexResponse{}
|
rsp := &IndexResponse{}
|
||||||
@@ -56,7 +56,7 @@ func (t *SearchService) Index(request *IndexRequest) (*IndexResponse, error) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Search for documents in a given in index
|
// Search for records in a given in index
|
||||||
func (t *SearchService) Search(request *SearchRequest) (*SearchResponse, error) {
|
func (t *SearchService) Search(request *SearchRequest) (*SearchResponse, error) {
|
||||||
|
|
||||||
rsp := &SearchResponse{}
|
rsp := &SearchResponse{}
|
||||||
@@ -81,22 +81,15 @@ type DeleteIndexResponse struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type DeleteRequest struct {
|
type DeleteRequest struct {
|
||||||
// The ID of the document to delete
|
// The ID of the record to delete
|
||||||
Id string `json:"id"`
|
Id string `json:"id"`
|
||||||
// The index the document belongs to
|
// The index the record belongs to
|
||||||
Index string `json:"index"`
|
Index string `json:"index"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type DeleteResponse struct {
|
type DeleteResponse struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Document struct {
|
|
||||||
// The JSON contents of the document
|
|
||||||
Contents map[string]interface{} `json:"contents"`
|
|
||||||
// The ID for this document. If blank, one will be generated
|
|
||||||
Id string `json:"id"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type Field struct {
|
type Field struct {
|
||||||
// The name of the field. Use a `.` separator to define nested fields e.g. foo.bar
|
// The name of the field. Use a `.` separator to define nested fields e.g. foo.bar
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
@@ -105,24 +98,34 @@ type Field struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type IndexRequest struct {
|
type IndexRequest struct {
|
||||||
// The document to index
|
// The data to index
|
||||||
Document *Document `json:"document"`
|
Data map[string]interface{} `json:"data"`
|
||||||
// The index this document belongs to
|
// Optional ID for the record
|
||||||
|
Id string `json:"id"`
|
||||||
|
// The index this record belongs to
|
||||||
Index string `json:"index"`
|
Index string `json:"index"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type IndexResponse struct {
|
type IndexResponse struct {
|
||||||
|
// the indexed record
|
||||||
|
Record *Record `json:"record"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Record struct {
|
||||||
|
// The JSON contents of the record
|
||||||
|
Data map[string]interface{} `json:"data"`
|
||||||
|
// The ID for this record. If blank, one will be generated
|
||||||
Id string `json:"id"`
|
Id string `json:"id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SearchRequest struct {
|
type SearchRequest struct {
|
||||||
// The index the document belongs to
|
// The index the record belongs to
|
||||||
Index string `json:"index"`
|
Index string `json:"index"`
|
||||||
// The query. See docs for query language examples
|
// The query. See docs for query language examples
|
||||||
Query string `json:"query"`
|
Query string `json:"query"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SearchResponse struct {
|
type SearchResponse struct {
|
||||||
// The matching documents
|
// The matching records
|
||||||
Documents []Document `json:"documents"`
|
Records []Record `json:"records"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -162,7 +162,17 @@ type ListResponse struct {
|
|||||||
Objects []ListObject `json:"objects"`
|
Objects []ListObject `json:"objects"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Object struct {
|
type ReadRequest struct {
|
||||||
|
// name of the object
|
||||||
|
Name string `json:"name"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ReadResponse struct {
|
||||||
|
// The object itself
|
||||||
|
Object *SpaceObject `json:"object"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type SpaceObject struct {
|
||||||
// when was this created
|
// when was this created
|
||||||
Created string `json:"created"`
|
Created string `json:"created"`
|
||||||
// the data within the object
|
// the data within the object
|
||||||
@@ -177,16 +187,6 @@ type Object struct {
|
|||||||
Visibility string `json:"visibility"`
|
Visibility string `json:"visibility"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ReadRequest struct {
|
|
||||||
// name of the object
|
|
||||||
Name string `json:"name"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type ReadResponse struct {
|
|
||||||
// The object itself
|
|
||||||
Object *Object `json:"object"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type UpdateRequest struct {
|
type UpdateRequest struct {
|
||||||
// The name of the object. Use forward slash delimiter to implement a nested directory-like structure e.g. images/foo.jpg
|
// The name of the object. Use forward slash delimiter to implement a nested directory-like structure e.g. images/foo.jpg
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
|
|||||||
@@ -75,6 +75,8 @@ type ZoneResponse struct {
|
|||||||
Location string `json:"location"`
|
Location string `json:"location"`
|
||||||
// e.g -0.37
|
// e.g -0.37
|
||||||
Longitude float64 `json:"longitude"`
|
Longitude float64 `json:"longitude"`
|
||||||
|
// UTC offset in hours
|
||||||
|
Offset int32 `json:"offset"`
|
||||||
// region of timezone
|
// region of timezone
|
||||||
Region string `json:"region"`
|
Region string `json:"region"`
|
||||||
// the timezone e.g Europe/London
|
// the timezone e.g Europe/London
|
||||||
|
|||||||
@@ -80,6 +80,8 @@ type URLPair struct {
|
|||||||
Created string `json:"created"`
|
Created string `json:"created"`
|
||||||
// destination url
|
// destination url
|
||||||
DestinationUrl string `json:"destinationURL"`
|
DestinationUrl string `json:"destinationURL"`
|
||||||
|
// The number of times the short URL has been resolved
|
||||||
|
HitCount int64 `json:"hitCount,string"`
|
||||||
// shortened url
|
// shortened url
|
||||||
ShortUrl string `json:"shortURL"`
|
ShortUrl string `json:"shortURL"`
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user