113 Commits

Author SHA1 Message Date
m3o-actions
cdb937b2cb Commit from m3o/m3o action 2022-01-31 18:10:43 +00:00
m3o-actions
fbf39cc693 Commit from m3o/m3o action 2022-01-31 16:18:59 +00:00
m3o-actions
1729996181 Commit from m3o/m3o action 2022-01-31 11:37:39 +00:00
m3o-actions
5fe1678ec5 Commit from m3o/m3o action 2022-01-31 11:31:42 +00:00
m3o-actions
8b790bd9b9 Commit from m3o/m3o action 2022-01-30 13:20:18 +00:00
m3o-actions
a9bcb78aa8 Commit from m3o/m3o action 2022-01-29 13:34:03 +00:00
m3o-actions
b3fd38731e Commit from m3o/m3o action 2022-01-29 13:32:49 +00:00
m3o-actions
ad326fd0b8 Commit from m3o/m3o action 2022-01-29 13:12:25 +00:00
m3o-actions
3ffe702d02 Commit from m3o/m3o action 2022-01-28 16:51:25 +00:00
m3o-actions
27a90b388a Commit from m3o/m3o action 2022-01-28 16:44:19 +00:00
m3o-actions
edfebe05df Commit from m3o/m3o action 2022-01-28 12:45:06 +00:00
m3o-actions
13441363d5 Commit from m3o/m3o action 2022-01-28 12:26:49 +00:00
m3o-actions
c5d206122c Commit from m3o/m3o action 2022-01-28 12:23:16 +00:00
m3o-actions
909ac3d71f Commit from m3o/m3o action 2022-01-28 11:45:42 +00:00
m3o-actions
3e8a881233 Commit from m3o/m3o action 2022-01-28 11:38:06 +00:00
m3o-actions
da1038343f Commit from m3o/m3o action 2022-01-28 11:07:21 +00:00
m3o-actions
fe7b620e59 Commit from m3o/m3o action 2022-01-27 14:31:56 +00:00
m3o-actions
58278dc08b Commit from m3o/m3o action 2022-01-26 20:25:51 +00:00
m3o-actions
362f73dca1 Commit from m3o/m3o action 2022-01-26 20:15:25 +00:00
m3o-actions
3cb3b40901 Commit from m3o/m3o action 2022-01-26 20:04:43 +00:00
m3o-actions
0aca22c769 Commit from m3o/m3o action 2022-01-26 19:15:56 +00:00
m3o-actions
9547c26947 Commit from m3o/m3o action 2022-01-26 13:06:45 +00:00
m3o-actions
9cd82a849f Commit from m3o/m3o action 2022-01-24 18:17:02 +00:00
m3o-actions
f142eddbb9 Commit from m3o/m3o action 2022-01-23 17:54:02 +00:00
m3o-actions
81eb8a213a Commit from m3o/m3o action 2022-01-23 09:47:29 +00:00
m3o-actions
79a9c94139 Commit from m3o/m3o action 2022-01-23 09:46:54 +00:00
m3o-actions
4a6b4ddbaa Commit from m3o/m3o action 2022-01-23 09:10:40 +00:00
m3o-actions
4646555d94 Commit from m3o/m3o action 2022-01-23 09:09:54 +00:00
m3o-actions
87d4ae480a Commit from m3o/m3o action 2022-01-23 09:09:16 +00:00
m3o-actions
f2c03ac414 Commit from m3o/m3o action 2022-01-23 09:08:22 +00:00
m3o-actions
00ad5f2668 Commit from m3o/m3o action 2022-01-21 15:55:22 +00:00
m3o-actions
5890e989e4 Commit from m3o/m3o action 2022-01-20 18:46:25 +00:00
m3o-actions
e7f0fd6434 Commit from m3o/m3o action 2022-01-20 15:13:38 +00:00
m3o-actions
d52ecd7232 Commit from m3o/m3o action 2022-01-20 15:13:18 +00:00
m3o-actions
3fd0023e27 Commit from m3o/m3o action 2022-01-20 08:15:38 +00:00
m3o-actions
83740822e1 Commit from m3o/m3o action 2022-01-20 08:06:17 +00:00
m3o-actions
7a4f8f2faa Commit from m3o/m3o action 2022-01-20 08:03:44 +00:00
m3o-actions
5db5bff7e5 Commit from m3o/m3o action 2022-01-20 07:58:53 +00:00
m3o-actions
bc3256a02a Commit from m3o/m3o action 2022-01-20 07:54:44 +00:00
m3o-actions
d346494459 Commit from m3o/m3o action 2022-01-20 07:52:53 +00:00
m3o-actions
847b17a423 Commit from m3o/m3o action 2022-01-19 21:52:39 +00:00
m3o-actions
051b7e8db7 Commit from m3o/m3o action 2022-01-19 21:51:49 +00:00
m3o-actions
ef53cae138 Commit from m3o/m3o action 2022-01-19 19:39:03 +00:00
m3o-actions
9c5e2fc5dd Commit from m3o/m3o action 2022-01-19 19:38:00 +00:00
m3o-actions
fbbc6fce2b Commit from m3o/m3o action 2022-01-19 18:45:46 +00:00
m3o-actions
75931d518a Commit from m3o/m3o action 2022-01-19 18:45:22 +00:00
m3o-actions
76e85f7e0a Commit from m3o/m3o action 2022-01-19 18:45:02 +00:00
m3o-actions
b4f72abd73 Commit from m3o/m3o action 2022-01-19 18:39:51 +00:00
m3o-actions
c9ddd8776c Commit from m3o/m3o action 2022-01-19 18:15:52 +00:00
m3o-actions
4e9cd04448 Commit from m3o/m3o action 2022-01-19 15:06:00 +00:00
m3o-actions
e4472e76bc Commit from m3o/m3o action 2022-01-19 10:30:21 +00:00
m3o-actions
b89a529672 Commit from m3o/m3o action 2022-01-18 14:54:20 +00:00
m3o-actions
1c567f0eff Commit from m3o/m3o action 2022-01-18 13:29:33 +00:00
m3o-actions
42b9941d93 Commit from m3o/m3o action 2022-01-18 09:21:40 +00:00
m3o-actions
ee0f545030 Commit from m3o/m3o action 2022-01-17 15:32:27 +00:00
m3o-actions
59a3c3c3a8 Commit from m3o/m3o action 2022-01-17 14:13:41 +00:00
m3o-actions
081b4bc7dd Commit from m3o/m3o action 2022-01-17 11:48:03 +00:00
m3o-actions
c296523bb2 Commit from m3o/m3o action 2022-01-17 11:42:01 +00:00
m3o-actions
fe83bf7d18 Commit from m3o/m3o action 2022-01-17 11:34:48 +00:00
m3o-actions
f68c53a04d Commit from m3o/m3o action 2022-01-15 21:05:12 +00:00
m3o-actions
04d7bf8148 Commit from m3o/m3o action 2022-01-15 20:59:52 +00:00
m3o-actions
a83b25a9aa Commit from m3o/m3o action 2022-01-15 20:55:42 +00:00
m3o-actions
b48eab72b9 Commit from m3o/m3o action 2022-01-15 20:55:33 +00:00
m3o-actions
8a600b6131 Commit from m3o/m3o action 2022-01-15 20:54:42 +00:00
m3o-actions
8408429e9b Commit from m3o/m3o action 2022-01-15 20:53:15 +00:00
m3o-actions
20a3a5bfd7 Commit from m3o/m3o action 2022-01-15 20:53:01 +00:00
m3o-actions
f01a912eb3 Commit from m3o/m3o action 2022-01-15 20:48:02 +00:00
m3o-actions
eebea56166 Commit from m3o/m3o action 2022-01-15 20:46:39 +00:00
m3o-actions
2d8f3d735d Commit from m3o/m3o action 2022-01-14 17:42:50 +00:00
m3o-actions
ccc5de5cda Commit from m3o/m3o action 2022-01-14 17:42:44 +00:00
m3o-actions
863b60c7db Commit from m3o/m3o action 2022-01-14 16:09:20 +00:00
m3o-actions
5caf581eff Commit from m3o/m3o action 2022-01-14 09:11:51 +00:00
m3o-actions
2dda68b677 Commit from m3o/m3o action 2022-01-14 09:11:13 +00:00
m3o-actions
8967d7aed8 Commit from m3o/m3o action 2022-01-13 14:13:38 +00:00
m3o-actions
88ec3b1629 Commit from m3o/m3o action 2022-01-13 13:23:08 +00:00
m3o-actions
3b8973592b Commit from m3o/m3o action 2022-01-13 11:39:07 +00:00
m3o-actions
af71fa56b0 Commit from m3o/m3o action 2022-01-13 11:00:05 +00:00
m3o-actions
1a6e2f4cb5 Commit from m3o/m3o action 2022-01-12 15:03:53 +00:00
m3o-actions
9abf8b4e6a Commit from m3o/m3o action 2022-01-12 14:17:28 +00:00
m3o-actions
74d67fe903 Commit from m3o/m3o action 2022-01-12 10:23:25 +00:00
m3o-actions
f9a04eab0b Commit from m3o/m3o action 2022-01-12 10:10:29 +00:00
m3o-actions
ecbcaa1f37 Commit from m3o/m3o action 2022-01-12 10:08:41 +00:00
m3o-actions
fc9078369c Commit from m3o/m3o action 2022-01-12 10:03:46 +00:00
m3o-actions
9fb8b7249a Commit from m3o/m3o action 2022-01-12 09:46:51 +00:00
m3o-actions
f238a3dde3 Commit from m3o/m3o action 2022-01-12 09:44:30 +00:00
m3o-actions
06e0e031f0 Commit from m3o/m3o action 2022-01-11 15:53:58 +00:00
m3o-actions
4671615268 Commit from m3o/m3o action 2022-01-11 14:33:46 +00:00
m3o-actions
50abf5f044 Commit from m3o/m3o action 2022-01-11 12:33:30 +00:00
m3o-actions
7ebbac3eb1 Commit from m3o/m3o action 2022-01-10 20:48:03 +00:00
m3o-actions
cff39c86e7 Commit from m3o/m3o action 2022-01-10 15:39:42 +00:00
m3o-actions
200da05cf0 Commit from m3o/m3o action 2022-01-10 15:13:17 +00:00
m3o-actions
0a2f0eb713 Commit from m3o/m3o action 2022-01-10 09:20:34 +00:00
m3o-actions
0d1952d41a Commit from m3o/m3o action 2022-01-07 12:55:10 +00:00
m3o-actions
4eaa0d7a79 Commit from m3o/m3o action 2022-01-07 12:48:23 +00:00
m3o-actions
fc3cf88dd1 Commit from m3o/m3o action 2022-01-07 11:59:24 +00:00
m3o-actions
4029f043af Commit from m3o/m3o action 2022-01-07 11:55:38 +00:00
m3o-actions
768c3a7277 Commit from m3o/m3o action 2022-01-07 11:09:48 +00:00
Dominic Wong
1b6f533cda remove search example 2022-01-07 11:05:22 +00:00
m3o-actions
23efeb1b54 Commit from m3o/m3o action 2022-01-06 22:20:09 +00:00
m3o-actions
28be83a1a3 Commit from m3o/m3o action 2022-01-06 22:09:57 +00:00
m3o-actions
163098f65c Commit from m3o/m3o action 2022-01-06 18:20:05 +00:00
m3o-actions
d75eee6adc Commit from m3o/m3o action 2022-01-06 17:04:52 +00:00
m3o-actions
f62afe5c72 Commit from m3o/m3o action 2022-01-06 17:00:05 +00:00
m3o-actions
05dcddb482 Commit from m3o/m3o action 2022-01-06 16:59:33 +00:00
m3o-actions
96bb1b0a89 Commit from m3o/m3o action 2022-01-06 16:57:05 +00:00
m3o-actions
3a49edfecc Commit from m3o/m3o action 2022-01-06 16:50:27 +00:00
m3o-actions
e8cd7403b7 Commit from m3o/m3o action 2022-01-06 16:44:20 +00:00
m3o-actions
8bba336dd3 Commit from m3o/m3o action 2022-01-06 15:23:27 +00:00
m3o-actions
a8b28f6b2a Commit from m3o/m3o action 2022-01-06 14:52:18 +00:00
m3o-actions
c919eb0016 Commit from m3o/m3o action 2022-01-06 11:30:48 +00:00
m3o-actions
6443d9822b Commit from m3o/m3o action 2022-01-06 11:14:12 +00:00
m3o-actions
cd580f41a7 Commit from m3o/m3o action 2022-01-06 11:13:13 +00:00
m3o-actions
f21152e1ed Commit from m3o/m3o action 2022-01-05 15:30:45 +00:00
76 changed files with 1858 additions and 1184 deletions

16
cache/cache.go vendored
View File

@@ -9,6 +9,7 @@ type Cache interface {
Delete(*DeleteRequest) (*DeleteResponse, error)
Get(*GetRequest) (*GetResponse, error)
Increment(*IncrementRequest) (*IncrementResponse, error)
ListKeys(*ListKeysRequest) (*ListKeysResponse, error)
Set(*SetRequest) (*SetResponse, error)
}
@@ -56,6 +57,14 @@ func (t *CacheService) Increment(request *IncrementRequest) (*IncrementResponse,
}
// List all the available keys
func (t *CacheService) ListKeys(request *ListKeysRequest) (*ListKeysResponse, error) {
rsp := &ListKeysResponse{}
return rsp, t.client.Call("cache", "ListKeys", request, rsp)
}
// Set an item in the cache. Overwrites any existing value already set.
func (t *CacheService) Set(request *SetRequest) (*SetResponse, error) {
@@ -116,6 +125,13 @@ type IncrementResponse struct {
Value int64 `json:"value,string"`
}
type ListKeysRequest struct {
}
type ListKeysResponse struct {
Keys []string `json:"keys"`
}
type SetRequest struct {
// The key to update
Key string `json:"key"`

52
carbon/carbon.go Executable file
View File

@@ -0,0 +1,52 @@
package carbon
import (
"go.m3o.com/client"
)
type Carbon interface {
Offset(*OffsetRequest) (*OffsetResponse, error)
}
func NewCarbonService(token string) *CarbonService {
return &CarbonService{
client: client.NewClient(&client.Options{
Token: token,
}),
}
}
type CarbonService struct {
client *client.Client
}
// Purchase 1KG (0.001 tonne) of carbon offsets in a single request
func (t *CarbonService) Offset(request *OffsetRequest) (*OffsetResponse, error) {
rsp := &OffsetResponse{}
return rsp, t.client.Call("carbon", "Offset", request, rsp)
}
type OffsetRequest struct {
}
type OffsetResponse struct {
// the metric used e.g KG or Tonnes
Metric string `json:"metric"`
// projects it was allocated to
Projects []Project `json:"projects"`
// number of tonnes
Tonnes float64 `json:"tonnes"`
// number of units purchased
Units int32 `json:"units"`
}
type Project struct {
// name of the project
Name string `json:"name"`
// percentage that went to this
Percentage float64 `json:"percentage"`
// amount in tonnes
Tonnes float64 `json:"tonnes"`
}

View File

@@ -5,7 +5,9 @@ import (
)
type Email interface {
Parse(*ParseRequest) (*ParseResponse, error)
Send(*SendRequest) (*SendResponse, error)
Validate(*ValidateRequest) (*ValidateResponse, error)
}
func NewEmailService(token string) *EmailService {
@@ -20,6 +22,14 @@ type EmailService struct {
client *client.Client
}
// Parse an RFC5322 address e.g "Joe Blogs <joe@example.com>"
func (t *EmailService) Parse(request *ParseRequest) (*ParseResponse, error) {
rsp := &ParseResponse{}
return rsp, t.client.Call("email", "Parse", request, rsp)
}
// Send an email by passing in from, to, subject, and a text or html body
func (t *EmailService) Send(request *SendRequest) (*SendResponse, error) {
@@ -28,6 +38,26 @@ func (t *EmailService) Send(request *SendRequest) (*SendResponse, error) {
}
// Validate an email address format
func (t *EmailService) Validate(request *ValidateRequest) (*ValidateResponse, error) {
rsp := &ValidateResponse{}
return rsp, t.client.Call("email", "Validate", request, rsp)
}
type ParseRequest struct {
// The address to parse. Can be of the format "Joe Blogs <joe@example.com>" or "joe@example.com"
Address string `json:"address"`
}
type ParseResponse struct {
// the email address
Address string `json:"address"`
// associated name e.g Joe Blogs
Name string `json:"name"`
}
type SendRequest struct {
// the display name of the sender
From string `json:"from"`
@@ -45,3 +75,11 @@ type SendRequest struct {
type SendResponse struct {
}
type ValidateRequest struct {
Address string `json:"address"`
}
type ValidateResponse struct {
IsValid bool `json:"is_valid"`
}

View File

@@ -1,6 +1,6 @@
# Address
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Address/api](https://m3o.com/Address/api).
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/address/api](https://m3o.com/address/api).
Endpoints:

View File

@@ -1,6 +1,6 @@
# Answer
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Answer/api](https://m3o.com/Answer/api).
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/answer/api](https://m3o.com/answer/api).
Endpoints:

View File

@@ -1,93 +1,9 @@
# App
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/App/api](https://m3o.com/App/api).
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/app/api](https://m3o.com/app/api).
Endpoints:
## Status
Get the status of an app
[https://m3o.com/app/api#Status](https://m3o.com/app/api#Status)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/app"
)
// Get the status of an app
func GetTheStatusOfAnApp() {
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
rsp, err := appService.Status(&app.StatusRequest{
Name: "helloworld",
})
fmt.Println(rsp, err)
}
```
## Resolve
Resolve an app by id to its raw backend endpoint
[https://m3o.com/app/api#Resolve](https://m3o.com/app/api#Resolve)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/app"
)
// Resolve an app by id to its raw backend endpoint
func ResolveAppById() {
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
rsp, err := appService.Resolve(&app.ResolveRequest{
Id: "helloworld",
})
fmt.Println(rsp, err)
}
```
## Update
Update the app. The latest source code will be downloaded, built and deployed.
[https://m3o.com/app/api#Update](https://m3o.com/app/api#Update)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/app"
)
// Update the app. The latest source code will be downloaded, built and deployed.
func UpdateAnApp() {
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
rsp, err := appService.Update(&app.UpdateRequest{
Name: "helloworld",
})
fmt.Println(rsp, err)
}
```
## Delete
Delete an app
@@ -230,3 +146,87 @@ func ListRegions() {
}
```
## Status
Get the status of an app
[https://m3o.com/app/api#Status](https://m3o.com/app/api#Status)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/app"
)
// Get the status of an app
func GetTheStatusOfAnApp() {
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
rsp, err := appService.Status(&app.StatusRequest{
Name: "helloworld",
})
fmt.Println(rsp, err)
}
```
## Resolve
Resolve an app by id to its raw backend endpoint
[https://m3o.com/app/api#Resolve](https://m3o.com/app/api#Resolve)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/app"
)
// Resolve an app by id to its raw backend endpoint
func ResolveAppById() {
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
rsp, err := appService.Resolve(&app.ResolveRequest{
Id: "helloworld",
})
fmt.Println(rsp, err)
}
```
## Update
Update the app. The latest source code will be downloaded, built and deployed.
[https://m3o.com/app/api#Update](https://m3o.com/app/api#Update)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/app"
)
// Update the app. The latest source code will be downloaded, built and deployed.
func UpdateAnApp() {
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
rsp, err := appService.Update(&app.UpdateRequest{
Name: "helloworld",
})
fmt.Println(rsp, err)
}
```

View File

@@ -1,6 +1,6 @@
# Avatar
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Avatar/api](https://m3o.com/Avatar/api).
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/avatar/api](https://m3o.com/avatar/api).
Endpoints:
@@ -25,9 +25,9 @@ import(
func GenerateAvatarAndReturnBase64stringOfTheAvatar() {
avatarService := avatar.NewAvatarService(os.Getenv("M3O_API_TOKEN"))
rsp, err := avatarService.Generate(&avatar.GenerateRequest{
Format: "png",
Format: "jpeg",
Gender: "female",
Upload: true,
Upload: false,
Username: "",
})
@@ -56,9 +56,9 @@ import(
func GenerateAnAvatarAndUploadTheAvatarToMicrosCdn() {
avatarService := avatar.NewAvatarService(os.Getenv("M3O_API_TOKEN"))
rsp, err := avatarService.Generate(&avatar.GenerateRequest{
Format: "jpeg",
Format: "png",
Gender: "female",
Upload: false,
Upload: true,
Username: "",
})

View File

@@ -11,9 +11,9 @@ import (
func main() {
avatarService := avatar.NewAvatarService(os.Getenv("M3O_API_TOKEN"))
rsp, err := avatarService.Generate(&avatar.GenerateRequest{
Format: "jpeg",
Format: "png",
Gender: "female",
Upload: false,
Upload: true,
Username: "",
})
fmt.Println(rsp, err)

View File

@@ -11,9 +11,9 @@ import (
func main() {
avatarService := avatar.NewAvatarService(os.Getenv("M3O_API_TOKEN"))
rsp, err := avatarService.Generate(&avatar.GenerateRequest{
Format: "png",
Format: "jpeg",
Gender: "female",
Upload: true,
Upload: false,
Username: "",
})
fmt.Println(rsp, err)

View File

@@ -1,6 +1,6 @@
# Cache
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Cache/api](https://m3o.com/Cache/api).
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/cache/api](https://m3o.com/cache/api).
Endpoints:
@@ -147,3 +147,30 @@ Value: 2,
}
```
## ListKeys
List all the available keys
[https://m3o.com/cache/api#ListKeys](https://m3o.com/cache/api#ListKeys)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/cache"
)
// List all the available keys
func ListTheKeys() {
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
rsp, err := cacheService.ListKeys(&cache.ListKeysRequest{
})
fmt.Println(rsp, err)
}
```

15
examples/cache/listKeys/listTheKeys/main.go vendored Executable file
View File

@@ -0,0 +1,15 @@
package main
import (
"fmt"
"os"
"go.m3o.com/cache"
)
// List all the available keys
func main() {
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
rsp, err := cacheService.ListKeys(&cache.ListKeysRequest{})
fmt.Println(rsp, err)
}

33
examples/carbon/README.md Executable file
View File

@@ -0,0 +1,33 @@
# Carbon
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/carbon/api](https://m3o.com/carbon/api).
Endpoints:
## Offset
Purchase 1KG (0.001 tonne) of carbon offsets in a single request
[https://m3o.com/carbon/api#Offset](https://m3o.com/carbon/api#Offset)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/carbon"
)
// Purchase 1KG (0.001 tonne) of carbon offsets in a single request
func OffsetCarbon() {
carbonService := carbon.NewCarbonService(os.Getenv("M3O_API_TOKEN"))
rsp, err := carbonService.Offset(&carbon.OffsetRequest{
})
fmt.Println(rsp, err)
}
```

View File

@@ -0,0 +1,15 @@
package main
import (
"fmt"
"os"
"go.m3o.com/carbon"
)
// Purchase 1KG (0.001 tonne) of carbon offsets in a single request
func main() {
carbonService := carbon.NewCarbonService(os.Getenv("M3O_API_TOKEN"))
rsp, err := carbonService.Offset(&carbon.OffsetRequest{})
fmt.Println(rsp, err)
}

View File

@@ -1,6 +1,6 @@
# Contact
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Contact/api](https://m3o.com/Contact/api).
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/contact/api](https://m3o.com/contact/api).
Endpoints:

View File

@@ -1,65 +1,9 @@
# Crypto
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Crypto/api](https://m3o.com/Crypto/api).
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/crypto/api](https://m3o.com/crypto/api).
Endpoints:
## 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
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)
}
```

View File

@@ -1,64 +1,9 @@
# Currency
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Currency/api](https://m3o.com/Currency/api).
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/currency/api](https://m3o.com/currency/api).
Endpoints:
## Codes
Codes returns the supported currency codes for the API
[https://m3o.com/currency/api#Codes](https://m3o.com/currency/api#Codes)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/currency"
)
// Codes returns the supported currency codes for the API
func GetSupportedCodes() {
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
rsp, err := currencyService.Codes(&currency.CodesRequest{
})
fmt.Println(rsp, err)
}
```
## Rates
Rates returns the currency rates for a given code e.g USD
[https://m3o.com/currency/api#Rates](https://m3o.com/currency/api#Rates)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/currency"
)
// Rates returns the currency rates for a given code e.g USD
func GetRatesForUsd() {
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
rsp, err := currencyService.Rates(&currency.RatesRequest{
Code: "USD",
})
fmt.Println(rsp, err)
}
```
## Convert
Convert returns the currency conversion rate between two pairs e.g USD/GBP
@@ -147,3 +92,58 @@ Date: "2021-05-30",
}
```
## Codes
Codes returns the supported currency codes for the API
[https://m3o.com/currency/api#Codes](https://m3o.com/currency/api#Codes)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/currency"
)
// Codes returns the supported currency codes for the API
func GetSupportedCodes() {
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
rsp, err := currencyService.Codes(&currency.CodesRequest{
})
fmt.Println(rsp, err)
}
```
## Rates
Rates returns the currency rates for a given code e.g USD
[https://m3o.com/currency/api#Rates](https://m3o.com/currency/api#Rates)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/currency"
)
// Rates returns the currency rates for a given code e.g USD
func GetRatesForUsd() {
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
rsp, err := currencyService.Rates(&currency.RatesRequest{
Code: "USD",
})
fmt.Println(rsp, err)
}
```

View File

@@ -1,38 +1,9 @@
# Db
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Db/api](https://m3o.com/Db/api).
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/db/api](https://m3o.com/db/api).
Endpoints:
## 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)
}
```
## Update
Update a record in the database. Include an "id" in the record to update.
@@ -92,34 +63,6 @@ Table: "example",
})
fmt.Println(rsp, err)
}
```
## Truncate
Truncate the records in a table
[https://m3o.com/db/api#Truncate](https://m3o.com/db/api#Truncate)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/db"
)
// Truncate the records in a table
func TruncateTable() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Truncate(&db.TruncateRequest{
Table: "example",
})
fmt.Println(rsp, err)
}
```
## DropTable
@@ -203,6 +146,97 @@ func ListTables() {
})
fmt.Println(rsp, err)
}
```
## Create
Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
[https://m3o.com/db/api#Create](https://m3o.com/db/api#Create)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/db"
)
// Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
func CreateArecord() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Create(&db.CreateRequest{
Record: map[string]interface{}{
"isActive": true,
"id": "1",
"name": "Jane",
"age": 42,
},
Table: "example",
})
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 the records in a table
[https://m3o.com/db/api#Truncate](https://m3o.com/db/api#Truncate)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/db"
)
// Truncate the records in a table
func TruncateTable() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Truncate(&db.TruncateRequest{
Table: "example",
})
fmt.Println(rsp, err)
}
```
## RenameTable
@@ -234,37 +268,3 @@ To: "examples3",
}
```
## Create
Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
[https://m3o.com/db/api#Create](https://m3o.com/db/api#Create)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/db"
)
// Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
func CreateArecord() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Create(&db.CreateRequest{
Record: map[string]interface{}{
"id": "1",
"name": "Jane",
"age": 42,
"isActive": true,
},
Table: "example",
})
fmt.Println(rsp, err)
}
```

View File

@@ -1,9 +1,37 @@
# Email
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Email/api](https://m3o.com/Email/api).
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/email/api](https://m3o.com/email/api).
Endpoints:
## 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 an email by passing in from, to, subject, and a text or html body
@@ -36,3 +64,31 @@ Please verify your email by clicking this link: $micro_verification_link`,
}
```
## Parse
Parse an RFC5322 address e.g "Joe Blogs <joe@example.com>"
[https://m3o.com/email/api#Parse](https://m3o.com/email/api#Parse)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/email"
)
// Parse an RFC5322 address e.g "Joe Blogs <joe@example.com>"
func ParseEmail() {
emailService := email.NewEmailService(os.Getenv("M3O_API_TOKEN"))
rsp, err := emailService.Parse(&email.ParseRequest{
Address: "Joe Blogs <joe@example.com>",
})
fmt.Println(rsp, err)
}
```

View File

@@ -0,0 +1,17 @@
package main
import (
"fmt"
"os"
"go.m3o.com/email"
)
// Parse an RFC5322 address e.g "Joe Blogs <joe@example.com>"
func main() {
emailService := email.NewEmailService(os.Getenv("M3O_API_TOKEN"))
rsp, err := emailService.Parse(&email.ParseRequest{
Address: "Joe Blogs <joe@example.com>",
})
fmt.Println(rsp, err)
}

View File

@@ -0,0 +1,17 @@
package main
import (
"fmt"
"os"
"go.m3o.com/email"
)
// Validate an email address format
func main() {
emailService := email.NewEmailService(os.Getenv("M3O_API_TOKEN"))
rsp, err := emailService.Validate(&email.ValidateRequest{
Address: "joe@example.com",
})
fmt.Println(rsp, err)
}

View File

@@ -1,6 +1,6 @@
# Emoji
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Emoji/api](https://m3o.com/Emoji/api).
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/emoji/api](https://m3o.com/emoji/api).
Endpoints:

View File

@@ -1,6 +1,6 @@
# Evchargers
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Evchargers/api](https://m3o.com/Evchargers/api).
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/evchargers/api](https://m3o.com/evchargers/api).
Endpoints:

View File

@@ -1,42 +1,9 @@
# Event
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Event/api](https://m3o.com/Event/api).
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/event/api](https://m3o.com/event/api).
Endpoints:
## Publish
Publish a event to the event stream.
[https://m3o.com/event/api#Publish](https://m3o.com/event/api#Publish)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/event"
)
// Publish a event to the event stream.
func PublishAnEvent() {
eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN"))
rsp, err := eventService.Publish(&event.PublishRequest{
Message: map[string]interface{}{
"id": "1",
"type": "signup",
"user": "john",
},
Topic: "user",
})
fmt.Println(rsp, err)
}
```
## Consume
Consume events from a given topic.
@@ -106,3 +73,36 @@ func ReadEventsOnAtopic() {
}
```
## Publish
Publish a event to the event stream.
[https://m3o.com/event/api#Publish](https://m3o.com/event/api#Publish)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/event"
)
// Publish a event to the event stream.
func PublishAnEvent() {
eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN"))
rsp, err := eventService.Publish(&event.PublishRequest{
Message: map[string]interface{}{
"id": "1",
"type": "signup",
"user": "john",
},
Topic: "user",
})
fmt.Println(rsp, err)
}
```

View File

@@ -1,9 +1,66 @@
# File
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/File/api](https://m3o.com/File/api).
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/file/api](https://m3o.com/file/api).
Endpoints:
## List
List files by their project and optionally a path.
[https://m3o.com/file/api#List](https://m3o.com/file/api#List)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/file"
)
// List files by their project and optionally a path.
func ListFiles() {
fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN"))
rsp, err := fileService.List(&file.ListRequest{
Project: "examples",
})
fmt.Println(rsp, err)
}
```
## Read
Read a file by path
[https://m3o.com/file/api#Read](https://m3o.com/file/api#Read)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/file"
)
// Read a file by path
func ReadFile() {
fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN"))
rsp, err := fileService.Read(&file.ReadRequest{
Path: "/document/text-files/file.txt",
Project: "examples",
})
fmt.Println(rsp, err)
}
```
## Delete
Delete a file by project name/path
@@ -65,60 +122,3 @@ func SaveFile() {
}
```
## List
List files by their project and optionally a path.
[https://m3o.com/file/api#List](https://m3o.com/file/api#List)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/file"
)
// List files by their project and optionally a path.
func ListFiles() {
fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN"))
rsp, err := fileService.List(&file.ListRequest{
Project: "examples",
})
fmt.Println(rsp, err)
}
```
## Read
Read a file by path
[https://m3o.com/file/api#Read](https://m3o.com/file/api#Read)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/file"
)
// Read a file by path
func ReadFile() {
fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN"))
rsp, err := fileService.Read(&file.ReadRequest{
Path: "/document/text-files/file.txt",
Project: "examples",
})
fmt.Println(rsp, err)
}
```

View File

@@ -1,6 +1,6 @@
# Forex
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Forex/api](https://m3o.com/Forex/api).
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/forex/api](https://m3o.com/forex/api).
Endpoints:

View File

@@ -1,15 +1,15 @@
# Function
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Function/api](https://m3o.com/Function/api).
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/function/api](https://m3o.com/function/api).
Endpoints:
## Update
## Reserve
Update a function. Downloads the source, builds and redeploys
Reserve function names and resources beyond free quota
[https://m3o.com/function/api#Update](https://m3o.com/function/api#Update)
[https://m3o.com/function/api#Reserve](https://m3o.com/function/api#Reserve)
```go
package example
@@ -21,100 +21,15 @@ import(
"go.m3o.com/function"
)
// Update a function. Downloads the source, builds and redeploys
func UpdateAfunction() {
// Reserve function names and resources beyond free quota
func ReserveAfunction() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.Update(&function.UpdateRequest{
rsp, err := functionService.Reserve(&function.ReserveRequest{
Name: "helloworld",
})
fmt.Println(rsp, err)
}
```
## Call
Call a function by name
[https://m3o.com/function/api#Call](https://m3o.com/function/api#Call)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/function"
)
// Call a function by name
func CallAfunction() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.Call(&function.CallRequest{
Name: "helloworld",
Request: map[string]interface{}{
"name": "Alice",
},
})
fmt.Println(rsp, err)
}
```
## List
List all the deployed functions
[https://m3o.com/function/api#List](https://m3o.com/function/api#List)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/function"
)
// List all the deployed functions
func ListFunctions() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.List(&function.ListRequest{
})
fmt.Println(rsp, err)
}
```
## Regions
Return a list of supported regions
[https://m3o.com/function/api#Regions](https://m3o.com/function/api#Regions)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/function"
)
// Return a list of supported regions
func ListRegions() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.Regions(&function.RegionsRequest{
})
fmt.Println(rsp, err)
}
```
## Deploy
@@ -149,6 +64,60 @@ Subfolder: "examples/go-function",
})
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)
}
```
## 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
@@ -205,34 +174,6 @@ func DescribeFunctionStatus() {
})
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
@@ -263,3 +204,62 @@ func ProxyUrl() {
}
```
## Update
Update a function. Downloads the source, builds and redeploys
[https://m3o.com/function/api#Update](https://m3o.com/function/api#Update)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/function"
)
// Update a function. Downloads the source, builds and redeploys
func UpdateAfunction() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.Update(&function.UpdateRequest{
Name: "helloworld",
})
fmt.Println(rsp, err)
}
```
## Call
Call a function by name
[https://m3o.com/function/api#Call](https://m3o.com/function/api#Call)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/function"
)
// Call a function by name
func CallAfunction() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.Call(&function.CallRequest{
Name: "helloworld",
Request: map[string]interface{}{
"name": "Alice",
},
})
fmt.Println(rsp, err)
}
```

View File

@@ -1,6 +1,6 @@
# Geocoding
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Geocoding/api](https://m3o.com/Geocoding/api).
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/geocoding/api](https://m3o.com/geocoding/api).
Endpoints:

View File

@@ -1,6 +1,6 @@
# Gifs
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Gifs/api](https://m3o.com/Gifs/api).
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/gifs/api](https://m3o.com/gifs/api).
Endpoints:

View File

@@ -1,6 +1,6 @@
# Google
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Google/api](https://m3o.com/Google/api).
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/google/api](https://m3o.com/google/api).
Endpoints:

View File

@@ -1,6 +1,6 @@
# Helloworld
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Helloworld/api](https://m3o.com/Helloworld/api).
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/helloworld/api](https://m3o.com/helloworld/api).
Endpoints:

View File

@@ -1,6 +1,6 @@
# Holidays
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Holidays/api](https://m3o.com/Holidays/api).
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/holidays/api](https://m3o.com/holidays/api).
Endpoints:

View File

@@ -1,6 +1,6 @@
# Id
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Id/api](https://m3o.com/Id/api).
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/id/api](https://m3o.com/id/api).
Endpoints:

View File

@@ -1,107 +1,9 @@
# Image
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Image/api](https://m3o.com/Image/api).
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/image/api](https://m3o.com/image/api).
Endpoints:
## Upload
Upload an image by either sending a base64 encoded image to this endpoint or a URL.
To resize an image before uploading, see the Resize endpoint.
To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
with each parameter as a form field.
[https://m3o.com/image/api#Upload](https://m3o.com/image/api#Upload)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/image"
)
// Upload an image by either sending a base64 encoded image to this endpoint or a URL.
// To resize an image before uploading, see the Resize endpoint.
// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
// with each parameter as a form field.
func UploadAbase64imageToMicrosCdn() {
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
rsp, err := imageService.Upload(&image.UploadRequest{
Base64: "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAx0lEQVR4nOzaMaoDMQyE4ZHj+x82vVdhwQoTkzKQEcwP5r0ihT7sbjUTeAJ4HCegXQJYfOYefOyjDuBiz3yjwJBoCIl6QZOeUjTC1Ix1IxEJXF9+0KWsf2bD4bn37OO/c/wuQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9Sa/NG94Tf3j4WBdaxudMEkn4IM2rZBA0wBrvo7aOcpj2emXvLeVt0IGm0GVXUj91mvAAAA//+V2CZl+4AKXwAAAABJRU5ErkJggg==",
Name: "cat.jpeg",
})
fmt.Println(rsp, err)
}
```
## Upload
Upload an image by either sending a base64 encoded image to this endpoint or a URL.
To resize an image before uploading, see the Resize endpoint.
To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
with each parameter as a form field.
[https://m3o.com/image/api#Upload](https://m3o.com/image/api#Upload)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/image"
)
// Upload an image by either sending a base64 encoded image to this endpoint or a URL.
// To resize an image before uploading, see the Resize endpoint.
// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
// with each parameter as a form field.
func UploadAnImageFromAurlToMicrosCdn() {
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
rsp, err := imageService.Upload(&image.UploadRequest{
Name: "cat.jpeg",
Url: "somewebsite.com/cat.png",
})
fmt.Println(rsp, err)
}
```
## Delete
Delete an image previously uploaded.
[https://m3o.com/image/api#Delete](https://m3o.com/image/api#Delete)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/image"
)
// Delete an image previously uploaded.
func DeleteAnUploadedImage() {
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
rsp, err := imageService.Delete(&image.DeleteRequest{
Url: "https://cdn.m3ocontent.com/micro/images/micro/41e23b39-48dd-42b6-9738-79a313414bb8/cat.png",
})
fmt.Println(rsp, err)
}
```
## Resize
Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters.
@@ -256,3 +158,101 @@ Url: "somewebsite.com/cat.png",
}
```
## Upload
Upload an image by either sending a base64 encoded image to this endpoint or a URL.
To resize an image before uploading, see the Resize endpoint.
To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
with each parameter as a form field.
[https://m3o.com/image/api#Upload](https://m3o.com/image/api#Upload)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/image"
)
// Upload an image by either sending a base64 encoded image to this endpoint or a URL.
// To resize an image before uploading, see the Resize endpoint.
// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
// with each parameter as a form field.
func UploadAbase64imageToMicrosCdn() {
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
rsp, err := imageService.Upload(&image.UploadRequest{
Base64: "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAx0lEQVR4nOzaMaoDMQyE4ZHj+x82vVdhwQoTkzKQEcwP5r0ihT7sbjUTeAJ4HCegXQJYfOYefOyjDuBiz3yjwJBoCIl6QZOeUjTC1Ix1IxEJXF9+0KWsf2bD4bn37OO/c/wuQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9Sa/NG94Tf3j4WBdaxudMEkn4IM2rZBA0wBrvo7aOcpj2emXvLeVt0IGm0GVXUj91mvAAAA//+V2CZl+4AKXwAAAABJRU5ErkJggg==",
Name: "cat.jpeg",
})
fmt.Println(rsp, err)
}
```
## Upload
Upload an image by either sending a base64 encoded image to this endpoint or a URL.
To resize an image before uploading, see the Resize endpoint.
To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
with each parameter as a form field.
[https://m3o.com/image/api#Upload](https://m3o.com/image/api#Upload)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/image"
)
// Upload an image by either sending a base64 encoded image to this endpoint or a URL.
// To resize an image before uploading, see the Resize endpoint.
// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
// with each parameter as a form field.
func UploadAnImageFromAurlToMicrosCdn() {
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
rsp, err := imageService.Upload(&image.UploadRequest{
Name: "cat.jpeg",
Url: "somewebsite.com/cat.png",
})
fmt.Println(rsp, err)
}
```
## Delete
Delete an image previously uploaded.
[https://m3o.com/image/api#Delete](https://m3o.com/image/api#Delete)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/image"
)
// Delete an image previously uploaded.
func DeleteAnUploadedImage() {
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
rsp, err := imageService.Delete(&image.DeleteRequest{
Url: "https://cdn.m3ocontent.com/micro/images/micro/41e23b39-48dd-42b6-9738-79a313414bb8/cat.png",
})
fmt.Println(rsp, err)
}
```

View File

@@ -1,6 +1,6 @@
# Ip
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Ip/api](https://m3o.com/Ip/api).
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/ip/api](https://m3o.com/ip/api).
Endpoints:

View File

@@ -1,6 +1,6 @@
# Joke
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Joke/api](https://m3o.com/Joke/api).
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/joke/api](https://m3o.com/joke/api).
Endpoints:

View File

@@ -1,45 +1,9 @@
# Location
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Location/api](https://m3o.com/Location/api).
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/location/api](https://m3o.com/location/api).
Endpoints:
## Save
Save an entity's current position
[https://m3o.com/location/api#Save](https://m3o.com/location/api#Save)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/location"
)
// Save an entity's current position
func SaveAnEntity() {
locationService := location.NewLocationService(os.Getenv("M3O_API_TOKEN"))
rsp, err := locationService.Save(&location.SaveRequest{
Entity: &location.Entity{
Id: "1",
Location: &location.Point{
Latitude: 51.511061,
Longitude: -0.120022,
Timestamp: 1622802761,
},
Type: "bike",
},
})
fmt.Println(rsp, err)
}
```
## Read
Read an entity by its ID
@@ -102,3 +66,39 @@ Type: "bike",
}
```
## Save
Save an entity's current position
[https://m3o.com/location/api#Save](https://m3o.com/location/api#Save)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/location"
)
// Save an entity's current position
func SaveAnEntity() {
locationService := location.NewLocationService(os.Getenv("M3O_API_TOKEN"))
rsp, err := locationService.Save(&location.SaveRequest{
Entity: &location.Entity{
Id: "1",
Location: &location.Point{
Latitude: 51.511061,
Longitude: -0.120022,
Timestamp: 1622802761,
},
Type: "bike",
},
})
fmt.Println(rsp, err)
}
```

View File

@@ -1,6 +1,6 @@
# Movie
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Movie/api](https://m3o.com/Movie/api).
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/movie/api](https://m3o.com/movie/api).
Endpoints:

View File

@@ -1,42 +1,9 @@
# Mq
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Mq/api](https://m3o.com/Mq/api).
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/mq/api](https://m3o.com/mq/api).
Endpoints:
## Publish
Publish a message. Specify a topic to group messages for a specific topic.
[https://m3o.com/mq/api#Publish](https://m3o.com/mq/api#Publish)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/mq"
)
// Publish a message. Specify a topic to group messages for a specific topic.
func PublishAmessage() {
mqService := mq.NewMqService(os.Getenv("M3O_API_TOKEN"))
rsp, err := mqService.Publish(&mq.PublishRequest{
Message: map[string]interface{}{
"id": "1",
"type": "signup",
"user": "john",
},
Topic: "events",
})
fmt.Println(rsp, err)
}
```
## Subscribe
Subscribe to messages for a given topic.
@@ -78,3 +45,36 @@ func SubscribeToAtopic() {
}
}
```
## Publish
Publish a message. Specify a topic to group messages for a specific topic.
[https://m3o.com/mq/api#Publish](https://m3o.com/mq/api#Publish)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/mq"
)
// Publish a message. Specify a topic to group messages for a specific topic.
func PublishAmessage() {
mqService := mq.NewMqService(os.Getenv("M3O_API_TOKEN"))
rsp, err := mqService.Publish(&mq.PublishRequest{
Message: map[string]interface{}{
"id": "1",
"type": "signup",
"user": "john",
},
Topic: "events",
})
fmt.Println(rsp, err)
}
```

View File

@@ -12,9 +12,9 @@ func main() {
mqService := mq.NewMqService(os.Getenv("M3O_API_TOKEN"))
rsp, err := mqService.Publish(&mq.PublishRequest{
Message: map[string]interface{}{
"user": "john",
"id": "1",
"type": "signup",
"user": "john",
},
Topic: "events",
})

View File

@@ -1,6 +1,6 @@
# News
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/News/api](https://m3o.com/News/api).
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/news/api](https://m3o.com/news/api).
Endpoints:

View File

@@ -1,9 +1,37 @@
# Nft
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Nft/api](https://m3o.com/Nft/api).
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/nft/api](https://m3o.com/nft/api).
Endpoints:
## Collections
Get a list of collections
[https://m3o.com/nft/api#Collections](https://m3o.com/nft/api#Collections)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/nft"
)
// Get a list of collections
func ListCollections() {
nftService := nft.NewNftService(os.Getenv("M3O_API_TOKEN"))
rsp, err := nftService.Collections(&nft.CollectionsRequest{
Limit: 1,
})
fmt.Println(rsp, err)
}
```
## Assets
Return a list of assets
@@ -61,31 +89,3 @@ Name: "Guybrush Threepwood",
}
```
## Collections
Get a list of collections
[https://m3o.com/nft/api#Collections](https://m3o.com/nft/api#Collections)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/nft"
)
// Get a list of collections
func ListCollections() {
nftService := nft.NewNftService(os.Getenv("M3O_API_TOKEN"))
rsp, err := nftService.Collections(&nft.CollectionsRequest{
Limit: 1,
})
fmt.Println(rsp, err)
}
```

View File

@@ -1,66 +1,9 @@
# Notes
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Notes/api](https://m3o.com/Notes/api).
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/notes/api](https://m3o.com/notes/api).
Endpoints:
## Create
Create a new note
[https://m3o.com/notes/api#Create](https://m3o.com/notes/api#Create)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/notes"
)
// Create a new note
func CreateAnote() {
notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN"))
rsp, err := notesService.Create(&notes.CreateRequest{
Text: "This is my note",
Title: "New Note",
})
fmt.Println(rsp, err)
}
```
## Read
Read a note
[https://m3o.com/notes/api#Read](https://m3o.com/notes/api#Read)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/notes"
)
// Read a note
func ReadAnote() {
notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN"))
rsp, err := notesService.Read(&notes.ReadRequest{
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
})
fmt.Println(rsp, err)
}
```
## List
List all the notes
@@ -189,3 +132,60 @@ func SubscribeToEvents() {
}
}
```
## Create
Create a new note
[https://m3o.com/notes/api#Create](https://m3o.com/notes/api#Create)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/notes"
)
// Create a new note
func CreateAnote() {
notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN"))
rsp, err := notesService.Create(&notes.CreateRequest{
Text: "This is my note",
Title: "New Note",
})
fmt.Println(rsp, err)
}
```
## Read
Read a note
[https://m3o.com/notes/api#Read](https://m3o.com/notes/api#Read)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/notes"
)
// Read a note
func ReadAnote() {
notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN"))
rsp, err := notesService.Read(&notes.ReadRequest{
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
})
fmt.Println(rsp, err)
}
```

View File

@@ -1,6 +1,6 @@
# Otp
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Otp/api](https://m3o.com/Otp/api).
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/otp/api](https://m3o.com/otp/api).
Endpoints:

View File

@@ -1,6 +1,6 @@
# Postcode
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Postcode/api](https://m3o.com/Postcode/api).
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/postcode/api](https://m3o.com/postcode/api).
Endpoints:

View File

@@ -1,6 +1,6 @@
# Prayer
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Prayer/api](https://m3o.com/Prayer/api).
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/prayer/api](https://m3o.com/prayer/api).
Endpoints:

View File

@@ -1,6 +1,6 @@
# Qr
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Qr/api](https://m3o.com/Qr/api).
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/qr/api](https://m3o.com/qr/api).
Endpoints:

View File

@@ -1,37 +1,9 @@
# Quran
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Quran/api](https://m3o.com/Quran/api).
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/quran/api](https://m3o.com/quran/api).
Endpoints:
## Chapters
List the Chapters (surahs) of the Quran
[https://m3o.com/quran/api#Chapters](https://m3o.com/quran/api#Chapters)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/quran"
)
// List the Chapters (surahs) of the Quran
func ListChapters() {
quranService := quran.NewQuranService(os.Getenv("M3O_API_TOKEN"))
rsp, err := quranService.Chapters(&quran.ChaptersRequest{
Language: "en",
})
fmt.Println(rsp, err)
}
```
## Summary
Get a summary for a given chapter (surah)
@@ -120,3 +92,31 @@ func SearchTheQuran() {
}
```
## Chapters
List the Chapters (surahs) of the Quran
[https://m3o.com/quran/api#Chapters](https://m3o.com/quran/api#Chapters)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/quran"
)
// List the Chapters (surahs) of the Quran
func ListChapters() {
quranService := quran.NewQuranService(os.Getenv("M3O_API_TOKEN"))
rsp, err := quranService.Chapters(&quran.ChaptersRequest{
Language: "en",
})
fmt.Println(rsp, err)
}
```

View File

@@ -1,6 +1,6 @@
# Routing
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Routing/api](https://m3o.com/Routing/api).
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/routing/api](https://m3o.com/routing/api).
Endpoints:

View File

@@ -1,64 +1,9 @@
# Rss
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Rss/api](https://m3o.com/Rss/api).
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/rss/api](https://m3o.com/rss/api).
Endpoints:
## List
List the saved RSS fields
[https://m3o.com/rss/api#List](https://m3o.com/rss/api#List)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/rss"
)
// List the saved RSS fields
func ListRssFeeds() {
rssService := rss.NewRssService(os.Getenv("M3O_API_TOKEN"))
rsp, err := rssService.List(&rss.ListRequest{
})
fmt.Println(rsp, err)
}
```
## 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 a new RSS feed with a name, url, and category
@@ -117,3 +62,58 @@ func ReadAfeed() {
}
```
## List
List the saved RSS fields
[https://m3o.com/rss/api#List](https://m3o.com/rss/api#List)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/rss"
)
// List the saved RSS fields
func ListRssFeeds() {
rssService := rss.NewRssService(os.Getenv("M3O_API_TOKEN"))
rsp, err := rssService.List(&rss.ListRequest{
})
fmt.Println(rsp, err)
}
```
## 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)
}
```

View File

@@ -1,15 +1,15 @@
# Search
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Search/api](https://m3o.com/Search/api).
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/search/api](https://m3o.com/search/api).
Endpoints:
## Vote
## Index
Vote to have the Search api launched faster!
Index a document i.e. insert a document to search for.
[https://m3o.com/search/api#Vote](https://m3o.com/search/api#Vote)
[https://m3o.com/search/api#Index](https://m3o.com/search/api#Index)
```go
package example
@@ -21,11 +21,191 @@ import(
"go.m3o.com/search"
)
// Vote to have the Search api launched faster!
func VoteForTheApi() {
// Index a document i.e. insert a document to search for.
func IndexAdocument() {
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
rsp, err := searchService.Vote(&search.VoteRequest{
Message: "Launch it!",
rsp, err := searchService.Index(&search.IndexRequest{
Document: &search.Document{
Contents: map[string]interface{}{
"name": "John Doe",
"age": 37,
"starsign": "Leo",
},
Id: "1234",
},
Index: "customers",
})
fmt.Println(rsp, err)
}
```
## Search
Search for documents in a given in index
[https://m3o.com/search/api#Search](https://m3o.com/search/api#Search)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/search"
)
// Search for documents in a given in index
func SearchForAdocument() {
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
rsp, err := searchService.Search(&search.SearchRequest{
Index: "customers",
Query: "name == 'John'",
})
fmt.Println(rsp, err)
}
```
## Search
Search for documents in a given in index
[https://m3o.com/search/api#Search](https://m3o.com/search/api#Search)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/search"
)
// Search for documents in a given in index
func SearchOnMultipleFieldsand() {
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
rsp, err := searchService.Search(&search.SearchRequest{
Index: "customers",
Query: "name == 'John' AND starsign == 'Leo'",
})
fmt.Println(rsp, err)
}
```
## Search
Search for documents in a given in index
[https://m3o.com/search/api#Search](https://m3o.com/search/api#Search)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/search"
)
// Search for documents in a given in index
func SearchOnMultipleFieldsor() {
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
rsp, err := searchService.Search(&search.SearchRequest{
Index: "customers",
Query: "name == 'John' OR name == 'Jane'",
})
fmt.Println(rsp, err)
}
```
## Delete
Delete a document given its ID
[https://m3o.com/search/api#Delete](https://m3o.com/search/api#Delete)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/search"
)
// Delete a document given its ID
func DeleteAdocument() {
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
rsp, err := searchService.Delete(&search.DeleteRequest{
Id: "1234",
Index: "customers",
})
fmt.Println(rsp, err)
}
```
## CreateIndex
Create an index by name
[https://m3o.com/search/api#CreateIndex](https://m3o.com/search/api#CreateIndex)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/search"
)
// Create an index by name
func CreateAnIndex() {
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
rsp, err := searchService.CreateIndex(&search.CreateIndexRequest{
Index: "customers",
})
fmt.Println(rsp, err)
}
```
## DeleteIndex
Delete an index by name
[https://m3o.com/search/api#DeleteIndex](https://m3o.com/search/api#DeleteIndex)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/search"
)
// Delete an index by name
func DeleteAnIndex() {
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
rsp, err := searchService.DeleteIndex(&search.DeleteIndexRequest{
Index: "customers",
})
fmt.Println(rsp, err)

View File

@@ -7,11 +7,11 @@ import (
"go.m3o.com/search"
)
// Vote to have the Search api launched faster!
// Create an index by name
func main() {
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
rsp, err := searchService.Vote(&search.VoteRequest{
Message: "Launch it!",
rsp, err := searchService.CreateIndex(&search.CreateIndexRequest{
Index: "customers",
})
fmt.Println(rsp, err)
}

View File

@@ -0,0 +1,18 @@
package main
import (
"fmt"
"os"
"go.m3o.com/search"
)
// Delete a document given its ID
func main() {
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
rsp, err := searchService.Delete(&search.DeleteRequest{
Id: "1234",
Index: "customers",
})
fmt.Println(rsp, err)
}

View File

@@ -0,0 +1,17 @@
package main
import (
"fmt"
"os"
"go.m3o.com/search"
)
// Delete an index by name
func main() {
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
rsp, err := searchService.DeleteIndex(&search.DeleteIndexRequest{
Index: "customers",
})
fmt.Println(rsp, err)
}

View File

@@ -0,0 +1,25 @@
package main
import (
"fmt"
"os"
"go.m3o.com/search"
)
// Index a document i.e. insert a document to search for.
func main() {
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
rsp, err := searchService.Index(&search.IndexRequest{
Document: &search.Document{
Contents: map[string]interface{}{
"name": "John Doe",
"age": 37,
"starsign": "Leo",
},
Id: "1234",
},
Index: "customers",
})
fmt.Println(rsp, err)
}

View File

@@ -0,0 +1,18 @@
package main
import (
"fmt"
"os"
"go.m3o.com/search"
)
// Search for documents in a given in index
func main() {
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
rsp, err := searchService.Search(&search.SearchRequest{
Index: "customers",
Query: "name == 'John'",
})
fmt.Println(rsp, err)
}

View File

@@ -0,0 +1,18 @@
package main
import (
"fmt"
"os"
"go.m3o.com/search"
)
// Search for documents in a given in index
func main() {
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
rsp, err := searchService.Search(&search.SearchRequest{
Index: "customers",
Query: "name == 'John' AND starsign == 'Leo'",
})
fmt.Println(rsp, err)
}

View File

@@ -0,0 +1,18 @@
package main
import (
"fmt"
"os"
"go.m3o.com/search"
)
// Search for documents in a given in index
func main() {
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
rsp, err := searchService.Search(&search.SearchRequest{
Index: "customers",
Query: "name == 'John' OR name == 'Jane'",
})
fmt.Println(rsp, err)
}

View File

@@ -1,6 +1,6 @@
# Sentiment
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Sentiment/api](https://m3o.com/Sentiment/api).
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/sentiment/api](https://m3o.com/sentiment/api).
Endpoints:

View File

@@ -1,6 +1,6 @@
# Sms
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Sms/api](https://m3o.com/Sms/api).
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/sms/api](https://m3o.com/sms/api).
Endpoints:

View File

@@ -1,37 +1,9 @@
# Space
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Space/api](https://m3o.com/Space/api).
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/space/api](https://m3o.com/space/api).
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
@@ -232,3 +204,31 @@ 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)
}
```

View File

@@ -1,6 +1,6 @@
# Spam
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Spam/api](https://m3o.com/Spam/api).
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/spam/api](https://m3o.com/spam/api).
Endpoints:

View File

@@ -1,6 +1,6 @@
# Stock
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Stock/api](https://m3o.com/Stock/api).
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/stock/api](https://m3o.com/stock/api).
Endpoints:

View File

@@ -1,36 +1,9 @@
# Stream
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Stream/api](https://m3o.com/Stream/api).
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/stream/api](https://m3o.com/stream/api).
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
Create a channel with a given name and description. Channels are created automatically but
@@ -119,3 +92,30 @@ 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)
}
```

View File

@@ -1,6 +1,6 @@
# Sunnah
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Sunnah/api](https://m3o.com/Sunnah/api).
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/sunnah/api](https://m3o.com/sunnah/api).
Endpoints:

View File

@@ -1,6 +1,6 @@
# Thumbnail
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Thumbnail/api](https://m3o.com/Thumbnail/api).
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/thumbnail/api](https://m3o.com/thumbnail/api).
Endpoints:

View File

@@ -1,6 +1,6 @@
# Time
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Time/api](https://m3o.com/Time/api).
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/time/api](https://m3o.com/time/api).
Endpoints:

View File

@@ -1,6 +1,6 @@
# Translate
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Translate/api](https://m3o.com/Translate/api).
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/translate/api](https://m3o.com/translate/api).
Endpoints:

View File

@@ -1,6 +1,6 @@
# Twitter
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Twitter/api](https://m3o.com/Twitter/api).
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/twitter/api](https://m3o.com/twitter/api).
Endpoints:

View File

@@ -1,6 +1,6 @@
# Url
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Url/api](https://m3o.com/Url/api).
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/url/api](https://m3o.com/url/api).
Endpoints:

View File

@@ -1,16 +1,15 @@
# User
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/User/api](https://m3o.com/User/api).
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/user/api](https://m3o.com/user/api).
Endpoints:
## Login
## ReadSession
Login using username or email. The response will return a new session for successful login,
401 in the case of login failure and 500 for any other error
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#Login](https://m3o.com/user/api#Login)
[https://m3o.com/user/api#ReadSession](https://m3o.com/user/api#ReadSession)
```go
package example
@@ -22,13 +21,11 @@ import(
"go.m3o.com/user"
)
// Login using username or email. The response will return a new session for successful login,
// 401 in the case of login failure and 500 for any other error
func LogAuserIn() {
// 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.Login(&user.LoginRequest{
Email: "joe@example.com",
Password: "Password1",
rsp, err := userService.ReadSession(&user.ReadSessionRequest{
SessionId: "df91a612-5b24-4634-99ff-240220ab8f55",
})
fmt.Println(rsp, err)
@@ -62,117 +59,6 @@ Offset: 0,
})
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)
}
```
## 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{
Email: "joe@example.com",
Token: "012345",
})
fmt.Println(rsp, err)
}
```
## SendVerificationEmail
Send a verification email
to the user being signed up. Email from will be from 'noreply@email.m3ocontent.com',
but you can provide the title and contents.
The verification link will be injected in to the email as a template variable, $micro_verification_link.
Example: 'Hi there, welcome onboard! Use the link below to verify your email: $micro_verification_link'
The variable will be replaced with an actual url that will look similar to this:
'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 the user being signed up. Email from will be from 'noreply@email.m3ocontent.com',
// but you can provide the title and contents.
// The verification link will be injected in to the email as a template variable, $micro_verification_link.
// Example: 'Hi there, welcome onboard! Use the link below to verify your email: $micro_verification_link'
// The variable will be replaced with an actual url that will look similar to this:
// '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)
}
```
## ResetPassword
@@ -206,15 +92,13 @@ NewPassword: "NewPassword1",
}
```
## VerifyToken
## Login
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.
Login using username or email. The response will return a new session for successful login,
401 in the case of login failure and 500 for any other error
[https://m3o.com/user/api#VerifyToken](https://m3o.com/user/api#VerifyToken)
[https://m3o.com/user/api#Login](https://m3o.com/user/api#Login)
```go
package example
@@ -226,26 +110,25 @@ import(
"go.m3o.com/user"
)
// Check whether the token attached to MagicLink is valid or not.
// Ideally, you need to call this endpoint from your http request
// handler that handles the endpoint which is specified in the
// SendMagicLink request.
func VerifyAtoken() {
// Login using username or email. The response will return a new session for successful login,
// 401 in the case of login failure and 500 for any other error
func LogAuserIn() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.VerifyToken(&user.VerifyTokenRequest{
Token: "EdsUiidouJJJLldjlloofUiorkojflsWWdld",
rsp, err := userService.Login(&user.LoginRequest{
Email: "joe@example.com",
Password: "Password1",
})
fmt.Println(rsp, err)
}
```
## UpdatePassword
## Delete
Update the account password
Delete an account by id
[https://m3o.com/user/api#UpdatePassword](https://m3o.com/user/api#UpdatePassword)
[https://m3o.com/user/api#Delete](https://m3o.com/user/api#Delete)
```go
package example
@@ -257,13 +140,42 @@ import(
"go.m3o.com/user"
)
// Update the account password
func UpdateTheAccountPassword() {
// Delete an account by id
func DeleteUserAccount() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.UpdatePassword(&user.UpdatePasswordRequest{
ConfirmPassword: "Password2",
NewPassword: "Password2",
OldPassword: "Password1",
rsp, err := userService.Delete(&user.DeleteRequest{
Id: "8b98acbe-0b6a-4d66-a414-5ffbf666786f",
})
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)
@@ -352,6 +264,71 @@ func ReadAccountByEmail() {
})
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)
}
```
## VerifyToken
Check whether the token attached to MagicLink is valid or not.
Ideally, you need to call this endpoint from your http request
handler that handles the endpoint which is specified in the
SendMagicLink request.
[https://m3o.com/user/api#VerifyToken](https://m3o.com/user/api#VerifyToken)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Check whether the token attached to MagicLink is valid or not.
// Ideally, you need to call this endpoint from your http request
// handler that handles the endpoint which is specified in the
// SendMagicLink request.
func VerifyAtoken() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.VerifyToken(&user.VerifyTokenRequest{
Token: "EdsUiidouJJJLldjlloofUiorkojflsWWdld",
})
fmt.Println(rsp, err)
}
```
## SendPasswordResetEmail
@@ -388,12 +365,12 @@ TextContent: `Hi there,
}
```
## ReadSession
## VerifyEmail
Read a session by the session id. In the event it has expired or is not found and error is returned.
Verify the email address of an account from a token sent in an email to the user.
[https://m3o.com/user/api#ReadSession](https://m3o.com/user/api#ReadSession)
[https://m3o.com/user/api#VerifyEmail](https://m3o.com/user/api#VerifyEmail)
```go
package example
@@ -405,15 +382,79 @@ import(
"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() {
// 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.ReadSession(&user.ReadSessionRequest{
rsp, err := userService.VerifyEmail(&user.VerifyEmailRequest{
Email: "joe@example.com",
Token: "012345",
})
fmt.Println(rsp, err)
}
```
## Logout
Logout a user account
[https://m3o.com/user/api#Logout](https://m3o.com/user/api#Logout)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Logout a user account
func LogAuserOut() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.Logout(&user.LogoutRequest{
SessionId: "df91a612-5b24-4634-99ff-240220ab8f55",
})
fmt.Println(rsp, err)
}
```
## 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)
}
```
## Update
@@ -445,12 +486,18 @@ Id: "user-1",
}
```
## Delete
## SendVerificationEmail
Delete an account by id
Send a verification email
to the user being signed up. Email from will be from 'noreply@email.m3ocontent.com',
but you can provide the title and contents.
The verification link will be injected in to the email as a template variable, $micro_verification_link.
Example: 'Hi there, welcome onboard! Use the link below to verify your email: $micro_verification_link'
The variable will be replaced with an actual url that will look similar to this:
'https://user.m3o.com/user/verify?token=a-verification-token&redirectUrl=your-redir-url'
[https://m3o.com/user/api#Delete](https://m3o.com/user/api#Delete)
[https://m3o.com/user/api#SendVerificationEmail](https://m3o.com/user/api#SendVerificationEmail)
```go
package example
@@ -462,70 +509,24 @@ import(
"go.m3o.com/user"
)
// Delete an account by id
func DeleteUserAccount() {
// Send a verification email
// to the user being signed up. Email from will be from 'noreply@email.m3ocontent.com',
// but you can provide the title and contents.
// The verification link will be injected in to the email as a template variable, $micro_verification_link.
// Example: 'Hi there, welcome onboard! Use the link below to verify your email: $micro_verification_link'
// The variable will be replaced with an actual url that will look similar to this:
// '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.Delete(&user.DeleteRequest{
Id: "8b98acbe-0b6a-4d66-a414-5ffbf666786f",
})
fmt.Println(rsp, err)
}
```
## Logout
Logout a user account
[https://m3o.com/user/api#Logout](https://m3o.com/user/api#Logout)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Logout a user account
func LogAuserOut() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.Logout(&user.LogoutRequest{
SessionId: "df91a612-5b24-4634-99ff-240220ab8f55",
})
fmt.Println(rsp, err)
}
```
## 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{
rsp, err := userService.SendVerificationEmail(&user.SendVerificationEmailRequest{
Email: "joe@example.com",
Id: "user-1",
Password: "Password1",
Username: "joe",
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)

View File

@@ -14,6 +14,7 @@ func main() {
ConfirmPassword: "Password2",
NewPassword: "Password2",
OldPassword: "Password1",
UserId: "user-1",
})
fmt.Println(rsp, err)
}

View File

@@ -1,6 +1,6 @@
# Vehicle
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Vehicle/api](https://m3o.com/Vehicle/api).
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/vehicle/api](https://m3o.com/vehicle/api).
Endpoints:

View File

@@ -1,6 +1,6 @@
# Weather
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Weather/api](https://m3o.com/Weather/api).
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/weather/api](https://m3o.com/weather/api).
Endpoints:

View File

@@ -1,6 +1,6 @@
# Youtube
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Youtube/api](https://m3o.com/Youtube/api).
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/youtube/api](https://m3o.com/youtube/api).
Endpoints:

3
m3o.go
View File

@@ -6,6 +6,7 @@ import (
"go.m3o.com/app"
"go.m3o.com/avatar"
"go.m3o.com/cache"
"go.m3o.com/carbon"
"go.m3o.com/contact"
"go.m3o.com/crypto"
"go.m3o.com/currency"
@@ -67,6 +68,7 @@ func NewClient(token string) *Client {
AppService: app.NewAppService(token),
AvatarService: avatar.NewAvatarService(token),
CacheService: cache.NewCacheService(token),
CarbonService: carbon.NewCarbonService(token),
ContactService: contact.NewContactService(token),
CryptoService: crypto.NewCryptoService(token),
CurrencyService: currency.NewCurrencyService(token),
@@ -128,6 +130,7 @@ type Client struct {
AppService *app.AppService
AvatarService *avatar.AvatarService
CacheService *cache.CacheService
CarbonService *carbon.CarbonService
ContactService *contact.ContactService
CryptoService *crypto.CryptoService
CurrencyService *currency.CurrencyService

View File

@@ -5,7 +5,11 @@ import (
)
type Search interface {
Vote(*VoteRequest) (*VoteResponse, error)
CreateIndex(*CreateIndexRequest) (*CreateIndexResponse, error)
DeleteIndex(*DeleteIndexRequest) (*DeleteIndexResponse, error)
Delete(*DeleteRequest) (*DeleteResponse, error)
Index(*IndexRequest) (*IndexResponse, error)
Search(*SearchRequest) (*SearchResponse, error)
}
func NewSearchService(token string) *SearchService {
@@ -20,20 +24,105 @@ type SearchService struct {
client *client.Client
}
// Vote to have the Search api launched faster!
func (t *SearchService) Vote(request *VoteRequest) (*VoteResponse, error) {
// Create an index by name
func (t *SearchService) CreateIndex(request *CreateIndexRequest) (*CreateIndexResponse, error) {
rsp := &VoteResponse{}
return rsp, t.client.Call("search", "Vote", request, rsp)
rsp := &CreateIndexResponse{}
return rsp, t.client.Call("search", "CreateIndex", request, rsp)
}
type VoteRequest struct {
// optional message
Message string `json:"message"`
// Delete an index by name
func (t *SearchService) DeleteIndex(request *DeleteIndexRequest) (*DeleteIndexResponse, error) {
rsp := &DeleteIndexResponse{}
return rsp, t.client.Call("search", "DeleteIndex", request, rsp)
}
type VoteResponse struct {
// response message
Message string `json:"message"`
// Delete a document given its ID
func (t *SearchService) Delete(request *DeleteRequest) (*DeleteResponse, error) {
rsp := &DeleteResponse{}
return rsp, t.client.Call("search", "Delete", request, rsp)
}
// Index a document i.e. insert a document to search for.
func (t *SearchService) Index(request *IndexRequest) (*IndexResponse, error) {
rsp := &IndexResponse{}
return rsp, t.client.Call("search", "Index", request, rsp)
}
// Search for documents in a given in index
func (t *SearchService) Search(request *SearchRequest) (*SearchResponse, error) {
rsp := &SearchResponse{}
return rsp, t.client.Call("search", "Search", request, rsp)
}
type CreateIndexRequest struct {
// The name of the index
Index string `json:"index"`
}
type CreateIndexResponse struct {
}
type DeleteIndexRequest struct {
// The name of the index to delete
Index string `json:"index"`
}
type DeleteIndexResponse struct {
}
type DeleteRequest struct {
// The ID of the document to delete
Id string `json:"id"`
// The index the document belongs to
Index string `json:"index"`
}
type DeleteResponse struct {
}
type Document struct {
// The JSON contents of the document
Contents map[string]interface{} `json:"contents"`
// The ID for this document. If blank, one will be generated
Id string `json:"id"`
}
type Field struct {
// The name of the field. Use a `.` separator to define nested fields e.g. foo.bar
Name string `json:"name"`
// The type of the field - string, number
Type string `json:"type"`
}
type IndexRequest struct {
// The document to index
Document *Document `json:"document"`
// The index this document belongs to
Index string `json:"index"`
}
type IndexResponse struct {
Id string `json:"id"`
}
type SearchRequest struct {
// The index the document belongs to
Index string `json:"index"`
// The query. See docs for query language examples
Query string `json:"query"`
}
type SearchResponse struct {
// The matching documents
Documents []Document `json:"documents"`
}