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:
@@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/App/api](https
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Vote
|
||||
|
||||
Vote to have the App api launched faster!
|
||||
|
||||
|
||||
[https://m3o.com/app/api#Vote](https://m3o.com/app/api#Vote)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/app"
|
||||
)
|
||||
|
||||
// Vote to have the App api launched faster!
|
||||
func VoteForTheApi() {
|
||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := appService.Vote(&app.VoteRequest{
|
||||
Message: "Launch it!",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Reserve
|
||||
|
||||
Reserve your app name
|
||||
@@ -60,3 +32,31 @@ func ReserveAppName() {
|
||||
|
||||
}
|
||||
```
|
||||
## Vote
|
||||
|
||||
Vote to have the App api launched faster!
|
||||
|
||||
|
||||
[https://m3o.com/app/api#Vote](https://m3o.com/app/api#Vote)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/app"
|
||||
)
|
||||
|
||||
// Vote to have the App api launched faster!
|
||||
func VoteForTheApi() {
|
||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := appService.Vote(&app.VoteRequest{
|
||||
Message: "Launch it!",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
58
examples/cache/README.md
vendored
58
examples/cache/README.md
vendored
@@ -4,6 +4,35 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Cache/api](htt
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Set
|
||||
|
||||
Set an item in the cache. Overwrites any existing value already set.
|
||||
|
||||
|
||||
[https://m3o.com/cache/api#Set](https://m3o.com/cache/api#Set)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/cache"
|
||||
)
|
||||
|
||||
// Set an item in the cache. Overwrites any existing value already set.
|
||||
func SetAvalue() {
|
||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := cacheService.Set(&cache.SetRequest{
|
||||
Key: "foo",
|
||||
Value: "bar",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Get
|
||||
|
||||
Get an item from the cache by key. If key is not found, an empty response is returned.
|
||||
@@ -118,32 +147,3 @@ Value: 2,
|
||||
|
||||
}
|
||||
```
|
||||
## Set
|
||||
|
||||
Set an item in the cache. Overwrites any existing value already set.
|
||||
|
||||
|
||||
[https://m3o.com/cache/api#Set](https://m3o.com/cache/api#Set)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/cache"
|
||||
)
|
||||
|
||||
// Set an item in the cache. Overwrites any existing value already set.
|
||||
func SetAvalue() {
|
||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := cacheService.Set(&cache.SetRequest{
|
||||
Key: "foo",
|
||||
Value: "bar",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Crypto/api](ht
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Quote
|
||||
|
||||
Get the last quote for a given crypto ticker
|
||||
|
||||
|
||||
[https://m3o.com/crypto/api#Quote](https://m3o.com/crypto/api#Quote)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/crypto"
|
||||
)
|
||||
|
||||
// Get the last quote for a given crypto ticker
|
||||
func GetAcryptocurrencyQuote() {
|
||||
cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := cryptoService.Quote(&crypto.QuoteRequest{
|
||||
Symbol: "BTCUSD",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## History
|
||||
|
||||
Returns the history for the previous close
|
||||
@@ -88,31 +116,3 @@ func GetCryptocurrencyPrice() {
|
||||
|
||||
}
|
||||
```
|
||||
## Quote
|
||||
|
||||
Get the last quote for a given crypto ticker
|
||||
|
||||
|
||||
[https://m3o.com/crypto/api#Quote](https://m3o.com/crypto/api#Quote)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/crypto"
|
||||
)
|
||||
|
||||
// Get the last quote for a given crypto ticker
|
||||
func GetAcryptocurrencyQuote() {
|
||||
cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := cryptoService.Quote(&crypto.QuoteRequest{
|
||||
Symbol: "BTCUSD",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,6 +4,35 @@ 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
|
||||
@@ -118,32 +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)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,12 +4,12 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Db/api](https:
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Delete
|
||||
## ListTables
|
||||
|
||||
Delete a record in the database by id.
|
||||
List tables in the DB
|
||||
|
||||
|
||||
[https://m3o.com/db/api#Delete](https://m3o.com/db/api#Delete)
|
||||
[https://m3o.com/db/api#ListTables](https://m3o.com/db/api#ListTables)
|
||||
|
||||
```go
|
||||
package example
|
||||
@@ -21,24 +21,22 @@ import(
|
||||
"go.m3o.com/db"
|
||||
)
|
||||
|
||||
// Delete a record in the database by id.
|
||||
func DeleteArecord() {
|
||||
// List tables in the DB
|
||||
func ListTables() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.Delete(&db.DeleteRequest{
|
||||
Id: "1",
|
||||
Table: "example",
|
||||
|
||||
rsp, err := dbService.ListTables(&db.ListTablesRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## RenameTable
|
||||
## Update
|
||||
|
||||
Rename a table
|
||||
Update a record in the database. Include an "id" in the record to update.
|
||||
|
||||
|
||||
[https://m3o.com/db/api#RenameTable](https://m3o.com/db/api#RenameTable)
|
||||
[https://m3o.com/db/api#Update](https://m3o.com/db/api#Update)
|
||||
|
||||
```go
|
||||
package example
|
||||
@@ -50,44 +48,13 @@ import(
|
||||
"go.m3o.com/db"
|
||||
)
|
||||
|
||||
// Rename a table
|
||||
func RenameTable() {
|
||||
// Update a record in the database. Include an "id" in the record to update.
|
||||
func UpdateArecord() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.RenameTable(&db.RenameTableRequest{
|
||||
From: "examples2",
|
||||
To: "examples3",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Create
|
||||
|
||||
Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
|
||||
|
||||
|
||||
[https://m3o.com/db/api#Create](https://m3o.com/db/api#Create)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/db"
|
||||
)
|
||||
|
||||
// Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
|
||||
func CreateArecord() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.Create(&db.CreateRequest{
|
||||
rsp, err := dbService.Update(&db.UpdateRequest{
|
||||
Record: map[string]interface{}{
|
||||
"age": 42,
|
||||
"isActive": true,
|
||||
"id": "1",
|
||||
"name": "Jane",
|
||||
"age": 43,
|
||||
},
|
||||
Table: "example",
|
||||
|
||||
@@ -123,6 +90,35 @@ Table: "example",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Delete
|
||||
|
||||
Delete a record in the database by id.
|
||||
|
||||
|
||||
[https://m3o.com/db/api#Delete](https://m3o.com/db/api#Delete)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/db"
|
||||
)
|
||||
|
||||
// Delete a record in the database by id.
|
||||
func DeleteArecord() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.Delete(&db.DeleteRequest{
|
||||
Id: "1",
|
||||
Table: "example",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Truncate
|
||||
@@ -151,6 +147,40 @@ func TruncateTable() {
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Create
|
||||
|
||||
Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
|
||||
|
||||
|
||||
[https://m3o.com/db/api#Create](https://m3o.com/db/api#Create)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/db"
|
||||
)
|
||||
|
||||
// Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
|
||||
func CreateArecord() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.Create(&db.CreateRequest{
|
||||
Record: map[string]interface{}{
|
||||
"id": "1",
|
||||
"name": "Jane",
|
||||
"age": 42,
|
||||
"isActive": true,
|
||||
},
|
||||
Table: "example",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## DropTable
|
||||
@@ -209,12 +239,12 @@ func CountEntriesInAtable() {
|
||||
|
||||
}
|
||||
```
|
||||
## ListTables
|
||||
## RenameTable
|
||||
|
||||
List tables in the DB
|
||||
Rename a table
|
||||
|
||||
|
||||
[https://m3o.com/db/api#ListTables](https://m3o.com/db/api#ListTables)
|
||||
[https://m3o.com/db/api#RenameTable](https://m3o.com/db/api#RenameTable)
|
||||
|
||||
```go
|
||||
package example
|
||||
@@ -226,42 +256,12 @@ import(
|
||||
"go.m3o.com/db"
|
||||
)
|
||||
|
||||
// List tables in the DB
|
||||
func ListTables() {
|
||||
// Rename a table
|
||||
func RenameTable() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.ListTables(&db.ListTablesRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Update
|
||||
|
||||
Update a record in the database. Include an "id" in the record to update.
|
||||
|
||||
|
||||
[https://m3o.com/db/api#Update](https://m3o.com/db/api#Update)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/db"
|
||||
)
|
||||
|
||||
// Update a record in the database. Include an "id" in the record to update.
|
||||
func UpdateArecord() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.Update(&db.UpdateRequest{
|
||||
Record: map[string]interface{}{
|
||||
"id": "1",
|
||||
"age": 43,
|
||||
},
|
||||
Table: "example",
|
||||
rsp, err := dbService.RenameTable(&db.RenameTableRequest{
|
||||
From: "examples2",
|
||||
To: "examples3",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
@@ -12,10 +12,10 @@ 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,
|
||||
"id": "1",
|
||||
},
|
||||
Table: "example",
|
||||
})
|
||||
|
||||
@@ -12,8 +12,8 @@ func main() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.Update(&db.UpdateRequest{
|
||||
Record: map[string]interface{}{
|
||||
"id": "1",
|
||||
"age": 43,
|
||||
"id": "1",
|
||||
},
|
||||
Table: "example",
|
||||
})
|
||||
|
||||
@@ -26,9 +26,9 @@ func PublishAnEvent() {
|
||||
eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := eventService.Publish(&event.PublishRequest{
|
||||
Message: map[string]interface{}{
|
||||
"id": "1",
|
||||
"type": "signup",
|
||||
"user": "john",
|
||||
"id": "1",
|
||||
},
|
||||
Topic: "user",
|
||||
|
||||
|
||||
@@ -12,9 +12,9 @@ func main() {
|
||||
eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := eventService.Publish(&event.PublishRequest{
|
||||
Message: map[string]interface{}{
|
||||
"user": "john",
|
||||
"id": "1",
|
||||
"type": "signup",
|
||||
"user": "john",
|
||||
},
|
||||
Topic: "user",
|
||||
})
|
||||
|
||||
@@ -4,35 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/File/api](http
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Read
|
||||
|
||||
Read a file by path
|
||||
|
||||
|
||||
[https://m3o.com/file/api#Read](https://m3o.com/file/api#Read)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/file"
|
||||
)
|
||||
|
||||
// Read a file by path
|
||||
func ReadFile() {
|
||||
fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := fileService.Read(&file.ReadRequest{
|
||||
Path: "/document/text-files/file.txt",
|
||||
Project: "examples",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Save
|
||||
|
||||
Save a file
|
||||
@@ -91,6 +62,35 @@ func ListFiles() {
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Read
|
||||
|
||||
Read a file by path
|
||||
|
||||
|
||||
[https://m3o.com/file/api#Read](https://m3o.com/file/api#Read)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/file"
|
||||
)
|
||||
|
||||
// Read a file by path
|
||||
func ReadFile() {
|
||||
fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := fileService.Read(&file.ReadRequest{
|
||||
Path: "/document/text-files/file.txt",
|
||||
Project: "examples",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Delete
|
||||
|
||||
@@ -4,91 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Function/api](
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Call
|
||||
|
||||
Call a function by name
|
||||
|
||||
|
||||
[https://m3o.com/function/api#Call](https://m3o.com/function/api#Call)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/function"
|
||||
)
|
||||
|
||||
// Call a function by name
|
||||
func CallAfunction() {
|
||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := functionService.Call(&function.CallRequest{
|
||||
Name: "helloworld",
|
||||
Request: map[string]interface{}{
|
||||
},
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## List
|
||||
|
||||
List all the deployed functions
|
||||
|
||||
|
||||
[https://m3o.com/function/api#List](https://m3o.com/function/api#List)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/function"
|
||||
)
|
||||
|
||||
// List all the deployed functions
|
||||
func ListFunctions() {
|
||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := functionService.List(&function.ListRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Delete
|
||||
|
||||
Delete a function by name
|
||||
|
||||
|
||||
[https://m3o.com/function/api#Delete](https://m3o.com/function/api#Delete)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/function"
|
||||
)
|
||||
|
||||
// Delete a function by name
|
||||
func DeleteAfunction() {
|
||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := functionService.Delete(&function.DeleteRequest{
|
||||
Name: "helloworld",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Describe
|
||||
|
||||
Get the info for a deployed function
|
||||
@@ -179,3 +94,88 @@ Runtime: "nodejs14",
|
||||
|
||||
}
|
||||
```
|
||||
## Call
|
||||
|
||||
Call a function by name
|
||||
|
||||
|
||||
[https://m3o.com/function/api#Call](https://m3o.com/function/api#Call)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/function"
|
||||
)
|
||||
|
||||
// Call a function by name
|
||||
func CallAfunction() {
|
||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := functionService.Call(&function.CallRequest{
|
||||
Name: "helloworld",
|
||||
Request: map[string]interface{}{
|
||||
},
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## List
|
||||
|
||||
List all the deployed functions
|
||||
|
||||
|
||||
[https://m3o.com/function/api#List](https://m3o.com/function/api#List)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/function"
|
||||
)
|
||||
|
||||
// List all the deployed functions
|
||||
func ListFunctions() {
|
||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := functionService.List(&function.ListRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Delete
|
||||
|
||||
Delete a function by name
|
||||
|
||||
|
||||
[https://m3o.com/function/api#Delete](https://m3o.com/function/api#Delete)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/function"
|
||||
)
|
||||
|
||||
// Delete a function by name
|
||||
func DeleteAfunction() {
|
||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := functionService.Delete(&function.DeleteRequest{
|
||||
Name: "helloworld",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,35 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Geocoding/api]
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Reverse
|
||||
|
||||
Reverse lookup an address from gps coordinates
|
||||
|
||||
|
||||
[https://m3o.com/geocoding/api#Reverse](https://m3o.com/geocoding/api#Reverse)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/geocoding"
|
||||
)
|
||||
|
||||
// Reverse lookup an address from gps coordinates
|
||||
func ReverseGeocodeLocation() {
|
||||
geocodingService := geocoding.NewGeocodingService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := geocodingService.Reverse(&geocoding.ReverseRequest{
|
||||
Latitude: 51.5123064,
|
||||
Longitude: -0.1216235,
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Lookup
|
||||
|
||||
Lookup returns a geocoded address including normalized address and gps coordinates. All fields are optional, provide more to get more accurate results
|
||||
@@ -64,3 +35,32 @@ Postcode: "wc2b",
|
||||
|
||||
}
|
||||
```
|
||||
## Reverse
|
||||
|
||||
Reverse lookup an address from gps coordinates
|
||||
|
||||
|
||||
[https://m3o.com/geocoding/api#Reverse](https://m3o.com/geocoding/api#Reverse)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/geocoding"
|
||||
)
|
||||
|
||||
// Reverse lookup an address from gps coordinates
|
||||
func ReverseGeocodeLocation() {
|
||||
geocodingService := geocoding.NewGeocodingService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := geocodingService.Reverse(&geocoding.ReverseRequest{
|
||||
Latitude: 51.5123064,
|
||||
Longitude: -0.1216235,
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Location/api](
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Read
|
||||
|
||||
Read an entity by its ID
|
||||
|
||||
|
||||
[https://m3o.com/location/api#Read](https://m3o.com/location/api#Read)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/location"
|
||||
)
|
||||
|
||||
// Read an entity by its ID
|
||||
func GetLocationById() {
|
||||
locationService := location.NewLocationService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := locationService.Read(&location.ReadRequest{
|
||||
Id: "1",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Search
|
||||
|
||||
Search for entities in a given radius
|
||||
@@ -102,3 +74,31 @@ func SaveAnEntity() {
|
||||
|
||||
}
|
||||
```
|
||||
## Read
|
||||
|
||||
Read an entity by its ID
|
||||
|
||||
|
||||
[https://m3o.com/location/api#Read](https://m3o.com/location/api#Read)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/location"
|
||||
)
|
||||
|
||||
// Read an entity by its ID
|
||||
func GetLocationById() {
|
||||
locationService := location.NewLocationService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := locationService.Read(&location.ReadRequest{
|
||||
Id: "1",
|
||||
|
||||
})
|
||||
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,63 @@ 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
|
||||
|
||||
|
||||
[https://m3o.com/notes/api#Read](https://m3o.com/notes/api#Read)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/notes"
|
||||
)
|
||||
|
||||
// Read a note
|
||||
func ReadAnote() {
|
||||
notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := notesService.Read(¬es.ReadRequest{
|
||||
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## List
|
||||
|
||||
List all the notes
|
||||
@@ -132,60 +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)
|
||||
|
||||
}
|
||||
```
|
||||
## Read
|
||||
|
||||
Read a note
|
||||
|
||||
|
||||
[https://m3o.com/notes/api#Read](https://m3o.com/notes/api#Read)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/notes"
|
||||
)
|
||||
|
||||
// Read a note
|
||||
func ReadAnote() {
|
||||
notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := notesService.Read(¬es.ReadRequest{
|
||||
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,34 +4,6 @@ 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
|
||||
@@ -87,3 +59,31 @@ 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/Quran/api](htt
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Chapters
|
||||
|
||||
List the Chapters (surahs) of the Quran
|
||||
|
||||
|
||||
[https://m3o.com/quran/api#Chapters](https://m3o.com/quran/api#Chapters)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/quran"
|
||||
)
|
||||
|
||||
// List the Chapters (surahs) of the Quran
|
||||
func ListChapters() {
|
||||
quranService := quran.NewQuranService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := quranService.Chapters(&quran.ChaptersRequest{
|
||||
Language: "en",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Summary
|
||||
|
||||
Get a summary for a given chapter (surah)
|
||||
@@ -92,31 +120,3 @@ func SearchTheQuran() {
|
||||
|
||||
}
|
||||
```
|
||||
## Chapters
|
||||
|
||||
List the Chapters (surahs) of the Quran
|
||||
|
||||
|
||||
[https://m3o.com/quran/api#Chapters](https://m3o.com/quran/api#Chapters)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/quran"
|
||||
)
|
||||
|
||||
// List the Chapters (surahs) of the Quran
|
||||
func ListChapters() {
|
||||
quranService := quran.NewQuranService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := quranService.Chapters(&quran.ChaptersRequest{
|
||||
Language: "en",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,41 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Routing/api](h
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Route
|
||||
|
||||
Retrieve a route as a simple list of gps points along with total distance and estimated duration
|
||||
|
||||
|
||||
[https://m3o.com/routing/api#Route](https://m3o.com/routing/api#Route)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/routing"
|
||||
)
|
||||
|
||||
// Retrieve a route as a simple list of gps points along with total distance and estimated duration
|
||||
func GpsPointsForAroute() {
|
||||
routingService := routing.NewRoutingService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := routingService.Route(&routing.RouteRequest{
|
||||
Destination: &routing.Point{
|
||||
Latitude: 52.529407,
|
||||
Longitude: 13.397634,
|
||||
},
|
||||
Origin: &routing.Point{
|
||||
Latitude: 52.517037,
|
||||
Longitude: 13.38886,
|
||||
},
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Eta
|
||||
|
||||
Get the eta for a route from origin to destination. The eta is an estimated time based on car routes
|
||||
@@ -109,3 +74,38 @@ Origin: &routing.Point{
|
||||
|
||||
}
|
||||
```
|
||||
## Route
|
||||
|
||||
Retrieve a route as a simple list of gps points along with total distance and estimated duration
|
||||
|
||||
|
||||
[https://m3o.com/routing/api#Route](https://m3o.com/routing/api#Route)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/routing"
|
||||
)
|
||||
|
||||
// Retrieve a route as a simple list of gps points along with total distance and estimated duration
|
||||
func GpsPointsForAroute() {
|
||||
routingService := routing.NewRoutingService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := routingService.Route(&routing.RouteRequest{
|
||||
Destination: &routing.Point{
|
||||
Latitude: 52.529407,
|
||||
Longitude: 13.397634,
|
||||
},
|
||||
Origin: &routing.Point{
|
||||
Latitude: 52.517037,
|
||||
Longitude: 13.38886,
|
||||
},
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,6 +4,61 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Rss/api](https
|
||||
|
||||
Endpoints:
|
||||
|
||||
## List
|
||||
|
||||
List the saved RSS fields
|
||||
|
||||
|
||||
[https://m3o.com/rss/api#List](https://m3o.com/rss/api#List)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/rss"
|
||||
)
|
||||
|
||||
// List the saved RSS fields
|
||||
func ListRssFeeds() {
|
||||
rssService := rss.NewRssService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := rssService.List(&rss.ListRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Remove
|
||||
|
||||
Remove an RSS feed by name
|
||||
|
||||
|
||||
[https://m3o.com/rss/api#Remove](https://m3o.com/rss/api#Remove)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/rss"
|
||||
)
|
||||
|
||||
// Remove an RSS feed by name
|
||||
func RemoveAfeed() {
|
||||
rssService := rss.NewRssService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := rssService.Remove(&rss.RemoveRequest{
|
||||
Name: "bbc",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Add
|
||||
|
||||
Add a new RSS feed with a name, url, and category
|
||||
@@ -62,58 +117,3 @@ func ReadAfeed() {
|
||||
|
||||
}
|
||||
```
|
||||
## List
|
||||
|
||||
List the saved RSS fields
|
||||
|
||||
|
||||
[https://m3o.com/rss/api#List](https://m3o.com/rss/api#List)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/rss"
|
||||
)
|
||||
|
||||
// List the saved RSS fields
|
||||
func ListRssFeeds() {
|
||||
rssService := rss.NewRssService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := rssService.List(&rss.ListRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Remove
|
||||
|
||||
Remove an RSS feed by name
|
||||
|
||||
|
||||
[https://m3o.com/rss/api#Remove](https://m3o.com/rss/api#Remove)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/rss"
|
||||
)
|
||||
|
||||
// Remove an RSS feed by name
|
||||
func RemoveAfeed() {
|
||||
rssService := rss.NewRssService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := rssService.Remove(&rss.RemoveRequest{
|
||||
Name: "bbc",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,6 +4,90 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Space/api](htt
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Read
|
||||
|
||||
Read an object in space
|
||||
|
||||
|
||||
[https://m3o.com/space/api#Read](https://m3o.com/space/api#Read)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/space"
|
||||
)
|
||||
|
||||
// Read an object in space
|
||||
func ReadAnObject() {
|
||||
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := spaceService.Read(&space.ReadRequest{
|
||||
Name: "images/file.jpg",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Download
|
||||
|
||||
Download an object via a presigned url
|
||||
|
||||
|
||||
[https://m3o.com/space/api#Download](https://m3o.com/space/api#Download)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/space"
|
||||
)
|
||||
|
||||
// Download an object via a presigned url
|
||||
func DownloadAnObject() {
|
||||
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := spaceService.Download(&space.DownloadRequest{
|
||||
Name: "images/file.jpg",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Upload
|
||||
|
||||
Upload a large object (> 10MB). Returns a time limited presigned URL to be used for uploading the object
|
||||
|
||||
|
||||
[https://m3o.com/space/api#Upload](https://m3o.com/space/api#Upload)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/space"
|
||||
)
|
||||
|
||||
// Upload a large object (> 10MB). Returns a time limited presigned URL to be used for uploading the object
|
||||
func UploadAnObject() {
|
||||
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := spaceService.Upload(&space.UploadRequest{
|
||||
Name: "images/file.jpg",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Create
|
||||
|
||||
Create an object. Returns error if object with this name already exists. Max object size of 10MB, see Upload endpoint for larger objects. If you want to update an existing object use the `Update` endpoint
|
||||
@@ -156,87 +240,3 @@ func HeadAnObject() {
|
||||
|
||||
}
|
||||
```
|
||||
## Read
|
||||
|
||||
Read an object in space
|
||||
|
||||
|
||||
[https://m3o.com/space/api#Read](https://m3o.com/space/api#Read)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/space"
|
||||
)
|
||||
|
||||
// Read an object in space
|
||||
func ReadAnObject() {
|
||||
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := spaceService.Read(&space.ReadRequest{
|
||||
Name: "images/file.jpg",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Download
|
||||
|
||||
Download an object via a presigned url
|
||||
|
||||
|
||||
[https://m3o.com/space/api#Download](https://m3o.com/space/api#Download)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/space"
|
||||
)
|
||||
|
||||
// Download an object via a presigned url
|
||||
func DownloadAnObject() {
|
||||
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := spaceService.Download(&space.DownloadRequest{
|
||||
Name: "images/file.jpg",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Upload
|
||||
|
||||
Upload a large object (> 10MB). Returns a time limited presigned URL to be used for uploading the object
|
||||
|
||||
|
||||
[https://m3o.com/space/api#Upload](https://m3o.com/space/api#Upload)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/space"
|
||||
)
|
||||
|
||||
// Upload a large object (> 10MB). Returns a time limited presigned URL to be used for uploading the object
|
||||
func UploadAnObject() {
|
||||
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := spaceService.Upload(&space.UploadRequest{
|
||||
Name: "images/file.jpg",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,63 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Stock/api](htt
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Quote
|
||||
|
||||
Get the last quote for the stock
|
||||
|
||||
|
||||
[https://m3o.com/stock/api#Quote](https://m3o.com/stock/api#Quote)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/stock"
|
||||
)
|
||||
|
||||
// Get the last quote for the stock
|
||||
func GetAstockQuote() {
|
||||
stockService := stock.NewStockService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := stockService.Quote(&stock.QuoteRequest{
|
||||
Symbol: "AAPL",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## History
|
||||
|
||||
Get the historic open-close for a given day
|
||||
|
||||
|
||||
[https://m3o.com/stock/api#History](https://m3o.com/stock/api#History)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/stock"
|
||||
)
|
||||
|
||||
// Get the historic open-close for a given day
|
||||
func GetHistoricData() {
|
||||
stockService := stock.NewStockService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := stockService.History(&stock.HistoryRequest{
|
||||
Date: "2020-10-01",
|
||||
Stock: "AAPL",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## OrderBook
|
||||
|
||||
Get the historic order book and each trade by timestamp
|
||||
@@ -121,3 +64,60 @@ func GetAstockPrice() {
|
||||
|
||||
}
|
||||
```
|
||||
## Quote
|
||||
|
||||
Get the last quote for the stock
|
||||
|
||||
|
||||
[https://m3o.com/stock/api#Quote](https://m3o.com/stock/api#Quote)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/stock"
|
||||
)
|
||||
|
||||
// Get the last quote for the stock
|
||||
func GetAstockQuote() {
|
||||
stockService := stock.NewStockService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := stockService.Quote(&stock.QuoteRequest{
|
||||
Symbol: "AAPL",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## History
|
||||
|
||||
Get the historic open-close for a given day
|
||||
|
||||
|
||||
[https://m3o.com/stock/api#History](https://m3o.com/stock/api#History)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/stock"
|
||||
)
|
||||
|
||||
// Get the historic open-close for a given day
|
||||
func GetHistoricData() {
|
||||
stockService := stock.NewStockService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := stockService.History(&stock.HistoryRequest{
|
||||
Date: "2020-10-01",
|
||||
Stock: "AAPL",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,6 +4,37 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Stream/api](ht
|
||||
|
||||
Endpoints:
|
||||
|
||||
## CreateChannel
|
||||
|
||||
Create a channel with a given name and description. Channels are created automatically but
|
||||
this allows you to specify a description that's persisted for the lifetime of the channel.
|
||||
|
||||
|
||||
[https://m3o.com/stream/api#CreateChannel](https://m3o.com/stream/api#CreateChannel)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/stream"
|
||||
)
|
||||
|
||||
// Create a channel with a given name and description. Channels are created automatically but
|
||||
// this allows you to specify a description that's persisted for the lifetime of the channel.
|
||||
func CreateChannel() {
|
||||
streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := streamService.CreateChannel(&stream.CreateChannelRequest{
|
||||
Description: "The channel for all things",
|
||||
Name: "general",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## SendMessage
|
||||
|
||||
Send a message to the stream.
|
||||
@@ -88,34 +119,3 @@ func ListChannels() {
|
||||
|
||||
}
|
||||
```
|
||||
## CreateChannel
|
||||
|
||||
Create a channel with a given name and description. Channels are created automatically but
|
||||
this allows you to specify a description that's persisted for the lifetime of the channel.
|
||||
|
||||
|
||||
[https://m3o.com/stream/api#CreateChannel](https://m3o.com/stream/api#CreateChannel)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/stream"
|
||||
)
|
||||
|
||||
// Create a channel with a given name and description. Channels are created automatically but
|
||||
// this allows you to specify a description that's persisted for the lifetime of the channel.
|
||||
func CreateChannel() {
|
||||
streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := streamService.CreateChannel(&stream.CreateChannelRequest{
|
||||
Description: "The channel for all things",
|
||||
Name: "general",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,6 +4,35 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Sunnah/api](ht
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Collections
|
||||
|
||||
Get a list of available collections. A collection is
|
||||
a compilation of hadiths collected and written by an author.
|
||||
|
||||
|
||||
[https://m3o.com/sunnah/api#Collections](https://m3o.com/sunnah/api#Collections)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/sunnah"
|
||||
)
|
||||
|
||||
// Get a list of available collections. A collection is
|
||||
// a compilation of hadiths collected and written by an author.
|
||||
func ListAvailableCollections() {
|
||||
sunnahService := sunnah.NewSunnahService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := sunnahService.Collections(&sunnah.CollectionsRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Books
|
||||
|
||||
Get a list of books from within a collection. A book can contain many chapters
|
||||
@@ -94,32 +123,3 @@ Collection: "bukhari",
|
||||
|
||||
}
|
||||
```
|
||||
## Collections
|
||||
|
||||
Get a list of available collections. A collection is
|
||||
a compilation of hadiths collected and written by an author.
|
||||
|
||||
|
||||
[https://m3o.com/sunnah/api#Collections](https://m3o.com/sunnah/api#Collections)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/sunnah"
|
||||
)
|
||||
|
||||
// Get a list of available collections. A collection is
|
||||
// a compilation of hadiths collected and written by an author.
|
||||
func ListAvailableCollections() {
|
||||
sunnahService := sunnah.NewSunnahService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := sunnahService.Collections(&sunnah.CollectionsRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,6 +4,33 @@ 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
|
||||
@@ -32,30 +59,3 @@ 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,35 +4,6 @@ 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
|
||||
@@ -116,3 +87,32 @@ 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)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,13 +4,12 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/User/api](http
|
||||
|
||||
Endpoints:
|
||||
|
||||
## SendPasswordResetEmail
|
||||
## UpdatePassword
|
||||
|
||||
Send an email with a verification code to reset password.
|
||||
Call "ResetPassword" endpoint once user provides the code.
|
||||
Update the account password
|
||||
|
||||
|
||||
[https://m3o.com/user/api#SendPasswordResetEmail](https://m3o.com/user/api#SendPasswordResetEmail)
|
||||
[https://m3o.com/user/api#UpdatePassword](https://m3o.com/user/api#UpdatePassword)
|
||||
|
||||
```go
|
||||
package example
|
||||
@@ -22,22 +21,190 @@ import(
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Send an email with a verification code to reset password.
|
||||
// Call "ResetPassword" endpoint once user provides the code.
|
||||
func SendPasswordResetEmail() {
|
||||
// Update the account password
|
||||
func UpdateTheAccountPassword() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.SendPasswordResetEmail(&user.SendPasswordResetEmailRequest{
|
||||
Email: "joe@example.com",
|
||||
FromName: "Awesome Dot Com",
|
||||
Subject: "Password reset",
|
||||
TextContent: `Hi there,
|
||||
click here to reset your password: myapp.com/reset/code?=$code`,
|
||||
rsp, err := userService.UpdatePassword(&user.UpdatePasswordRequest{
|
||||
ConfirmPassword: "Password2",
|
||||
NewPassword: "Password2",
|
||||
OldPassword: "Password1",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## List
|
||||
|
||||
List all users. Returns a paged list of results
|
||||
|
||||
|
||||
[https://m3o.com/user/api#List](https://m3o.com/user/api#List)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// List all users. Returns a paged list of results
|
||||
func ListAllUsers() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.List(&user.ListRequest{
|
||||
Limit: 100,
|
||||
Offset: 0,
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## VerifyToken
|
||||
|
||||
Check whether the token attached to MagicLink is valid or not.
|
||||
Ideally, you need to call this endpoint from your http request
|
||||
handler that handles the endpoint which is specified in the
|
||||
SendMagicLink request.
|
||||
|
||||
|
||||
[https://m3o.com/user/api#VerifyToken](https://m3o.com/user/api#VerifyToken)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Check whether the token attached to MagicLink is valid or not.
|
||||
// Ideally, you need to call this endpoint from your http request
|
||||
// handler that handles the endpoint which is specified in the
|
||||
// SendMagicLink request.
|
||||
func VerifyAtoken() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.VerifyToken(&user.VerifyTokenRequest{
|
||||
Token: "EdsUiidouJJJLldjlloofUiorkojflsWWdld",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## 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)
|
||||
|
||||
}
|
||||
```
|
||||
## 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"))
|
||||
|
||||
stream, 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`,
|
||||
|
||||
})
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
for {
|
||||
rsp, err := stream.Recv()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println(rsp)
|
||||
}
|
||||
}
|
||||
```
|
||||
## Delete
|
||||
|
||||
Delete an account by id
|
||||
@@ -94,12 +261,13 @@ func ReadAsessionByTheSessionId() {
|
||||
|
||||
}
|
||||
```
|
||||
## SendMagicLink
|
||||
## SendPasswordResetEmail
|
||||
|
||||
Login using email only - Passwordless
|
||||
Send an email with a verification code to reset password.
|
||||
Call "ResetPassword" endpoint once user provides the code.
|
||||
|
||||
|
||||
[https://m3o.com/user/api#SendMagicLink](https://m3o.com/user/api#SendMagicLink)
|
||||
[https://m3o.com/user/api#SendPasswordResetEmail](https://m3o.com/user/api#SendPasswordResetEmail)
|
||||
|
||||
```go
|
||||
package example
|
||||
@@ -111,35 +279,108 @@ import(
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Login using email only - Passwordless
|
||||
func SendAmagicLink() {
|
||||
// Send an email with a verification code to reset password.
|
||||
// Call "ResetPassword" endpoint once user provides the code.
|
||||
func SendPasswordResetEmail() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
|
||||
stream, err := userService.SendMagicLink(&user.SendMagicLinkRequest{
|
||||
Address: "www.example.com",
|
||||
Email: "joe@example.com",
|
||||
Endpoint: "verifytoken",
|
||||
rsp, err := userService.SendPasswordResetEmail(&user.SendPasswordResetEmailRequest{
|
||||
Email: "joe@example.com",
|
||||
FromName: "Awesome Dot Com",
|
||||
Subject: "MagicLink to access your account",
|
||||
Subject: "Password reset",
|
||||
TextContent: `Hi there,
|
||||
|
||||
Click here to access your account $micro_verification_link`,
|
||||
click here to reset your password: myapp.com/reset/code?=$code`,
|
||||
|
||||
})
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## ResetPassword
|
||||
|
||||
for {
|
||||
rsp, err := stream.Recv()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
Reset password with the code sent by the "SendPasswordResetEmail" endoint.
|
||||
|
||||
fmt.Println(rsp)
|
||||
}
|
||||
|
||||
[https://m3o.com/user/api#ResetPassword](https://m3o.com/user/api#ResetPassword)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Reset password with the code sent by the "SendPasswordResetEmail" endoint.
|
||||
func ResetPassword() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.ResetPassword(&user.ResetPasswordRequest{
|
||||
Code: "012345",
|
||||
ConfirmPassword: "NewPassword1",
|
||||
Email: "joe@example.com",
|
||||
NewPassword: "NewPassword1",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## 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)
|
||||
|
||||
}
|
||||
```
|
||||
## Logout
|
||||
|
||||
Logout a user account
|
||||
|
||||
|
||||
[https://m3o.com/user/api#Logout](https://m3o.com/user/api#Logout)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Logout a user account
|
||||
func LogAuserOut() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.Logout(&user.LogoutRequest{
|
||||
SessionId: "df91a612-5b24-4634-99ff-240220ab8f55",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Create
|
||||
@@ -171,35 +412,6 @@ Username: "joe",
|
||||
})
|
||||
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)
|
||||
|
||||
}
|
||||
```
|
||||
## Read
|
||||
@@ -284,63 +496,6 @@ func ReadAccountByEmail() {
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Logout
|
||||
|
||||
Logout a user account
|
||||
|
||||
|
||||
[https://m3o.com/user/api#Logout](https://m3o.com/user/api#Logout)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Logout a user account
|
||||
func LogAuserOut() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.Logout(&user.LogoutRequest{
|
||||
SessionId: "df91a612-5b24-4634-99ff-240220ab8f55",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## List
|
||||
|
||||
List all users. Returns a paged list of results
|
||||
|
||||
|
||||
[https://m3o.com/user/api#List](https://m3o.com/user/api#List)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// List all users. Returns a paged list of results
|
||||
func ListAllUsers() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.List(&user.ListRequest{
|
||||
Limit: 100,
|
||||
Offset: 0,
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## SendVerificationEmail
|
||||
@@ -390,158 +545,3 @@ Please verify your email by clicking this link: $micro_verification_link`,
|
||||
|
||||
}
|
||||
```
|
||||
## ResetPassword
|
||||
|
||||
Reset password with the code sent by the "SendPasswordResetEmail" endoint.
|
||||
|
||||
|
||||
[https://m3o.com/user/api#ResetPassword](https://m3o.com/user/api#ResetPassword)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Reset password with the code sent by the "SendPasswordResetEmail" endoint.
|
||||
func ResetPassword() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.ResetPassword(&user.ResetPasswordRequest{
|
||||
Code: "012345",
|
||||
ConfirmPassword: "NewPassword1",
|
||||
Email: "joe@example.com",
|
||||
NewPassword: "NewPassword1",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Login
|
||||
|
||||
Login using username or email. The response will return a new session for successful login,
|
||||
401 in the case of login failure and 500 for any other error
|
||||
|
||||
|
||||
[https://m3o.com/user/api#Login](https://m3o.com/user/api#Login)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Login using username or email. The response will return a new session for successful login,
|
||||
// 401 in the case of login failure and 500 for any other error
|
||||
func LogAuserIn() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.Login(&user.LoginRequest{
|
||||
Email: "joe@example.com",
|
||||
Password: "Password1",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## 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)
|
||||
|
||||
}
|
||||
```
|
||||
## 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)
|
||||
|
||||
}
|
||||
```
|
||||
## VerifyToken
|
||||
|
||||
Check whether the token attached to MagicLink is valid or not.
|
||||
Ideally, you need to call this endpoint from your http request
|
||||
handler that handles the endpoint which is specified in the
|
||||
SendMagicLink request.
|
||||
|
||||
|
||||
[https://m3o.com/user/api#VerifyToken](https://m3o.com/user/api#VerifyToken)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Check whether the token attached to MagicLink is valid or not.
|
||||
// Ideally, you need to call this endpoint from your http request
|
||||
// handler that handles the endpoint which is specified in the
|
||||
// SendMagicLink request.
|
||||
func VerifyAtoken() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.VerifyToken(&user.VerifyTokenRequest{
|
||||
Token: "EdsUiidouJJJLldjlloofUiorkojflsWWdld",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user