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,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Crypto/api](ht
|
||||
|
||||
Endpoints:
|
||||
|
||||
## History
|
||||
|
||||
Returns the history for the previous close
|
||||
|
||||
|
||||
[https://m3o.com/crypto/api#History](https://m3o.com/crypto/api#History)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/crypto"
|
||||
)
|
||||
|
||||
// Returns the history for the previous close
|
||||
func GetPreviousClose() {
|
||||
cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := cryptoService.History(&crypto.HistoryRequest{
|
||||
Symbol: "BTCUSD",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## News
|
||||
|
||||
Get news related to a currency
|
||||
@@ -88,31 +116,3 @@ func GetAcryptocurrencyQuote() {
|
||||
|
||||
}
|
||||
```
|
||||
## History
|
||||
|
||||
Returns the history for the previous close
|
||||
|
||||
|
||||
[https://m3o.com/crypto/api#History](https://m3o.com/crypto/api#History)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/crypto"
|
||||
)
|
||||
|
||||
// Returns the history for the previous close
|
||||
func GetPreviousClose() {
|
||||
cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := cryptoService.History(&crypto.HistoryRequest{
|
||||
Symbol: "BTCUSD",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,6 +4,61 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Currency/api](
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Codes
|
||||
|
||||
Codes returns the supported currency codes for the API
|
||||
|
||||
|
||||
[https://m3o.com/currency/api#Codes](https://m3o.com/currency/api#Codes)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/currency"
|
||||
)
|
||||
|
||||
// Codes returns the supported currency codes for the API
|
||||
func GetSupportedCodes() {
|
||||
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := currencyService.Codes(¤cy.CodesRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Rates
|
||||
|
||||
Rates returns the currency rates for a given code e.g USD
|
||||
|
||||
|
||||
[https://m3o.com/currency/api#Rates](https://m3o.com/currency/api#Rates)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/currency"
|
||||
)
|
||||
|
||||
// Rates returns the currency rates for a given code e.g USD
|
||||
func GetRatesForUsd() {
|
||||
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := currencyService.Rates(¤cy.RatesRequest{
|
||||
Code: "USD",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Convert
|
||||
|
||||
Convert returns the currency conversion rate between two pairs e.g USD/GBP
|
||||
@@ -92,58 +147,3 @@ Date: "2021-05-30",
|
||||
|
||||
}
|
||||
```
|
||||
## Codes
|
||||
|
||||
Codes returns the supported currency codes for the API
|
||||
|
||||
|
||||
[https://m3o.com/currency/api#Codes](https://m3o.com/currency/api#Codes)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/currency"
|
||||
)
|
||||
|
||||
// Codes returns the supported currency codes for the API
|
||||
func GetSupportedCodes() {
|
||||
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := currencyService.Codes(¤cy.CodesRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Rates
|
||||
|
||||
Rates returns the currency rates for a given code e.g USD
|
||||
|
||||
|
||||
[https://m3o.com/currency/api#Rates](https://m3o.com/currency/api#Rates)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/currency"
|
||||
)
|
||||
|
||||
// Rates returns the currency rates for a given code e.g USD
|
||||
func GetRatesForUsd() {
|
||||
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := currencyService.Rates(¤cy.RatesRequest{
|
||||
Code: "USD",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,90 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Db/api](https:
|
||||
|
||||
Endpoints:
|
||||
|
||||
## ListTables
|
||||
|
||||
List tables in the DB
|
||||
|
||||
|
||||
[https://m3o.com/db/api#ListTables](https://m3o.com/db/api#ListTables)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/db"
|
||||
)
|
||||
|
||||
// List tables in the DB
|
||||
func ListTables() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.ListTables(&db.ListTablesRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Read
|
||||
|
||||
Read data from a table. Lookup can be by ID or via querying any field in the record.
|
||||
|
||||
|
||||
[https://m3o.com/db/api#Read](https://m3o.com/db/api#Read)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/db"
|
||||
)
|
||||
|
||||
// Read data from a table. Lookup can be by ID or via querying any field in the record.
|
||||
func ReadRecords() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.Read(&db.ReadRequest{
|
||||
Query: "age == 43",
|
||||
Table: "users",
|
||||
|
||||
})
|
||||
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: "users",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## DropTable
|
||||
|
||||
Drop a table in the DB
|
||||
@@ -114,34 +30,6 @@ func DropTable() {
|
||||
})
|
||||
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: "users",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## RenameTable
|
||||
@@ -173,12 +61,12 @@ To: "events_backup",
|
||||
|
||||
}
|
||||
```
|
||||
## Create
|
||||
## Read
|
||||
|
||||
Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
|
||||
Read data from a table. Lookup can be by ID or via querying any field in the record.
|
||||
|
||||
|
||||
[https://m3o.com/db/api#Create](https://m3o.com/db/api#Create)
|
||||
[https://m3o.com/db/api#Read](https://m3o.com/db/api#Read)
|
||||
|
||||
```go
|
||||
package example
|
||||
@@ -190,16 +78,11 @@ import(
|
||||
"go.m3o.com/db"
|
||||
)
|
||||
|
||||
// Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
|
||||
func CreateArecord() {
|
||||
// Read data from a table. Lookup can be by ID or via querying any field in the record.
|
||||
func ReadRecords() {
|
||||
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,
|
||||
},
|
||||
rsp, err := dbService.Read(&db.ReadRequest{
|
||||
Query: "age == 43",
|
||||
Table: "users",
|
||||
|
||||
})
|
||||
@@ -268,3 +151,120 @@ Table: "users",
|
||||
|
||||
}
|
||||
```
|
||||
## 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: "users",
|
||||
|
||||
})
|
||||
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: "users",
|
||||
|
||||
})
|
||||
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)
|
||||
|
||||
}
|
||||
```
|
||||
## 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{}{
|
||||
"name": "Jane",
|
||||
"age": 42,
|
||||
"isActive": true,
|
||||
"id": "1",
|
||||
},
|
||||
Table: "users",
|
||||
|
||||
})
|
||||
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{}{
|
||||
"isActive": true,
|
||||
"id": "1",
|
||||
"name": "Jane",
|
||||
"age": 42,
|
||||
"isActive": true,
|
||||
"id": "1",
|
||||
},
|
||||
Table: "users",
|
||||
})
|
||||
|
||||
@@ -4,39 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Event/api](htt
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Publish
|
||||
|
||||
Publish a event to the event stream.
|
||||
|
||||
|
||||
[https://m3o.com/event/api#Publish](https://m3o.com/event/api#Publish)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/event"
|
||||
)
|
||||
|
||||
// Publish a event to the event stream.
|
||||
func PublishAnEvent() {
|
||||
eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := eventService.Publish(&event.PublishRequest{
|
||||
Message: map[string]interface{}{
|
||||
"id": "1",
|
||||
"type": "signup",
|
||||
"user": "john",
|
||||
},
|
||||
Topic: "user",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Consume
|
||||
|
||||
Consume events from a given topic.
|
||||
@@ -106,3 +73,36 @@ func ReadEventsOnAtopic() {
|
||||
|
||||
}
|
||||
```
|
||||
## Publish
|
||||
|
||||
Publish a event to the event stream.
|
||||
|
||||
|
||||
[https://m3o.com/event/api#Publish](https://m3o.com/event/api#Publish)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/event"
|
||||
)
|
||||
|
||||
// Publish a event to the event stream.
|
||||
func PublishAnEvent() {
|
||||
eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := eventService.Publish(&event.PublishRequest{
|
||||
Message: map[string]interface{}{
|
||||
"id": "1",
|
||||
"type": "signup",
|
||||
"user": "john",
|
||||
},
|
||||
Topic: "user",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,62 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Function/api](
|
||||
|
||||
Endpoints:
|
||||
|
||||
## 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: "my-first-func",
|
||||
Project: "tests",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Describe
|
||||
|
||||
Get the info for a deployed function
|
||||
@@ -151,3 +95,59 @@ Request: map[string]interface{}{
|
||||
|
||||
}
|
||||
```
|
||||
## 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: "my-first-func",
|
||||
Project: "tests",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,6 +4,111 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Image/api](htt
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Convert
|
||||
|
||||
Convert an image from one format (jpeg, png etc.) to an other either on the fly (from base64 to base64),
|
||||
or by uploading the conversion result.
|
||||
To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
|
||||
with each parameter as a form field.
|
||||
|
||||
|
||||
[https://m3o.com/image/api#Convert](https://m3o.com/image/api#Convert)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/image"
|
||||
)
|
||||
|
||||
// Convert an image from one format (jpeg, png etc.) to an other either on the fly (from base64 to base64),
|
||||
// or by uploading the conversion result.
|
||||
// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
|
||||
// with each parameter as a form field.
|
||||
func ConvertApngImageToAjpegTakenFromAurlAndSavedToAurlOnMicrosCdn() {
|
||||
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := imageService.Convert(&image.ConvertRequest{
|
||||
Name: "cat.jpeg",
|
||||
Url: "somewebsite.com/cat.png",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Upload
|
||||
|
||||
Upload an image by either sending a base64 encoded image to this endpoint or a URL.
|
||||
To resize an image before uploading, see the Resize endpoint.
|
||||
To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
|
||||
with each parameter as a form field.
|
||||
|
||||
|
||||
[https://m3o.com/image/api#Upload](https://m3o.com/image/api#Upload)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/image"
|
||||
)
|
||||
|
||||
// Upload an image by either sending a base64 encoded image to this endpoint or a URL.
|
||||
// To resize an image before uploading, see the Resize endpoint.
|
||||
// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
|
||||
// with each parameter as a form field.
|
||||
func UploadAbase64imageToMicrosCdn() {
|
||||
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := imageService.Upload(&image.UploadRequest{
|
||||
Base64: "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAx0lEQVR4nOzaMaoDMQyE4ZHj+x82vVdhwQoTkzKQEcwP5r0ihT7sbjUTeAJ4HCegXQJYfOYefOyjDuBiz3yjwJBoCIl6QZOeUjTC1Ix1IxEJXF9+0KWsf2bD4bn37OO/c/wuQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9Sa/NG94Tf3j4WBdaxudMEkn4IM2rZBA0wBrvo7aOcpj2emXvLeVt0IGm0GVXUj91mvAAAA//+V2CZl+4AKXwAAAABJRU5ErkJggg==",
|
||||
Name: "cat.jpeg",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Upload
|
||||
|
||||
Upload an image by either sending a base64 encoded image to this endpoint or a URL.
|
||||
To resize an image before uploading, see the Resize endpoint.
|
||||
To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
|
||||
with each parameter as a form field.
|
||||
|
||||
|
||||
[https://m3o.com/image/api#Upload](https://m3o.com/image/api#Upload)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/image"
|
||||
)
|
||||
|
||||
// Upload an image by either sending a base64 encoded image to this endpoint or a URL.
|
||||
// To resize an image before uploading, see the Resize endpoint.
|
||||
// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
|
||||
// with each parameter as a form field.
|
||||
func UploadAnImageFromAurlToMicrosCdn() {
|
||||
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := imageService.Upload(&image.UploadRequest{
|
||||
Name: "cat.jpeg",
|
||||
Url: "somewebsite.com/cat.png",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Delete
|
||||
|
||||
Delete an image previously uploaded.
|
||||
@@ -151,108 +256,3 @@ Width: 100,
|
||||
|
||||
}
|
||||
```
|
||||
## Convert
|
||||
|
||||
Convert an image from one format (jpeg, png etc.) to an other either on the fly (from base64 to base64),
|
||||
or by uploading the conversion result.
|
||||
To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
|
||||
with each parameter as a form field.
|
||||
|
||||
|
||||
[https://m3o.com/image/api#Convert](https://m3o.com/image/api#Convert)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/image"
|
||||
)
|
||||
|
||||
// Convert an image from one format (jpeg, png etc.) to an other either on the fly (from base64 to base64),
|
||||
// or by uploading the conversion result.
|
||||
// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
|
||||
// with each parameter as a form field.
|
||||
func ConvertApngImageToAjpegTakenFromAurlAndSavedToAurlOnMicrosCdn() {
|
||||
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := imageService.Convert(&image.ConvertRequest{
|
||||
Name: "cat.jpeg",
|
||||
Url: "somewebsite.com/cat.png",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Upload
|
||||
|
||||
Upload an image by either sending a base64 encoded image to this endpoint or a URL.
|
||||
To resize an image before uploading, see the Resize endpoint.
|
||||
To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
|
||||
with each parameter as a form field.
|
||||
|
||||
|
||||
[https://m3o.com/image/api#Upload](https://m3o.com/image/api#Upload)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/image"
|
||||
)
|
||||
|
||||
// Upload an image by either sending a base64 encoded image to this endpoint or a URL.
|
||||
// To resize an image before uploading, see the Resize endpoint.
|
||||
// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
|
||||
// with each parameter as a form field.
|
||||
func UploadAbase64imageToMicrosCdn() {
|
||||
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := imageService.Upload(&image.UploadRequest{
|
||||
Base64: "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAx0lEQVR4nOzaMaoDMQyE4ZHj+x82vVdhwQoTkzKQEcwP5r0ihT7sbjUTeAJ4HCegXQJYfOYefOyjDuBiz3yjwJBoCIl6QZOeUjTC1Ix1IxEJXF9+0KWsf2bD4bn37OO/c/wuQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9Sa/NG94Tf3j4WBdaxudMEkn4IM2rZBA0wBrvo7aOcpj2emXvLeVt0IGm0GVXUj91mvAAAA//+V2CZl+4AKXwAAAABJRU5ErkJggg==",
|
||||
Name: "cat.jpeg",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Upload
|
||||
|
||||
Upload an image by either sending a base64 encoded image to this endpoint or a URL.
|
||||
To resize an image before uploading, see the Resize endpoint.
|
||||
To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
|
||||
with each parameter as a form field.
|
||||
|
||||
|
||||
[https://m3o.com/image/api#Upload](https://m3o.com/image/api#Upload)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/image"
|
||||
)
|
||||
|
||||
// Upload an image by either sending a base64 encoded image to this endpoint or a URL.
|
||||
// To resize an image before uploading, see the Resize endpoint.
|
||||
// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
|
||||
// with each parameter as a form field.
|
||||
func UploadAnImageFromAurlToMicrosCdn() {
|
||||
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := imageService.Upload(&image.UploadRequest{
|
||||
Name: "cat.jpeg",
|
||||
Url: "somewebsite.com/cat.png",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,40 +4,6 @@ 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
|
||||
@@ -102,3 +68,37 @@ func GetLocationById() {
|
||||
|
||||
}
|
||||
```
|
||||
## Search
|
||||
|
||||
Search for entities in a given radius
|
||||
|
||||
|
||||
[https://m3o.com/location/api#Search](https://m3o.com/location/api#Search)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/location"
|
||||
)
|
||||
|
||||
// Search for entities in a given radius
|
||||
func SearchForLocations() {
|
||||
locationService := location.NewLocationService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := locationService.Search(&location.SearchRequest{
|
||||
Center: &location.Point{
|
||||
Latitude: 51.511061,
|
||||
Longitude: -0.120022,
|
||||
},
|
||||
NumEntities: 10,
|
||||
Radius: 100,
|
||||
Type: "bike",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -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,61 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Notes/api](htt
|
||||
|
||||
Endpoints:
|
||||
|
||||
## 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
|
||||
|
||||
|
||||
[https://m3o.com/notes/api#List](https://m3o.com/notes/api#List)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/notes"
|
||||
)
|
||||
|
||||
// List all the notes
|
||||
func ListAllNotes() {
|
||||
notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := notesService.List(¬es.ListRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Update
|
||||
|
||||
Update a note
|
||||
@@ -134,58 +189,3 @@ Title: "New Note",
|
||||
|
||||
}
|
||||
```
|
||||
## 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
|
||||
|
||||
|
||||
[https://m3o.com/notes/api#List](https://m3o.com/notes/api#List)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/notes"
|
||||
)
|
||||
|
||||
// List all the notes
|
||||
func ListAllNotes() {
|
||||
notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := notesService.List(¬es.ListRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,6 +4,38 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Quran/api](htt
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Verses
|
||||
|
||||
Lookup the verses (ayahs) for a chapter including
|
||||
translation, interpretation and breakdown by individual
|
||||
words.
|
||||
|
||||
|
||||
[https://m3o.com/quran/api#Verses](https://m3o.com/quran/api#Verses)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/quran"
|
||||
)
|
||||
|
||||
// Lookup the verses (ayahs) for a chapter including
|
||||
// translation, interpretation and breakdown by individual
|
||||
// words.
|
||||
func GetVersesOfAchapter() {
|
||||
quranService := quran.NewQuranService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := quranService.Verses(&quran.VersesRequest{
|
||||
Chapter: 1,
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Search
|
||||
|
||||
Search the Quran for any form of query or questions
|
||||
@@ -88,35 +120,3 @@ func GetChapterSummary() {
|
||||
|
||||
}
|
||||
```
|
||||
## Verses
|
||||
|
||||
Lookup the verses (ayahs) for a chapter including
|
||||
translation, interpretation and breakdown by individual
|
||||
words.
|
||||
|
||||
|
||||
[https://m3o.com/quran/api#Verses](https://m3o.com/quran/api#Verses)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/quran"
|
||||
)
|
||||
|
||||
// Lookup the verses (ayahs) for a chapter including
|
||||
// translation, interpretation and breakdown by individual
|
||||
// words.
|
||||
func GetVersesOfAchapter() {
|
||||
quranService := quran.NewQuranService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := quranService.Verses(&quran.VersesRequest{
|
||||
Chapter: 1,
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,33 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Stream/api](ht
|
||||
|
||||
Endpoints:
|
||||
|
||||
## ListChannels
|
||||
|
||||
List all the active channels
|
||||
|
||||
|
||||
[https://m3o.com/stream/api#ListChannels](https://m3o.com/stream/api#ListChannels)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/stream"
|
||||
)
|
||||
|
||||
// List all the active channels
|
||||
func ListChannels() {
|
||||
streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := streamService.ListChannels(&stream.ListChannelsRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## CreateChannel
|
||||
|
||||
Create a channel with a given name and description. Channels are created automatically but
|
||||
@@ -119,3 +92,30 @@ func ListMessages() {
|
||||
|
||||
}
|
||||
```
|
||||
## ListChannels
|
||||
|
||||
List all the active channels
|
||||
|
||||
|
||||
[https://m3o.com/stream/api#ListChannels](https://m3o.com/stream/api#ListChannels)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/stream"
|
||||
)
|
||||
|
||||
// List all the active channels
|
||||
func ListChannels() {
|
||||
streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := streamService.ListChannels(&stream.ListChannelsRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -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,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)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,40 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/User/api](http
|
||||
|
||||
Endpoints:
|
||||
|
||||
## SendPasswordResetEmail
|
||||
|
||||
Send an email with a verification code to reset password.
|
||||
Call "ResetPassword" endpoint once user provides the code.
|
||||
|
||||
|
||||
[https://m3o.com/user/api#SendPasswordResetEmail](https://m3o.com/user/api#SendPasswordResetEmail)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// 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"))
|
||||
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`,
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## ResetPassword
|
||||
|
||||
Reset password with the code sent by the "SendPasswordResetEmail" endoint.
|
||||
@@ -67,66 +33,6 @@ 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)
|
||||
|
||||
}
|
||||
```
|
||||
## 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)
|
||||
|
||||
}
|
||||
```
|
||||
## Logout
|
||||
@@ -155,6 +61,62 @@ func LogAuserOut() {
|
||||
})
|
||||
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)
|
||||
|
||||
}
|
||||
```
|
||||
## Delete
|
||||
|
||||
Delete an account by id
|
||||
|
||||
|
||||
[https://m3o.com/user/api#Delete](https://m3o.com/user/api#Delete)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Delete an account by id
|
||||
func DeleteUserAccount() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.Delete(&user.DeleteRequest{
|
||||
Id: "8b98acbe-0b6a-4d66-a414-5ffbf666786f",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Create
|
||||
@@ -186,6 +148,35 @@ 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)
|
||||
|
||||
}
|
||||
```
|
||||
## UpdatePassword
|
||||
@@ -349,12 +340,13 @@ Please verify your email by clicking this link: $micro_verification_link`,
|
||||
|
||||
}
|
||||
```
|
||||
## Delete
|
||||
## SendPasswordResetEmail
|
||||
|
||||
Delete an account by id
|
||||
Send an email with a verification code to reset password.
|
||||
Call "ResetPassword" endpoint once user provides the code.
|
||||
|
||||
|
||||
[https://m3o.com/user/api#Delete](https://m3o.com/user/api#Delete)
|
||||
[https://m3o.com/user/api#SendPasswordResetEmail](https://m3o.com/user/api#SendPasswordResetEmail)
|
||||
|
||||
```go
|
||||
package example
|
||||
@@ -366,23 +358,28 @@ import(
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Delete an account by id
|
||||
func DeleteUserAccount() {
|
||||
// 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"))
|
||||
rsp, err := userService.Delete(&user.DeleteRequest{
|
||||
Id: "8b98acbe-0b6a-4d66-a414-5ffbf666786f",
|
||||
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`,
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## 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
|
||||
@@ -394,23 +391,25 @@ 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)
|
||||
|
||||
}
|
||||
```
|
||||
## Update
|
||||
## Login
|
||||
|
||||
Update the account username or email
|
||||
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#Update](https://m3o.com/user/api#Update)
|
||||
[https://m3o.com/user/api#Login](https://m3o.com/user/api#Login)
|
||||
|
||||
```go
|
||||
package example
|
||||
@@ -422,12 +421,13 @@ import(
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Update the account username or email
|
||||
func UpdateAnAccount() {
|
||||
// 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.Update(&user.UpdateRequest{
|
||||
Email: "joe+2@example.com",
|
||||
Id: "user-1",
|
||||
rsp, err := userService.Login(&user.LoginRequest{
|
||||
Email: "joe@example.com",
|
||||
Password: "Password1",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
Reference in New Issue
Block a user