mirror of
https://github.com/kevin-DL/m3o-go.git
synced 2026-01-11 18:44:26 +00:00
Commit from m3o/m3o action
This commit is contained in:
52
carbon/carbon.go
Executable file
52
carbon/carbon.go
Executable file
@@ -0,0 +1,52 @@
|
||||
package carbon
|
||||
|
||||
import (
|
||||
"go.m3o.com/client"
|
||||
)
|
||||
|
||||
type Carbon interface {
|
||||
Offset(*OffsetRequest) (*OffsetResponse, error)
|
||||
}
|
||||
|
||||
func NewCarbonService(token string) *CarbonService {
|
||||
return &CarbonService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type CarbonService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Purchase 1kg (0.001 tonnes) 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"`
|
||||
}
|
||||
@@ -4,6 +4,93 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/App/api](https
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Reserve
|
||||
|
||||
Reserve apps beyond the free quota. Call Run after.
|
||||
|
||||
|
||||
[https://m3o.com/app/api#Reserve](https://m3o.com/app/api#Reserve)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/app"
|
||||
)
|
||||
|
||||
// Reserve apps beyond the free quota. Call Run after.
|
||||
func ReserveAppName() {
|
||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := appService.Reserve(&app.ReserveRequest{
|
||||
Name: "helloworld",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## List
|
||||
|
||||
List all the apps
|
||||
|
||||
|
||||
[https://m3o.com/app/api#List](https://m3o.com/app/api#List)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/app"
|
||||
)
|
||||
|
||||
// List all the apps
|
||||
func ListTheApps() {
|
||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := appService.List(&app.ListRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Run
|
||||
|
||||
Run an app from a source repo. Specify region etc.
|
||||
|
||||
|
||||
[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 a source repo. Specify region etc.
|
||||
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
|
||||
@@ -143,90 +230,3 @@ func DeleteAnApp() {
|
||||
|
||||
}
|
||||
```
|
||||
## Reserve
|
||||
|
||||
Reserve apps beyond the free quota. Call Run after.
|
||||
|
||||
|
||||
[https://m3o.com/app/api#Reserve](https://m3o.com/app/api#Reserve)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/app"
|
||||
)
|
||||
|
||||
// Reserve apps beyond the free quota. Call Run after.
|
||||
func ReserveAppName() {
|
||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := appService.Reserve(&app.ReserveRequest{
|
||||
Name: "helloworld",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## List
|
||||
|
||||
List all the apps
|
||||
|
||||
|
||||
[https://m3o.com/app/api#List](https://m3o.com/app/api#List)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/app"
|
||||
)
|
||||
|
||||
// List all the apps
|
||||
func ListTheApps() {
|
||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := appService.List(&app.ListRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Run
|
||||
|
||||
Run an app from a source repo. Specify region etc.
|
||||
|
||||
|
||||
[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 a source repo. Specify region etc.
|
||||
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)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
56
examples/cache/README.md
vendored
56
examples/cache/README.md
vendored
@@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Cache/api](htt
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Delete
|
||||
|
||||
Delete a value from the cache. If key not found a success response is returned.
|
||||
|
||||
|
||||
[https://m3o.com/cache/api#Delete](https://m3o.com/cache/api#Delete)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/cache"
|
||||
)
|
||||
|
||||
// Delete a value from the cache. If key not found a success response is returned.
|
||||
func DeleteAvalue() {
|
||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := cacheService.Delete(&cache.DeleteRequest{
|
||||
Key: "foo",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Increment
|
||||
|
||||
Increment a value (if it's a number). If key not found it is equivalent to set.
|
||||
@@ -119,31 +147,3 @@ func GetAvalue() {
|
||||
|
||||
}
|
||||
```
|
||||
## Delete
|
||||
|
||||
Delete a value from the cache. If key not found a success response is returned.
|
||||
|
||||
|
||||
[https://m3o.com/cache/api#Delete](https://m3o.com/cache/api#Delete)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/cache"
|
||||
)
|
||||
|
||||
// Delete a value from the cache. If key not found a success response is returned.
|
||||
func DeleteAvalue() {
|
||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := cacheService.Delete(&cache.DeleteRequest{
|
||||
Key: "foo",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
33
examples/carbon/README.md
Executable file
33
examples/carbon/README.md
Executable file
@@ -0,0 +1,33 @@
|
||||
# Carbon
|
||||
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Carbon/api](https://m3o.com/Carbon/api).
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Offset
|
||||
|
||||
Purchase 1kg (0.001 tonnes) 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 tonnes) of carbon offsets in a single request
|
||||
func OffsetCarbon() {
|
||||
carbonService := carbon.NewCarbonService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := carbonService.Offset(&carbon.OffsetRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
15
examples/carbon/offset/offsetCarbon/main.go
Executable file
15
examples/carbon/offset/offsetCarbon/main.go
Executable file
@@ -0,0 +1,15 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/carbon"
|
||||
)
|
||||
|
||||
// Purchase 1kg (0.001 tonnes) 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)
|
||||
}
|
||||
@@ -4,6 +4,62 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Contact/api](h
|
||||
|
||||
Endpoints:
|
||||
|
||||
## List
|
||||
|
||||
|
||||
|
||||
|
||||
[https://m3o.com/contact/api#List](https://m3o.com/contact/api#List)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/contact"
|
||||
)
|
||||
|
||||
//
|
||||
func ListContactsWithDefaultOffsetAndLimitDefaultLimitIs20() {
|
||||
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := contactService.List(&contact.ListRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## List
|
||||
|
||||
|
||||
|
||||
|
||||
[https://m3o.com/contact/api#List](https://m3o.com/contact/api#List)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/contact"
|
||||
)
|
||||
|
||||
//
|
||||
func ListContactsWithSpecificOffsetAndLimit() {
|
||||
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := contactService.List(&contact.ListRequest{
|
||||
Limit: 1,
|
||||
Offset: 1,
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Create
|
||||
|
||||
|
||||
@@ -161,59 +217,3 @@ func DeleteAcontact() {
|
||||
|
||||
}
|
||||
```
|
||||
## List
|
||||
|
||||
|
||||
|
||||
|
||||
[https://m3o.com/contact/api#List](https://m3o.com/contact/api#List)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/contact"
|
||||
)
|
||||
|
||||
//
|
||||
func ListContactsWithDefaultOffsetAndLimitDefaultLimitIs20() {
|
||||
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := contactService.List(&contact.ListRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## List
|
||||
|
||||
|
||||
|
||||
|
||||
[https://m3o.com/contact/api#List](https://m3o.com/contact/api#List)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/contact"
|
||||
)
|
||||
|
||||
//
|
||||
func ListContactsWithSpecificOffsetAndLimit() {
|
||||
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := contactService.List(&contact.ListRequest{
|
||||
Limit: 1,
|
||||
Offset: 1,
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,6 +4,62 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Currency/api](
|
||||
|
||||
Endpoints:
|
||||
|
||||
## History
|
||||
|
||||
Returns the historic rates for a currency on a given date
|
||||
|
||||
|
||||
[https://m3o.com/currency/api#History](https://m3o.com/currency/api#History)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/currency"
|
||||
)
|
||||
|
||||
// Returns the historic rates for a currency on a given date
|
||||
func HistoricRatesForAcurrency() {
|
||||
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := currencyService.History(¤cy.HistoryRequest{
|
||||
Code: "USD",
|
||||
Date: "2021-05-30",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Codes
|
||||
|
||||
Codes returns the supported currency codes for the API
|
||||
|
||||
|
||||
[https://m3o.com/currency/api#Codes](https://m3o.com/currency/api#Codes)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/currency"
|
||||
)
|
||||
|
||||
// Codes returns the supported currency codes for the API
|
||||
func GetSupportedCodes() {
|
||||
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := currencyService.Codes(¤cy.CodesRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Rates
|
||||
|
||||
Rates returns the currency rates for a given code e.g USD
|
||||
@@ -91,59 +147,3 @@ To: "GBP",
|
||||
|
||||
}
|
||||
```
|
||||
## History
|
||||
|
||||
Returns the historic rates for a currency on a given date
|
||||
|
||||
|
||||
[https://m3o.com/currency/api#History](https://m3o.com/currency/api#History)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/currency"
|
||||
)
|
||||
|
||||
// Returns the historic rates for a currency on a given date
|
||||
func HistoricRatesForAcurrency() {
|
||||
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := currencyService.History(¤cy.HistoryRequest{
|
||||
Code: "USD",
|
||||
Date: "2021-05-30",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Codes
|
||||
|
||||
Codes returns the supported currency codes for the API
|
||||
|
||||
|
||||
[https://m3o.com/currency/api#Codes](https://m3o.com/currency/api#Codes)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/currency"
|
||||
)
|
||||
|
||||
// Codes returns the supported currency codes for the API
|
||||
func GetSupportedCodes() {
|
||||
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := currencyService.Codes(¤cy.CodesRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,6 +4,96 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Db/api](https:
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Create
|
||||
|
||||
Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
|
||||
|
||||
|
||||
[https://m3o.com/db/api#Create](https://m3o.com/db/api#Create)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/db"
|
||||
)
|
||||
|
||||
// Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
|
||||
func CreateArecord() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.Create(&db.CreateRequest{
|
||||
Record: map[string]interface{}{
|
||||
"isActive": true,
|
||||
"id": "1",
|
||||
"name": "Jane",
|
||||
"age": 42,
|
||||
},
|
||||
Table: "example",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Delete
|
||||
|
||||
Delete a record in the database by id.
|
||||
|
||||
|
||||
[https://m3o.com/db/api#Delete](https://m3o.com/db/api#Delete)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/db"
|
||||
)
|
||||
|
||||
// Delete a record in the database by id.
|
||||
func DeleteArecord() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.Delete(&db.DeleteRequest{
|
||||
Id: "1",
|
||||
Table: "example",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## 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
|
||||
@@ -33,12 +123,12 @@ To: "examples3",
|
||||
|
||||
}
|
||||
```
|
||||
## Create
|
||||
## Count
|
||||
|
||||
Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
|
||||
Count records in a table
|
||||
|
||||
|
||||
[https://m3o.com/db/api#Create](https://m3o.com/db/api#Create)
|
||||
[https://m3o.com/db/api#Count](https://m3o.com/db/api#Count)
|
||||
|
||||
```go
|
||||
package example
|
||||
@@ -50,17 +140,11 @@ import(
|
||||
"go.m3o.com/db"
|
||||
)
|
||||
|
||||
// Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
|
||||
func CreateArecord() {
|
||||
// Count records in a table
|
||||
func CountEntriesInAtable() {
|
||||
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",
|
||||
rsp, err := dbService.Count(&db.CountRequest{
|
||||
Table: "example",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
@@ -128,12 +212,12 @@ Table: "example",
|
||||
|
||||
}
|
||||
```
|
||||
## Delete
|
||||
## Truncate
|
||||
|
||||
Delete a record in the database by id.
|
||||
Truncate the records in a table
|
||||
|
||||
|
||||
[https://m3o.com/db/api#Delete](https://m3o.com/db/api#Delete)
|
||||
[https://m3o.com/db/api#Truncate](https://m3o.com/db/api#Truncate)
|
||||
|
||||
```go
|
||||
package example
|
||||
@@ -145,12 +229,11 @@ import(
|
||||
"go.m3o.com/db"
|
||||
)
|
||||
|
||||
// Delete a record in the database by id.
|
||||
func DeleteArecord() {
|
||||
// Truncate the records in a table
|
||||
func TruncateTable() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.Delete(&db.DeleteRequest{
|
||||
Id: "1",
|
||||
Table: "example",
|
||||
rsp, err := dbService.Truncate(&db.TruncateRequest{
|
||||
Table: "example",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
@@ -185,86 +268,3 @@ func DropTable() {
|
||||
|
||||
}
|
||||
```
|
||||
## 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)
|
||||
|
||||
}
|
||||
```
|
||||
## Truncate
|
||||
|
||||
Truncate the records in a table
|
||||
|
||||
|
||||
[https://m3o.com/db/api#Truncate](https://m3o.com/db/api#Truncate)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/db"
|
||||
)
|
||||
|
||||
// Truncate the records in a table
|
||||
func TruncateTable() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.Truncate(&db.TruncateRequest{
|
||||
Table: "example",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## 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)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,36 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Emoji/api](htt
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Send
|
||||
|
||||
Send an emoji to anyone via SMS. Messages are sent in the form '<message> Sent from <from>'
|
||||
|
||||
|
||||
[https://m3o.com/emoji/api#Send](https://m3o.com/emoji/api#Send)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/emoji"
|
||||
)
|
||||
|
||||
// Send an emoji to anyone via SMS. Messages are sent in the form '<message> Sent from <from>'
|
||||
func SendAtextContainingAnEmojiToAnyoneViaSms() {
|
||||
emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := emojiService.Send(&emoji.SendRequest{
|
||||
From: "Alice",
|
||||
Message: "let's grab a :beer:",
|
||||
To: "+44782669123",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Find
|
||||
|
||||
Find an emoji by its alias e.g :beer:
|
||||
@@ -119,3 +89,33 @@ func PrintTextIncludingEmoji() {
|
||||
|
||||
}
|
||||
```
|
||||
## Send
|
||||
|
||||
Send an emoji to anyone via SMS. Messages are sent in the form '<message> Sent from <from>'
|
||||
|
||||
|
||||
[https://m3o.com/emoji/api#Send](https://m3o.com/emoji/api#Send)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/emoji"
|
||||
)
|
||||
|
||||
// Send an emoji to anyone via SMS. Messages are sent in the form '<message> Sent from <from>'
|
||||
func SendAtextContainingAnEmojiToAnyoneViaSms() {
|
||||
emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := emojiService.Send(&emoji.SendRequest{
|
||||
From: "Alice",
|
||||
Message: "let's grab a :beer:",
|
||||
To: "+44782669123",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -12,9 +12,9 @@ func main() {
|
||||
eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := eventService.Publish(&event.PublishRequest{
|
||||
Message: map[string]interface{}{
|
||||
"id": "1",
|
||||
"type": "signup",
|
||||
"user": "john",
|
||||
"id": "1",
|
||||
},
|
||||
Topic: "user",
|
||||
})
|
||||
|
||||
@@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Function/api](
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Delete
|
||||
|
||||
Delete a function by name
|
||||
|
||||
|
||||
[https://m3o.com/function/api#Delete](https://m3o.com/function/api#Delete)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/function"
|
||||
)
|
||||
|
||||
// Delete a function by name
|
||||
func DeleteAfunction() {
|
||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := functionService.Delete(&function.DeleteRequest{
|
||||
Name: "helloworld",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Reserve
|
||||
|
||||
Reserve function names and resources beyond free quota
|
||||
@@ -64,6 +92,117 @@ Subfolder: "examples/go-function",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Update
|
||||
|
||||
Update a function. Downloads the source, builds and redeploys
|
||||
|
||||
|
||||
[https://m3o.com/function/api#Update](https://m3o.com/function/api#Update)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/function"
|
||||
)
|
||||
|
||||
// Update a function. Downloads the source, builds and redeploys
|
||||
func UpdateAfunction() {
|
||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := functionService.Update(&function.UpdateRequest{
|
||||
Name: "helloworld",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Describe
|
||||
|
||||
Get the info for a deployed function
|
||||
|
||||
|
||||
[https://m3o.com/function/api#Describe](https://m3o.com/function/api#Describe)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/function"
|
||||
)
|
||||
|
||||
// Get the info for a deployed function
|
||||
func DescribeFunctionStatus() {
|
||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := functionService.Describe(&function.DescribeRequest{
|
||||
Name: "helloworld",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Regions
|
||||
|
||||
Return a list of supported regions
|
||||
|
||||
|
||||
[https://m3o.com/function/api#Regions](https://m3o.com/function/api#Regions)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/function"
|
||||
)
|
||||
|
||||
// Return a list of supported regions
|
||||
func ListRegions() {
|
||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := functionService.Regions(&function.RegionsRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Proxy
|
||||
|
||||
Return the backend url for proxying
|
||||
|
||||
|
||||
[https://m3o.com/function/api#Proxy](https://m3o.com/function/api#Proxy)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/function"
|
||||
)
|
||||
|
||||
// Return the backend url for proxying
|
||||
func ProxyUrl() {
|
||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := functionService.Proxy(&function.ProxyRequest{
|
||||
Id: "helloworld",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Call
|
||||
@@ -124,142 +263,3 @@ func ListFunctions() {
|
||||
|
||||
}
|
||||
```
|
||||
## Delete
|
||||
|
||||
Delete a function by name
|
||||
|
||||
|
||||
[https://m3o.com/function/api#Delete](https://m3o.com/function/api#Delete)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/function"
|
||||
)
|
||||
|
||||
// Delete a function by name
|
||||
func DeleteAfunction() {
|
||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := functionService.Delete(&function.DeleteRequest{
|
||||
Name: "helloworld",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Describe
|
||||
|
||||
Get the info for a deployed function
|
||||
|
||||
|
||||
[https://m3o.com/function/api#Describe](https://m3o.com/function/api#Describe)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/function"
|
||||
)
|
||||
|
||||
// Get the info for a deployed function
|
||||
func DescribeFunctionStatus() {
|
||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := functionService.Describe(&function.DescribeRequest{
|
||||
Name: "helloworld",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Update
|
||||
|
||||
Update a function. Downloads the source, builds and redeploys
|
||||
|
||||
|
||||
[https://m3o.com/function/api#Update](https://m3o.com/function/api#Update)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/function"
|
||||
)
|
||||
|
||||
// Update a function. Downloads the source, builds and redeploys
|
||||
func UpdateAfunction() {
|
||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := functionService.Update(&function.UpdateRequest{
|
||||
Name: "helloworld",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Regions
|
||||
|
||||
Return a list of supported regions
|
||||
|
||||
|
||||
[https://m3o.com/function/api#Regions](https://m3o.com/function/api#Regions)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/function"
|
||||
)
|
||||
|
||||
// Return a list of supported regions
|
||||
func ListRegions() {
|
||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := functionService.Regions(&function.RegionsRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Proxy
|
||||
|
||||
Return the backend url for proxying
|
||||
|
||||
|
||||
[https://m3o.com/function/api#Proxy](https://m3o.com/function/api#Proxy)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/function"
|
||||
)
|
||||
|
||||
// Return the backend url for proxying
|
||||
func ProxyUrl() {
|
||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := functionService.Proxy(&function.ProxyRequest{
|
||||
Id: "helloworld",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,6 +4,40 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Location/api](
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Search
|
||||
|
||||
Search for entities in a given radius
|
||||
|
||||
|
||||
[https://m3o.com/location/api#Search](https://m3o.com/location/api#Search)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/location"
|
||||
)
|
||||
|
||||
// Search for entities in a given radius
|
||||
func SearchForLocations() {
|
||||
locationService := location.NewLocationService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := locationService.Search(&location.SearchRequest{
|
||||
Center: &location.Point{
|
||||
Latitude: 51.511061,
|
||||
Longitude: -0.120022,
|
||||
},
|
||||
NumEntities: 10,
|
||||
Radius: 100,
|
||||
Type: "bike",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Save
|
||||
|
||||
Save an entity's current position
|
||||
@@ -68,37 +102,3 @@ func GetLocationById() {
|
||||
|
||||
}
|
||||
```
|
||||
## Search
|
||||
|
||||
Search for entities in a given radius
|
||||
|
||||
|
||||
[https://m3o.com/location/api#Search](https://m3o.com/location/api#Search)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/location"
|
||||
)
|
||||
|
||||
// Search for entities in a given radius
|
||||
func SearchForLocations() {
|
||||
locationService := location.NewLocationService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := locationService.Search(&location.SearchRequest{
|
||||
Center: &location.Point{
|
||||
Latitude: 51.511061,
|
||||
Longitude: -0.120022,
|
||||
},
|
||||
NumEntities: 10,
|
||||
Radius: 100,
|
||||
Type: "bike",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -26,9 +26,9 @@ func PublishAmessage() {
|
||||
mqService := mq.NewMqService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := mqService.Publish(&mq.PublishRequest{
|
||||
Message: map[string]interface{}{
|
||||
"id": "1",
|
||||
"type": "signup",
|
||||
"user": "john",
|
||||
"id": "1",
|
||||
},
|
||||
Topic: "events",
|
||||
|
||||
|
||||
@@ -12,9 +12,9 @@ func main() {
|
||||
mqService := mq.NewMqService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := mqService.Publish(&mq.PublishRequest{
|
||||
Message: map[string]interface{}{
|
||||
"user": "john",
|
||||
"id": "1",
|
||||
"type": "signup",
|
||||
"user": "john",
|
||||
},
|
||||
Topic: "events",
|
||||
})
|
||||
|
||||
@@ -4,6 +4,35 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Notes/api](htt
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Create
|
||||
|
||||
Create a new note
|
||||
|
||||
|
||||
[https://m3o.com/notes/api#Create](https://m3o.com/notes/api#Create)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/notes"
|
||||
)
|
||||
|
||||
// Create a new note
|
||||
func CreateAnote() {
|
||||
notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := notesService.Create(¬es.CreateRequest{
|
||||
Text: "This is my note",
|
||||
Title: "New Note",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Read
|
||||
|
||||
Read a note
|
||||
@@ -160,32 +189,3 @@ func SubscribeToEvents() {
|
||||
}
|
||||
}
|
||||
```
|
||||
## Create
|
||||
|
||||
Create a new note
|
||||
|
||||
|
||||
[https://m3o.com/notes/api#Create](https://m3o.com/notes/api#Create)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/notes"
|
||||
)
|
||||
|
||||
// Create a new note
|
||||
func CreateAnote() {
|
||||
notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := notesService.Create(¬es.CreateRequest{
|
||||
Text: "This is my note",
|
||||
Title: "New Note",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Postcode/api](
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Lookup
|
||||
|
||||
Lookup a postcode to retrieve the related region, county, etc
|
||||
|
||||
|
||||
[https://m3o.com/postcode/api#Lookup](https://m3o.com/postcode/api#Lookup)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/postcode"
|
||||
)
|
||||
|
||||
// Lookup a postcode to retrieve the related region, county, etc
|
||||
func LookupPostcode() {
|
||||
postcodeService := postcode.NewPostcodeService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := postcodeService.Lookup(&postcode.LookupRequest{
|
||||
Postcode: "SW1A 2AA",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Random
|
||||
|
||||
Return a random postcode and its related info
|
||||
@@ -59,31 +87,3 @@ func ReturnArandomPostcodeAndItsInformation() {
|
||||
|
||||
}
|
||||
```
|
||||
## Lookup
|
||||
|
||||
Lookup a postcode to retrieve the related region, county, etc
|
||||
|
||||
|
||||
[https://m3o.com/postcode/api#Lookup](https://m3o.com/postcode/api#Lookup)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/postcode"
|
||||
)
|
||||
|
||||
// Lookup a postcode to retrieve the related region, county, etc
|
||||
func LookupPostcode() {
|
||||
postcodeService := postcode.NewPostcodeService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := postcodeService.Lookup(&postcode.LookupRequest{
|
||||
Postcode: "SW1A 2AA",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Search/api](ht
|
||||
|
||||
Endpoints:
|
||||
|
||||
## DeleteIndex
|
||||
|
||||
Delete an index.
|
||||
|
||||
|
||||
[https://m3o.com/search/api#DeleteIndex](https://m3o.com/search/api#DeleteIndex)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/search"
|
||||
)
|
||||
|
||||
// Delete an index.
|
||||
func DeleteAnIndex() {
|
||||
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := searchService.DeleteIndex(&search.DeleteIndexRequest{
|
||||
Index: "customers",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Index
|
||||
|
||||
Index a document i.e. insert a document to search for.
|
||||
@@ -156,31 +184,3 @@ Index: "customers",
|
||||
|
||||
}
|
||||
```
|
||||
## DeleteIndex
|
||||
|
||||
Delete an index.
|
||||
|
||||
|
||||
[https://m3o.com/search/api#DeleteIndex](https://m3o.com/search/api#DeleteIndex)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/search"
|
||||
)
|
||||
|
||||
// Delete an index.
|
||||
func DeleteAnIndex() {
|
||||
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := searchService.DeleteIndex(&search.DeleteIndexRequest{
|
||||
Index: "customers",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Stock/api](htt
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Price
|
||||
|
||||
Get the last price for a given stock ticker
|
||||
|
||||
|
||||
[https://m3o.com/stock/api#Price](https://m3o.com/stock/api#Price)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/stock"
|
||||
)
|
||||
|
||||
// Get the last price for a given stock ticker
|
||||
func GetAstockPrice() {
|
||||
stockService := stock.NewStockService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := stockService.Price(&stock.PriceRequest{
|
||||
Symbol: "AAPL",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Quote
|
||||
|
||||
Get the last quote for the stock
|
||||
@@ -121,3 +93,31 @@ Stock: "AAPL",
|
||||
|
||||
}
|
||||
```
|
||||
## Price
|
||||
|
||||
Get the last price for a given stock ticker
|
||||
|
||||
|
||||
[https://m3o.com/stock/api#Price](https://m3o.com/stock/api#Price)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/stock"
|
||||
)
|
||||
|
||||
// Get the last price for a given stock ticker
|
||||
func GetAstockPrice() {
|
||||
stockService := stock.NewStockService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := stockService.Price(&stock.PriceRequest{
|
||||
Symbol: "AAPL",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,61 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Stream/api](ht
|
||||
|
||||
Endpoints:
|
||||
|
||||
## ListMessages
|
||||
|
||||
List messages for a given channel
|
||||
|
||||
|
||||
[https://m3o.com/stream/api#ListMessages](https://m3o.com/stream/api#ListMessages)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/stream"
|
||||
)
|
||||
|
||||
// List messages for a given channel
|
||||
func ListMessages() {
|
||||
streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := streamService.ListMessages(&stream.ListMessagesRequest{
|
||||
Channel: "general",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## ListChannels
|
||||
|
||||
List all the active channels
|
||||
|
||||
|
||||
[https://m3o.com/stream/api#ListChannels](https://m3o.com/stream/api#ListChannels)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/stream"
|
||||
)
|
||||
|
||||
// List all the active channels
|
||||
func ListChannels() {
|
||||
streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := streamService.ListChannels(&stream.ListChannelsRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## CreateChannel
|
||||
|
||||
Create a channel with a given name and description. Channels are created automatically but
|
||||
@@ -119,3 +64,58 @@ Text: "Hey checkout this tweet https://twitter.com/m3oservices/status/1455291054
|
||||
|
||||
}
|
||||
```
|
||||
## ListMessages
|
||||
|
||||
List messages for a given channel
|
||||
|
||||
|
||||
[https://m3o.com/stream/api#ListMessages](https://m3o.com/stream/api#ListMessages)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/stream"
|
||||
)
|
||||
|
||||
// List messages for a given channel
|
||||
func ListMessages() {
|
||||
streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := streamService.ListMessages(&stream.ListMessagesRequest{
|
||||
Channel: "general",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## ListChannels
|
||||
|
||||
List all the active channels
|
||||
|
||||
|
||||
[https://m3o.com/stream/api#ListChannels](https://m3o.com/stream/api#ListChannels)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/stream"
|
||||
)
|
||||
|
||||
// List all the active channels
|
||||
func ListChannels() {
|
||||
streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := streamService.ListChannels(&stream.ListChannelsRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,6 +4,37 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Sunnah/api](ht
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Hadiths
|
||||
|
||||
Hadiths returns a list of hadiths and their corresponding text for a
|
||||
given book within a collection.
|
||||
|
||||
|
||||
[https://m3o.com/sunnah/api#Hadiths](https://m3o.com/sunnah/api#Hadiths)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/sunnah"
|
||||
)
|
||||
|
||||
// Hadiths returns a list of hadiths and their corresponding text for a
|
||||
// given book within a collection.
|
||||
func ListTheHadithsInAbook() {
|
||||
sunnahService := sunnah.NewSunnahService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := sunnahService.Hadiths(&sunnah.HadithsRequest{
|
||||
Book: 1,
|
||||
Collection: "bukhari",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Collections
|
||||
|
||||
Get a list of available collections. A collection is
|
||||
@@ -92,34 +123,3 @@ Collection: "bukhari",
|
||||
|
||||
}
|
||||
```
|
||||
## Hadiths
|
||||
|
||||
Hadiths returns a list of hadiths and their corresponding text for a
|
||||
given book within a collection.
|
||||
|
||||
|
||||
[https://m3o.com/sunnah/api#Hadiths](https://m3o.com/sunnah/api#Hadiths)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/sunnah"
|
||||
)
|
||||
|
||||
// Hadiths returns a list of hadiths and their corresponding text for a
|
||||
// given book within a collection.
|
||||
func ListTheHadithsInAbook() {
|
||||
sunnahService := sunnah.NewSunnahService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := sunnahService.Hadiths(&sunnah.HadithsRequest{
|
||||
Book: 1,
|
||||
Collection: "bukhari",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,33 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Time/api](http
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Now
|
||||
|
||||
Get the current time
|
||||
|
||||
|
||||
[https://m3o.com/time/api#Now](https://m3o.com/time/api#Now)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/time"
|
||||
)
|
||||
|
||||
// Get the current time
|
||||
func ReturnsCurrentTimeOptionallyWithLocation() {
|
||||
timeService := time.NewTimeService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := timeService.Now(&time.NowRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Zone
|
||||
|
||||
Get the timezone info for a specific location
|
||||
@@ -59,3 +32,30 @@ func GetTheTimezoneInfoForAspecificLocation() {
|
||||
|
||||
}
|
||||
```
|
||||
## Now
|
||||
|
||||
Get the current time
|
||||
|
||||
|
||||
[https://m3o.com/time/api#Now](https://m3o.com/time/api#Now)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/time"
|
||||
)
|
||||
|
||||
// Get the current time
|
||||
func ReturnsCurrentTimeOptionallyWithLocation() {
|
||||
timeService := time.NewTimeService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := timeService.Now(&time.NowRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,6 +4,35 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Twitter/api](h
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Timeline
|
||||
|
||||
Get the timeline for a given user
|
||||
|
||||
|
||||
[https://m3o.com/twitter/api#Timeline](https://m3o.com/twitter/api#Timeline)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/twitter"
|
||||
)
|
||||
|
||||
// Get the timeline for a given user
|
||||
func GetAtwitterTimeline() {
|
||||
twitterService := twitter.NewTwitterService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := twitterService.Timeline(&twitter.TimelineRequest{
|
||||
Limit: 1,
|
||||
Username: "m3oservices",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Search
|
||||
|
||||
Search for tweets with a simple query
|
||||
@@ -87,32 +116,3 @@ func GetAusersTwitterProfile() {
|
||||
|
||||
}
|
||||
```
|
||||
## Timeline
|
||||
|
||||
Get the timeline for a given user
|
||||
|
||||
|
||||
[https://m3o.com/twitter/api#Timeline](https://m3o.com/twitter/api#Timeline)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/twitter"
|
||||
)
|
||||
|
||||
// Get the timeline for a given user
|
||||
func GetAtwitterTimeline() {
|
||||
twitterService := twitter.NewTwitterService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := twitterService.Timeline(&twitter.TimelineRequest{
|
||||
Limit: 1,
|
||||
Username: "m3oservices",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -36,6 +36,99 @@ TextContent: `Hi there,
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## ReadSession
|
||||
|
||||
Read a session by the session id. In the event it has expired or is not found and error is returned.
|
||||
|
||||
|
||||
[https://m3o.com/user/api#ReadSession](https://m3o.com/user/api#ReadSession)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Read a session by the session id. In the event it has expired or is not found and error is returned.
|
||||
func ReadAsessionByTheSessionId() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.ReadSession(&user.ReadSessionRequest{
|
||||
SessionId: "df91a612-5b24-4634-99ff-240220ab8f55",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## SendMagicLink
|
||||
|
||||
Login using email only - Passwordless
|
||||
|
||||
|
||||
[https://m3o.com/user/api#SendMagicLink](https://m3o.com/user/api#SendMagicLink)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Login using email only - Passwordless
|
||||
func SendAmagicLink() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.SendMagicLink(&user.SendMagicLinkRequest{
|
||||
Address: "www.example.com",
|
||||
Email: "joe@example.com",
|
||||
Endpoint: "verifytoken",
|
||||
FromName: "Awesome Dot Com",
|
||||
Subject: "MagicLink to access your account",
|
||||
TextContent: `Hi there,
|
||||
|
||||
Click here to access your account $micro_verification_link`,
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## UpdatePassword
|
||||
|
||||
Update the account password
|
||||
|
||||
|
||||
[https://m3o.com/user/api#UpdatePassword](https://m3o.com/user/api#UpdatePassword)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Update the account password
|
||||
func UpdateTheAccountPassword() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.UpdatePassword(&user.UpdatePasswordRequest{
|
||||
ConfirmPassword: "Password2",
|
||||
NewPassword: "Password2",
|
||||
OldPassword: "Password1",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## ResetPassword
|
||||
@@ -69,12 +162,12 @@ NewPassword: "NewPassword1",
|
||||
|
||||
}
|
||||
```
|
||||
## ReadSession
|
||||
## VerifyEmail
|
||||
|
||||
Read a session by the session id. In the event it has expired or is not found and error is returned.
|
||||
Verify the email address of an account from a token sent in an email to the user.
|
||||
|
||||
|
||||
[https://m3o.com/user/api#ReadSession](https://m3o.com/user/api#ReadSession)
|
||||
[https://m3o.com/user/api#VerifyEmail](https://m3o.com/user/api#VerifyEmail)
|
||||
|
||||
```go
|
||||
package example
|
||||
@@ -86,26 +179,24 @@ import(
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Read a session by the session id. In the event it has expired or is not found and error is returned.
|
||||
func ReadAsessionByTheSessionId() {
|
||||
// Verify the email address of an account from a token sent in an email to the user.
|
||||
func VerifyEmail() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.ReadSession(&user.ReadSessionRequest{
|
||||
SessionId: "df91a612-5b24-4634-99ff-240220ab8f55",
|
||||
rsp, err := userService.VerifyEmail(&user.VerifyEmailRequest{
|
||||
Email: "joe@example.com",
|
||||
Token: "012345",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## VerifyToken
|
||||
## List
|
||||
|
||||
Check whether the token attached to MagicLink is valid or not.
|
||||
Ideally, you need to call this endpoint from your http request
|
||||
handler that handles the endpoint which is specified in the
|
||||
SendMagicLink request.
|
||||
List all users. Returns a paged list of results
|
||||
|
||||
|
||||
[https://m3o.com/user/api#VerifyToken](https://m3o.com/user/api#VerifyToken)
|
||||
[https://m3o.com/user/api#List](https://m3o.com/user/api#List)
|
||||
|
||||
```go
|
||||
package example
|
||||
@@ -117,14 +208,41 @@ import(
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Check whether the token attached to MagicLink is valid or not.
|
||||
// Ideally, you need to call this endpoint from your http request
|
||||
// handler that handles the endpoint which is specified in the
|
||||
// SendMagicLink request.
|
||||
func VerifyAtoken() {
|
||||
// List all users. Returns a paged list of results
|
||||
func ListAllUsers() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.VerifyToken(&user.VerifyTokenRequest{
|
||||
Token: "EdsUiidouJJJLldjlloofUiorkojflsWWdld",
|
||||
rsp, err := userService.List(&user.ListRequest{
|
||||
Limit: 100,
|
||||
Offset: 0,
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Update
|
||||
|
||||
Update the account username or email
|
||||
|
||||
|
||||
[https://m3o.com/user/api#Update](https://m3o.com/user/api#Update)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Update the account username or email
|
||||
func UpdateAnAccount() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.Update(&user.UpdateRequest{
|
||||
Email: "joe+2@example.com",
|
||||
Id: "user-1",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
@@ -178,12 +296,13 @@ Please verify your email by clicking this link: $micro_verification_link`,
|
||||
|
||||
}
|
||||
```
|
||||
## Create
|
||||
## Login
|
||||
|
||||
Create a new user account. The email address and username for the account must be unique.
|
||||
Login using username or email. The response will return a new session for successful login,
|
||||
401 in the case of login failure and 500 for any other error
|
||||
|
||||
|
||||
[https://m3o.com/user/api#Create](https://m3o.com/user/api#Create)
|
||||
[https://m3o.com/user/api#Login](https://m3o.com/user/api#Login)
|
||||
|
||||
```go
|
||||
package example
|
||||
@@ -195,26 +314,25 @@ import(
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Create a new user account. The email address and username for the account must be unique.
|
||||
func CreateAnAccount() {
|
||||
// Login using username or email. The response will return a new session for successful login,
|
||||
// 401 in the case of login failure and 500 for any other error
|
||||
func LogAuserIn() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.Create(&user.CreateRequest{
|
||||
rsp, err := userService.Login(&user.LoginRequest{
|
||||
Email: "joe@example.com",
|
||||
Id: "user-1",
|
||||
Password: "Password1",
|
||||
Username: "joe",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Update
|
||||
## Logout
|
||||
|
||||
Update the account username or email
|
||||
Logout a user account
|
||||
|
||||
|
||||
[https://m3o.com/user/api#Update](https://m3o.com/user/api#Update)
|
||||
[https://m3o.com/user/api#Logout](https://m3o.com/user/api#Logout)
|
||||
|
||||
```go
|
||||
package example
|
||||
@@ -226,42 +344,11 @@ import(
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Update the account username or email
|
||||
func UpdateAnAccount() {
|
||||
// Logout a user account
|
||||
func LogAuserOut() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.Update(&user.UpdateRequest{
|
||||
Email: "joe+2@example.com",
|
||||
Id: "user-1",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## UpdatePassword
|
||||
|
||||
Update the account password
|
||||
|
||||
|
||||
[https://m3o.com/user/api#UpdatePassword](https://m3o.com/user/api#UpdatePassword)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Update the account password
|
||||
func UpdateTheAccountPassword() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.UpdatePassword(&user.UpdatePasswordRequest{
|
||||
ConfirmPassword: "Password2",
|
||||
NewPassword: "Password2",
|
||||
OldPassword: "Password1",
|
||||
rsp, err := userService.Logout(&user.LogoutRequest{
|
||||
SessionId: "df91a612-5b24-4634-99ff-240220ab8f55",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
@@ -350,101 +437,6 @@ func ReadAccountByEmail() {
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Login
|
||||
|
||||
Login using username or email. The response will return a new session for successful login,
|
||||
401 in the case of login failure and 500 for any other error
|
||||
|
||||
|
||||
[https://m3o.com/user/api#Login](https://m3o.com/user/api#Login)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Login using username or email. The response will return a new session for successful login,
|
||||
// 401 in the case of login failure and 500 for any other error
|
||||
func LogAuserIn() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.Login(&user.LoginRequest{
|
||||
Email: "joe@example.com",
|
||||
Password: "Password1",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## SendMagicLink
|
||||
|
||||
Login using email only - Passwordless
|
||||
|
||||
|
||||
[https://m3o.com/user/api#SendMagicLink](https://m3o.com/user/api#SendMagicLink)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Login using email only - Passwordless
|
||||
func SendAmagicLink() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.SendMagicLink(&user.SendMagicLinkRequest{
|
||||
Address: "www.example.com",
|
||||
Email: "joe@example.com",
|
||||
Endpoint: "verifytoken",
|
||||
FromName: "Awesome Dot Com",
|
||||
Subject: "MagicLink to access your account",
|
||||
TextContent: `Hi there,
|
||||
|
||||
Click here to access your account $micro_verification_link`,
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## VerifyEmail
|
||||
|
||||
Verify the email address of an account from a token sent in an email to the user.
|
||||
|
||||
|
||||
[https://m3o.com/user/api#VerifyEmail](https://m3o.com/user/api#VerifyEmail)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Verify the email address of an account from a token sent in an email to the user.
|
||||
func VerifyEmail() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.VerifyEmail(&user.VerifyEmailRequest{
|
||||
Email: "joe@example.com",
|
||||
Token: "012345",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Delete
|
||||
@@ -475,12 +467,15 @@ func DeleteUserAccount() {
|
||||
|
||||
}
|
||||
```
|
||||
## Logout
|
||||
## VerifyToken
|
||||
|
||||
Logout a user account
|
||||
Check whether the token attached to MagicLink is valid or not.
|
||||
Ideally, you need to call this endpoint from your http request
|
||||
handler that handles the endpoint which is specified in the
|
||||
SendMagicLink request.
|
||||
|
||||
|
||||
[https://m3o.com/user/api#Logout](https://m3o.com/user/api#Logout)
|
||||
[https://m3o.com/user/api#VerifyToken](https://m3o.com/user/api#VerifyToken)
|
||||
|
||||
```go
|
||||
package example
|
||||
@@ -492,23 +487,26 @@ import(
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Logout a user account
|
||||
func LogAuserOut() {
|
||||
// Check whether the token attached to MagicLink is valid or not.
|
||||
// Ideally, you need to call this endpoint from your http request
|
||||
// handler that handles the endpoint which is specified in the
|
||||
// SendMagicLink request.
|
||||
func VerifyAtoken() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.Logout(&user.LogoutRequest{
|
||||
SessionId: "df91a612-5b24-4634-99ff-240220ab8f55",
|
||||
rsp, err := userService.VerifyToken(&user.VerifyTokenRequest{
|
||||
Token: "EdsUiidouJJJLldjlloofUiorkojflsWWdld",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## List
|
||||
## Create
|
||||
|
||||
List all users. Returns a paged list of results
|
||||
Create a new user account. The email address and username for the account must be unique.
|
||||
|
||||
|
||||
[https://m3o.com/user/api#List](https://m3o.com/user/api#List)
|
||||
[https://m3o.com/user/api#Create](https://m3o.com/user/api#Create)
|
||||
|
||||
```go
|
||||
package example
|
||||
@@ -520,12 +518,14 @@ import(
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// List all users. Returns a paged list of results
|
||||
func ListAllUsers() {
|
||||
// Create a new user account. The email address and username for the account must be unique.
|
||||
func CreateAnAccount() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.List(&user.ListRequest{
|
||||
Limit: 100,
|
||||
Offset: 0,
|
||||
rsp, err := userService.Create(&user.CreateRequest{
|
||||
Email: "joe@example.com",
|
||||
Id: "user-1",
|
||||
Password: "Password1",
|
||||
Username: "joe",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
3
m3o.go
3
m3o.go
@@ -6,6 +6,7 @@ import (
|
||||
"go.m3o.com/app"
|
||||
"go.m3o.com/avatar"
|
||||
"go.m3o.com/cache"
|
||||
"go.m3o.com/carbon"
|
||||
"go.m3o.com/contact"
|
||||
"go.m3o.com/crypto"
|
||||
"go.m3o.com/currency"
|
||||
@@ -67,6 +68,7 @@ func NewClient(token string) *Client {
|
||||
AppService: app.NewAppService(token),
|
||||
AvatarService: avatar.NewAvatarService(token),
|
||||
CacheService: cache.NewCacheService(token),
|
||||
CarbonService: carbon.NewCarbonService(token),
|
||||
ContactService: contact.NewContactService(token),
|
||||
CryptoService: crypto.NewCryptoService(token),
|
||||
CurrencyService: currency.NewCurrencyService(token),
|
||||
@@ -128,6 +130,7 @@ type Client struct {
|
||||
AppService *app.AppService
|
||||
AvatarService *avatar.AvatarService
|
||||
CacheService *cache.CacheService
|
||||
CarbonService *carbon.CarbonService
|
||||
ContactService *contact.ContactService
|
||||
CryptoService *crypto.CryptoService
|
||||
CurrencyService *currency.CurrencyService
|
||||
|
||||
Reference in New Issue
Block a user