mirror of
https://github.com/kevin-DL/m3o-go.git
synced 2026-01-24 07:25:35 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a8ae6694c6 | ||
|
|
58743a5a31 |
31
.github/workflows/generate.yml
vendored
31
.github/workflows/generate.yml
vendored
@@ -1,31 +0,0 @@
|
|||||||
name: Test Clients
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
- beta
|
|
||||||
- ci
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
generate:
|
|
||||||
name: Test Clients
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Check out repo
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
path: clients
|
|
||||||
#ref: main
|
|
||||||
|
|
||||||
- name: Test
|
|
||||||
working-directory: clients
|
|
||||||
env:
|
|
||||||
M3O_API_TOKEN: ${{ secrets.M3O_API_TOKEN }}
|
|
||||||
run: |
|
|
||||||
# stream is temporarily excluded as it hangs forever because test does not close connection
|
|
||||||
# @TODO remove "idempotent: true" from stream example
|
|
||||||
O=$(find . -name ".run" | grep -v stream | xargs -n1 dirname | xargs -n1 go run)
|
|
||||||
echo $O
|
|
||||||
if grep -q Detail "$O"; then
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
@@ -1,11 +1,3 @@
|
|||||||
<p align="center">
|
|
||||||
<a href="https://discord.gg/TBR9bRjd6Z">
|
|
||||||
<img src="https://discordapp.com/api/guilds/861917584437805127/widget.png?style=banner2" alt="Discord Banner"/>
|
|
||||||
</a>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
# M3O Go Client [](https://godoc.org/github.com/m3o/m3o-go) [](https://goreportcard.com/report/github.com/m3o/m3o-go) [](https://github.com/m3o/m3o-go/blob/master/LICENSE)
|
# M3O Go Client [](https://godoc.org/github.com/m3o/m3o-go) [](https://goreportcard.com/report/github.com/m3o/m3o-go) [](https://github.com/m3o/m3o-go/blob/master/LICENSE)
|
||||||
|
|
||||||
This is the Go client to access APIs on the M3O Platform
|
This is the Go client to access APIs on the M3O Platform
|
||||||
|
|||||||
@@ -4,10 +4,6 @@ import (
|
|||||||
"go.m3o.com/client"
|
"go.m3o.com/client"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Address interface {
|
|
||||||
LookupPostcode(*LookupPostcodeRequest) (*LookupPostcodeResponse, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewAddressService(token string) *AddressService {
|
func NewAddressService(token string) *AddressService {
|
||||||
return &AddressService{
|
return &AddressService{
|
||||||
client: client.NewClient(&client.Options{
|
client: client.NewClient(&client.Options{
|
||||||
@@ -22,10 +18,8 @@ type AddressService struct {
|
|||||||
|
|
||||||
// Lookup a list of UK addresses by postcode
|
// Lookup a list of UK addresses by postcode
|
||||||
func (t *AddressService) LookupPostcode(request *LookupPostcodeRequest) (*LookupPostcodeResponse, error) {
|
func (t *AddressService) LookupPostcode(request *LookupPostcodeRequest) (*LookupPostcodeResponse, error) {
|
||||||
|
|
||||||
rsp := &LookupPostcodeResponse{}
|
rsp := &LookupPostcodeResponse{}
|
||||||
return rsp, t.client.Call("address", "LookupPostcode", request, rsp)
|
return rsp, t.client.Call("address", "LookupPostcode", request, rsp)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type LookupPostcodeRequest struct {
|
type LookupPostcodeRequest struct {
|
||||||
@@ -39,13 +33,13 @@ type LookupPostcodeResponse struct {
|
|||||||
|
|
||||||
type Record struct {
|
type Record struct {
|
||||||
// building name
|
// building name
|
||||||
BuildingName string `json:"building_name"`
|
BuildingName string `json:"buildingName"`
|
||||||
// the county
|
// the county
|
||||||
County string `json:"county"`
|
County string `json:"county"`
|
||||||
// line one of address
|
// line one of address
|
||||||
LineOne string `json:"line_one"`
|
LineOne string `json:"lineOne"`
|
||||||
// line two of address
|
// line two of address
|
||||||
LineTwo string `json:"line_two"`
|
LineTwo string `json:"lineTwo"`
|
||||||
// dependent locality
|
// dependent locality
|
||||||
Locality string `json:"locality"`
|
Locality string `json:"locality"`
|
||||||
// organisation if present
|
// organisation if present
|
||||||
|
|||||||
@@ -4,10 +4,6 @@ import (
|
|||||||
"go.m3o.com/client"
|
"go.m3o.com/client"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Answer interface {
|
|
||||||
Question(*QuestionRequest) (*QuestionResponse, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewAnswerService(token string) *AnswerService {
|
func NewAnswerService(token string) *AnswerService {
|
||||||
return &AnswerService{
|
return &AnswerService{
|
||||||
client: client.NewClient(&client.Options{
|
client: client.NewClient(&client.Options{
|
||||||
@@ -22,10 +18,8 @@ type AnswerService struct {
|
|||||||
|
|
||||||
// Ask a question and receive an instant answer
|
// Ask a question and receive an instant answer
|
||||||
func (t *AnswerService) Question(request *QuestionRequest) (*QuestionResponse, error) {
|
func (t *AnswerService) Question(request *QuestionRequest) (*QuestionResponse, error) {
|
||||||
|
|
||||||
rsp := &QuestionResponse{}
|
rsp := &QuestionResponse{}
|
||||||
return rsp, t.client.Call("answer", "Question", request, rsp)
|
return rsp, t.client.Call("answer", "Question", request, rsp)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type QuestionRequest struct {
|
type QuestionRequest struct {
|
||||||
|
|||||||
215
app/app.go
215
app/app.go
@@ -1,215 +0,0 @@
|
|||||||
package app
|
|
||||||
|
|
||||||
import (
|
|
||||||
"go.m3o.com/client"
|
|
||||||
)
|
|
||||||
|
|
||||||
type App interface {
|
|
||||||
Delete(*DeleteRequest) (*DeleteResponse, error)
|
|
||||||
List(*ListRequest) (*ListResponse, error)
|
|
||||||
Regions(*RegionsRequest) (*RegionsResponse, error)
|
|
||||||
Reserve(*ReserveRequest) (*ReserveResponse, error)
|
|
||||||
Resolve(*ResolveRequest) (*ResolveResponse, error)
|
|
||||||
Run(*RunRequest) (*RunResponse, error)
|
|
||||||
Status(*StatusRequest) (*StatusResponse, error)
|
|
||||||
Update(*UpdateRequest) (*UpdateResponse, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewAppService(token string) *AppService {
|
|
||||||
return &AppService{
|
|
||||||
client: client.NewClient(&client.Options{
|
|
||||||
Token: token,
|
|
||||||
}),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type AppService struct {
|
|
||||||
client *client.Client
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete an app
|
|
||||||
func (t *AppService) Delete(request *DeleteRequest) (*DeleteResponse, error) {
|
|
||||||
|
|
||||||
rsp := &DeleteResponse{}
|
|
||||||
return rsp, t.client.Call("app", "Delete", request, rsp)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// List all the apps
|
|
||||||
func (t *AppService) List(request *ListRequest) (*ListResponse, error) {
|
|
||||||
|
|
||||||
rsp := &ListResponse{}
|
|
||||||
return rsp, t.client.Call("app", "List", request, rsp)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return the support regions
|
|
||||||
func (t *AppService) Regions(request *RegionsRequest) (*RegionsResponse, error) {
|
|
||||||
|
|
||||||
rsp := &RegionsResponse{}
|
|
||||||
return rsp, t.client.Call("app", "Regions", request, rsp)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reserve apps beyond the free quota. Call Run after.
|
|
||||||
func (t *AppService) Reserve(request *ReserveRequest) (*ReserveResponse, error) {
|
|
||||||
|
|
||||||
rsp := &ReserveResponse{}
|
|
||||||
return rsp, t.client.Call("app", "Reserve", request, rsp)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Resolve an app by id to its raw backend endpoint
|
|
||||||
func (t *AppService) Resolve(request *ResolveRequest) (*ResolveResponse, error) {
|
|
||||||
|
|
||||||
rsp := &ResolveResponse{}
|
|
||||||
return rsp, t.client.Call("app", "Resolve", request, rsp)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Run an app from source
|
|
||||||
func (t *AppService) Run(request *RunRequest) (*RunResponse, error) {
|
|
||||||
|
|
||||||
rsp := &RunResponse{}
|
|
||||||
return rsp, t.client.Call("app", "Run", request, rsp)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the status of an app
|
|
||||||
func (t *AppService) Status(request *StatusRequest) (*StatusResponse, error) {
|
|
||||||
|
|
||||||
rsp := &StatusResponse{}
|
|
||||||
return rsp, t.client.Call("app", "Status", request, rsp)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update the app. The latest source code will be downloaded, built and deployed.
|
|
||||||
func (t *AppService) Update(request *UpdateRequest) (*UpdateResponse, error) {
|
|
||||||
|
|
||||||
rsp := &UpdateResponse{}
|
|
||||||
return rsp, t.client.Call("app", "Update", request, rsp)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
type DeleteRequest struct {
|
|
||||||
// name of the app
|
|
||||||
Name string `json:"name"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type DeleteResponse struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
type ListRequest struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
type ListResponse struct {
|
|
||||||
// all the apps
|
|
||||||
Services []Service `json:"services"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type RegionsRequest struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
type RegionsResponse struct {
|
|
||||||
Regions []string `json:"regions"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type Reservation struct {
|
|
||||||
// time of reservation
|
|
||||||
Created string `json:"created"`
|
|
||||||
// time reservation expires
|
|
||||||
Expires string `json:"expires"`
|
|
||||||
// name of the app
|
|
||||||
Name string `json:"name"`
|
|
||||||
// owner id
|
|
||||||
Owner string `json:"owner"`
|
|
||||||
// associated token
|
|
||||||
Token string `json:"token"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type ReserveRequest struct {
|
|
||||||
// name of your app e.g helloworld
|
|
||||||
Name string `json:"name"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type ReserveResponse struct {
|
|
||||||
// The app reservation
|
|
||||||
Reservation *Reservation `json:"reservation"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type ResolveRequest struct {
|
|
||||||
// the service id
|
|
||||||
Id string `json:"id"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type ResolveResponse struct {
|
|
||||||
// the end provider url
|
|
||||||
Url string `json:"url"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type RunRequest struct {
|
|
||||||
// branch. defaults to master
|
|
||||||
Branch string `json:"branch"`
|
|
||||||
// associated env vars to pass in
|
|
||||||
EnvVars map[string]string `json:"env_vars"`
|
|
||||||
// name of the app
|
|
||||||
Name string `json:"name"`
|
|
||||||
// port to run on
|
|
||||||
Port int32 `json:"port"`
|
|
||||||
// region to run in
|
|
||||||
Region string `json:"region"`
|
|
||||||
// source repository
|
|
||||||
Repo string `json:"repo"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type RunResponse struct {
|
|
||||||
// The running service
|
|
||||||
Service *Service `json:"service"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type Service struct {
|
|
||||||
// branch of code
|
|
||||||
Branch string `json:"branch"`
|
|
||||||
// time of creation
|
|
||||||
Created string `json:"created"`
|
|
||||||
// custom domains
|
|
||||||
CustomDomains string `json:"custom_domains"`
|
|
||||||
// associated env vars
|
|
||||||
EnvVars map[string]string `json:"env_vars"`
|
|
||||||
// unique id
|
|
||||||
Id string `json:"id"`
|
|
||||||
// name of the app
|
|
||||||
Name string `json:"name"`
|
|
||||||
// port running on
|
|
||||||
Port int32 `json:"port"`
|
|
||||||
// region running in
|
|
||||||
Region string `json:"region"`
|
|
||||||
// source repository
|
|
||||||
Repo string `json:"repo"`
|
|
||||||
// status of the app
|
|
||||||
Status string `json:"status"`
|
|
||||||
// last updated
|
|
||||||
Updated string `json:"updated"`
|
|
||||||
// app url
|
|
||||||
Url string `json:"url"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type StatusRequest struct {
|
|
||||||
// name of the app
|
|
||||||
Name string `json:"name"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type StatusResponse struct {
|
|
||||||
// running service info
|
|
||||||
Service *Service `json:"service"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type UpdateRequest struct {
|
|
||||||
// Additional env vars to update
|
|
||||||
EnvVars map[string]string `json:"env_vars"`
|
|
||||||
// name of the app
|
|
||||||
Name string `json:"name"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type UpdateResponse struct {
|
|
||||||
}
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
package avatar
|
|
||||||
|
|
||||||
import (
|
|
||||||
"go.m3o.com/client"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Avatar interface {
|
|
||||||
Generate(*GenerateRequest) (*GenerateResponse, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewAvatarService(token string) *AvatarService {
|
|
||||||
return &AvatarService{
|
|
||||||
client: client.NewClient(&client.Options{
|
|
||||||
Token: token,
|
|
||||||
}),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type AvatarService struct {
|
|
||||||
client *client.Client
|
|
||||||
}
|
|
||||||
|
|
||||||
// Generate an unique avatar
|
|
||||||
func (t *AvatarService) Generate(request *GenerateRequest) (*GenerateResponse, error) {
|
|
||||||
|
|
||||||
rsp := &GenerateResponse{}
|
|
||||||
return rsp, t.client.Call("avatar", "Generate", request, rsp)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
type GenerateRequest struct {
|
|
||||||
// encode format of avatar image: `png` or `jpeg`; default is `jpeg`
|
|
||||||
Format string `json:"format"`
|
|
||||||
// avatar's gender: `male` or `female`; default is `male`
|
|
||||||
Gender string `json:"gender"`
|
|
||||||
// set to true to upload to the M3O CDN and receive the url
|
|
||||||
Upload bool `json:"upload"`
|
|
||||||
// avatar's username, unique username will generate the unique avatar;
|
|
||||||
// if empty, every request generates a random avatar;
|
|
||||||
// if upload == true, username will be the CDN filename rather than a random uuid string
|
|
||||||
Username string `json:"username"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type GenerateResponse struct {
|
|
||||||
// base64 encoded string of the avatar image
|
|
||||||
Base64 string `json:"base64"`
|
|
||||||
// M3O's CDN url of the avatar image
|
|
||||||
Url string `json:"url"`
|
|
||||||
}
|
|
||||||
42
cache/cache.go
vendored
42
cache/cache.go
vendored
@@ -4,15 +4,6 @@ import (
|
|||||||
"go.m3o.com/client"
|
"go.m3o.com/client"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Cache interface {
|
|
||||||
Decrement(*DecrementRequest) (*DecrementResponse, error)
|
|
||||||
Delete(*DeleteRequest) (*DeleteResponse, error)
|
|
||||||
Get(*GetRequest) (*GetResponse, error)
|
|
||||||
Increment(*IncrementRequest) (*IncrementResponse, error)
|
|
||||||
ListKeys(*ListKeysRequest) (*ListKeysResponse, error)
|
|
||||||
Set(*SetRequest) (*SetResponse, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewCacheService(token string) *CacheService {
|
func NewCacheService(token string) *CacheService {
|
||||||
return &CacheService{
|
return &CacheService{
|
||||||
client: client.NewClient(&client.Options{
|
client: client.NewClient(&client.Options{
|
||||||
@@ -25,52 +16,34 @@ type CacheService struct {
|
|||||||
client *client.Client
|
client *client.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decrement a value (if it's a number). If key not found it is equivalent to set.
|
// Decrement a value (if it's a number)
|
||||||
func (t *CacheService) Decrement(request *DecrementRequest) (*DecrementResponse, error) {
|
func (t *CacheService) Decrement(request *DecrementRequest) (*DecrementResponse, error) {
|
||||||
|
|
||||||
rsp := &DecrementResponse{}
|
rsp := &DecrementResponse{}
|
||||||
return rsp, t.client.Call("cache", "Decrement", request, rsp)
|
return rsp, t.client.Call("cache", "Decrement", request, rsp)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete a value from the cache. If key not found a success response is returned.
|
// Delete a value from the cache
|
||||||
func (t *CacheService) Delete(request *DeleteRequest) (*DeleteResponse, error) {
|
func (t *CacheService) Delete(request *DeleteRequest) (*DeleteResponse, error) {
|
||||||
|
|
||||||
rsp := &DeleteResponse{}
|
rsp := &DeleteResponse{}
|
||||||
return rsp, t.client.Call("cache", "Delete", request, rsp)
|
return rsp, t.client.Call("cache", "Delete", request, rsp)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get an item from the cache by key. If key is not found, an empty response is returned.
|
// Get an item from the cache by key
|
||||||
func (t *CacheService) Get(request *GetRequest) (*GetResponse, error) {
|
func (t *CacheService) Get(request *GetRequest) (*GetResponse, error) {
|
||||||
|
|
||||||
rsp := &GetResponse{}
|
rsp := &GetResponse{}
|
||||||
return rsp, t.client.Call("cache", "Get", request, rsp)
|
return rsp, t.client.Call("cache", "Get", request, rsp)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Increment a value (if it's a number). If key not found it is equivalent to set.
|
// Increment a value (if it's a number)
|
||||||
func (t *CacheService) Increment(request *IncrementRequest) (*IncrementResponse, error) {
|
func (t *CacheService) Increment(request *IncrementRequest) (*IncrementResponse, error) {
|
||||||
|
|
||||||
rsp := &IncrementResponse{}
|
rsp := &IncrementResponse{}
|
||||||
return rsp, t.client.Call("cache", "Increment", request, rsp)
|
return rsp, t.client.Call("cache", "Increment", request, rsp)
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// List all the available keys
|
|
||||||
func (t *CacheService) ListKeys(request *ListKeysRequest) (*ListKeysResponse, error) {
|
|
||||||
|
|
||||||
rsp := &ListKeysResponse{}
|
|
||||||
return rsp, t.client.Call("cache", "ListKeys", request, rsp)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set an item in the cache. Overwrites any existing value already set.
|
// Set an item in the cache. Overwrites any existing value already set.
|
||||||
func (t *CacheService) Set(request *SetRequest) (*SetResponse, error) {
|
func (t *CacheService) Set(request *SetRequest) (*SetResponse, error) {
|
||||||
|
|
||||||
rsp := &SetResponse{}
|
rsp := &SetResponse{}
|
||||||
return rsp, t.client.Call("cache", "Set", request, rsp)
|
return rsp, t.client.Call("cache", "Set", request, rsp)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type DecrementRequest struct {
|
type DecrementRequest struct {
|
||||||
@@ -125,13 +98,6 @@ type IncrementResponse struct {
|
|||||||
Value int64 `json:"value,string"`
|
Value int64 `json:"value,string"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ListKeysRequest struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
type ListKeysResponse struct {
|
|
||||||
Keys []string `json:"keys"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type SetRequest struct {
|
type SetRequest struct {
|
||||||
// The key to update
|
// The key to update
|
||||||
Key string `json:"key"`
|
Key string `json:"key"`
|
||||||
|
|||||||
@@ -1,52 +0,0 @@
|
|||||||
package carbon
|
|
||||||
|
|
||||||
import (
|
|
||||||
"go.m3o.com/client"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Carbon interface {
|
|
||||||
Offset(*OffsetRequest) (*OffsetResponse, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewCarbonService(token string) *CarbonService {
|
|
||||||
return &CarbonService{
|
|
||||||
client: client.NewClient(&client.Options{
|
|
||||||
Token: token,
|
|
||||||
}),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type CarbonService struct {
|
|
||||||
client *client.Client
|
|
||||||
}
|
|
||||||
|
|
||||||
// Purchase 1KG (0.001 tonne) of carbon offsets in a single request
|
|
||||||
func (t *CarbonService) Offset(request *OffsetRequest) (*OffsetResponse, error) {
|
|
||||||
|
|
||||||
rsp := &OffsetResponse{}
|
|
||||||
return rsp, t.client.Call("carbon", "Offset", request, rsp)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
type OffsetRequest struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
type OffsetResponse struct {
|
|
||||||
// the metric used e.g KG or Tonnes
|
|
||||||
Metric string `json:"metric"`
|
|
||||||
// projects it was allocated to
|
|
||||||
Projects []Project `json:"projects"`
|
|
||||||
// number of tonnes
|
|
||||||
Tonnes float64 `json:"tonnes"`
|
|
||||||
// number of units purchased
|
|
||||||
Units int32 `json:"units"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type Project struct {
|
|
||||||
// name of the project
|
|
||||||
Name string `json:"name"`
|
|
||||||
// percentage that went to this
|
|
||||||
Percentage float64 `json:"percentage"`
|
|
||||||
// amount in tonnes
|
|
||||||
Tonnes float64 `json:"tonnes"`
|
|
||||||
}
|
|
||||||
256
chat/chat.go
256
chat/chat.go
@@ -1,256 +0,0 @@
|
|||||||
package chat
|
|
||||||
|
|
||||||
import (
|
|
||||||
"go.m3o.com/client"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Chat interface {
|
|
||||||
Create(*CreateRequest) (*CreateResponse, error)
|
|
||||||
Delete(*DeleteRequest) (*DeleteResponse, error)
|
|
||||||
History(*HistoryRequest) (*HistoryResponse, error)
|
|
||||||
Invite(*InviteRequest) (*InviteResponse, error)
|
|
||||||
Join(*JoinRequest) (*JoinResponseStream, error)
|
|
||||||
Kick(*KickRequest) (*KickResponse, error)
|
|
||||||
Leave(*LeaveRequest) (*LeaveResponse, error)
|
|
||||||
List(*ListRequest) (*ListResponse, error)
|
|
||||||
Send(*SendRequest) (*SendResponse, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewChatService(token string) *ChatService {
|
|
||||||
return &ChatService{
|
|
||||||
client: client.NewClient(&client.Options{
|
|
||||||
Token: token,
|
|
||||||
}),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type ChatService struct {
|
|
||||||
client *client.Client
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a new chat room
|
|
||||||
func (t *ChatService) Create(request *CreateRequest) (*CreateResponse, error) {
|
|
||||||
|
|
||||||
rsp := &CreateResponse{}
|
|
||||||
return rsp, t.client.Call("chat", "Create", request, rsp)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete a chat room
|
|
||||||
func (t *ChatService) Delete(request *DeleteRequest) (*DeleteResponse, error) {
|
|
||||||
|
|
||||||
rsp := &DeleteResponse{}
|
|
||||||
return rsp, t.client.Call("chat", "Delete", request, rsp)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// List the messages in a chat
|
|
||||||
func (t *ChatService) History(request *HistoryRequest) (*HistoryResponse, error) {
|
|
||||||
|
|
||||||
rsp := &HistoryResponse{}
|
|
||||||
return rsp, t.client.Call("chat", "History", request, rsp)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Invite a user to a chat room
|
|
||||||
func (t *ChatService) Invite(request *InviteRequest) (*InviteResponse, error) {
|
|
||||||
|
|
||||||
rsp := &InviteResponse{}
|
|
||||||
return rsp, t.client.Call("chat", "Invite", request, rsp)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Join a chat room
|
|
||||||
func (t *ChatService) Join(request *JoinRequest) (*JoinResponseStream, error) {
|
|
||||||
stream, err := t.client.Stream("chat", "Join", request)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &JoinResponseStream{
|
|
||||||
stream: stream,
|
|
||||||
}, nil
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
type JoinResponseStream struct {
|
|
||||||
stream *client.Stream
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t *JoinResponseStream) Recv() (*JoinResponse, error) {
|
|
||||||
var rsp JoinResponse
|
|
||||||
if err := t.stream.Recv(&rsp); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &rsp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Kick a user from a chat room
|
|
||||||
func (t *ChatService) Kick(request *KickRequest) (*KickResponse, error) {
|
|
||||||
|
|
||||||
rsp := &KickResponse{}
|
|
||||||
return rsp, t.client.Call("chat", "Kick", request, rsp)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Leave a chat room
|
|
||||||
func (t *ChatService) Leave(request *LeaveRequest) (*LeaveResponse, error) {
|
|
||||||
|
|
||||||
rsp := &LeaveResponse{}
|
|
||||||
return rsp, t.client.Call("chat", "Leave", request, rsp)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// List available chats
|
|
||||||
func (t *ChatService) List(request *ListRequest) (*ListResponse, error) {
|
|
||||||
|
|
||||||
rsp := &ListResponse{}
|
|
||||||
return rsp, t.client.Call("chat", "List", request, rsp)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Connect to a chat to receive a stream of messages
|
|
||||||
// Send a message to a chat
|
|
||||||
func (t *ChatService) Send(request *SendRequest) (*SendResponse, error) {
|
|
||||||
|
|
||||||
rsp := &SendResponse{}
|
|
||||||
return rsp, t.client.Call("chat", "Send", request, rsp)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
type CreateRequest struct {
|
|
||||||
// chat description
|
|
||||||
Description string `json:"description"`
|
|
||||||
// name of the room
|
|
||||||
Name string `json:"name"`
|
|
||||||
// whether its a private room
|
|
||||||
Private bool `json:"private"`
|
|
||||||
// optional list of user ids
|
|
||||||
UserIds string `json:"user_ids"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type CreateResponse struct {
|
|
||||||
// the unique chat room
|
|
||||||
Room *Room `json:"room"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type DeleteRequest struct {
|
|
||||||
// the chat room id to delete
|
|
||||||
RoomId string `json:"room_id"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type DeleteResponse struct {
|
|
||||||
Room *Room `json:"room"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type HistoryRequest struct {
|
|
||||||
// the chat room id to get
|
|
||||||
RoomId string `json:"room_id"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type HistoryResponse struct {
|
|
||||||
// messages in the chat room
|
|
||||||
Messages []Message `json:"messages"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type InviteRequest struct {
|
|
||||||
// the room id
|
|
||||||
RoomId string `json:"room_id"`
|
|
||||||
// the user id
|
|
||||||
UserId string `json:"user_id"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type InviteResponse struct {
|
|
||||||
Room *Room `json:"room"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type JoinRequest struct {
|
|
||||||
// chat room to join
|
|
||||||
RoomId string `json:"room_id"`
|
|
||||||
// user id joining
|
|
||||||
UserId string `json:"user_id"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type JoinResponse struct {
|
|
||||||
Message *Message `json:"message"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type KickRequest struct {
|
|
||||||
// the chat room id
|
|
||||||
RoomId string `json:"room_id"`
|
|
||||||
// the user id
|
|
||||||
UserId string `json:"user_id"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type KickResponse struct {
|
|
||||||
Room *Room `json:"room"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type LeaveRequest struct {
|
|
||||||
// the chat room id
|
|
||||||
RoomId string `json:"room_id"`
|
|
||||||
// the user id
|
|
||||||
UserId string `json:"user_id"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type LeaveResponse struct {
|
|
||||||
Room *Room `json:"room"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type ListRequest struct {
|
|
||||||
// optional user id to filter by
|
|
||||||
UserId string `json:"user_id"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type ListResponse struct {
|
|
||||||
Rooms []Room `json:"rooms"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type Message struct {
|
|
||||||
// a client side id, should be validated by the server to make the request retry safe
|
|
||||||
Client string `json:"client"`
|
|
||||||
// id of the message, allocated by the server
|
|
||||||
Id string `json:"id"`
|
|
||||||
// id of the chat the message is being sent to / from
|
|
||||||
RoomId string `json:"room_id"`
|
|
||||||
// time the message was sent in RFC3339 format
|
|
||||||
SentAt string `json:"sent_at"`
|
|
||||||
// subject of the message
|
|
||||||
Subject string `json:"subject"`
|
|
||||||
// text of the message
|
|
||||||
Text string `json:"text"`
|
|
||||||
// id of the user who sent the message
|
|
||||||
UserId string `json:"user_id"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type Room struct {
|
|
||||||
// time of creation
|
|
||||||
CreatedAt string `json:"created_at"`
|
|
||||||
// description of the that
|
|
||||||
Description string `json:"description"`
|
|
||||||
// unique room id
|
|
||||||
Id string `json:"id"`
|
|
||||||
// name of the chat
|
|
||||||
Name string `json:"name"`
|
|
||||||
// whether its a private room
|
|
||||||
Private bool `json:"private"`
|
|
||||||
// list of users
|
|
||||||
UserIds string `json:"user_ids"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type SendRequest struct {
|
|
||||||
// a client side id, should be validated by the server to make the request retry safe
|
|
||||||
Client string `json:"client"`
|
|
||||||
// id of the chat room the message is being sent to / from
|
|
||||||
RoomId string `json:"room_id"`
|
|
||||||
// subject of the message
|
|
||||||
Subject string `json:"subject"`
|
|
||||||
// text of the message
|
|
||||||
Text string `json:"text"`
|
|
||||||
// id of the user who sent the message
|
|
||||||
UserId string `json:"user_id"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type SendResponse struct {
|
|
||||||
// the message which was created
|
|
||||||
Message *Message `json:"message"`
|
|
||||||
}
|
|
||||||
@@ -6,10 +6,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestBasicCall(t *testing.T) {
|
func TestBasicCall(t *testing.T) {
|
||||||
if v := os.Getenv("IN_TRAVIS"); v == "yes" {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
response := map[string]interface{}{}
|
response := map[string]interface{}{}
|
||||||
if err := NewClient(&Options{
|
if err := NewClient(&Options{
|
||||||
Token: os.Getenv("TOKEN"),
|
Token: os.Getenv("TOKEN"),
|
||||||
|
|||||||
@@ -1,162 +0,0 @@
|
|||||||
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"`
|
|
||||||
}
|
|
||||||
@@ -1,200 +0,0 @@
|
|||||||
package contact
|
|
||||||
|
|
||||||
import (
|
|
||||||
"go.m3o.com/client"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Contact interface {
|
|
||||||
Create(*CreateRequest) (*CreateResponse, error)
|
|
||||||
Delete(*DeleteRequest) (*DeleteResponse, error)
|
|
||||||
List(*ListRequest) (*ListResponse, error)
|
|
||||||
Read(*ReadRequest) (*ReadResponse, error)
|
|
||||||
Update(*UpdateRequest) (*UpdateResponse, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewContactService(token string) *ContactService {
|
|
||||||
return &ContactService{
|
|
||||||
client: client.NewClient(&client.Options{
|
|
||||||
Token: token,
|
|
||||||
}),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type ContactService struct {
|
|
||||||
client *client.Client
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a contact
|
|
||||||
func (t *ContactService) Create(request *CreateRequest) (*CreateResponse, error) {
|
|
||||||
|
|
||||||
rsp := &CreateResponse{}
|
|
||||||
return rsp, t.client.Call("contact", "Create", request, rsp)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete a contact
|
|
||||||
func (t *ContactService) Delete(request *DeleteRequest) (*DeleteResponse, error) {
|
|
||||||
|
|
||||||
rsp := &DeleteResponse{}
|
|
||||||
return rsp, t.client.Call("contact", "Delete", request, rsp)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// List contacts
|
|
||||||
func (t *ContactService) List(request *ListRequest) (*ListResponse, error) {
|
|
||||||
|
|
||||||
rsp := &ListResponse{}
|
|
||||||
return rsp, t.client.Call("contact", "List", request, rsp)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read contact details
|
|
||||||
func (t *ContactService) Read(request *ReadRequest) (*ReadResponse, error) {
|
|
||||||
|
|
||||||
rsp := &ReadResponse{}
|
|
||||||
return rsp, t.client.Call("contact", "Read", request, rsp)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update a contact
|
|
||||||
func (t *ContactService) Update(request *UpdateRequest) (*UpdateResponse, error) {
|
|
||||||
|
|
||||||
rsp := &UpdateResponse{}
|
|
||||||
return rsp, t.client.Call("contact", "Update", request, rsp)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
type Address struct {
|
|
||||||
// the label of the address
|
|
||||||
Label string `json:"label"`
|
|
||||||
// the address location
|
|
||||||
Location string `json:"location"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type ContactInfo struct {
|
|
||||||
// the address
|
|
||||||
Addresses []Address `json:"addresses"`
|
|
||||||
// the birthday
|
|
||||||
Birthday string `json:"birthday"`
|
|
||||||
// create date string in RFC3339
|
|
||||||
CreatedAt string `json:"created_at"`
|
|
||||||
// the emails
|
|
||||||
Emails []Email `json:"emails"`
|
|
||||||
// contact id
|
|
||||||
Id string `json:"id"`
|
|
||||||
// the contact links
|
|
||||||
Links []Link `json:"links"`
|
|
||||||
// the contact name
|
|
||||||
Name string `json:"name"`
|
|
||||||
// note of the contact
|
|
||||||
Note string `json:"note"`
|
|
||||||
// the phone numbers
|
|
||||||
Phones []Phone `json:"phones"`
|
|
||||||
// the social media username
|
|
||||||
SocialMedias *SocialMedia `json:"social_medias"`
|
|
||||||
// update date string in RFC3339
|
|
||||||
UpdatedAt string `json:"updated_at"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type CreateRequest struct {
|
|
||||||
// optional, location
|
|
||||||
Addresses []Address `json:"addresses"`
|
|
||||||
// optional, birthday
|
|
||||||
Birthday string `json:"birthday"`
|
|
||||||
// optional, emails
|
|
||||||
Emails []Email `json:"emails"`
|
|
||||||
// optional, links
|
|
||||||
Links []Link `json:"links"`
|
|
||||||
// required, the name of the contact
|
|
||||||
Name string `json:"name"`
|
|
||||||
// optional, note of the contact
|
|
||||||
Note string `json:"note"`
|
|
||||||
// optional, phone numbers
|
|
||||||
Phones []Phone `json:"phones"`
|
|
||||||
// optional, social media
|
|
||||||
SocialMedias *SocialMedia `json:"social_medias"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type CreateResponse struct {
|
|
||||||
Contact *ContactInfo `json:"contact"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type DeleteRequest struct {
|
|
||||||
// the id of the contact
|
|
||||||
Id string `json:"id"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type DeleteResponse struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
type Email struct {
|
|
||||||
// the email address
|
|
||||||
Address string `json:"address"`
|
|
||||||
// the label of the email
|
|
||||||
Label string `json:"label"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type Link struct {
|
|
||||||
// the label of the link
|
|
||||||
Label string `json:"label"`
|
|
||||||
// the url of the contact
|
|
||||||
Url string `json:"url"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type ListRequest struct {
|
|
||||||
// optional, default is 30
|
|
||||||
Limit int32 `json:"limit"`
|
|
||||||
// optional
|
|
||||||
Offset int32 `json:"offset"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type ListResponse struct {
|
|
||||||
Contacts []ContactInfo `json:"contacts"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type Phone struct {
|
|
||||||
// the label of the phone number
|
|
||||||
Label string `json:"label"`
|
|
||||||
// phone number
|
|
||||||
Number string `json:"number"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type ReadRequest struct {
|
|
||||||
Id string `json:"id"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type ReadResponse struct {
|
|
||||||
Contact *ContactInfo `json:"contact"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type SocialMedia struct {
|
|
||||||
// the label of the social
|
|
||||||
Label string `json:"label"`
|
|
||||||
// the username of social media
|
|
||||||
Username string `json:"username"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type UpdateRequest struct {
|
|
||||||
// optional, addresses
|
|
||||||
Addresses []Address `json:"addresses"`
|
|
||||||
// optional, birthday
|
|
||||||
Birthday string `json:"birthday"`
|
|
||||||
// optional, emails
|
|
||||||
Emails []Email `json:"emails"`
|
|
||||||
// required, the contact id
|
|
||||||
Id string `json:"id"`
|
|
||||||
// optional, links
|
|
||||||
Links []Link `json:"links"`
|
|
||||||
// required, the name
|
|
||||||
Name string `json:"name"`
|
|
||||||
// optional, note
|
|
||||||
Note string `json:"note"`
|
|
||||||
// optional, phone number
|
|
||||||
Phones []Phone `json:"phones"`
|
|
||||||
// optional, social media
|
|
||||||
SocialMedias *SocialMedia `json:"social_medias"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type UpdateResponse struct {
|
|
||||||
Contact *ContactInfo `json:"contact"`
|
|
||||||
}
|
|
||||||
@@ -4,14 +4,6 @@ import (
|
|||||||
"go.m3o.com/client"
|
"go.m3o.com/client"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Crypto interface {
|
|
||||||
History(*HistoryRequest) (*HistoryResponse, error)
|
|
||||||
News(*NewsRequest) (*NewsResponse, error)
|
|
||||||
Price(*PriceRequest) (*PriceResponse, error)
|
|
||||||
Quote(*QuoteRequest) (*QuoteResponse, error)
|
|
||||||
Symbols(*SymbolsRequest) (*SymbolsResponse, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewCryptoService(token string) *CryptoService {
|
func NewCryptoService(token string) *CryptoService {
|
||||||
return &CryptoService{
|
return &CryptoService{
|
||||||
client: client.NewClient(&client.Options{
|
client: client.NewClient(&client.Options{
|
||||||
@@ -26,42 +18,26 @@ type CryptoService struct {
|
|||||||
|
|
||||||
// Returns the history for the previous close
|
// Returns the history for the previous close
|
||||||
func (t *CryptoService) History(request *HistoryRequest) (*HistoryResponse, error) {
|
func (t *CryptoService) History(request *HistoryRequest) (*HistoryResponse, error) {
|
||||||
|
|
||||||
rsp := &HistoryResponse{}
|
rsp := &HistoryResponse{}
|
||||||
return rsp, t.client.Call("crypto", "History", request, rsp)
|
return rsp, t.client.Call("crypto", "History", request, rsp)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get news related to a currency
|
// Get news related to a currency
|
||||||
func (t *CryptoService) News(request *NewsRequest) (*NewsResponse, error) {
|
func (t *CryptoService) News(request *NewsRequest) (*NewsResponse, error) {
|
||||||
|
|
||||||
rsp := &NewsResponse{}
|
rsp := &NewsResponse{}
|
||||||
return rsp, t.client.Call("crypto", "News", request, rsp)
|
return rsp, t.client.Call("crypto", "News", request, rsp)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the last price for a given crypto ticker
|
// Get the last price for a given crypto ticker
|
||||||
func (t *CryptoService) Price(request *PriceRequest) (*PriceResponse, error) {
|
func (t *CryptoService) Price(request *PriceRequest) (*PriceResponse, error) {
|
||||||
|
|
||||||
rsp := &PriceResponse{}
|
rsp := &PriceResponse{}
|
||||||
return rsp, t.client.Call("crypto", "Price", request, rsp)
|
return rsp, t.client.Call("crypto", "Price", request, rsp)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the last quote for a given crypto ticker
|
// Get the last quote for a given crypto ticker
|
||||||
func (t *CryptoService) Quote(request *QuoteRequest) (*QuoteResponse, error) {
|
func (t *CryptoService) Quote(request *QuoteRequest) (*QuoteResponse, error) {
|
||||||
|
|
||||||
rsp := &QuoteResponse{}
|
rsp := &QuoteResponse{}
|
||||||
return rsp, t.client.Call("crypto", "Quote", request, rsp)
|
return rsp, t.client.Call("crypto", "Quote", request, rsp)
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns the full list of supported symbols
|
|
||||||
func (t *CryptoService) Symbols(request *SymbolsRequest) (*SymbolsResponse, error) {
|
|
||||||
|
|
||||||
rsp := &SymbolsResponse{}
|
|
||||||
return rsp, t.client.Call("crypto", "Symbols", request, rsp)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Article struct {
|
type Article struct {
|
||||||
@@ -130,27 +106,15 @@ type QuoteRequest struct {
|
|||||||
|
|
||||||
type QuoteResponse struct {
|
type QuoteResponse struct {
|
||||||
// the asking price
|
// the asking price
|
||||||
AskPrice float64 `json:"ask_price"`
|
AskPrice float64 `json:"askPrice"`
|
||||||
// the ask size
|
// the ask size
|
||||||
AskSize float64 `json:"ask_size"`
|
AskSize float64 `json:"askSize"`
|
||||||
// the bidding price
|
// the bidding price
|
||||||
BidPrice float64 `json:"bid_price"`
|
BidPrice float64 `json:"bidPrice"`
|
||||||
// the bid size
|
// the bid size
|
||||||
BidSize float64 `json:"bid_size"`
|
BidSize float64 `json:"bidSize"`
|
||||||
// the crypto symbol
|
// the crypto symbol
|
||||||
Symbol string `json:"symbol"`
|
Symbol string `json:"symbol"`
|
||||||
// the UTC timestamp of the quote
|
// the UTC timestamp of the quote
|
||||||
Timestamp string `json:"timestamp"`
|
Timestamp string `json:"timestamp"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Symbol struct {
|
|
||||||
Name string `json:"name"`
|
|
||||||
Symbol string `json:"symbol"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type SymbolsRequest struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
type SymbolsResponse struct {
|
|
||||||
Symbols []Symbol `json:"symbols"`
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -4,13 +4,6 @@ import (
|
|||||||
"go.m3o.com/client"
|
"go.m3o.com/client"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Currency interface {
|
|
||||||
Codes(*CodesRequest) (*CodesResponse, error)
|
|
||||||
Convert(*ConvertRequest) (*ConvertResponse, error)
|
|
||||||
History(*HistoryRequest) (*HistoryResponse, error)
|
|
||||||
Rates(*RatesRequest) (*RatesResponse, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewCurrencyService(token string) *CurrencyService {
|
func NewCurrencyService(token string) *CurrencyService {
|
||||||
return &CurrencyService{
|
return &CurrencyService{
|
||||||
client: client.NewClient(&client.Options{
|
client: client.NewClient(&client.Options{
|
||||||
@@ -25,34 +18,26 @@ type CurrencyService struct {
|
|||||||
|
|
||||||
// Codes returns the supported currency codes for the API
|
// Codes returns the supported currency codes for the API
|
||||||
func (t *CurrencyService) Codes(request *CodesRequest) (*CodesResponse, error) {
|
func (t *CurrencyService) Codes(request *CodesRequest) (*CodesResponse, error) {
|
||||||
|
|
||||||
rsp := &CodesResponse{}
|
rsp := &CodesResponse{}
|
||||||
return rsp, t.client.Call("currency", "Codes", request, rsp)
|
return rsp, t.client.Call("currency", "Codes", request, rsp)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert returns the currency conversion rate between two pairs e.g USD/GBP
|
// Convert returns the currency conversion rate between two pairs e.g USD/GBP
|
||||||
func (t *CurrencyService) Convert(request *ConvertRequest) (*ConvertResponse, error) {
|
func (t *CurrencyService) Convert(request *ConvertRequest) (*ConvertResponse, error) {
|
||||||
|
|
||||||
rsp := &ConvertResponse{}
|
rsp := &ConvertResponse{}
|
||||||
return rsp, t.client.Call("currency", "Convert", request, rsp)
|
return rsp, t.client.Call("currency", "Convert", request, rsp)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the historic rates for a currency on a given date
|
// Returns the historic rates for a currency on a given date
|
||||||
func (t *CurrencyService) History(request *HistoryRequest) (*HistoryResponse, error) {
|
func (t *CurrencyService) History(request *HistoryRequest) (*HistoryResponse, error) {
|
||||||
|
|
||||||
rsp := &HistoryResponse{}
|
rsp := &HistoryResponse{}
|
||||||
return rsp, t.client.Call("currency", "History", request, rsp)
|
return rsp, t.client.Call("currency", "History", request, rsp)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rates returns the currency rates for a given code e.g USD
|
// Rates returns the currency rates for a given code e.g USD
|
||||||
func (t *CurrencyService) Rates(request *RatesRequest) (*RatesResponse, error) {
|
func (t *CurrencyService) Rates(request *RatesRequest) (*RatesResponse, error) {
|
||||||
|
|
||||||
rsp := &RatesResponse{}
|
rsp := &RatesResponse{}
|
||||||
return rsp, t.client.Call("currency", "Rates", request, rsp)
|
return rsp, t.client.Call("currency", "Rates", request, rsp)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Code struct {
|
type Code struct {
|
||||||
|
|||||||
78
db/db.go
78
db/db.go
@@ -4,18 +4,6 @@ import (
|
|||||||
"go.m3o.com/client"
|
"go.m3o.com/client"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Db interface {
|
|
||||||
Count(*CountRequest) (*CountResponse, error)
|
|
||||||
Create(*CreateRequest) (*CreateResponse, error)
|
|
||||||
Delete(*DeleteRequest) (*DeleteResponse, error)
|
|
||||||
DropTable(*DropTableRequest) (*DropTableResponse, error)
|
|
||||||
ListTables(*ListTablesRequest) (*ListTablesResponse, error)
|
|
||||||
Read(*ReadRequest) (*ReadResponse, error)
|
|
||||||
RenameTable(*RenameTableRequest) (*RenameTableResponse, error)
|
|
||||||
Truncate(*TruncateRequest) (*TruncateResponse, error)
|
|
||||||
Update(*UpdateRequest) (*UpdateResponse, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewDbService(token string) *DbService {
|
func NewDbService(token string) *DbService {
|
||||||
return &DbService{
|
return &DbService{
|
||||||
client: client.NewClient(&client.Options{
|
client: client.NewClient(&client.Options{
|
||||||
@@ -30,74 +18,38 @@ type DbService struct {
|
|||||||
|
|
||||||
// Count records in a table
|
// Count records in a table
|
||||||
func (t *DbService) Count(request *CountRequest) (*CountResponse, error) {
|
func (t *DbService) Count(request *CountRequest) (*CountResponse, error) {
|
||||||
|
|
||||||
rsp := &CountResponse{}
|
rsp := &CountResponse{}
|
||||||
return rsp, t.client.Call("db", "Count", request, rsp)
|
return rsp, t.client.Call("db", "Count", request, rsp)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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.
|
||||||
func (t *DbService) Create(request *CreateRequest) (*CreateResponse, error) {
|
func (t *DbService) Create(request *CreateRequest) (*CreateResponse, error) {
|
||||||
|
|
||||||
rsp := &CreateResponse{}
|
rsp := &CreateResponse{}
|
||||||
return rsp, t.client.Call("db", "Create", request, rsp)
|
return rsp, t.client.Call("db", "Create", request, rsp)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete a record in the database by id.
|
// Delete a record in the database by id.
|
||||||
func (t *DbService) Delete(request *DeleteRequest) (*DeleteResponse, error) {
|
func (t *DbService) Delete(request *DeleteRequest) (*DeleteResponse, error) {
|
||||||
|
|
||||||
rsp := &DeleteResponse{}
|
rsp := &DeleteResponse{}
|
||||||
return rsp, t.client.Call("db", "Delete", request, rsp)
|
return rsp, t.client.Call("db", "Delete", request, rsp)
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Drop a table in the DB
|
|
||||||
func (t *DbService) DropTable(request *DropTableRequest) (*DropTableResponse, error) {
|
|
||||||
|
|
||||||
rsp := &DropTableResponse{}
|
|
||||||
return rsp, t.client.Call("db", "DropTable", request, rsp)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// List tables in the DB
|
|
||||||
func (t *DbService) ListTables(request *ListTablesRequest) (*ListTablesResponse, error) {
|
|
||||||
|
|
||||||
rsp := &ListTablesResponse{}
|
|
||||||
return rsp, t.client.Call("db", "ListTables", request, rsp)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read data from a table. Lookup can be by ID or via querying any field in the record.
|
// Read data from a table. Lookup can be by ID or via querying any field in the record.
|
||||||
func (t *DbService) Read(request *ReadRequest) (*ReadResponse, error) {
|
func (t *DbService) Read(request *ReadRequest) (*ReadResponse, error) {
|
||||||
|
|
||||||
rsp := &ReadResponse{}
|
rsp := &ReadResponse{}
|
||||||
return rsp, t.client.Call("db", "Read", request, rsp)
|
return rsp, t.client.Call("db", "Read", request, rsp)
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Rename a table
|
|
||||||
func (t *DbService) RenameTable(request *RenameTableRequest) (*RenameTableResponse, error) {
|
|
||||||
|
|
||||||
rsp := &RenameTableResponse{}
|
|
||||||
return rsp, t.client.Call("db", "RenameTable", request, rsp)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Truncate the records in a table
|
// Truncate the records in a table
|
||||||
func (t *DbService) Truncate(request *TruncateRequest) (*TruncateResponse, error) {
|
func (t *DbService) Truncate(request *TruncateRequest) (*TruncateResponse, error) {
|
||||||
|
|
||||||
rsp := &TruncateResponse{}
|
rsp := &TruncateResponse{}
|
||||||
return rsp, t.client.Call("db", "Truncate", request, rsp)
|
return rsp, t.client.Call("db", "Truncate", request, rsp)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update a record in the database. Include an "id" in the record to update.
|
// Update a record in the database. Include an "id" in the record to update.
|
||||||
func (t *DbService) Update(request *UpdateRequest) (*UpdateResponse, error) {
|
func (t *DbService) Update(request *UpdateRequest) (*UpdateResponse, error) {
|
||||||
|
|
||||||
rsp := &UpdateResponse{}
|
rsp := &UpdateResponse{}
|
||||||
return rsp, t.client.Call("db", "Update", request, rsp)
|
return rsp, t.client.Call("db", "Update", request, rsp)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type CountRequest struct {
|
type CountRequest struct {
|
||||||
@@ -111,8 +63,6 @@ type CountResponse struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type CreateRequest struct {
|
type CreateRequest struct {
|
||||||
// optional record id to use
|
|
||||||
Id string `json:"id"`
|
|
||||||
// JSON encoded record or records (can be array or object)
|
// JSON encoded record or records (can be array or object)
|
||||||
Record map[string]interface{} `json:"record"`
|
Record map[string]interface{} `json:"record"`
|
||||||
// Optional table name. Defaults to 'default'
|
// Optional table name. Defaults to 'default'
|
||||||
@@ -134,21 +84,6 @@ type DeleteRequest struct {
|
|||||||
type DeleteResponse struct {
|
type DeleteResponse struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type DropTableRequest struct {
|
|
||||||
Table string `json:"table"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type DropTableResponse struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
type ListTablesRequest struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
type ListTablesResponse struct {
|
|
||||||
// list of tables
|
|
||||||
Tables []string `json:"tables"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type ReadRequest struct {
|
type ReadRequest struct {
|
||||||
// Read by id. Equivalent to 'id == "your-id"'
|
// Read by id. Equivalent to 'id == "your-id"'
|
||||||
Id string `json:"id"`
|
Id string `json:"id"`
|
||||||
@@ -175,21 +110,14 @@ type ReadResponse struct {
|
|||||||
Records []map[string]interface{} `json:"records"`
|
Records []map[string]interface{} `json:"records"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type RenameTableRequest struct {
|
|
||||||
// current table name
|
|
||||||
From string `json:"from"`
|
|
||||||
// new table name
|
|
||||||
To string `json:"to"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type RenameTableResponse struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
type TruncateRequest struct {
|
type TruncateRequest struct {
|
||||||
|
// Optional table name. Defaults to 'default'
|
||||||
Table string `json:"table"`
|
Table string `json:"table"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type TruncateResponse struct {
|
type TruncateResponse struct {
|
||||||
|
// The table truncated
|
||||||
|
Table string `json:"table"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type UpdateRequest struct {
|
type UpdateRequest struct {
|
||||||
|
|||||||
@@ -4,12 +4,6 @@ import (
|
|||||||
"go.m3o.com/client"
|
"go.m3o.com/client"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Email interface {
|
|
||||||
Parse(*ParseRequest) (*ParseResponse, error)
|
|
||||||
Send(*SendRequest) (*SendResponse, error)
|
|
||||||
Validate(*ValidateRequest) (*ValidateResponse, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewEmailService(token string) *EmailService {
|
func NewEmailService(token string) *EmailService {
|
||||||
return &EmailService{
|
return &EmailService{
|
||||||
client: client.NewClient(&client.Options{
|
client: client.NewClient(&client.Options{
|
||||||
@@ -22,64 +16,26 @@ type EmailService struct {
|
|||||||
client *client.Client
|
client *client.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse an RFC5322 address e.g "Joe Blogs <joe@example.com>"
|
|
||||||
func (t *EmailService) Parse(request *ParseRequest) (*ParseResponse, error) {
|
|
||||||
|
|
||||||
rsp := &ParseResponse{}
|
|
||||||
return rsp, t.client.Call("email", "Parse", request, rsp)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send an email by passing in from, to, subject, and a text or html body
|
// Send an email by passing in from, to, subject, and a text or html body
|
||||||
func (t *EmailService) Send(request *SendRequest) (*SendResponse, error) {
|
func (t *EmailService) Send(request *SendRequest) (*SendResponse, error) {
|
||||||
|
|
||||||
rsp := &SendResponse{}
|
rsp := &SendResponse{}
|
||||||
return rsp, t.client.Call("email", "Send", request, rsp)
|
return rsp, t.client.Call("email", "Send", request, rsp)
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Validate an email address format
|
|
||||||
func (t *EmailService) Validate(request *ValidateRequest) (*ValidateResponse, error) {
|
|
||||||
|
|
||||||
rsp := &ValidateResponse{}
|
|
||||||
return rsp, t.client.Call("email", "Validate", request, rsp)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
type ParseRequest struct {
|
|
||||||
// The address to parse. Can be of the format "Joe Blogs <joe@example.com>" or "joe@example.com"
|
|
||||||
Address string `json:"address"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type ParseResponse struct {
|
|
||||||
// the email address
|
|
||||||
Address string `json:"address"`
|
|
||||||
// associated name e.g Joe Blogs
|
|
||||||
Name string `json:"name"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type SendRequest struct {
|
type SendRequest struct {
|
||||||
// the display name of the sender
|
// the display name of the sender
|
||||||
From string `json:"from"`
|
From string `json:"from"`
|
||||||
// the html body
|
// the html body
|
||||||
HtmlBody string `json:"html_body"`
|
HtmlBody string `json:"htmlBody"`
|
||||||
// an optional reply to email address
|
// an optional reply to email address
|
||||||
ReplyTo string `json:"reply_to"`
|
ReplyTo string `json:"replyTo"`
|
||||||
// the email subject
|
// the email subject
|
||||||
Subject string `json:"subject"`
|
Subject string `json:"subject"`
|
||||||
// the text body
|
// the text body
|
||||||
TextBody string `json:"text_body"`
|
TextBody string `json:"textBody"`
|
||||||
// the email address of the recipient
|
// the email address of the recipient
|
||||||
To string `json:"to"`
|
To string `json:"to"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SendResponse struct {
|
type SendResponse struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type ValidateRequest struct {
|
|
||||||
Address string `json:"address"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type ValidateResponse struct {
|
|
||||||
IsValid bool `json:"is_valid"`
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -4,12 +4,6 @@ import (
|
|||||||
"go.m3o.com/client"
|
"go.m3o.com/client"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Emoji interface {
|
|
||||||
Find(*FindRequest) (*FindResponse, error)
|
|
||||||
Flag(*FlagRequest) (*FlagResponse, error)
|
|
||||||
Print(*PrintRequest) (*PrintResponse, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewEmojiService(token string) *EmojiService {
|
func NewEmojiService(token string) *EmojiService {
|
||||||
return &EmojiService{
|
return &EmojiService{
|
||||||
client: client.NewClient(&client.Options{
|
client: client.NewClient(&client.Options{
|
||||||
@@ -24,27 +18,27 @@ type EmojiService struct {
|
|||||||
|
|
||||||
// Find an emoji by its alias e.g :beer:
|
// Find an emoji by its alias e.g :beer:
|
||||||
func (t *EmojiService) Find(request *FindRequest) (*FindResponse, error) {
|
func (t *EmojiService) Find(request *FindRequest) (*FindResponse, error) {
|
||||||
|
|
||||||
rsp := &FindResponse{}
|
rsp := &FindResponse{}
|
||||||
return rsp, t.client.Call("emoji", "Find", request, rsp)
|
return rsp, t.client.Call("emoji", "Find", request, rsp)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the flag for a country. Requires country code e.g GB for great britain
|
// Get the flag for a country. Requires country code e.g GB for great britain
|
||||||
func (t *EmojiService) Flag(request *FlagRequest) (*FlagResponse, error) {
|
func (t *EmojiService) Flag(request *FlagRequest) (*FlagResponse, error) {
|
||||||
|
|
||||||
rsp := &FlagResponse{}
|
rsp := &FlagResponse{}
|
||||||
return rsp, t.client.Call("emoji", "Flag", request, rsp)
|
return rsp, t.client.Call("emoji", "Flag", request, rsp)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print text and renders the emojis with aliases e.g
|
// Print text and renders the emojis with aliases e.g
|
||||||
// let's grab a :beer: becomes let's grab a 🍺
|
// let's grab a :beer: becomes let's grab a 🍺
|
||||||
func (t *EmojiService) Print(request *PrintRequest) (*PrintResponse, error) {
|
func (t *EmojiService) Print(request *PrintRequest) (*PrintResponse, error) {
|
||||||
|
|
||||||
rsp := &PrintResponse{}
|
rsp := &PrintResponse{}
|
||||||
return rsp, t.client.Call("emoji", "Print", request, rsp)
|
return rsp, t.client.Call("emoji", "Print", request, rsp)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send an emoji to anyone via SMS. Messages are sent in the form '<message> Sent from <from>'
|
||||||
|
func (t *EmojiService) Send(request *SendRequest) (*SendResponse, error) {
|
||||||
|
rsp := &SendResponse{}
|
||||||
|
return rsp, t.client.Call("emoji", "Send", request, rsp)
|
||||||
}
|
}
|
||||||
|
|
||||||
type FindRequest struct {
|
type FindRequest struct {
|
||||||
@@ -76,3 +70,17 @@ type PrintResponse struct {
|
|||||||
// text with rendered emojis
|
// text with rendered emojis
|
||||||
Text string `json:"text"`
|
Text string `json:"text"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SendRequest struct {
|
||||||
|
// the name of the sender from e.g Alice
|
||||||
|
From string `json:"from"`
|
||||||
|
// message to send including emoji aliases
|
||||||
|
Message string `json:"message"`
|
||||||
|
// phone number to send to (including international dialing code)
|
||||||
|
To string `json:"to"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type SendResponse struct {
|
||||||
|
// whether or not it succeeded
|
||||||
|
Success bool `json:"success"`
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,11 +4,6 @@ import (
|
|||||||
"go.m3o.com/client"
|
"go.m3o.com/client"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Evchargers interface {
|
|
||||||
ReferenceData(*ReferenceDataRequest) (*ReferenceDataResponse, error)
|
|
||||||
Search(*SearchRequest) (*SearchResponse, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewEvchargersService(token string) *EvchargersService {
|
func NewEvchargersService(token string) *EvchargersService {
|
||||||
return &EvchargersService{
|
return &EvchargersService{
|
||||||
client: client.NewClient(&client.Options{
|
client: client.NewClient(&client.Options{
|
||||||
@@ -23,66 +18,62 @@ type EvchargersService struct {
|
|||||||
|
|
||||||
// Retrieve reference data as used by this API and in conjunction with the Search endpoint
|
// Retrieve reference data as used by this API and in conjunction with the Search endpoint
|
||||||
func (t *EvchargersService) ReferenceData(request *ReferenceDataRequest) (*ReferenceDataResponse, error) {
|
func (t *EvchargersService) ReferenceData(request *ReferenceDataRequest) (*ReferenceDataResponse, error) {
|
||||||
|
|
||||||
rsp := &ReferenceDataResponse{}
|
rsp := &ReferenceDataResponse{}
|
||||||
return rsp, t.client.Call("evchargers", "ReferenceData", request, rsp)
|
return rsp, t.client.Call("evchargers", "ReferenceData", request, rsp)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Search by giving a coordinate and a max distance, or bounding box and optional filters
|
// Search by giving a coordinate and a max distance, or bounding box and optional filters
|
||||||
func (t *EvchargersService) Search(request *SearchRequest) (*SearchResponse, error) {
|
func (t *EvchargersService) Search(request *SearchRequest) (*SearchResponse, error) {
|
||||||
|
|
||||||
rsp := &SearchResponse{}
|
rsp := &SearchResponse{}
|
||||||
return rsp, t.client.Call("evchargers", "Search", request, rsp)
|
return rsp, t.client.Call("evchargers", "Search", request, rsp)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Address struct {
|
type Address struct {
|
||||||
// Any comments about how to access the charger
|
// Any comments about how to access the charger
|
||||||
AccessComments string `json:"access_comments"`
|
AccessComments string `json:"accessComments"`
|
||||||
AddressLine1 string `json:"address_line_1"`
|
AddressLine1 string `json:"addressLine1"`
|
||||||
AddressLine2 string `json:"address_line_2"`
|
AddressLine2 string `json:"addressLine2"`
|
||||||
Country *Country `json:"country"`
|
Country *Country `json:"country"`
|
||||||
CountryId string `json:"country_id"`
|
CountryId string `json:"countryId"`
|
||||||
LatLng string `json:"lat_lng"`
|
LatLng string `json:"latLng"`
|
||||||
Location *Coordinates `json:"location"`
|
Location *Coordinates `json:"location"`
|
||||||
Postcode string `json:"postcode"`
|
Postcode string `json:"postcode"`
|
||||||
StateOrProvince string `json:"state_or_province"`
|
StateOrProvince string `json:"stateOrProvince"`
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
Town string `json:"town"`
|
Town string `json:"town"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type BoundingBox struct {
|
type BoundingBox struct {
|
||||||
BottomLeft *Coordinates `json:"bottom_left"`
|
BottomLeft *Coordinates `json:"bottomLeft"`
|
||||||
TopRight *Coordinates `json:"top_right"`
|
TopRight *Coordinates `json:"topRight"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ChargerType struct {
|
type ChargerType struct {
|
||||||
Comments string `json:"comments"`
|
Comments string `json:"comments"`
|
||||||
Id string `json:"id"`
|
Id string `json:"id"`
|
||||||
// Is this 40KW+
|
// Is this 40KW+
|
||||||
IsFastChargeCapable bool `json:"is_fast_charge_capable"`
|
IsFastChargeCapable bool `json:"isFastChargeCapable"`
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type CheckinStatusType struct {
|
type CheckinStatusType struct {
|
||||||
Id string `json:"id"`
|
Id string `json:"id"`
|
||||||
IsAutomated bool `json:"is_automated"`
|
IsAutomated bool `json:"isAutomated"`
|
||||||
IsPositive bool `json:"is_positive"`
|
IsPositive bool `json:"isPositive"`
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Connection struct {
|
type Connection struct {
|
||||||
// The amps offered
|
// The amps offered
|
||||||
Amps float64 `json:"amps"`
|
Amps float64 `json:"amps"`
|
||||||
ConnectionType *ConnectionType `json:"connection_type"`
|
ConnectionType *ConnectionType `json:"connectionType"`
|
||||||
// The ID of the connection type
|
// The ID of the connection type
|
||||||
ConnectionTypeId string `json:"connection_type_id"`
|
ConnectionTypeId string `json:"connectionTypeId"`
|
||||||
// The current
|
// The current
|
||||||
Current string `json:"current"`
|
Current string `json:"current"`
|
||||||
Level *ChargerType `json:"level"`
|
Level *ChargerType `json:"level"`
|
||||||
// The level of charging power available
|
// The level of charging power available
|
||||||
LevelId string `json:"level_id"`
|
LevelId string `json:"levelId"`
|
||||||
// The power in KW
|
// The power in KW
|
||||||
Power float64 `json:"power"`
|
Power float64 `json:"power"`
|
||||||
Reference string `json:"reference"`
|
Reference string `json:"reference"`
|
||||||
@@ -91,10 +82,10 @@ type Connection struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ConnectionType struct {
|
type ConnectionType struct {
|
||||||
FormalName string `json:"formal_name"`
|
FormalName string `json:"formalName"`
|
||||||
Id string `json:"id"`
|
Id string `json:"id"`
|
||||||
IsDiscontinued bool `json:"is_discontinued"`
|
IsDiscontinued bool `json:"isDiscontinued"`
|
||||||
IsObsolete bool `json:"is_obsolete"`
|
IsObsolete bool `json:"isObsolete"`
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,9 +95,9 @@ type Coordinates struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Country struct {
|
type Country struct {
|
||||||
ContinentCode string `json:"continent_code"`
|
ContinentCode string `json:"continentCode"`
|
||||||
Id string `json:"id"`
|
Id string `json:"id"`
|
||||||
IsoCode string `json:"iso_code"`
|
IsoCode string `json:"isoCode"`
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,7 +109,7 @@ type CurrentType struct {
|
|||||||
|
|
||||||
type DataProvider struct {
|
type DataProvider struct {
|
||||||
Comments string `json:"comments"`
|
Comments string `json:"comments"`
|
||||||
DataProviderStatusType *DataProviderStatusType `json:"data_provider_status_type"`
|
DataProviderStatusType *DataProviderStatusType `json:"dataProviderStatusType"`
|
||||||
Id string `json:"id"`
|
Id string `json:"id"`
|
||||||
// How is this data licensed
|
// How is this data licensed
|
||||||
License string `json:"license"`
|
License string `json:"license"`
|
||||||
@@ -128,19 +119,19 @@ type DataProvider struct {
|
|||||||
|
|
||||||
type DataProviderStatusType struct {
|
type DataProviderStatusType struct {
|
||||||
Id string `json:"id"`
|
Id string `json:"id"`
|
||||||
IsProviderEnabled bool `json:"is_provider_enabled"`
|
IsProviderEnabled bool `json:"isProviderEnabled"`
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Operator struct {
|
type Operator struct {
|
||||||
Comments string `json:"comments"`
|
Comments string `json:"comments"`
|
||||||
ContactEmail string `json:"contact_email"`
|
ContactEmail string `json:"contactEmail"`
|
||||||
FaultReportEmail string `json:"fault_report_email"`
|
FaultReportEmail string `json:"faultReportEmail"`
|
||||||
Id string `json:"id"`
|
Id string `json:"id"`
|
||||||
// Is this operator a private individual vs a company
|
// Is this operator a private individual vs a company
|
||||||
IsPrivateIndividual bool `json:"is_private_individual"`
|
IsPrivateIndividual bool `json:"isPrivateIndividual"`
|
||||||
PhonePrimary string `json:"phone_primary"`
|
PhonePrimary string `json:"phonePrimary"`
|
||||||
PhoneSecondary string `json:"phone_secondary"`
|
PhoneSecondary string `json:"phoneSecondary"`
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
Website string `json:"website"`
|
Website string `json:"website"`
|
||||||
}
|
}
|
||||||
@@ -153,19 +144,19 @@ type Poi struct {
|
|||||||
// The cost of charging
|
// The cost of charging
|
||||||
Cost string `json:"cost"`
|
Cost string `json:"cost"`
|
||||||
// The ID of the data provider
|
// The ID of the data provider
|
||||||
DataProviderId string `json:"data_provider_id"`
|
DataProviderId string `json:"dataProviderId"`
|
||||||
// The ID of the charger
|
// The ID of the charger
|
||||||
Id string `json:"id"`
|
Id string `json:"id"`
|
||||||
// The number of charging points
|
// The number of charging points
|
||||||
NumPoints int64 `json:"num_points,string"`
|
NumPoints int64 `json:"numPoints,string"`
|
||||||
// The operator
|
// The operator
|
||||||
Operator *Operator `json:"operator"`
|
Operator *Operator `json:"operator"`
|
||||||
// The ID of the operator of the charger
|
// The ID of the operator of the charger
|
||||||
OperatorId string `json:"operator_id"`
|
OperatorId string `json:"operatorId"`
|
||||||
// The type of usage
|
// The type of usage
|
||||||
UsageType *UsageType `json:"usage_type"`
|
UsageType *UsageType `json:"usageType"`
|
||||||
// The type of usage for this charger point (is it public, membership required, etc)
|
// The type of usage for this charger point (is it public, membership required, etc)
|
||||||
UsageTypeId string `json:"usage_type_id"`
|
UsageTypeId string `json:"usageTypeId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ReferenceDataRequest struct {
|
type ReferenceDataRequest struct {
|
||||||
@@ -173,36 +164,36 @@ type ReferenceDataRequest struct {
|
|||||||
|
|
||||||
type ReferenceDataResponse struct {
|
type ReferenceDataResponse struct {
|
||||||
// The types of charger
|
// The types of charger
|
||||||
ChargerTypes *ChargerType `json:"charger_types"`
|
ChargerTypes *ChargerType `json:"chargerTypes"`
|
||||||
// The types of checkin status
|
// The types of checkin status
|
||||||
CheckinStatusTypes *CheckinStatusType `json:"checkin_status_types"`
|
CheckinStatusTypes *CheckinStatusType `json:"checkinStatusTypes"`
|
||||||
// The types of connection
|
// The types of connection
|
||||||
ConnectionTypes *ConnectionType `json:"connection_types"`
|
ConnectionTypes *ConnectionType `json:"connectionTypes"`
|
||||||
// The countries
|
// The countries
|
||||||
Countries []Country `json:"countries"`
|
Countries []Country `json:"countries"`
|
||||||
// The types of current
|
// The types of current
|
||||||
CurrentTypes *CurrentType `json:"current_types"`
|
CurrentTypes *CurrentType `json:"currentTypes"`
|
||||||
// The providers of the charger data
|
// The providers of the charger data
|
||||||
DataProviders *DataProvider `json:"data_providers"`
|
DataProviders *DataProvider `json:"dataProviders"`
|
||||||
// The companies operating the chargers
|
// The companies operating the chargers
|
||||||
Operators []Operator `json:"operators"`
|
Operators []Operator `json:"operators"`
|
||||||
// The status of the charger
|
// The status of the charger
|
||||||
StatusTypes *StatusType `json:"status_types"`
|
StatusTypes *StatusType `json:"statusTypes"`
|
||||||
// The status of a submission
|
// The status of a submission
|
||||||
SubmissionStatusTypes *SubmissionStatusType `json:"submission_status_types"`
|
SubmissionStatusTypes *SubmissionStatusType `json:"submissionStatusTypes"`
|
||||||
// The different types of usage
|
// The different types of usage
|
||||||
UsageTypes *UsageType `json:"usage_types"`
|
UsageTypes *UsageType `json:"usageTypes"`
|
||||||
// The types of user comment
|
// The types of user comment
|
||||||
UserCommentTypes *UserCommentType `json:"user_comment_types"`
|
UserCommentTypes *UserCommentType `json:"userCommentTypes"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SearchRequest struct {
|
type SearchRequest struct {
|
||||||
// Bounding box to search within (top left and bottom right coordinates)
|
// Bounding box to search within (top left and bottom right coordinates)
|
||||||
Box *BoundingBox `json:"box"`
|
Box *BoundingBox `json:"box"`
|
||||||
// IDs of the connection type
|
// IDs of the connection type
|
||||||
ConnectionTypes string `json:"connection_types"`
|
ConnectionTypes string `json:"connectionTypes"`
|
||||||
// Country ID
|
// Country ID
|
||||||
CountryId string `json:"country_id"`
|
CountryId string `json:"countryId"`
|
||||||
// Search distance from point in metres, defaults to 5000m
|
// Search distance from point in metres, defaults to 5000m
|
||||||
Distance int64 `json:"distance,string"`
|
Distance int64 `json:"distance,string"`
|
||||||
// Supported charging levels
|
// Supported charging levels
|
||||||
@@ -210,13 +201,13 @@ type SearchRequest struct {
|
|||||||
// Coordinates from which to begin search
|
// Coordinates from which to begin search
|
||||||
Location *Coordinates `json:"location"`
|
Location *Coordinates `json:"location"`
|
||||||
// Maximum number of results to return, defaults to 100
|
// Maximum number of results to return, defaults to 100
|
||||||
MaxResults int64 `json:"max_results,string"`
|
MaxResults int64 `json:"maxResults,string"`
|
||||||
// Minimum power in KW. Note: data not available for many chargers
|
// Minimum power in KW. Note: data not available for many chargers
|
||||||
MinPower int64 `json:"min_power,string"`
|
MinPower int64 `json:"minPower,string"`
|
||||||
// IDs of the the EV charger operator
|
// IDs of the the EV charger operator
|
||||||
Operators []string `json:"operators"`
|
Operators []string `json:"operators"`
|
||||||
// Usage of the charge point (is it public, membership required, etc)
|
// Usage of the charge point (is it public, membership required, etc)
|
||||||
UsageTypes string `json:"usage_types"`
|
UsageTypes string `json:"usageTypes"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SearchResponse struct {
|
type SearchResponse struct {
|
||||||
@@ -225,21 +216,21 @@ type SearchResponse struct {
|
|||||||
|
|
||||||
type StatusType struct {
|
type StatusType struct {
|
||||||
Id string `json:"id"`
|
Id string `json:"id"`
|
||||||
IsOperational bool `json:"is_operational"`
|
IsOperational bool `json:"isOperational"`
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SubmissionStatusType struct {
|
type SubmissionStatusType struct {
|
||||||
Id string `json:"id"`
|
Id string `json:"id"`
|
||||||
IsLive bool `json:"is_live"`
|
IsLive bool `json:"isLive"`
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type UsageType struct {
|
type UsageType struct {
|
||||||
Id string `json:"id"`
|
Id string `json:"id"`
|
||||||
IsAccessKeyRequired bool `json:"is_access_key_required"`
|
IsAccessKeyRequired bool `json:"isAccessKeyRequired"`
|
||||||
IsMembershipRequired bool `json:"is_membership_required"`
|
IsMembershipRequired bool `json:"isMembershipRequired"`
|
||||||
IsPayAtLocation bool `json:"is_pay_at_location"`
|
IsPayAtLocation bool `json:"isPayAtLocation"`
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
116
event/event.go
116
event/event.go
@@ -1,116 +0,0 @@
|
|||||||
package event
|
|
||||||
|
|
||||||
import (
|
|
||||||
"go.m3o.com/client"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Event interface {
|
|
||||||
Consume(*ConsumeRequest) (*ConsumeResponseStream, error)
|
|
||||||
Publish(*PublishRequest) (*PublishResponse, error)
|
|
||||||
Read(*ReadRequest) (*ReadResponse, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewEventService(token string) *EventService {
|
|
||||||
return &EventService{
|
|
||||||
client: client.NewClient(&client.Options{
|
|
||||||
Token: token,
|
|
||||||
}),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type EventService struct {
|
|
||||||
client *client.Client
|
|
||||||
}
|
|
||||||
|
|
||||||
// Consume events from a given topic.
|
|
||||||
func (t *EventService) Consume(request *ConsumeRequest) (*ConsumeResponseStream, error) {
|
|
||||||
stream, err := t.client.Stream("event", "Consume", request)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &ConsumeResponseStream{
|
|
||||||
stream: stream,
|
|
||||||
}, nil
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
type ConsumeResponseStream struct {
|
|
||||||
stream *client.Stream
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t *ConsumeResponseStream) Recv() (*ConsumeResponse, error) {
|
|
||||||
var rsp ConsumeResponse
|
|
||||||
if err := t.stream.Recv(&rsp); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &rsp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Publish a event to the event stream.
|
|
||||||
func (t *EventService) Publish(request *PublishRequest) (*PublishResponse, error) {
|
|
||||||
|
|
||||||
rsp := &PublishResponse{}
|
|
||||||
return rsp, t.client.Call("event", "Publish", request, rsp)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read stored events
|
|
||||||
func (t *EventService) Read(request *ReadRequest) (*ReadResponse, error) {
|
|
||||||
|
|
||||||
rsp := &ReadResponse{}
|
|
||||||
return rsp, t.client.Call("event", "Read", request, rsp)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
type ConsumeRequest struct {
|
|
||||||
// Optional group for the subscription
|
|
||||||
Group string `json:"group"`
|
|
||||||
// Optional offset to read from e.g "2006-01-02T15:04:05.999Z07:00"
|
|
||||||
Offset string `json:"offset"`
|
|
||||||
// The topic to subscribe to
|
|
||||||
Topic string `json:"topic"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type ConsumeResponse struct {
|
|
||||||
// Unique message id
|
|
||||||
Id string `json:"id"`
|
|
||||||
// The next json message on the topic
|
|
||||||
Message map[string]interface{} `json:"message"`
|
|
||||||
// Timestamp of publishing
|
|
||||||
Timestamp string `json:"timestamp"`
|
|
||||||
// The topic subscribed to
|
|
||||||
Topic string `json:"topic"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type Ev struct {
|
|
||||||
// event id
|
|
||||||
Id string `json:"id"`
|
|
||||||
// event message
|
|
||||||
Message map[string]interface{} `json:"message"`
|
|
||||||
// event timestamp
|
|
||||||
Timestamp string `json:"timestamp"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type PublishRequest struct {
|
|
||||||
// The json message to publish
|
|
||||||
Message map[string]interface{} `json:"message"`
|
|
||||||
// The topic to publish to
|
|
||||||
Topic string `json:"topic"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type PublishResponse struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
type ReadRequest struct {
|
|
||||||
// number of events to read; default 25
|
|
||||||
Limit int32 `json:"limit"`
|
|
||||||
// offset for the events; default 0
|
|
||||||
Offset int32 `json:"offset"`
|
|
||||||
// topic to read from
|
|
||||||
Topic string `json:"topic"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type ReadResponse struct {
|
|
||||||
// the events
|
|
||||||
Events []Ev `json:"events"`
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
# Address
|
# Address
|
||||||
|
|
||||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/address/api](https://m3o.com/address/api).
|
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Address/api](https://m3o.com/Address/api).
|
||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
@@ -29,6 +29,5 @@ func LookupPostcode() {
|
|||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/address"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Lookup a list of UK addresses by postcode
|
|
||||||
func main() {
|
|
||||||
addressService := address.NewAddressService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := addressService.LookupPostcode(&address.LookupPostcodeRequest{
|
|
||||||
Postcode: "SW1A 2AA",
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
# Answer
|
# Answer
|
||||||
|
|
||||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/answer/api](https://m3o.com/answer/api).
|
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Answer/api](https://m3o.com/Answer/api).
|
||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
@@ -29,6 +29,5 @@ func AskAquestion() {
|
|||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/answer"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Ask a question and receive an instant answer
|
|
||||||
func main() {
|
|
||||||
answerService := answer.NewAnswerService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := answerService.Question(&answer.QuestionRequest{
|
|
||||||
Query: "microsoft",
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
}
|
|
||||||
@@ -1,232 +0,0 @@
|
|||||||
# App
|
|
||||||
|
|
||||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/app/api](https://m3o.com/app/api).
|
|
||||||
|
|
||||||
Endpoints:
|
|
||||||
|
|
||||||
## Resolve
|
|
||||||
|
|
||||||
Resolve an app by id to its raw backend endpoint
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/app/api#Resolve](https://m3o.com/app/api#Resolve)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/app"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Resolve an app by id to its raw backend endpoint
|
|
||||||
func ResolveAppById() {
|
|
||||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := appService.Resolve(&app.ResolveRequest{
|
|
||||||
Id: "helloworld",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Update
|
|
||||||
|
|
||||||
Update the app. The latest source code will be downloaded, built and deployed.
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/app/api#Update](https://m3o.com/app/api#Update)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/app"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Update the app. The latest source code will be downloaded, built and deployed.
|
|
||||||
func UpdateAnApp() {
|
|
||||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := appService.Update(&app.UpdateRequest{
|
|
||||||
Name: "helloworld",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Delete
|
|
||||||
|
|
||||||
Delete an app
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/app/api#Delete](https://m3o.com/app/api#Delete)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/app"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Delete an app
|
|
||||||
func DeleteAnApp() {
|
|
||||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := appService.Delete(&app.DeleteRequest{
|
|
||||||
Name: "helloworld",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Reserve
|
|
||||||
|
|
||||||
Reserve apps beyond the free quota. Call Run after.
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/app/api#Reserve](https://m3o.com/app/api#Reserve)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/app"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Reserve apps beyond the free quota. Call Run after.
|
|
||||||
func ReserveAppName() {
|
|
||||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := appService.Reserve(&app.ReserveRequest{
|
|
||||||
Name: "helloworld",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## List
|
|
||||||
|
|
||||||
List 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 an app from source
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/app/api#Run](https://m3o.com/app/api#Run)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/app"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Run an app from source
|
|
||||||
func RunAnApp() {
|
|
||||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := appService.Run(&app.RunRequest{
|
|
||||||
Branch: "master",
|
|
||||||
Name: "helloworld",
|
|
||||||
Port: 8080,
|
|
||||||
Region: "europe-west1",
|
|
||||||
Repo: "github.com/asim/helloworld",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Regions
|
|
||||||
|
|
||||||
Return the support regions
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/app/api#Regions](https://m3o.com/app/api#Regions)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/app"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Return the support regions
|
|
||||||
func ListRegions() {
|
|
||||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := appService.Regions(&app.RegionsRequest{
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## 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)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/app"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Delete an app
|
|
||||||
func main() {
|
|
||||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := appService.Delete(&app.DeleteRequest{
|
|
||||||
Name: "helloworld",
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/app"
|
|
||||||
)
|
|
||||||
|
|
||||||
// List all the apps
|
|
||||||
func main() {
|
|
||||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := appService.List(&app.ListRequest{})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/app"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Return the support regions
|
|
||||||
func main() {
|
|
||||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := appService.Regions(&app.RegionsRequest{})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/app"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Reserve apps beyond the free quota. Call Run after.
|
|
||||||
func main() {
|
|
||||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := appService.Reserve(&app.ReserveRequest{
|
|
||||||
Name: "helloworld",
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/app"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Resolve an app by id to its raw backend endpoint
|
|
||||||
func main() {
|
|
||||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := appService.Resolve(&app.ResolveRequest{
|
|
||||||
Id: "helloworld",
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/app"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Run an app from source
|
|
||||||
func main() {
|
|
||||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := appService.Run(&app.RunRequest{
|
|
||||||
Branch: "master",
|
|
||||||
Name: "helloworld",
|
|
||||||
Port: 8080,
|
|
||||||
Region: "europe-west1",
|
|
||||||
Repo: "github.com/asim/helloworld",
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/app"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Get the status of an app
|
|
||||||
func main() {
|
|
||||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := appService.Status(&app.StatusRequest{
|
|
||||||
Name: "helloworld",
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/app"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Update the app. The latest source code will be downloaded, built and deployed.
|
|
||||||
func main() {
|
|
||||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := appService.Update(&app.UpdateRequest{
|
|
||||||
Name: "helloworld",
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
}
|
|
||||||
@@ -1,68 +0,0 @@
|
|||||||
# Avatar
|
|
||||||
|
|
||||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/avatar/api](https://m3o.com/avatar/api).
|
|
||||||
|
|
||||||
Endpoints:
|
|
||||||
|
|
||||||
## Generate
|
|
||||||
|
|
||||||
Generate an unique avatar
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/avatar/api#Generate](https://m3o.com/avatar/api#Generate)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/avatar"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Generate an unique avatar
|
|
||||||
func GenerateAvatarAndReturnBase64stringOfTheAvatar() {
|
|
||||||
avatarService := avatar.NewAvatarService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := avatarService.Generate(&avatar.GenerateRequest{
|
|
||||||
Format: "jpeg",
|
|
||||||
Gender: "female",
|
|
||||||
Upload: false,
|
|
||||||
Username: "",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Generate
|
|
||||||
|
|
||||||
Generate an unique avatar
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/avatar/api#Generate](https://m3o.com/avatar/api#Generate)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/avatar"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Generate an unique avatar
|
|
||||||
func GenerateAnAvatarAndUploadTheAvatarToMicrosCdn() {
|
|
||||||
avatarService := avatar.NewAvatarService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := avatarService.Generate(&avatar.GenerateRequest{
|
|
||||||
Format: "png",
|
|
||||||
Gender: "female",
|
|
||||||
Upload: true,
|
|
||||||
Username: "",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/avatar"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Generate an unique avatar
|
|
||||||
func main() {
|
|
||||||
avatarService := avatar.NewAvatarService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := avatarService.Generate(&avatar.GenerateRequest{
|
|
||||||
Format: "png",
|
|
||||||
Gender: "female",
|
|
||||||
Upload: true,
|
|
||||||
Username: "",
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/avatar"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Generate an unique avatar
|
|
||||||
func main() {
|
|
||||||
avatarService := avatar.NewAvatarService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := avatarService.Generate(&avatar.GenerateRequest{
|
|
||||||
Format: "jpeg",
|
|
||||||
Gender: "female",
|
|
||||||
Upload: false,
|
|
||||||
Username: "",
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
}
|
|
||||||
102
examples/cache/README.md
vendored
102
examples/cache/README.md
vendored
@@ -1,65 +1,9 @@
|
|||||||
# Cache
|
# Cache
|
||||||
|
|
||||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/cache/api](https://m3o.com/cache/api).
|
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Cache/api](https://m3o.com/Cache/api).
|
||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
## Decrement
|
|
||||||
|
|
||||||
Decrement a value (if it's a number). If key not found it is equivalent to set.
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/cache/api#Decrement](https://m3o.com/cache/api#Decrement)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/cache"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Decrement a value (if it's a number). If key not found it is equivalent to set.
|
|
||||||
func DecrementAvalue() {
|
|
||||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := cacheService.Decrement(&cache.DecrementRequest{
|
|
||||||
Key: "counter",
|
|
||||||
Value: 2,
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## ListKeys
|
|
||||||
|
|
||||||
List all the available keys
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/cache/api#ListKeys](https://m3o.com/cache/api#ListKeys)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/cache"
|
|
||||||
)
|
|
||||||
|
|
||||||
// List all the available keys
|
|
||||||
func ListTheKeys() {
|
|
||||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := cacheService.ListKeys(&cache.ListKeysRequest{
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Set
|
## Set
|
||||||
|
|
||||||
Set an item in the cache. Overwrites any existing value already set.
|
Set an item in the cache. Overwrites any existing value already set.
|
||||||
@@ -86,12 +30,11 @@ Value: "bar",
|
|||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Get
|
## Get
|
||||||
|
|
||||||
Get an item from the cache by key. If key is not found, an empty response is returned.
|
Get an item from the cache by key
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/cache/api#Get](https://m3o.com/cache/api#Get)
|
[https://m3o.com/cache/api#Get](https://m3o.com/cache/api#Get)
|
||||||
@@ -106,7 +49,7 @@ import(
|
|||||||
"go.m3o.com/cache"
|
"go.m3o.com/cache"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Get an item from the cache by key. If key is not found, an empty response is returned.
|
// Get an item from the cache by key
|
||||||
func GetAvalue() {
|
func GetAvalue() {
|
||||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := cacheService.Get(&cache.GetRequest{
|
rsp, err := cacheService.Get(&cache.GetRequest{
|
||||||
@@ -114,12 +57,11 @@ func GetAvalue() {
|
|||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Delete
|
## Delete
|
||||||
|
|
||||||
Delete a value from the cache. If key not found a success response is returned.
|
Delete a value from the cache
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/cache/api#Delete](https://m3o.com/cache/api#Delete)
|
[https://m3o.com/cache/api#Delete](https://m3o.com/cache/api#Delete)
|
||||||
@@ -134,7 +76,7 @@ import(
|
|||||||
"go.m3o.com/cache"
|
"go.m3o.com/cache"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Delete a value from the cache. If key not found a success response is returned.
|
// Delete a value from the cache
|
||||||
func DeleteAvalue() {
|
func DeleteAvalue() {
|
||||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := cacheService.Delete(&cache.DeleteRequest{
|
rsp, err := cacheService.Delete(&cache.DeleteRequest{
|
||||||
@@ -142,12 +84,11 @@ func DeleteAvalue() {
|
|||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Increment
|
## Increment
|
||||||
|
|
||||||
Increment a value (if it's a number). If key not found it is equivalent to set.
|
Increment a value (if it's a number)
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/cache/api#Increment](https://m3o.com/cache/api#Increment)
|
[https://m3o.com/cache/api#Increment](https://m3o.com/cache/api#Increment)
|
||||||
@@ -162,7 +103,7 @@ import(
|
|||||||
"go.m3o.com/cache"
|
"go.m3o.com/cache"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Increment a value (if it's a number). If key not found it is equivalent to set.
|
// Increment a value (if it's a number)
|
||||||
func IncrementAvalue() {
|
func IncrementAvalue() {
|
||||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := cacheService.Increment(&cache.IncrementRequest{
|
rsp, err := cacheService.Increment(&cache.IncrementRequest{
|
||||||
@@ -171,6 +112,33 @@ Value: 2,
|
|||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Decrement
|
||||||
|
|
||||||
|
Decrement a value (if it's a number)
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/cache/api#Decrement](https://m3o.com/cache/api#Decrement)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/cache"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Decrement a value (if it's a number)
|
||||||
|
func DecrementAvalue() {
|
||||||
|
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := cacheService.Decrement(&cache.DecrementRequest{
|
||||||
|
Key: "counter",
|
||||||
|
Value: 2,
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
2
examples/cache/decrement/decrementAValue.go
vendored
2
examples/cache/decrement/decrementAValue.go
vendored
@@ -7,7 +7,7 @@ import (
|
|||||||
"go.m3o.com/cache"
|
"go.m3o.com/cache"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Decrement a value (if it's a number). If key not found it is equivalent to set.
|
// Decrement a value (if it's a number)
|
||||||
func DecrementAvalue() {
|
func DecrementAvalue() {
|
||||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := cacheService.Decrement(&cache.DecrementRequest{
|
rsp, err := cacheService.Decrement(&cache.DecrementRequest{
|
||||||
|
|||||||
18
examples/cache/decrement/decrementAValue/main.go
vendored
18
examples/cache/decrement/decrementAValue/main.go
vendored
@@ -1,18 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/cache"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Decrement a value (if it's a number). If key not found it is equivalent to set.
|
|
||||||
func main() {
|
|
||||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := cacheService.Decrement(&cache.DecrementRequest{
|
|
||||||
Key: "counter",
|
|
||||||
Value: 2,
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
}
|
|
||||||
2
examples/cache/delete/deleteAValue.go
vendored
2
examples/cache/delete/deleteAValue.go
vendored
@@ -7,7 +7,7 @@ import (
|
|||||||
"go.m3o.com/cache"
|
"go.m3o.com/cache"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Delete a value from the cache. If key not found a success response is returned.
|
// Delete a value from the cache
|
||||||
func DeleteAvalue() {
|
func DeleteAvalue() {
|
||||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := cacheService.Delete(&cache.DeleteRequest{
|
rsp, err := cacheService.Delete(&cache.DeleteRequest{
|
||||||
|
|||||||
17
examples/cache/delete/deleteAValue/main.go
vendored
17
examples/cache/delete/deleteAValue/main.go
vendored
@@ -1,17 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/cache"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Delete a value from the cache. If key not found a success response is returned.
|
|
||||||
func main() {
|
|
||||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := cacheService.Delete(&cache.DeleteRequest{
|
|
||||||
Key: "foo",
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
}
|
|
||||||
2
examples/cache/get/getAValue.go
vendored
2
examples/cache/get/getAValue.go
vendored
@@ -7,7 +7,7 @@ import (
|
|||||||
"go.m3o.com/cache"
|
"go.m3o.com/cache"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Get an item from the cache by key. If key is not found, an empty response is returned.
|
// Get an item from the cache by key
|
||||||
func GetAvalue() {
|
func GetAvalue() {
|
||||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := cacheService.Get(&cache.GetRequest{
|
rsp, err := cacheService.Get(&cache.GetRequest{
|
||||||
|
|||||||
17
examples/cache/get/getAValue/main.go
vendored
17
examples/cache/get/getAValue/main.go
vendored
@@ -1,17 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/cache"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Get an item from the cache by key. If key is not found, an empty response is returned.
|
|
||||||
func main() {
|
|
||||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := cacheService.Get(&cache.GetRequest{
|
|
||||||
Key: "foo",
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
}
|
|
||||||
2
examples/cache/increment/incrementAValue.go
vendored
2
examples/cache/increment/incrementAValue.go
vendored
@@ -7,7 +7,7 @@ import (
|
|||||||
"go.m3o.com/cache"
|
"go.m3o.com/cache"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Increment a value (if it's a number). If key not found it is equivalent to set.
|
// Increment a value (if it's a number)
|
||||||
func IncrementAvalue() {
|
func IncrementAvalue() {
|
||||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := cacheService.Increment(&cache.IncrementRequest{
|
rsp, err := cacheService.Increment(&cache.IncrementRequest{
|
||||||
|
|||||||
18
examples/cache/increment/incrementAValue/main.go
vendored
18
examples/cache/increment/incrementAValue/main.go
vendored
@@ -1,18 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/cache"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Increment a value (if it's a number). If key not found it is equivalent to set.
|
|
||||||
func main() {
|
|
||||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := cacheService.Increment(&cache.IncrementRequest{
|
|
||||||
Key: "counter",
|
|
||||||
Value: 2,
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
}
|
|
||||||
15
examples/cache/listKeys/listTheKeys/main.go
vendored
15
examples/cache/listKeys/listTheKeys/main.go
vendored
@@ -1,15 +0,0 @@
|
|||||||
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)
|
|
||||||
}
|
|
||||||
0
examples/cache/set/setAValue/.run
vendored
0
examples/cache/set/setAValue/.run
vendored
18
examples/cache/set/setAValue/main.go
vendored
18
examples/cache/set/setAValue/main.go
vendored
@@ -1,18 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/cache"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Set an item in the cache. Overwrites any existing value already set.
|
|
||||||
func main() {
|
|
||||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := cacheService.Set(&cache.SetRequest{
|
|
||||||
Key: "foo",
|
|
||||||
Value: "bar",
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
# 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)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
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)
|
|
||||||
}
|
|
||||||
@@ -1,269 +0,0 @@
|
|||||||
# Chat
|
|
||||||
|
|
||||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/chat/api](https://m3o.com/chat/api).
|
|
||||||
|
|
||||||
Endpoints:
|
|
||||||
|
|
||||||
## Create
|
|
||||||
|
|
||||||
Create a new chat room
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/chat/api#Create](https://m3o.com/chat/api#Create)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/chat"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Create a new chat room
|
|
||||||
func CreateAnewChat() {
|
|
||||||
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := chatService.Create(&chat.CreateRequest{
|
|
||||||
Description: "The general chat room",
|
|
||||||
Name: "general",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Invite
|
|
||||||
|
|
||||||
Invite a user to a chat room
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/chat/api#Invite](https://m3o.com/chat/api#Invite)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/chat"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Invite a user to a chat room
|
|
||||||
func InviteAuser() {
|
|
||||||
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := chatService.Invite(&chat.InviteRequest{
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Send
|
|
||||||
|
|
||||||
Connect to a chat to receive a stream of messages
|
|
||||||
Send a message to a chat
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/chat/api#Send](https://m3o.com/chat/api#Send)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/chat"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Connect to a chat to receive a stream of messages
|
|
||||||
// Send a message to a chat
|
|
||||||
func SendAmessage() {
|
|
||||||
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := chatService.Send(&chat.SendRequest{
|
|
||||||
Client: "web",
|
|
||||||
Subject: "Random",
|
|
||||||
Text: "Hey whats up?",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## History
|
|
||||||
|
|
||||||
List the messages in a chat
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/chat/api#History](https://m3o.com/chat/api#History)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/chat"
|
|
||||||
)
|
|
||||||
|
|
||||||
// List the messages in a chat
|
|
||||||
func GetChatHistory() {
|
|
||||||
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := chatService.History(&chat.HistoryRequest{
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Join
|
|
||||||
|
|
||||||
Join a chat room
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/chat/api#Join](https://m3o.com/chat/api#Join)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/chat"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Join a chat room
|
|
||||||
func JoinAroom() {
|
|
||||||
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
|
|
||||||
stream, err := chatService.Join(&chat.JoinRequest{
|
|
||||||
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
for {
|
|
||||||
rsp, err := stream.Recv()
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Println(rsp)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Kick
|
|
||||||
|
|
||||||
Kick a user from a chat room
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/chat/api#Kick](https://m3o.com/chat/api#Kick)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/chat"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Kick a user from a chat room
|
|
||||||
func KickAuserFromAroom() {
|
|
||||||
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := chatService.Kick(&chat.KickRequest{
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Leave
|
|
||||||
|
|
||||||
Leave a chat room
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/chat/api#Leave](https://m3o.com/chat/api#Leave)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/chat"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Leave a chat room
|
|
||||||
func LeaveAroom() {
|
|
||||||
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := chatService.Leave(&chat.LeaveRequest{
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## List
|
|
||||||
|
|
||||||
List available chats
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/chat/api#List](https://m3o.com/chat/api#List)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/chat"
|
|
||||||
)
|
|
||||||
|
|
||||||
// List available chats
|
|
||||||
func ListChatRooms() {
|
|
||||||
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := chatService.List(&chat.ListRequest{
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Delete
|
|
||||||
|
|
||||||
Delete a chat room
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/chat/api#Delete](https://m3o.com/chat/api#Delete)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/chat"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Delete a chat room
|
|
||||||
func DeleteAchat() {
|
|
||||||
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := chatService.Delete(&chat.DeleteRequest{
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/chat"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Create a new chat room
|
|
||||||
func main() {
|
|
||||||
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := chatService.Create(&chat.CreateRequest{
|
|
||||||
Description: "The general chat room",
|
|
||||||
Name: "general",
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/chat"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Delete a chat room
|
|
||||||
func main() {
|
|
||||||
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := chatService.Delete(&chat.DeleteRequest{})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/chat"
|
|
||||||
)
|
|
||||||
|
|
||||||
// List the messages in a chat
|
|
||||||
func main() {
|
|
||||||
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := chatService.History(&chat.HistoryRequest{})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/chat"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Invite a user to a chat room
|
|
||||||
func main() {
|
|
||||||
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := chatService.Invite(&chat.InviteRequest{})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/chat"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Join a chat room
|
|
||||||
func main() {
|
|
||||||
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
stream, err := chatService.Join(&chat.JoinRequest{})
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
for {
|
|
||||||
rsp, err := stream.Recv()
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Println(rsp)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/chat"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Kick a user from a chat room
|
|
||||||
func main() {
|
|
||||||
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := chatService.Kick(&chat.KickRequest{})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/chat"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Leave a chat room
|
|
||||||
func main() {
|
|
||||||
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := chatService.Leave(&chat.LeaveRequest{})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/chat"
|
|
||||||
)
|
|
||||||
|
|
||||||
// List available chats
|
|
||||||
func main() {
|
|
||||||
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := chatService.List(&chat.ListRequest{})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/chat"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Connect to a chat to receive a stream of messages
|
|
||||||
// Send a message to a chat
|
|
||||||
func main() {
|
|
||||||
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := chatService.Send(&chat.SendRequest{
|
|
||||||
Client: "web",
|
|
||||||
Subject: "Random",
|
|
||||||
Text: "Hey whats up?",
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
}
|
|
||||||
@@ -1,190 +0,0 @@
|
|||||||
# 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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
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)
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
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)
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
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)
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
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)
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/comments"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Update a comment
|
|
||||||
func main() {
|
|
||||||
commentsService := comments.NewCommentsService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := commentsService.Update(&comments.UpdateRequest{
|
|
||||||
Comment: &comments.Comment{
|
|
||||||
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
|
|
||||||
Subject: "Update Comment",
|
|
||||||
Text: "Updated comment text",
|
|
||||||
},
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
}
|
|
||||||
@@ -1,219 +0,0 @@
|
|||||||
# Contact
|
|
||||||
|
|
||||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/contact/api](https://m3o.com/contact/api).
|
|
||||||
|
|
||||||
Endpoints:
|
|
||||||
|
|
||||||
## Delete
|
|
||||||
|
|
||||||
Delete a contact
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/contact/api#Delete](https://m3o.com/contact/api#Delete)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/contact"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Delete a contact
|
|
||||||
func DeleteAcontact() {
|
|
||||||
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := contactService.Delete(&contact.DeleteRequest{
|
|
||||||
Id: "42e48a3c-6221-11ec-96d2-acde48001122",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## List
|
|
||||||
|
|
||||||
List contacts
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/contact/api#List](https://m3o.com/contact/api#List)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/contact"
|
|
||||||
)
|
|
||||||
|
|
||||||
// List contacts
|
|
||||||
func ListContactsWithDefaultOffsetAndLimitDefaultLimitIs20() {
|
|
||||||
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := contactService.List(&contact.ListRequest{
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## List
|
|
||||||
|
|
||||||
List contacts
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/contact/api#List](https://m3o.com/contact/api#List)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/contact"
|
|
||||||
)
|
|
||||||
|
|
||||||
// List contacts
|
|
||||||
func ListContactsWithSpecificOffsetAndLimit() {
|
|
||||||
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := contactService.List(&contact.ListRequest{
|
|
||||||
Limit: 1,
|
|
||||||
Offset: 1,
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Create
|
|
||||||
|
|
||||||
Create a contact
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/contact/api#Create](https://m3o.com/contact/api#Create)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/contact"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Create a contact
|
|
||||||
func CreateAcontact() {
|
|
||||||
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := contactService.Create(&contact.CreateRequest{
|
|
||||||
Addresses: []contact.Address{
|
|
||||||
contact.Address{
|
|
||||||
Label: "company address",
|
|
||||||
Location: "123 street address",
|
|
||||||
}},
|
|
||||||
Birthday: "1995-01-01",
|
|
||||||
Emails: []contact.Email{
|
|
||||||
contact.Email{
|
|
||||||
Address: "home@example.com",
|
|
||||||
Label: "home",
|
|
||||||
}},
|
|
||||||
Links: []contact.Link{
|
|
||||||
contact.Link{
|
|
||||||
Label: "blog",
|
|
||||||
Url: "https://blog.joe.me",
|
|
||||||
}},
|
|
||||||
Name: "joe",
|
|
||||||
Note: "this person is very important",
|
|
||||||
Phones: []contact.Phone{
|
|
||||||
contact.Phone{
|
|
||||||
Label: "home",
|
|
||||||
Number: "010-12345678",
|
|
||||||
}},
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Update
|
|
||||||
|
|
||||||
Update a contact
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/contact/api#Update](https://m3o.com/contact/api#Update)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/contact"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Update a contact
|
|
||||||
func UpdateAcontact() {
|
|
||||||
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := contactService.Update(&contact.UpdateRequest{
|
|
||||||
Addresses: []contact.Address{
|
|
||||||
contact.Address{
|
|
||||||
Label: "company address",
|
|
||||||
Location: "123 street address",
|
|
||||||
}},
|
|
||||||
Birthday: "1995-01-01",
|
|
||||||
Emails: []contact.Email{
|
|
||||||
contact.Email{
|
|
||||||
Address: "home@example.com",
|
|
||||||
Label: "home",
|
|
||||||
}},
|
|
||||||
Id: "42e48a3c-6221-11ec-96d2-acde48001122",
|
|
||||||
Links: []contact.Link{
|
|
||||||
contact.Link{
|
|
||||||
Label: "blog",
|
|
||||||
Url: "https://blog.joe.me",
|
|
||||||
}},
|
|
||||||
Name: "joe",
|
|
||||||
Note: "this person is very important",
|
|
||||||
Phones: []contact.Phone{
|
|
||||||
contact.Phone{
|
|
||||||
Label: "home",
|
|
||||||
Number: "010-12345678",
|
|
||||||
}},
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Read
|
|
||||||
|
|
||||||
Read contact details
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/contact/api#Read](https://m3o.com/contact/api#Read)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/contact"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Read contact details
|
|
||||||
func GetAcontact() {
|
|
||||||
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := contactService.Read(&contact.ReadRequest{
|
|
||||||
Id: "42e48a3c-6221-11ec-96d2-acde48001122",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/contact"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Create a contact
|
|
||||||
func main() {
|
|
||||||
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := contactService.Create(&contact.CreateRequest{
|
|
||||||
Addresses: []contact.Address{
|
|
||||||
contact.Address{
|
|
||||||
Label: "company address",
|
|
||||||
Location: "123 street address",
|
|
||||||
}},
|
|
||||||
Birthday: "1995-01-01",
|
|
||||||
Emails: []contact.Email{
|
|
||||||
contact.Email{
|
|
||||||
Address: "home@example.com",
|
|
||||||
Label: "home",
|
|
||||||
}},
|
|
||||||
Links: []contact.Link{
|
|
||||||
contact.Link{
|
|
||||||
Label: "blog",
|
|
||||||
Url: "https://blog.joe.me",
|
|
||||||
}},
|
|
||||||
Name: "joe",
|
|
||||||
Note: "this person is very important",
|
|
||||||
Phones: []contact.Phone{
|
|
||||||
contact.Phone{
|
|
||||||
Label: "home",
|
|
||||||
Number: "010-12345678",
|
|
||||||
}},
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/contact"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Delete a contact
|
|
||||||
func main() {
|
|
||||||
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := contactService.Delete(&contact.DeleteRequest{
|
|
||||||
Id: "42e48a3c-6221-11ec-96d2-acde48001122",
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/contact"
|
|
||||||
)
|
|
||||||
|
|
||||||
// List contacts
|
|
||||||
func main() {
|
|
||||||
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := contactService.List(&contact.ListRequest{})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/contact"
|
|
||||||
)
|
|
||||||
|
|
||||||
// List contacts
|
|
||||||
func main() {
|
|
||||||
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := contactService.List(&contact.ListRequest{
|
|
||||||
Limit: 1,
|
|
||||||
Offset: 1,
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/contact"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Read contact details
|
|
||||||
func main() {
|
|
||||||
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := contactService.Read(&contact.ReadRequest{
|
|
||||||
Id: "42e48a3c-6221-11ec-96d2-acde48001122",
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
}
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/contact"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Update a contact
|
|
||||||
func main() {
|
|
||||||
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := contactService.Update(&contact.UpdateRequest{
|
|
||||||
Addresses: []contact.Address{
|
|
||||||
contact.Address{
|
|
||||||
Label: "company address",
|
|
||||||
Location: "123 street address",
|
|
||||||
}},
|
|
||||||
Birthday: "1995-01-01",
|
|
||||||
Emails: []contact.Email{
|
|
||||||
contact.Email{
|
|
||||||
Address: "home@example.com",
|
|
||||||
Label: "home",
|
|
||||||
}},
|
|
||||||
Id: "42e48a3c-6221-11ec-96d2-acde48001122",
|
|
||||||
Links: []contact.Link{
|
|
||||||
contact.Link{
|
|
||||||
Label: "blog",
|
|
||||||
Url: "https://blog.joe.me",
|
|
||||||
}},
|
|
||||||
Name: "joe",
|
|
||||||
Note: "this person is very important",
|
|
||||||
Phones: []contact.Phone{
|
|
||||||
contact.Phone{
|
|
||||||
Label: "home",
|
|
||||||
Number: "010-12345678",
|
|
||||||
}},
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
# Crypto
|
# Crypto
|
||||||
|
|
||||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/crypto/api](https://m3o.com/crypto/api).
|
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Crypto/api](https://m3o.com/Crypto/api).
|
||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
@@ -29,7 +29,6 @@ func GetCryptocurrencyNews() {
|
|||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Price
|
## Price
|
||||||
@@ -57,7 +56,6 @@ func GetCryptocurrencyPrice() {
|
|||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Quote
|
## Quote
|
||||||
@@ -85,7 +83,6 @@ func GetAcryptocurrencyQuote() {
|
|||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## History
|
## History
|
||||||
@@ -113,33 +110,5 @@ func GetPreviousClose() {
|
|||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Symbols
|
|
||||||
|
|
||||||
Returns the full list of supported symbols
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/crypto/api#Symbols](https://m3o.com/crypto/api#Symbols)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/crypto"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Returns the full list of supported symbols
|
|
||||||
func GetListOfAllSupportedSymbols() {
|
|
||||||
cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := cryptoService.Symbols(&crypto.SymbolsRequest{
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/crypto"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Returns the history for the previous close
|
|
||||||
func main() {
|
|
||||||
cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := cryptoService.History(&crypto.HistoryRequest{
|
|
||||||
Symbol: "BTCUSD",
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/crypto"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Get news related to a currency
|
|
||||||
func main() {
|
|
||||||
cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := cryptoService.News(&crypto.NewsRequest{
|
|
||||||
Symbol: "BTCUSD",
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/crypto"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Get the last price for a given crypto ticker
|
|
||||||
func main() {
|
|
||||||
cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := cryptoService.Price(&crypto.PriceRequest{
|
|
||||||
Symbol: "BTCUSD",
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/crypto"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Get the last quote for a given crypto ticker
|
|
||||||
func main() {
|
|
||||||
cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := cryptoService.Quote(&crypto.QuoteRequest{
|
|
||||||
Symbol: "BTCUSD",
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/crypto"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Returns the full list of supported symbols
|
|
||||||
func main() {
|
|
||||||
cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := cryptoService.Symbols(&crypto.SymbolsRequest{})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
# Currency
|
# Currency
|
||||||
|
|
||||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/currency/api](https://m3o.com/currency/api).
|
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Currency/api](https://m3o.com/Currency/api).
|
||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
@@ -28,7 +28,6 @@ func GetSupportedCodes() {
|
|||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Rates
|
## Rates
|
||||||
@@ -56,7 +55,6 @@ func GetRatesForUsd() {
|
|||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Convert
|
## Convert
|
||||||
@@ -85,7 +83,6 @@ To: "GBP",
|
|||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Convert
|
## Convert
|
||||||
@@ -115,7 +112,6 @@ To: "GBP",
|
|||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## History
|
## History
|
||||||
@@ -144,6 +140,5 @@ Date: "2021-05-30",
|
|||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/currency"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Codes returns the supported currency codes for the API
|
|
||||||
func main() {
|
|
||||||
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := currencyService.Codes(¤cy.CodesRequest{})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/currency"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Convert returns the currency conversion rate between two pairs e.g USD/GBP
|
|
||||||
func main() {
|
|
||||||
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := currencyService.Convert(¤cy.ConvertRequest{
|
|
||||||
Amount: 10,
|
|
||||||
From: "USD",
|
|
||||||
To: "GBP",
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/currency"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Convert returns the currency conversion rate between two pairs e.g USD/GBP
|
|
||||||
func main() {
|
|
||||||
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := currencyService.Convert(¤cy.ConvertRequest{
|
|
||||||
From: "USD",
|
|
||||||
To: "GBP",
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/currency"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Returns the historic rates for a currency on a given date
|
|
||||||
func main() {
|
|
||||||
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := currencyService.History(¤cy.HistoryRequest{
|
|
||||||
Code: "USD",
|
|
||||||
Date: "2021-05-30",
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/currency"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Rates returns the currency rates for a given code e.g USD
|
|
||||||
func main() {
|
|
||||||
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := currencyService.Rates(¤cy.RatesRequest{
|
|
||||||
Code: "USD",
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
# Db
|
# Db
|
||||||
|
|
||||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/db/api](https://m3o.com/db/api).
|
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Db/api](https://m3o.com/Db/api).
|
||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
@@ -26,16 +26,15 @@ func CreateArecord() {
|
|||||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := dbService.Create(&db.CreateRequest{
|
rsp, err := dbService.Create(&db.CreateRequest{
|
||||||
Record: map[string]interface{}{
|
Record: map[string]interface{}{
|
||||||
"isActive": true,
|
|
||||||
"id": "1",
|
"id": "1",
|
||||||
"name": "Jane",
|
"name": "Jane",
|
||||||
"age": 42,
|
"age": 42,
|
||||||
|
"isActive": true,
|
||||||
},
|
},
|
||||||
Table: "example",
|
Table: "users",
|
||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Update
|
## Update
|
||||||
@@ -60,71 +59,13 @@ func UpdateArecord() {
|
|||||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := dbService.Update(&db.UpdateRequest{
|
rsp, err := dbService.Update(&db.UpdateRequest{
|
||||||
Record: map[string]interface{}{
|
Record: map[string]interface{}{
|
||||||
"id": "1",
|
|
||||||
"age": 43,
|
"age": 43,
|
||||||
|
"id": "1",
|
||||||
},
|
},
|
||||||
Table: "example",
|
Table: "users",
|
||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Delete
|
|
||||||
|
|
||||||
Delete a record in the database by id.
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/db/api#Delete](https://m3o.com/db/api#Delete)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/db"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Delete a record in the database by id.
|
|
||||||
func DeleteArecord() {
|
|
||||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := dbService.Delete(&db.DeleteRequest{
|
|
||||||
Id: "1",
|
|
||||||
Table: "example",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Count
|
|
||||||
|
|
||||||
Count records in a table
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/db/api#Count](https://m3o.com/db/api#Count)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/db"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Count records in a table
|
|
||||||
func CountEntriesInAtable() {
|
|
||||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := dbService.Count(&db.CountRequest{
|
|
||||||
Table: "example",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Read
|
## Read
|
||||||
@@ -149,11 +90,38 @@ func ReadRecords() {
|
|||||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := dbService.Read(&db.ReadRequest{
|
rsp, err := dbService.Read(&db.ReadRequest{
|
||||||
Query: "age == 43",
|
Query: "age == 43",
|
||||||
Table: "example",
|
Table: "users",
|
||||||
|
|
||||||
})
|
})
|
||||||
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: "users",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Truncate
|
## Truncate
|
||||||
@@ -177,19 +145,18 @@ import(
|
|||||||
func TruncateTable() {
|
func TruncateTable() {
|
||||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := dbService.Truncate(&db.TruncateRequest{
|
rsp, err := dbService.Truncate(&db.TruncateRequest{
|
||||||
Table: "example",
|
Table: "users",
|
||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## DropTable
|
## Count
|
||||||
|
|
||||||
Drop a table in the DB
|
Count records in a table
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/db/api#DropTable](https://m3o.com/db/api#DropTable)
|
[https://m3o.com/db/api#Count](https://m3o.com/db/api#Count)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
package example
|
package example
|
||||||
@@ -201,70 +168,13 @@ import(
|
|||||||
"go.m3o.com/db"
|
"go.m3o.com/db"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Drop a table in the DB
|
// Count records in a table
|
||||||
func DropTable() {
|
func CountEntriesInAtable() {
|
||||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := dbService.DropTable(&db.DropTableRequest{
|
rsp, err := dbService.Count(&db.CountRequest{
|
||||||
Table: "example",
|
Table: "users",
|
||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## ListTables
|
|
||||||
|
|
||||||
List tables in the DB
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/db/api#ListTables](https://m3o.com/db/api#ListTables)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/db"
|
|
||||||
)
|
|
||||||
|
|
||||||
// List tables in the DB
|
|
||||||
func ListTables() {
|
|
||||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := dbService.ListTables(&db.ListTablesRequest{
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## RenameTable
|
|
||||||
|
|
||||||
Rename a table
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/db/api#RenameTable](https://m3o.com/db/api#RenameTable)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/db"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Rename a table
|
|
||||||
func RenameTable() {
|
|
||||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := dbService.RenameTable(&db.RenameTableRequest{
|
|
||||||
From: "examples2",
|
|
||||||
To: "examples3",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/db"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Count records in a table
|
|
||||||
func main() {
|
|
||||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := dbService.Count(&db.CountRequest{
|
|
||||||
Table: "example",
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/db"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
|
|
||||||
func main() {
|
|
||||||
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)
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/db"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Delete a record in the database by id.
|
|
||||||
func main() {
|
|
||||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := dbService.Delete(&db.DeleteRequest{
|
|
||||||
Id: "1",
|
|
||||||
Table: "example",
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/db"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Drop a table in the DB
|
|
||||||
func main() {
|
|
||||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := dbService.DropTable(&db.DropTableRequest{
|
|
||||||
Table: "example",
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/db"
|
|
||||||
)
|
|
||||||
|
|
||||||
// List tables in the DB
|
|
||||||
func main() {
|
|
||||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := dbService.ListTables(&db.ListTablesRequest{})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/db"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Read data from a table. Lookup can be by ID or via querying any field in the record.
|
|
||||||
func main() {
|
|
||||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := dbService.Read(&db.ReadRequest{
|
|
||||||
Query: "age == 43",
|
|
||||||
Table: "example",
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/db"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Rename a table
|
|
||||||
func main() {
|
|
||||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := dbService.RenameTable(&db.RenameTableRequest{
|
|
||||||
From: "examples2",
|
|
||||||
To: "examples3",
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/db"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Truncate the records in a table
|
|
||||||
func main() {
|
|
||||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := dbService.Truncate(&db.TruncateRequest{
|
|
||||||
Table: "example",
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/db"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Update a record in the database. Include an "id" in the record to update.
|
|
||||||
func main() {
|
|
||||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := dbService.Update(&db.UpdateRequest{
|
|
||||||
Record: map[string]interface{}{
|
|
||||||
"age": 43,
|
|
||||||
"id": "1",
|
|
||||||
},
|
|
||||||
Table: "example",
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
# Email
|
# Email
|
||||||
|
|
||||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/email/api](https://m3o.com/email/api).
|
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Email/api](https://m3o.com/Email/api).
|
||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
@@ -33,62 +33,5 @@ Please verify your email by clicking this link: $micro_verification_link`,
|
|||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Parse
|
|
||||||
|
|
||||||
Parse an RFC5322 address e.g "Joe Blogs <joe@example.com>"
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/email/api#Parse](https://m3o.com/email/api#Parse)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/email"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Parse an RFC5322 address e.g "Joe Blogs <joe@example.com>"
|
|
||||||
func ParseEmail() {
|
|
||||||
emailService := email.NewEmailService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := emailService.Parse(&email.ParseRequest{
|
|
||||||
Address: "Joe Blogs <joe@example.com>",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Validate
|
|
||||||
|
|
||||||
Validate an email address format
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/email/api#Validate](https://m3o.com/email/api#Validate)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/email"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Validate an email address format
|
|
||||||
func ValidateEmail() {
|
|
||||||
emailService := email.NewEmailService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := emailService.Validate(&email.ValidateRequest{
|
|
||||||
Address: "joe@example.com",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
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)
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/email"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Send an email by passing in from, to, subject, and a text or html body
|
|
||||||
func main() {
|
|
||||||
emailService := email.NewEmailService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := emailService.Send(&email.SendRequest{
|
|
||||||
From: "Awesome Dot Com",
|
|
||||||
Subject: "Email verification",
|
|
||||||
TextBody: `Hi there,
|
|
||||||
|
|
||||||
Please verify your email by clicking this link: $micro_verification_link`,
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
}
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user