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:
@@ -56,7 +56,7 @@ func (t *AppService) Resolve(request *ResolveRequest) (*ResolveResponse, error)
|
||||
|
||||
}
|
||||
|
||||
// Run an app
|
||||
// Run an app from a source repo. Specify region etc.
|
||||
func (t *AppService) Run(request *RunRequest) (*RunResponse, error) {
|
||||
|
||||
rsp := &RunResponse{}
|
||||
@@ -72,7 +72,7 @@ func (t *AppService) Status(request *StatusRequest) (*StatusResponse, error) {
|
||||
|
||||
}
|
||||
|
||||
// Update the app
|
||||
// Update the app. The latest source code will be downloaded, built and deployed.
|
||||
func (t *AppService) Update(request *UpdateRequest) (*UpdateResponse, error) {
|
||||
|
||||
rsp := &UpdateResponse{}
|
||||
|
||||
@@ -4,90 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/App/api](https
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Update
|
||||
|
||||
Update the app
|
||||
|
||||
|
||||
[https://m3o.com/app/api#Update](https://m3o.com/app/api#Update)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/app"
|
||||
)
|
||||
|
||||
// Update the app
|
||||
func UpdateAnApp() {
|
||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := appService.Update(&app.UpdateRequest{
|
||||
Name: "helloworld",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Delete
|
||||
|
||||
Delete an app
|
||||
|
||||
|
||||
[https://m3o.com/app/api#Delete](https://m3o.com/app/api#Delete)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/app"
|
||||
)
|
||||
|
||||
// Delete an app
|
||||
func DeleteAnApp() {
|
||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := appService.Delete(&app.DeleteRequest{
|
||||
Name: "helloworld",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Reserve
|
||||
|
||||
Reserve apps beyond the free quota. Call Run after.
|
||||
|
||||
|
||||
[https://m3o.com/app/api#Reserve](https://m3o.com/app/api#Reserve)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/app"
|
||||
)
|
||||
|
||||
// Reserve apps beyond the free quota. Call Run after.
|
||||
func ReserveAppName() {
|
||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := appService.Reserve(&app.ReserveRequest{
|
||||
Name: "helloworld",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## List
|
||||
|
||||
List all the apps
|
||||
@@ -117,7 +33,7 @@ func ListTheApps() {
|
||||
```
|
||||
## Run
|
||||
|
||||
Run an app
|
||||
Run an app from a source repo. Specify region etc.
|
||||
|
||||
|
||||
[https://m3o.com/app/api#Run](https://m3o.com/app/api#Run)
|
||||
@@ -132,14 +48,14 @@ import(
|
||||
"go.m3o.com/app"
|
||||
)
|
||||
|
||||
// Run an app
|
||||
// Run an app from a source repo. Specify region etc.
|
||||
func RunAnApp() {
|
||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := appService.Run(&app.RunRequest{
|
||||
Branch: "master",
|
||||
Name: "helloworld",
|
||||
Port: 8080,
|
||||
Region: "eu-west-1",
|
||||
Region: "europe-west1",
|
||||
Repo: "github.com/asim/helloworld",
|
||||
|
||||
})
|
||||
@@ -230,3 +146,87 @@ func ResolveAppById() {
|
||||
|
||||
}
|
||||
```
|
||||
## Update
|
||||
|
||||
Update the app. The latest source code will be downloaded, built and deployed.
|
||||
|
||||
|
||||
[https://m3o.com/app/api#Update](https://m3o.com/app/api#Update)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/app"
|
||||
)
|
||||
|
||||
// Update the app. The latest source code will be downloaded, built and deployed.
|
||||
func UpdateAnApp() {
|
||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := appService.Update(&app.UpdateRequest{
|
||||
Name: "helloworld",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Delete
|
||||
|
||||
Delete an app
|
||||
|
||||
|
||||
[https://m3o.com/app/api#Delete](https://m3o.com/app/api#Delete)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/app"
|
||||
)
|
||||
|
||||
// Delete an app
|
||||
func DeleteAnApp() {
|
||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := appService.Delete(&app.DeleteRequest{
|
||||
Name: "helloworld",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Reserve
|
||||
|
||||
Reserve apps beyond the free quota. Call Run after.
|
||||
|
||||
|
||||
[https://m3o.com/app/api#Reserve](https://m3o.com/app/api#Reserve)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/app"
|
||||
)
|
||||
|
||||
// Reserve apps beyond the free quota. Call Run after.
|
||||
func ReserveAppName() {
|
||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := appService.Reserve(&app.ReserveRequest{
|
||||
Name: "helloworld",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -7,14 +7,14 @@ import (
|
||||
"go.m3o.com/app"
|
||||
)
|
||||
|
||||
// Run an app
|
||||
// Run an app from a source repo. Specify region etc.
|
||||
func main() {
|
||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := appService.Run(&app.RunRequest{
|
||||
Branch: "master",
|
||||
Name: "helloworld",
|
||||
Port: 8080,
|
||||
Region: "eu-west-1",
|
||||
Region: "europe-west1",
|
||||
Repo: "github.com/asim/helloworld",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"go.m3o.com/app"
|
||||
)
|
||||
|
||||
// Update the app
|
||||
// Update the app. The latest source code will be downloaded, built and deployed.
|
||||
func main() {
|
||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := appService.Update(&app.UpdateRequest{
|
||||
|
||||
@@ -4,62 +4,6 @@ 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
|
||||
|
||||
|
||||
[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
|
||||
@@ -116,3 +60,59 @@ 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)
|
||||
|
||||
}
|
||||
```
|
||||
## 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,33 @@ 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
|
||||
@@ -120,30 +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)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,12 +4,12 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Db/api](https:
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Delete
|
||||
## Read
|
||||
|
||||
Delete a record in the database by id.
|
||||
Read data from a table. Lookup can be by ID or via querying any field in the record.
|
||||
|
||||
|
||||
[https://m3o.com/db/api#Delete](https://m3o.com/db/api#Delete)
|
||||
[https://m3o.com/db/api#Read](https://m3o.com/db/api#Read)
|
||||
|
||||
```go
|
||||
package example
|
||||
@@ -21,16 +21,44 @@ import(
|
||||
"go.m3o.com/db"
|
||||
)
|
||||
|
||||
// Delete a record in the database by id.
|
||||
func DeleteArecord() {
|
||||
// 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.Delete(&db.DeleteRequest{
|
||||
Id: "1",
|
||||
rsp, err := dbService.Read(&db.ReadRequest{
|
||||
Query: "age == 43",
|
||||
Table: "example",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Count
|
||||
|
||||
Count records in a table
|
||||
|
||||
|
||||
[https://m3o.com/db/api#Count](https://m3o.com/db/api#Count)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/db"
|
||||
)
|
||||
|
||||
// Count records in a table
|
||||
func CountEntriesInAtable() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.Count(&db.CountRequest{
|
||||
Table: "example",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## ListTables
|
||||
@@ -145,8 +173,8 @@ func UpdateArecord() {
|
||||
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",
|
||||
|
||||
@@ -155,12 +183,12 @@ Table: "example",
|
||||
|
||||
}
|
||||
```
|
||||
## Read
|
||||
## Delete
|
||||
|
||||
Read data from a table. Lookup can be by ID or via querying any field in the record.
|
||||
Delete a record in the database by id.
|
||||
|
||||
|
||||
[https://m3o.com/db/api#Read](https://m3o.com/db/api#Read)
|
||||
[https://m3o.com/db/api#Delete](https://m3o.com/db/api#Delete)
|
||||
|
||||
```go
|
||||
package example
|
||||
@@ -172,11 +200,11 @@ import(
|
||||
"go.m3o.com/db"
|
||||
)
|
||||
|
||||
// Read data from a table. Lookup can be by ID or via querying any field in the record.
|
||||
func ReadRecords() {
|
||||
// Delete a record in the database by id.
|
||||
func DeleteArecord() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.Read(&db.ReadRequest{
|
||||
Query: "age == 43",
|
||||
rsp, err := dbService.Delete(&db.DeleteRequest{
|
||||
Id: "1",
|
||||
Table: "example",
|
||||
|
||||
})
|
||||
@@ -240,31 +268,3 @@ func DropTable() {
|
||||
|
||||
}
|
||||
```
|
||||
## Count
|
||||
|
||||
Count records in a table
|
||||
|
||||
|
||||
[https://m3o.com/db/api#Count](https://m3o.com/db/api#Count)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/db"
|
||||
)
|
||||
|
||||
// Count records in a table
|
||||
func CountEntriesInAtable() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.Count(&db.CountRequest{
|
||||
Table: "example",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,36 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Emoji/api](htt
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Send
|
||||
|
||||
Send an emoji to anyone via SMS. Messages are sent in the form '<message> Sent from <from>'
|
||||
|
||||
|
||||
[https://m3o.com/emoji/api#Send](https://m3o.com/emoji/api#Send)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/emoji"
|
||||
)
|
||||
|
||||
// Send an emoji to anyone via SMS. Messages are sent in the form '<message> Sent from <from>'
|
||||
func SendAtextContainingAnEmojiToAnyoneViaSms() {
|
||||
emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := emojiService.Send(&emoji.SendRequest{
|
||||
From: "Alice",
|
||||
Message: "let's grab a :beer:",
|
||||
To: "+44782669123",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Find
|
||||
|
||||
Find an emoji by its alias e.g :beer:
|
||||
@@ -119,3 +89,33 @@ func PrintTextIncludingEmoji() {
|
||||
|
||||
}
|
||||
```
|
||||
## Send
|
||||
|
||||
Send an emoji to anyone via SMS. Messages are sent in the form '<message> Sent from <from>'
|
||||
|
||||
|
||||
[https://m3o.com/emoji/api#Send](https://m3o.com/emoji/api#Send)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/emoji"
|
||||
)
|
||||
|
||||
// Send an emoji to anyone via SMS. Messages are sent in the form '<message> Sent from <from>'
|
||||
func SendAtextContainingAnEmojiToAnyoneViaSms() {
|
||||
emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := emojiService.Send(&emoji.SendRequest{
|
||||
From: "Alice",
|
||||
Message: "let's grab a :beer:",
|
||||
To: "+44782669123",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Event/api](htt
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Read
|
||||
|
||||
Read stored events
|
||||
|
||||
|
||||
[https://m3o.com/event/api#Read](https://m3o.com/event/api#Read)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/event"
|
||||
)
|
||||
|
||||
// Read stored events
|
||||
func ReadEventsOnAtopic() {
|
||||
eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := eventService.Read(&event.ReadRequest{
|
||||
Topic: "user",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Publish
|
||||
|
||||
Publish a event to the event stream.
|
||||
@@ -106,3 +78,31 @@ func ConsumeFromAtopic() {
|
||||
}
|
||||
}
|
||||
```
|
||||
## Read
|
||||
|
||||
Read stored events
|
||||
|
||||
|
||||
[https://m3o.com/event/api#Read](https://m3o.com/event/api#Read)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/event"
|
||||
)
|
||||
|
||||
// Read stored events
|
||||
func ReadEventsOnAtopic() {
|
||||
eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := eventService.Read(&event.ReadRequest{
|
||||
Topic: "user",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -12,9 +12,9 @@ func main() {
|
||||
eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := eventService.Publish(&event.PublishRequest{
|
||||
Message: map[string]interface{}{
|
||||
"user": "john",
|
||||
"id": "1",
|
||||
"type": "signup",
|
||||
"user": "john",
|
||||
},
|
||||
Topic: "user",
|
||||
})
|
||||
|
||||
@@ -4,6 +4,64 @@ 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)
|
||||
|
||||
}
|
||||
```
|
||||
## Delete
|
||||
|
||||
Delete a file by project name/path
|
||||
|
||||
|
||||
[https://m3o.com/file/api#Delete](https://m3o.com/file/api#Delete)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/file"
|
||||
)
|
||||
|
||||
// Delete a file by project name/path
|
||||
func DeleteFile() {
|
||||
fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := fileService.Delete(&file.DeleteRequest{
|
||||
Path: "/document/text-files/file.txt",
|
||||
Project: "examples",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Save
|
||||
|
||||
Save a file
|
||||
@@ -64,61 +122,3 @@ func ListFiles() {
|
||||
|
||||
}
|
||||
```
|
||||
## Read
|
||||
|
||||
Read a file by path
|
||||
|
||||
|
||||
[https://m3o.com/file/api#Read](https://m3o.com/file/api#Read)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/file"
|
||||
)
|
||||
|
||||
// Read a file by path
|
||||
func ReadFile() {
|
||||
fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := fileService.Read(&file.ReadRequest{
|
||||
Path: "/document/text-files/file.txt",
|
||||
Project: "examples",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Delete
|
||||
|
||||
Delete a file by project name/path
|
||||
|
||||
|
||||
[https://m3o.com/file/api#Delete](https://m3o.com/file/api#Delete)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/file"
|
||||
)
|
||||
|
||||
// Delete a file by project name/path
|
||||
func DeleteFile() {
|
||||
fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := fileService.Delete(&file.DeleteRequest{
|
||||
Path: "/document/text-files/file.txt",
|
||||
Project: "examples",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,6 +4,62 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Function/api](
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Delete
|
||||
|
||||
Delete a function by name
|
||||
|
||||
|
||||
[https://m3o.com/function/api#Delete](https://m3o.com/function/api#Delete)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/function"
|
||||
)
|
||||
|
||||
// Delete a function by name
|
||||
func DeleteAfunction() {
|
||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := functionService.Delete(&function.DeleteRequest{
|
||||
Name: "helloworld",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Describe
|
||||
|
||||
Get the info for a deployed function
|
||||
|
||||
|
||||
[https://m3o.com/function/api#Describe](https://m3o.com/function/api#Describe)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/function"
|
||||
)
|
||||
|
||||
// Get the info for a deployed function
|
||||
func DescribeFunctionStatus() {
|
||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := functionService.Describe(&function.DescribeRequest{
|
||||
Name: "helloworld",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Deploy
|
||||
|
||||
Deploy a group of functions
|
||||
@@ -123,59 +179,3 @@ func ListFunctions() {
|
||||
|
||||
}
|
||||
```
|
||||
## Delete
|
||||
|
||||
Delete a function by name
|
||||
|
||||
|
||||
[https://m3o.com/function/api#Delete](https://m3o.com/function/api#Delete)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/function"
|
||||
)
|
||||
|
||||
// Delete a function by name
|
||||
func DeleteAfunction() {
|
||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := functionService.Delete(&function.DeleteRequest{
|
||||
Name: "helloworld",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Describe
|
||||
|
||||
Get the info for a deployed function
|
||||
|
||||
|
||||
[https://m3o.com/function/api#Describe](https://m3o.com/function/api#Describe)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/function"
|
||||
)
|
||||
|
||||
// Get the info for a deployed function
|
||||
func DescribeFunctionStatus() {
|
||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := functionService.Describe(&function.DescribeRequest{
|
||||
Name: "helloworld",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -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,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,6 +4,42 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Location/api](
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Save
|
||||
|
||||
Save an entity's current position
|
||||
|
||||
|
||||
[https://m3o.com/location/api#Save](https://m3o.com/location/api#Save)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/location"
|
||||
)
|
||||
|
||||
// Save an entity's current position
|
||||
func SaveAnEntity() {
|
||||
locationService := location.NewLocationService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := locationService.Save(&location.SaveRequest{
|
||||
Entity: &location.Entity{
|
||||
Id: "1",
|
||||
Location: &location.Point{
|
||||
Latitude: 51.511061,
|
||||
Longitude: -0.120022,
|
||||
Timestamp: 1622802761,
|
||||
},
|
||||
Type: "bike",
|
||||
},
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Read
|
||||
|
||||
Read an entity by its ID
|
||||
@@ -66,39 +102,3 @@ Type: "bike",
|
||||
|
||||
}
|
||||
```
|
||||
## Save
|
||||
|
||||
Save an entity's current position
|
||||
|
||||
|
||||
[https://m3o.com/location/api#Save](https://m3o.com/location/api#Save)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/location"
|
||||
)
|
||||
|
||||
// Save an entity's current position
|
||||
func SaveAnEntity() {
|
||||
locationService := location.NewLocationService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := locationService.Save(&location.SaveRequest{
|
||||
Entity: &location.Entity{
|
||||
Id: "1",
|
||||
Location: &location.Point{
|
||||
Latitude: 51.511061,
|
||||
Longitude: -0.120022,
|
||||
Timestamp: 1622802761,
|
||||
},
|
||||
Type: "bike",
|
||||
},
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -12,9 +12,9 @@ func main() {
|
||||
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",
|
||||
})
|
||||
|
||||
@@ -4,93 +4,6 @@ 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
|
||||
|
||||
|
||||
[https://m3o.com/notes/api#Update](https://m3o.com/notes/api#Update)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/notes"
|
||||
)
|
||||
|
||||
// Update a note
|
||||
func UpdateAnote() {
|
||||
notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := notesService.Update(¬es.UpdateRequest{
|
||||
Note: ¬es.Note{
|
||||
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
|
||||
Text: "Updated note text",
|
||||
Title: "Update Note",
|
||||
},
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Delete
|
||||
|
||||
Delete a note
|
||||
@@ -189,3 +102,90 @@ 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)
|
||||
|
||||
}
|
||||
```
|
||||
## Update
|
||||
|
||||
Update a note
|
||||
|
||||
|
||||
[https://m3o.com/notes/api#Update](https://m3o.com/notes/api#Update)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/notes"
|
||||
)
|
||||
|
||||
// Update a note
|
||||
func UpdateAnote() {
|
||||
notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := notesService.Update(¬es.UpdateRequest{
|
||||
Note: ¬es.Note{
|
||||
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
|
||||
Text: "Updated note text",
|
||||
Title: "Update Note",
|
||||
},
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,62 +4,6 @@ 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)
|
||||
|
||||
|
||||
[https://m3o.com/quran/api#Summary](https://m3o.com/quran/api#Summary)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/quran"
|
||||
)
|
||||
|
||||
// Get a summary for a given chapter (surah)
|
||||
func GetChapterSummary() {
|
||||
quranService := quran.NewQuranService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := quranService.Summary(&quran.SummaryRequest{
|
||||
Chapter: 1,
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Verses
|
||||
|
||||
Lookup the verses (ayahs) for a chapter including
|
||||
@@ -120,3 +64,59 @@ 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)
|
||||
|
||||
}
|
||||
```
|
||||
## Summary
|
||||
|
||||
Get a summary for a given chapter (surah)
|
||||
|
||||
|
||||
[https://m3o.com/quran/api#Summary](https://m3o.com/quran/api#Summary)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/quran"
|
||||
)
|
||||
|
||||
// Get a summary for a given chapter (surah)
|
||||
func GetChapterSummary() {
|
||||
quranService := quran.NewQuranService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := quranService.Summary(&quran.SummaryRequest{
|
||||
Chapter: 1,
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,61 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Rss/api](https
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Feed
|
||||
|
||||
Get an RSS feed by name. If no name is given, all feeds are returned. Default limit is 25 entries.
|
||||
|
||||
|
||||
[https://m3o.com/rss/api#Feed](https://m3o.com/rss/api#Feed)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/rss"
|
||||
)
|
||||
|
||||
// Get an RSS feed by name. If no name is given, all feeds are returned. Default limit is 25 entries.
|
||||
func ReadAfeed() {
|
||||
rssService := rss.NewRssService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := rssService.Feed(&rss.FeedRequest{
|
||||
Name: "bbc",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## 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
|
||||
@@ -117,3 +62,58 @@ Url: "http://feeds.bbci.co.uk/news/rss.xml",
|
||||
|
||||
}
|
||||
```
|
||||
## Feed
|
||||
|
||||
Get an RSS feed by name. If no name is given, all feeds are returned. Default limit is 25 entries.
|
||||
|
||||
|
||||
[https://m3o.com/rss/api#Feed](https://m3o.com/rss/api#Feed)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/rss"
|
||||
)
|
||||
|
||||
// Get an RSS feed by name. If no name is given, all feeds are returned. Default limit is 25 entries.
|
||||
func ReadAfeed() {
|
||||
rssService := rss.NewRssService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := rssService.Feed(&rss.FeedRequest{
|
||||
Name: "bbc",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## 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)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,118 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Space/api](htt
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Delete
|
||||
|
||||
Delete an object from space
|
||||
|
||||
|
||||
[https://m3o.com/space/api#Delete](https://m3o.com/space/api#Delete)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/space"
|
||||
)
|
||||
|
||||
// Delete an object from space
|
||||
func DeleteAnObject() {
|
||||
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := spaceService.Delete(&space.DeleteRequest{
|
||||
Name: "images/file.jpg",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## List
|
||||
|
||||
List the objects in space
|
||||
|
||||
|
||||
[https://m3o.com/space/api#List](https://m3o.com/space/api#List)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/space"
|
||||
)
|
||||
|
||||
// List the objects in space
|
||||
func ListObjectsWithPrefix() {
|
||||
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := spaceService.List(&space.ListRequest{
|
||||
Prefix: "images/",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Head
|
||||
|
||||
Retrieve meta information about an object
|
||||
|
||||
|
||||
[https://m3o.com/space/api#Head](https://m3o.com/space/api#Head)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/space"
|
||||
)
|
||||
|
||||
// Retrieve meta information about an object
|
||||
func HeadAnObject() {
|
||||
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := spaceService.Head(&space.HeadRequest{
|
||||
Name: "images/file.jpg",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## 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
|
||||
@@ -232,3 +120,115 @@ Visibility: "public",
|
||||
|
||||
}
|
||||
```
|
||||
## Delete
|
||||
|
||||
Delete an object from space
|
||||
|
||||
|
||||
[https://m3o.com/space/api#Delete](https://m3o.com/space/api#Delete)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/space"
|
||||
)
|
||||
|
||||
// Delete an object from space
|
||||
func DeleteAnObject() {
|
||||
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := spaceService.Delete(&space.DeleteRequest{
|
||||
Name: "images/file.jpg",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## List
|
||||
|
||||
List the objects in space
|
||||
|
||||
|
||||
[https://m3o.com/space/api#List](https://m3o.com/space/api#List)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/space"
|
||||
)
|
||||
|
||||
// List the objects in space
|
||||
func ListObjectsWithPrefix() {
|
||||
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := spaceService.List(&space.ListRequest{
|
||||
Prefix: "images/",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Head
|
||||
|
||||
Retrieve meta information about an object
|
||||
|
||||
|
||||
[https://m3o.com/space/api#Head](https://m3o.com/space/api#Head)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/space"
|
||||
)
|
||||
|
||||
// Retrieve meta information about an object
|
||||
func HeadAnObject() {
|
||||
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := spaceService.Head(&space.HeadRequest{
|
||||
Name: "images/file.jpg",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## 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)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -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,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Twitter/api](h
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Search
|
||||
|
||||
Search for tweets with a simple query
|
||||
|
||||
|
||||
[https://m3o.com/twitter/api#Search](https://m3o.com/twitter/api#Search)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/twitter"
|
||||
)
|
||||
|
||||
// Search for tweets with a simple query
|
||||
func SearchForTweets() {
|
||||
twitterService := twitter.NewTwitterService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := twitterService.Search(&twitter.SearchRequest{
|
||||
Query: "cats",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Trends
|
||||
|
||||
Get the current global trending topics
|
||||
@@ -88,31 +116,3 @@ Username: "m3oservices",
|
||||
|
||||
}
|
||||
```
|
||||
## Search
|
||||
|
||||
Search for tweets with a simple query
|
||||
|
||||
|
||||
[https://m3o.com/twitter/api#Search](https://m3o.com/twitter/api#Search)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/twitter"
|
||||
)
|
||||
|
||||
// Search for tweets with a simple query
|
||||
func SearchForTweets() {
|
||||
twitterService := twitter.NewTwitterService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := twitterService.Search(&twitter.SearchRequest{
|
||||
Query: "cats",
|
||||
|
||||
})
|
||||
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.
|
||||
@@ -69,12 +35,13 @@ NewPassword: "NewPassword1",
|
||||
|
||||
}
|
||||
```
|
||||
## Delete
|
||||
## Login
|
||||
|
||||
Delete an account by id
|
||||
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#Delete](https://m3o.com/user/api#Delete)
|
||||
[https://m3o.com/user/api#Login](https://m3o.com/user/api#Login)
|
||||
|
||||
```go
|
||||
package example
|
||||
@@ -86,23 +53,25 @@ import(
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Delete an account by id
|
||||
func DeleteUserAccount() {
|
||||
// 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.Delete(&user.DeleteRequest{
|
||||
Id: "8b98acbe-0b6a-4d66-a414-5ffbf666786f",
|
||||
rsp, err := userService.Login(&user.LoginRequest{
|
||||
Email: "joe@example.com",
|
||||
Password: "Password1",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## SendMagicLink
|
||||
## Update
|
||||
|
||||
Login using email only - Passwordless
|
||||
Update the account username or email
|
||||
|
||||
|
||||
[https://m3o.com/user/api#SendMagicLink](https://m3o.com/user/api#SendMagicLink)
|
||||
[https://m3o.com/user/api#Update](https://m3o.com/user/api#Update)
|
||||
|
||||
```go
|
||||
package example
|
||||
@@ -114,48 +83,12 @@ import(
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Login using email only - Passwordless
|
||||
func SendAmagicLink() {
|
||||
// Update the account username or email
|
||||
func UpdateAnAccount() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.SendMagicLink(&user.SendMagicLinkRequest{
|
||||
Address: "www.example.com",
|
||||
Email: "joe@example.com",
|
||||
Endpoint: "verifytoken",
|
||||
FromName: "Awesome Dot Com",
|
||||
Subject: "MagicLink to access your account",
|
||||
TextContent: `Hi there,
|
||||
|
||||
Click here to access your account $micro_verification_link`,
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## UpdatePassword
|
||||
|
||||
Update the account password
|
||||
|
||||
|
||||
[https://m3o.com/user/api#UpdatePassword](https://m3o.com/user/api#UpdatePassword)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Update the account password
|
||||
func UpdateTheAccountPassword() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.UpdatePassword(&user.UpdatePasswordRequest{
|
||||
ConfirmPassword: "Password2",
|
||||
NewPassword: "Password2",
|
||||
OldPassword: "Password1",
|
||||
rsp, err := userService.Update(&user.UpdateRequest{
|
||||
Email: "joe+2@example.com",
|
||||
Id: "user-1",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
@@ -246,18 +179,12 @@ func ReadAccountByEmail() {
|
||||
|
||||
}
|
||||
```
|
||||
## SendVerificationEmail
|
||||
## SendMagicLink
|
||||
|
||||
Send a verification email
|
||||
to the user being signed up. Email from will be from 'noreply@email.m3ocontent.com',
|
||||
but you can provide the title and contents.
|
||||
The verification link will be injected in to the email as a template variable, $micro_verification_link.
|
||||
Example: 'Hi there, welcome onboard! Use the link below to verify your email: $micro_verification_link'
|
||||
The variable will be replaced with an actual url that will look similar to this:
|
||||
'https://user.m3o.com/user/verify?token=a-verification-token&redirectUrl=your-redir-url'
|
||||
Login using email only - Passwordless
|
||||
|
||||
|
||||
[https://m3o.com/user/api#SendVerificationEmail](https://m3o.com/user/api#SendVerificationEmail)
|
||||
[https://m3o.com/user/api#SendMagicLink](https://m3o.com/user/api#SendMagicLink)
|
||||
|
||||
```go
|
||||
package example
|
||||
@@ -269,206 +196,18 @@ import(
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Send a verification email
|
||||
// to the user being signed up. Email from will be from 'noreply@email.m3ocontent.com',
|
||||
// but you can provide the title and contents.
|
||||
// The verification link will be injected in to the email as a template variable, $micro_verification_link.
|
||||
// Example: 'Hi there, welcome onboard! Use the link below to verify your email: $micro_verification_link'
|
||||
// The variable will be replaced with an actual url that will look similar to this:
|
||||
// 'https://user.m3o.com/user/verify?token=a-verification-token&redirectUrl=your-redir-url'
|
||||
func SendVerificationEmail() {
|
||||
// Login using email only - Passwordless
|
||||
func SendAmagicLink() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.SendVerificationEmail(&user.SendVerificationEmailRequest{
|
||||
Email: "joe@example.com",
|
||||
FailureRedirectUrl: "https://m3o.com/verification-failed",
|
||||
rsp, err := userService.SendMagicLink(&user.SendMagicLinkRequest{
|
||||
Address: "www.example.com",
|
||||
Email: "joe@example.com",
|
||||
Endpoint: "verifytoken",
|
||||
FromName: "Awesome Dot Com",
|
||||
RedirectUrl: "https://m3o.com",
|
||||
Subject: "Email verification",
|
||||
Subject: "MagicLink to access your account",
|
||||
TextContent: `Hi there,
|
||||
|
||||
Please verify your email by clicking this link: $micro_verification_link`,
|
||||
|
||||
})
|
||||
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)
|
||||
|
||||
}
|
||||
```
|
||||
## 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)
|
||||
|
||||
}
|
||||
```
|
||||
## 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)
|
||||
|
||||
}
|
||||
```
|
||||
## Create
|
||||
|
||||
Create a new user account. The email address and username for the account must be unique.
|
||||
|
||||
|
||||
[https://m3o.com/user/api#Create](https://m3o.com/user/api#Create)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Create a new user account. The email address and username for the account must be unique.
|
||||
func CreateAnAccount() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.Create(&user.CreateRequest{
|
||||
Email: "joe@example.com",
|
||||
Id: "user-1",
|
||||
Password: "Password1",
|
||||
Username: "joe",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## 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)
|
||||
|
||||
}
|
||||
```
|
||||
## 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",
|
||||
Click here to access your account $micro_verification_link`,
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
@@ -532,3 +271,264 @@ Offset: 0,
|
||||
|
||||
}
|
||||
```
|
||||
## 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)
|
||||
|
||||
}
|
||||
```
|
||||
## 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)
|
||||
|
||||
}
|
||||
```
|
||||
## 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)
|
||||
|
||||
}
|
||||
```
|
||||
## 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)
|
||||
|
||||
}
|
||||
```
|
||||
## VerifyEmail
|
||||
|
||||
Verify the email address of an account from a token sent in an email to the user.
|
||||
|
||||
|
||||
[https://m3o.com/user/api#VerifyEmail](https://m3o.com/user/api#VerifyEmail)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Verify the email address of an account from a token sent in an email to the user.
|
||||
func VerifyEmail() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.VerifyEmail(&user.VerifyEmailRequest{
|
||||
Email: "joe@example.com",
|
||||
Token: "012345",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Delete
|
||||
|
||||
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
|
||||
|
||||
Create a new user account. The email address and username for the account must be unique.
|
||||
|
||||
|
||||
[https://m3o.com/user/api#Create](https://m3o.com/user/api#Create)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Create a new user account. The email address and username for the account must be unique.
|
||||
func CreateAnAccount() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.Create(&user.CreateRequest{
|
||||
Email: "joe@example.com",
|
||||
Id: "user-1",
|
||||
Password: "Password1",
|
||||
Username: "joe",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## SendVerificationEmail
|
||||
|
||||
Send a verification email
|
||||
to the user being signed up. Email from will be from 'noreply@email.m3ocontent.com',
|
||||
but you can provide the title and contents.
|
||||
The verification link will be injected in to the email as a template variable, $micro_verification_link.
|
||||
Example: 'Hi there, welcome onboard! Use the link below to verify your email: $micro_verification_link'
|
||||
The variable will be replaced with an actual url that will look similar to this:
|
||||
'https://user.m3o.com/user/verify?token=a-verification-token&redirectUrl=your-redir-url'
|
||||
|
||||
|
||||
[https://m3o.com/user/api#SendVerificationEmail](https://m3o.com/user/api#SendVerificationEmail)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Send a verification email
|
||||
// to the user being signed up. Email from will be from 'noreply@email.m3ocontent.com',
|
||||
// but you can provide the title and contents.
|
||||
// The verification link will be injected in to the email as a template variable, $micro_verification_link.
|
||||
// Example: 'Hi there, welcome onboard! Use the link below to verify your email: $micro_verification_link'
|
||||
// The variable will be replaced with an actual url that will look similar to this:
|
||||
// 'https://user.m3o.com/user/verify?token=a-verification-token&redirectUrl=your-redir-url'
|
||||
func SendVerificationEmail() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.SendVerificationEmail(&user.SendVerificationEmailRequest{
|
||||
Email: "joe@example.com",
|
||||
FailureRedirectUrl: "https://m3o.com/verification-failed",
|
||||
FromName: "Awesome Dot Com",
|
||||
RedirectUrl: "https://m3o.com",
|
||||
Subject: "Email verification",
|
||||
TextContent: `Hi there,
|
||||
|
||||
Please verify your email by clicking this link: $micro_verification_link`,
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user