mirror of
https://github.com/kevin-DL/m3o-go.git
synced 2026-01-11 10:34:27 +00:00
Commit from m3o/m3o action
This commit is contained in:
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"`
|
||||||
|
}
|
||||||
@@ -4,6 +4,61 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/app/api](https
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
|
## Reserve
|
||||||
|
|
||||||
|
Reserve apps beyond the free quota. Call Run after.
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/app/api#Reserve](https://m3o.com/app/api#Reserve)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/app"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Reserve apps beyond the free quota. Call Run after.
|
||||||
|
func ReserveAppName() {
|
||||||
|
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := appService.Reserve(&app.ReserveRequest{
|
||||||
|
Name: "helloworld",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## List
|
||||||
|
|
||||||
|
List all the apps
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/app/api#List](https://m3o.com/app/api#List)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/app"
|
||||||
|
)
|
||||||
|
|
||||||
|
// List all the apps
|
||||||
|
func ListTheApps() {
|
||||||
|
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := appService.List(&app.ListRequest{
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
## Run
|
## Run
|
||||||
|
|
||||||
Run an app from source
|
Run an app from source
|
||||||
@@ -175,58 +230,3 @@ func DeleteAnApp() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Reserve
|
|
||||||
|
|
||||||
Reserve apps beyond the free quota. Call Run after.
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/app/api#Reserve](https://m3o.com/app/api#Reserve)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/app"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Reserve apps beyond the free quota. Call Run after.
|
|
||||||
func ReserveAppName() {
|
|
||||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := appService.Reserve(&app.ReserveRequest{
|
|
||||||
Name: "helloworld",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## List
|
|
||||||
|
|
||||||
List all the apps
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/app/api#List](https://m3o.com/app/api#List)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/app"
|
|
||||||
)
|
|
||||||
|
|
||||||
// List all the apps
|
|
||||||
func ListTheApps() {
|
|
||||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := appService.List(&app.ListRequest{
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|||||||
@@ -4,6 +4,100 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/chat/api](http
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
|
## 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)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
## New
|
## New
|
||||||
|
|
||||||
Create a new chat room
|
Create a new chat room
|
||||||
@@ -31,6 +125,60 @@ Name: "general",
|
|||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
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)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## 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
|
## Send
|
||||||
@@ -90,73 +238,6 @@ func GetChatHistory() {
|
|||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## 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
|
||||||
@@ -186,84 +267,3 @@ func ListChatRooms() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## 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)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## 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)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## 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)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|||||||
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)
|
||||||
|
}
|
||||||
@@ -4,85 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/contact/api](h
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
## Update
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/contact/api#Update](https://m3o.com/contact/api#Update)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/contact"
|
|
||||||
)
|
|
||||||
|
|
||||||
//
|
|
||||||
func UpdateAcontact() {
|
|
||||||
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := contactService.Update(&contact.UpdateRequest{
|
|
||||||
Addresses: []contact.Address{
|
|
||||||
contact.Address{
|
|
||||||
Label: "company address",
|
|
||||||
Location: "123 street address",
|
|
||||||
}},
|
|
||||||
Birthday: "1995-01-01",
|
|
||||||
Emails: []contact.Email{
|
|
||||||
contact.Email{
|
|
||||||
Address: "home@example.com",
|
|
||||||
Label: "home",
|
|
||||||
}},
|
|
||||||
Id: "42e48a3c-6221-11ec-96d2-acde48001122",
|
|
||||||
Links: []contact.Link{
|
|
||||||
contact.Link{
|
|
||||||
Label: "blog",
|
|
||||||
Url: "https://blog.joe.me",
|
|
||||||
}},
|
|
||||||
Name: "joe",
|
|
||||||
Note: "this person is very important",
|
|
||||||
Phones: []contact.Phone{
|
|
||||||
contact.Phone{
|
|
||||||
Label: "home",
|
|
||||||
Number: "010-12345678",
|
|
||||||
}},
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Read
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/contact/api#Read](https://m3o.com/contact/api#Read)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/contact"
|
|
||||||
)
|
|
||||||
|
|
||||||
//
|
|
||||||
func GetAcontact() {
|
|
||||||
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := contactService.Read(&contact.ReadRequest{
|
|
||||||
Id: "42e48a3c-6221-11ec-96d2-acde48001122",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Delete
|
## Delete
|
||||||
|
|
||||||
|
|
||||||
@@ -217,3 +138,82 @@ contact.Phone{
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
## Update
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/contact/api#Update](https://m3o.com/contact/api#Update)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/contact"
|
||||||
|
)
|
||||||
|
|
||||||
|
//
|
||||||
|
func UpdateAcontact() {
|
||||||
|
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := contactService.Update(&contact.UpdateRequest{
|
||||||
|
Addresses: []contact.Address{
|
||||||
|
contact.Address{
|
||||||
|
Label: "company address",
|
||||||
|
Location: "123 street address",
|
||||||
|
}},
|
||||||
|
Birthday: "1995-01-01",
|
||||||
|
Emails: []contact.Email{
|
||||||
|
contact.Email{
|
||||||
|
Address: "home@example.com",
|
||||||
|
Label: "home",
|
||||||
|
}},
|
||||||
|
Id: "42e48a3c-6221-11ec-96d2-acde48001122",
|
||||||
|
Links: []contact.Link{
|
||||||
|
contact.Link{
|
||||||
|
Label: "blog",
|
||||||
|
Url: "https://blog.joe.me",
|
||||||
|
}},
|
||||||
|
Name: "joe",
|
||||||
|
Note: "this person is very important",
|
||||||
|
Phones: []contact.Phone{
|
||||||
|
contact.Phone{
|
||||||
|
Label: "home",
|
||||||
|
Number: "010-12345678",
|
||||||
|
}},
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Read
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/contact/api#Read](https://m3o.com/contact/api#Read)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/contact"
|
||||||
|
)
|
||||||
|
|
||||||
|
//
|
||||||
|
func GetAcontact() {
|
||||||
|
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := contactService.Read(&contact.ReadRequest{
|
||||||
|
Id: "42e48a3c-6221-11ec-96d2-acde48001122",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
@@ -4,62 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/crypto/api](ht
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
## News
|
|
||||||
|
|
||||||
Get news related to a currency
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/crypto/api#News](https://m3o.com/crypto/api#News)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/crypto"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Get news related to a currency
|
|
||||||
func GetCryptocurrencyNews() {
|
|
||||||
cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := cryptoService.News(&crypto.NewsRequest{
|
|
||||||
Symbol: "BTCUSD",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Price
|
|
||||||
|
|
||||||
Get the last price for a given crypto ticker
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/crypto/api#Price](https://m3o.com/crypto/api#Price)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/crypto"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Get the last price for a given crypto ticker
|
|
||||||
func GetCryptocurrencyPrice() {
|
|
||||||
cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := cryptoService.Price(&crypto.PriceRequest{
|
|
||||||
Symbol: "BTCUSD",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Quote
|
## Quote
|
||||||
|
|
||||||
Get the last quote for a given crypto ticker
|
Get the last quote for a given crypto ticker
|
||||||
@@ -116,3 +60,59 @@ func GetPreviousClose() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
## News
|
||||||
|
|
||||||
|
Get news related to a currency
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/crypto/api#News](https://m3o.com/crypto/api#News)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/crypto"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Get news related to a currency
|
||||||
|
func GetCryptocurrencyNews() {
|
||||||
|
cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := cryptoService.News(&crypto.NewsRequest{
|
||||||
|
Symbol: "BTCUSD",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Price
|
||||||
|
|
||||||
|
Get the last price for a given crypto ticker
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/crypto/api#Price](https://m3o.com/crypto/api#Price)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/crypto"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Get the last price for a given crypto ticker
|
||||||
|
func GetCryptocurrencyPrice() {
|
||||||
|
cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := cryptoService.Price(&crypto.PriceRequest{
|
||||||
|
Symbol: "BTCUSD",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
@@ -4,6 +4,63 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/db/api](https:
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
|
## Count
|
||||||
|
|
||||||
|
Count records in a table
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/db/api#Count](https://m3o.com/db/api#Count)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/db"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Count records in a table
|
||||||
|
func CountEntriesInAtable() {
|
||||||
|
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := dbService.Count(&db.CountRequest{
|
||||||
|
Table: "example",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## RenameTable
|
||||||
|
|
||||||
|
Rename a table
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/db/api#RenameTable](https://m3o.com/db/api#RenameTable)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/db"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Rename a table
|
||||||
|
func RenameTable() {
|
||||||
|
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := dbService.RenameTable(&db.RenameTableRequest{
|
||||||
|
From: "examples2",
|
||||||
|
To: "examples3",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
## Create
|
## Create
|
||||||
|
|
||||||
Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
|
Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
|
||||||
@@ -68,90 +125,6 @@ Table: "example",
|
|||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Delete
|
|
||||||
|
|
||||||
Delete a record in the database by id.
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/db/api#Delete](https://m3o.com/db/api#Delete)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/db"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Delete a record in the database by id.
|
|
||||||
func DeleteArecord() {
|
|
||||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := dbService.Delete(&db.DeleteRequest{
|
|
||||||
Id: "1",
|
|
||||||
Table: "example",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Count
|
|
||||||
|
|
||||||
Count records in a table
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/db/api#Count](https://m3o.com/db/api#Count)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/db"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Count records in a table
|
|
||||||
func CountEntriesInAtable() {
|
|
||||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := dbService.Count(&db.CountRequest{
|
|
||||||
Table: "example",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## ListTables
|
|
||||||
|
|
||||||
List tables in the DB
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/db/api#ListTables](https://m3o.com/db/api#ListTables)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/db"
|
|
||||||
)
|
|
||||||
|
|
||||||
// List tables in the DB
|
|
||||||
func ListTables() {
|
|
||||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := dbService.ListTables(&db.ListTablesRequest{
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Read
|
## Read
|
||||||
@@ -181,6 +154,35 @@ Table: "example",
|
|||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Delete
|
||||||
|
|
||||||
|
Delete a record in the database by id.
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/db/api#Delete](https://m3o.com/db/api#Delete)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/db"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Delete a record in the database by id.
|
||||||
|
func DeleteArecord() {
|
||||||
|
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := dbService.Delete(&db.DeleteRequest{
|
||||||
|
Id: "1",
|
||||||
|
Table: "example",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Truncate
|
## Truncate
|
||||||
@@ -239,12 +241,12 @@ func DropTable() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## RenameTable
|
## ListTables
|
||||||
|
|
||||||
Rename a table
|
List tables in the DB
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/db/api#RenameTable](https://m3o.com/db/api#RenameTable)
|
[https://m3o.com/db/api#ListTables](https://m3o.com/db/api#ListTables)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
package example
|
package example
|
||||||
@@ -256,13 +258,11 @@ import(
|
|||||||
"go.m3o.com/db"
|
"go.m3o.com/db"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Rename a table
|
// List tables in the DB
|
||||||
func RenameTable() {
|
func ListTables() {
|
||||||
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.ListTables(&db.ListTablesRequest{
|
||||||
From: "examples2",
|
|
||||||
To: "examples3",
|
|
||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/email/api](htt
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
|
## Validate
|
||||||
|
|
||||||
|
Validate an email address format
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/email/api#Validate](https://m3o.com/email/api#Validate)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/email"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Validate an email address format
|
||||||
|
func ValidateEmail() {
|
||||||
|
emailService := email.NewEmailService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := emailService.Validate(&email.ValidateRequest{
|
||||||
|
Address: "joe@example.com",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
## Send
|
## Send
|
||||||
|
|
||||||
Send an email by passing in from, to, subject, and a text or html body
|
Send an email by passing in from, to, subject, and a text or html body
|
||||||
@@ -64,31 +92,3 @@ func ParseEmail() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Validate
|
|
||||||
|
|
||||||
Validate an email address format
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/email/api#Validate](https://m3o.com/email/api#Validate)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/email"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Validate an email address format
|
|
||||||
func ValidateEmail() {
|
|
||||||
emailService := email.NewEmailService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := emailService.Validate(&email.ValidateRequest{
|
|
||||||
Address: "joe@example.com",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|||||||
@@ -4,36 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/emoji/api](htt
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
## Print
|
|
||||||
|
|
||||||
Print text and renders the emojis with aliases e.g
|
|
||||||
let's grab a :beer: becomes let's grab a 🍺
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/emoji/api#Print](https://m3o.com/emoji/api#Print)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/emoji"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Print text and renders the emojis with aliases e.g
|
|
||||||
// let's grab a :beer: becomes let's grab a 🍺
|
|
||||||
func PrintTextIncludingEmoji() {
|
|
||||||
emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := emojiService.Print(&emoji.PrintRequest{
|
|
||||||
Text: "let's grab a :beer:",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Find
|
## Find
|
||||||
|
|
||||||
Find an emoji by its alias e.g :beer:
|
Find an emoji by its alias e.g :beer:
|
||||||
@@ -89,3 +59,33 @@ func GetFlagByCountryCode() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
## Print
|
||||||
|
|
||||||
|
Print text and renders the emojis with aliases e.g
|
||||||
|
let's grab a :beer: becomes let's grab a 🍺
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/emoji/api#Print](https://m3o.com/emoji/api#Print)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/emoji"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Print text and renders the emojis with aliases e.g
|
||||||
|
// let's grab a :beer: becomes let's grab a 🍺
|
||||||
|
func PrintTextIncludingEmoji() {
|
||||||
|
emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := emojiService.Print(&emoji.PrintRequest{
|
||||||
|
Text: "let's grab a :beer:",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
@@ -26,9 +26,9 @@ func PublishAnEvent() {
|
|||||||
eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN"))
|
eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := eventService.Publish(&event.PublishRequest{
|
rsp, err := eventService.Publish(&event.PublishRequest{
|
||||||
Message: map[string]interface{}{
|
Message: map[string]interface{}{
|
||||||
|
"user": "john",
|
||||||
"id": "1",
|
"id": "1",
|
||||||
"type": "signup",
|
"type": "signup",
|
||||||
"user": "john",
|
|
||||||
},
|
},
|
||||||
Topic: "user",
|
Topic: "user",
|
||||||
|
|
||||||
|
|||||||
@@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/function/api](
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
## Proxy
|
|
||||||
|
|
||||||
Return the backend url for proxying
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/function/api#Proxy](https://m3o.com/function/api#Proxy)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/function"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Return the backend url for proxying
|
|
||||||
func ProxyUrl() {
|
|
||||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := functionService.Proxy(&function.ProxyRequest{
|
|
||||||
Id: "helloworld",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Deploy
|
## Deploy
|
||||||
|
|
||||||
Deploy a group of functions
|
Deploy a group of functions
|
||||||
@@ -64,6 +36,172 @@ Subfolder: "examples/go-function",
|
|||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## List
|
||||||
|
|
||||||
|
List all the deployed functions
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/function/api#List](https://m3o.com/function/api#List)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/function"
|
||||||
|
)
|
||||||
|
|
||||||
|
// List all the deployed functions
|
||||||
|
func ListFunctions() {
|
||||||
|
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := functionService.List(&function.ListRequest{
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Delete
|
||||||
|
|
||||||
|
Delete a function by name
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/function/api#Delete](https://m3o.com/function/api#Delete)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/function"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Delete a function by name
|
||||||
|
func DeleteAfunction() {
|
||||||
|
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := functionService.Delete(&function.DeleteRequest{
|
||||||
|
Name: "helloworld",
|
||||||
|
|
||||||
|
})
|
||||||
|
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)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Regions
|
||||||
|
|
||||||
|
Return a list of supported regions
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/function/api#Regions](https://m3o.com/function/api#Regions)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/function"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Return a list of supported regions
|
||||||
|
func ListRegions() {
|
||||||
|
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := functionService.Regions(&function.RegionsRequest{
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Reserve
|
||||||
|
|
||||||
|
Reserve function names and resources beyond free quota
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/function/api#Reserve](https://m3o.com/function/api#Reserve)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/function"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Reserve function names and resources beyond free quota
|
||||||
|
func ReserveAfunction() {
|
||||||
|
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := functionService.Reserve(&function.ReserveRequest{
|
||||||
|
Name: "helloworld",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Proxy
|
||||||
|
|
||||||
|
Return the backend url for proxying
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/function/api#Proxy](https://m3o.com/function/api#Proxy)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/function"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Return the backend url for proxying
|
||||||
|
func ProxyUrl() {
|
||||||
|
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := functionService.Proxy(&function.ProxyRequest{
|
||||||
|
Id: "helloworld",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Update
|
## Update
|
||||||
@@ -125,141 +263,3 @@ Request: map[string]interface{}{
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## 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)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## List
|
|
||||||
|
|
||||||
List all the deployed functions
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/function/api#List](https://m3o.com/function/api#List)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/function"
|
|
||||||
)
|
|
||||||
|
|
||||||
// List all the deployed functions
|
|
||||||
func ListFunctions() {
|
|
||||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := functionService.List(&function.ListRequest{
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Delete
|
|
||||||
|
|
||||||
Delete a function by name
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/function/api#Delete](https://m3o.com/function/api#Delete)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/function"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Delete a function by name
|
|
||||||
func DeleteAfunction() {
|
|
||||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := functionService.Delete(&function.DeleteRequest{
|
|
||||||
Name: "helloworld",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Regions
|
|
||||||
|
|
||||||
Return a list of supported regions
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/function/api#Regions](https://m3o.com/function/api#Regions)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/function"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Return a list of supported regions
|
|
||||||
func ListRegions() {
|
|
||||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := functionService.Regions(&function.RegionsRequest{
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## 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)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|||||||
@@ -4,6 +4,33 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/id/api](https:
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
|
## Types
|
||||||
|
|
||||||
|
List the types of IDs available. No query params needed.
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/id/api#Types](https://m3o.com/id/api#Types)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/id"
|
||||||
|
)
|
||||||
|
|
||||||
|
// List the types of IDs available. No query params needed.
|
||||||
|
func ListTheTypesOfIdsAvailable() {
|
||||||
|
idService := id.NewIdService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := idService.Types(&id.TypesRequest{
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
## Generate
|
## Generate
|
||||||
|
|
||||||
Generate a unique ID. Defaults to uuid.
|
Generate a unique ID. Defaults to uuid.
|
||||||
@@ -116,30 +143,3 @@ func GenerateAbigflakeId() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Types
|
|
||||||
|
|
||||||
List the types of IDs available. No query params needed.
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/id/api#Types](https://m3o.com/id/api#Types)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/id"
|
|
||||||
)
|
|
||||||
|
|
||||||
// List the types of IDs available. No query params needed.
|
|
||||||
func ListTheTypesOfIdsAvailable() {
|
|
||||||
idService := id.NewIdService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := idService.Types(&id.TypesRequest{
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|||||||
@@ -4,6 +4,75 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/lists/api](htt
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
|
## 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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
## Create
|
## Create
|
||||||
|
|
||||||
Create a new list
|
Create a new list
|
||||||
@@ -116,72 +185,3 @@ func UpdateAlist() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## 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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|||||||
@@ -4,40 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/location/api](
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
## Search
|
|
||||||
|
|
||||||
Search for entities in a given radius
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/location/api#Search](https://m3o.com/location/api#Search)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/location"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Search for entities in a given radius
|
|
||||||
func SearchForLocations() {
|
|
||||||
locationService := location.NewLocationService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := locationService.Search(&location.SearchRequest{
|
|
||||||
Center: &location.Point{
|
|
||||||
Latitude: 51.511061,
|
|
||||||
Longitude: -0.120022,
|
|
||||||
},
|
|
||||||
NumEntities: 10,
|
|
||||||
Radius: 100,
|
|
||||||
Type: "bike",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Save
|
## Save
|
||||||
|
|
||||||
Save an entity's current position
|
Save an entity's current position
|
||||||
@@ -102,3 +68,37 @@ func GetLocationById() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
## Search
|
||||||
|
|
||||||
|
Search for entities in a given radius
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/location/api#Search](https://m3o.com/location/api#Search)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/location"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Search for entities in a given radius
|
||||||
|
func SearchForLocations() {
|
||||||
|
locationService := location.NewLocationService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := locationService.Search(&location.SearchRequest{
|
||||||
|
Center: &location.Point{
|
||||||
|
Latitude: 51.511061,
|
||||||
|
Longitude: -0.120022,
|
||||||
|
},
|
||||||
|
NumEntities: 10,
|
||||||
|
Radius: 100,
|
||||||
|
Type: "bike",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
@@ -26,9 +26,9 @@ func PublishAmessage() {
|
|||||||
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,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/postcode/api](
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
|
## Validate
|
||||||
|
|
||||||
|
Validate a postcode.
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/postcode/api#Validate](https://m3o.com/postcode/api#Validate)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/postcode"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Validate a postcode.
|
||||||
|
func ReturnArandomPostcodeAndItsInformation() {
|
||||||
|
postcodeService := postcode.NewPostcodeService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := postcodeService.Validate(&postcode.ValidateRequest{
|
||||||
|
Postcode: "SW1A 2AA",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
## Lookup
|
## Lookup
|
||||||
|
|
||||||
Lookup a postcode to retrieve the related region, county, etc
|
Lookup a postcode to retrieve the related region, county, etc
|
||||||
@@ -59,31 +87,3 @@ func ReturnArandomPostcodeAndItsInformation() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Validate
|
|
||||||
|
|
||||||
Validate a postcode.
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/postcode/api#Validate](https://m3o.com/postcode/api#Validate)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/postcode"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Validate a postcode.
|
|
||||||
func ReturnArandomPostcodeAndItsInformation() {
|
|
||||||
postcodeService := postcode.NewPostcodeService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := postcodeService.Validate(&postcode.ValidateRequest{
|
|
||||||
Postcode: "SW1A 2AA",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|||||||
@@ -4,34 +4,6 @@ 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
|
||||||
@@ -117,3 +89,31 @@ 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,93 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/search/api](ht
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
## 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)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Delete
|
## Delete
|
||||||
|
|
||||||
Delete a document given its ID
|
Delete a document given its ID
|
||||||
@@ -212,3 +125,90 @@ Index: "customers",
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
## 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)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
@@ -13,9 +13,9 @@ func main() {
|
|||||||
rsp, err := searchService.Index(&search.IndexRequest{
|
rsp, err := searchService.Index(&search.IndexRequest{
|
||||||
Document: &search.Document{
|
Document: &search.Document{
|
||||||
Contents: map[string]interface{}{
|
Contents: map[string]interface{}{
|
||||||
|
"name": "John Doe",
|
||||||
"age": 37,
|
"age": 37,
|
||||||
"starsign": "Leo",
|
"starsign": "Leo",
|
||||||
"name": "John Doe",
|
|
||||||
},
|
},
|
||||||
Id: "1234",
|
Id: "1234",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -4,6 +4,118 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/space/api](htt
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
|
## 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 an object in space
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/space/api#Read](https://m3o.com/space/api#Read)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/space"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Read an object in space
|
||||||
|
func ReadAnObject() {
|
||||||
|
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := spaceService.Read(&space.ReadRequest{
|
||||||
|
Name: "images/file.jpg",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Download
|
||||||
|
|
||||||
|
Download an object via a presigned url
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/space/api#Download](https://m3o.com/space/api#Download)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/space"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Download an object via a presigned url
|
||||||
|
func DownloadAnObject() {
|
||||||
|
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := spaceService.Download(&space.DownloadRequest{
|
||||||
|
Name: "images/file.jpg",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
## Upload
|
## Upload
|
||||||
|
|
||||||
Upload a large object (> 10MB). Returns a time limited presigned URL to be used for uploading the object
|
Upload a large object (> 10MB). Returns a time limited presigned URL to be used for uploading the object
|
||||||
@@ -120,115 +232,3 @@ func DeleteAnObject() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## 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 an object in space
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/space/api#Read](https://m3o.com/space/api#Read)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/space"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Read an object in space
|
|
||||||
func ReadAnObject() {
|
|
||||||
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := spaceService.Read(&space.ReadRequest{
|
|
||||||
Name: "images/file.jpg",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Download
|
|
||||||
|
|
||||||
Download an object via a presigned url
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/space/api#Download](https://m3o.com/space/api#Download)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/space"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Download an object via a presigned url
|
|
||||||
func DownloadAnObject() {
|
|
||||||
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := spaceService.Download(&space.DownloadRequest{
|
|
||||||
Name: "images/file.jpg",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|||||||
@@ -4,6 +4,33 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/stream/api](ht
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
|
## ListChannels
|
||||||
|
|
||||||
|
List all the active channels
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/stream/api#ListChannels](https://m3o.com/stream/api#ListChannels)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/stream"
|
||||||
|
)
|
||||||
|
|
||||||
|
// List all the active channels
|
||||||
|
func ListChannels() {
|
||||||
|
streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := streamService.ListChannels(&stream.ListChannelsRequest{
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
## CreateChannel
|
## CreateChannel
|
||||||
|
|
||||||
Create a channel with a given name and description. Channels are created automatically but
|
Create a channel with a given name and description. Channels are created automatically but
|
||||||
@@ -92,30 +119,3 @@ func ListMessages() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## ListChannels
|
|
||||||
|
|
||||||
List all the active channels
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/stream/api#ListChannels](https://m3o.com/stream/api#ListChannels)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/stream"
|
|
||||||
)
|
|
||||||
|
|
||||||
// List all the active channels
|
|
||||||
func ListChannels() {
|
|
||||||
streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := streamService.ListChannels(&stream.ListChannelsRequest{
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|||||||
@@ -4,6 +4,37 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/sunnah/api](ht
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
|
## Hadiths
|
||||||
|
|
||||||
|
Hadiths returns a list of hadiths and their corresponding text for a
|
||||||
|
given book within a collection.
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/sunnah/api#Hadiths](https://m3o.com/sunnah/api#Hadiths)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/sunnah"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Hadiths returns a list of hadiths and their corresponding text for a
|
||||||
|
// given book within a collection.
|
||||||
|
func ListTheHadithsInAbook() {
|
||||||
|
sunnahService := sunnah.NewSunnahService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := sunnahService.Hadiths(&sunnah.HadithsRequest{
|
||||||
|
Book: 1,
|
||||||
|
Collection: "bukhari",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
## Collections
|
## Collections
|
||||||
|
|
||||||
Get a list of available collections. A collection is
|
Get a list of available collections. A collection is
|
||||||
@@ -92,34 +123,3 @@ Collection: "bukhari",
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Hadiths
|
|
||||||
|
|
||||||
Hadiths returns a list of hadiths and their corresponding text for a
|
|
||||||
given book within a collection.
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/sunnah/api#Hadiths](https://m3o.com/sunnah/api#Hadiths)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/sunnah"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Hadiths returns a list of hadiths and their corresponding text for a
|
|
||||||
// given book within a collection.
|
|
||||||
func ListTheHadithsInAbook() {
|
|
||||||
sunnahService := sunnah.NewSunnahService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := sunnahService.Hadiths(&sunnah.HadithsRequest{
|
|
||||||
Book: 1,
|
|
||||||
Collection: "bukhari",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|||||||
@@ -4,33 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/time/api](http
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
## Now
|
|
||||||
|
|
||||||
Get the current time
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/time/api#Now](https://m3o.com/time/api#Now)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/time"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Get the current time
|
|
||||||
func ReturnsCurrentTimeOptionallyWithLocation() {
|
|
||||||
timeService := time.NewTimeService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := timeService.Now(&time.NowRequest{
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Zone
|
## Zone
|
||||||
|
|
||||||
Get the timezone info for a specific location
|
Get the timezone info for a specific location
|
||||||
@@ -59,3 +32,30 @@ func GetTheTimezoneInfoForAspecificLocation() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
## Now
|
||||||
|
|
||||||
|
Get the current time
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/time/api#Now](https://m3o.com/time/api#Now)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Get the current time
|
||||||
|
func ReturnsCurrentTimeOptionallyWithLocation() {
|
||||||
|
timeService := time.NewTimeService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := timeService.Now(&time.NowRequest{
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
@@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/user/api](http
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
## Delete
|
|
||||||
|
|
||||||
Delete an account by id
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/user/api#Delete](https://m3o.com/user/api#Delete)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/user"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Delete an account by id
|
|
||||||
func DeleteUserAccount() {
|
|
||||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := userService.Delete(&user.DeleteRequest{
|
|
||||||
Id: "8b98acbe-0b6a-4d66-a414-5ffbf666786f",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Login
|
## Login
|
||||||
|
|
||||||
Login using username or email. The response will return a new session for successful login,
|
Login using username or email. The response will return a new session for successful login,
|
||||||
@@ -63,12 +35,15 @@ Password: "Password1",
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## List
|
## VerifyToken
|
||||||
|
|
||||||
List all users. Returns a paged list of results
|
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#List](https://m3o.com/user/api#List)
|
[https://m3o.com/user/api#VerifyToken](https://m3o.com/user/api#VerifyToken)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
package example
|
package example
|
||||||
@@ -80,59 +55,14 @@ import(
|
|||||||
"go.m3o.com/user"
|
"go.m3o.com/user"
|
||||||
)
|
)
|
||||||
|
|
||||||
// List all users. Returns a paged list of results
|
// Check whether the token attached to MagicLink is valid or not.
|
||||||
func ListAllUsers() {
|
// 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"))
|
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := userService.List(&user.ListRequest{
|
rsp, err := userService.VerifyToken(&user.VerifyTokenRequest{
|
||||||
Limit: 100,
|
Token: "EdsUiidouJJJLldjlloofUiorkojflsWWdld",
|
||||||
Offset: 0,
|
|
||||||
|
|
||||||
})
|
|
||||||
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)
|
fmt.Println(rsp, err)
|
||||||
@@ -167,159 +97,6 @@ Username: "joe",
|
|||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
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)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## SendMagicLink
|
|
||||||
|
|
||||||
Login using email only - Passwordless
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/user/api#SendMagicLink](https://m3o.com/user/api#SendMagicLink)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/user"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Login using email only - Passwordless
|
|
||||||
func SendAmagicLink() {
|
|
||||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := userService.SendMagicLink(&user.SendMagicLinkRequest{
|
|
||||||
Address: "www.example.com",
|
|
||||||
Email: "joe@example.com",
|
|
||||||
Endpoint: "verifytoken",
|
|
||||||
FromName: "Awesome Dot Com",
|
|
||||||
Subject: "MagicLink to access your account",
|
|
||||||
TextContent: `Hi there,
|
|
||||||
|
|
||||||
Click here to access your account $micro_verification_link`,
|
|
||||||
|
|
||||||
})
|
|
||||||
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)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## 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)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Read
|
## Read
|
||||||
@@ -404,6 +181,143 @@ func ReadAccountByEmail() {
|
|||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
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 an account by id
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/user/api#Delete](https://m3o.com/user/api#Delete)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/user"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Delete an account by id
|
||||||
|
func DeleteUserAccount() {
|
||||||
|
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := userService.Delete(&user.DeleteRequest{
|
||||||
|
Id: "8b98acbe-0b6a-4d66-a414-5ffbf666786f",
|
||||||
|
|
||||||
|
})
|
||||||
|
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)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## 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)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## SendPasswordResetEmail
|
## SendPasswordResetEmail
|
||||||
@@ -440,12 +354,12 @@ TextContent: `Hi there,
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## ResetPassword
|
## VerifyEmail
|
||||||
|
|
||||||
Reset password with the code sent by the "SendPasswordResetEmail" endpoint.
|
Verify the email address of an account from a token sent in an email to the user.
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/user/api#ResetPassword](https://m3o.com/user/api#ResetPassword)
|
[https://m3o.com/user/api#VerifyEmail](https://m3o.com/user/api#VerifyEmail)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
package example
|
package example
|
||||||
@@ -457,14 +371,77 @@ import(
|
|||||||
"go.m3o.com/user"
|
"go.m3o.com/user"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Reset password with the code sent by the "SendPasswordResetEmail" endpoint.
|
// Verify the email address of an account from a token sent in an email to the user.
|
||||||
func ResetPassword() {
|
func VerifyEmail() {
|
||||||
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.VerifyEmail(&user.VerifyEmailRequest{
|
||||||
Code: "012345",
|
Token: "012345",
|
||||||
ConfirmPassword: "NewPassword1",
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## SendMagicLink
|
||||||
|
|
||||||
|
Login using email only - Passwordless
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/user/api#SendMagicLink](https://m3o.com/user/api#SendMagicLink)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/user"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Login using email only - Passwordless
|
||||||
|
func SendAmagicLink() {
|
||||||
|
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := userService.SendMagicLink(&user.SendMagicLinkRequest{
|
||||||
|
Address: "www.example.com",
|
||||||
Email: "joe@example.com",
|
Email: "joe@example.com",
|
||||||
NewPassword: "NewPassword1",
|
Endpoint: "verifytoken",
|
||||||
|
FromName: "Awesome Dot Com",
|
||||||
|
Subject: "MagicLink to access your account",
|
||||||
|
TextContent: `Hi there,
|
||||||
|
|
||||||
|
Click here to access your account $micro_verification_link`,
|
||||||
|
|
||||||
|
})
|
||||||
|
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)
|
fmt.Println(rsp, err)
|
||||||
@@ -499,15 +476,12 @@ func LogAuserOut() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## VerifyToken
|
## ReadSession
|
||||||
|
|
||||||
Check whether the token attached to MagicLink is valid or not.
|
Read a session by the session id. In the event it has expired or is not found and error is returned.
|
||||||
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)
|
[https://m3o.com/user/api#ReadSession](https://m3o.com/user/api#ReadSession)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
package example
|
package example
|
||||||
@@ -519,14 +493,40 @@ import(
|
|||||||
"go.m3o.com/user"
|
"go.m3o.com/user"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Check whether the token attached to MagicLink is valid or not.
|
// Read a session by the session id. In the event it has expired or is not found and error is returned.
|
||||||
// Ideally, you need to call this endpoint from your http request
|
func ReadAsessionByTheSessionId() {
|
||||||
// handler that handles the endpoint which is specified in the
|
|
||||||
// SendMagicLink request.
|
|
||||||
func VerifyAtoken() {
|
|
||||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := userService.VerifyToken(&user.VerifyTokenRequest{
|
rsp, err := userService.ReadSession(&user.ReadSessionRequest{
|
||||||
Token: "EdsUiidouJJJLldjlloofUiorkojflsWWdld",
|
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)
|
fmt.Println(rsp, err)
|
||||||
|
|||||||
@@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/weather/api](h
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
## Now
|
|
||||||
|
|
||||||
Get the current weather report for a location by postcode, city, zip code, ip address
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/weather/api#Now](https://m3o.com/weather/api#Now)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/weather"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Get the current weather report for a location by postcode, city, zip code, ip address
|
|
||||||
func GetCurrentWeather() {
|
|
||||||
weatherService := weather.NewWeatherService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := weatherService.Now(&weather.NowRequest{
|
|
||||||
Location: "london",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Forecast
|
## Forecast
|
||||||
|
|
||||||
Get the weather forecast for the next 1-10 days
|
Get the weather forecast for the next 1-10 days
|
||||||
@@ -61,3 +33,31 @@ Location: "London",
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
## Now
|
||||||
|
|
||||||
|
Get the current weather report for a location by postcode, city, zip code, ip address
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/weather/api#Now](https://m3o.com/weather/api#Now)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/weather"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Get the current weather report for a location by postcode, city, zip code, ip address
|
||||||
|
func GetCurrentWeather() {
|
||||||
|
weatherService := weather.NewWeatherService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := weatherService.Now(&weather.NowRequest{
|
||||||
|
Location: "london",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
3
m3o.go
3
m3o.go
@@ -8,6 +8,7 @@ import (
|
|||||||
"go.m3o.com/cache"
|
"go.m3o.com/cache"
|
||||||
"go.m3o.com/carbon"
|
"go.m3o.com/carbon"
|
||||||
"go.m3o.com/chat"
|
"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"
|
||||||
@@ -75,6 +76,7 @@ func NewClient(token string) *Client {
|
|||||||
CacheService: cache.NewCacheService(token),
|
CacheService: cache.NewCacheService(token),
|
||||||
CarbonService: carbon.NewCarbonService(token),
|
CarbonService: carbon.NewCarbonService(token),
|
||||||
ChatService: chat.NewChatService(token),
|
ChatService: chat.NewChatService(token),
|
||||||
|
CommentsService: comments.NewCommentsService(token),
|
||||||
ContactService: contact.NewContactService(token),
|
ContactService: contact.NewContactService(token),
|
||||||
CryptoService: crypto.NewCryptoService(token),
|
CryptoService: crypto.NewCryptoService(token),
|
||||||
CurrencyService: currency.NewCurrencyService(token),
|
CurrencyService: currency.NewCurrencyService(token),
|
||||||
@@ -142,6 +144,7 @@ type Client struct {
|
|||||||
CacheService *cache.CacheService
|
CacheService *cache.CacheService
|
||||||
CarbonService *carbon.CarbonService
|
CarbonService *carbon.CarbonService
|
||||||
ChatService *chat.ChatService
|
ChatService *chat.ChatService
|
||||||
|
CommentsService *comments.CommentsService
|
||||||
ContactService *contact.ContactService
|
ContactService *contact.ContactService
|
||||||
CryptoService *crypto.CryptoService
|
CryptoService *crypto.CryptoService
|
||||||
CurrencyService *currency.CurrencyService
|
CurrencyService *currency.CurrencyService
|
||||||
|
|||||||
Reference in New Issue
Block a user