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:
112
examples/cache/README.md
vendored
112
examples/cache/README.md
vendored
@@ -4,62 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Cache/api](htt
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Get
|
||||
|
||||
Get an item from the cache by key. If key is not found, an empty response is returned.
|
||||
|
||||
|
||||
[https://m3o.com/cache/api#Get](https://m3o.com/cache/api#Get)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/cache"
|
||||
)
|
||||
|
||||
// Get an item from the cache by key. If key is not found, an empty response is returned.
|
||||
func GetAvalue() {
|
||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := cacheService.Get(&cache.GetRequest{
|
||||
Key: "foo",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Delete
|
||||
|
||||
Delete a value from the cache. If key not found a success response is returned.
|
||||
|
||||
|
||||
[https://m3o.com/cache/api#Delete](https://m3o.com/cache/api#Delete)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/cache"
|
||||
)
|
||||
|
||||
// Delete a value from the cache. If key not found a success response is returned.
|
||||
func DeleteAvalue() {
|
||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := cacheService.Delete(&cache.DeleteRequest{
|
||||
Key: "foo",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Increment
|
||||
|
||||
Increment a value (if it's a number). If key not found it is equivalent to set.
|
||||
@@ -147,3 +91,59 @@ Value: "bar",
|
||||
|
||||
}
|
||||
```
|
||||
## Get
|
||||
|
||||
Get an item from the cache by key. If key is not found, an empty response is returned.
|
||||
|
||||
|
||||
[https://m3o.com/cache/api#Get](https://m3o.com/cache/api#Get)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/cache"
|
||||
)
|
||||
|
||||
// Get an item from the cache by key. If key is not found, an empty response is returned.
|
||||
func GetAvalue() {
|
||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := cacheService.Get(&cache.GetRequest{
|
||||
Key: "foo",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Delete
|
||||
|
||||
Delete a value from the cache. If key not found a success response is returned.
|
||||
|
||||
|
||||
[https://m3o.com/cache/api#Delete](https://m3o.com/cache/api#Delete)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/cache"
|
||||
)
|
||||
|
||||
// Delete a value from the cache. If key not found a success response is returned.
|
||||
func DeleteAvalue() {
|
||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := cacheService.Delete(&cache.DeleteRequest{
|
||||
Key: "foo",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,34 +4,6 @@ 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
|
||||
@@ -116,3 +88,31 @@ 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,35 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Currency/api](
|
||||
|
||||
Endpoints:
|
||||
|
||||
## History
|
||||
|
||||
Returns the historic rates for a currency on a given date
|
||||
|
||||
|
||||
[https://m3o.com/currency/api#History](https://m3o.com/currency/api#History)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/currency"
|
||||
)
|
||||
|
||||
// Returns the historic rates for a currency on a given date
|
||||
func HistoricRatesForAcurrency() {
|
||||
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := currencyService.History(¤cy.HistoryRequest{
|
||||
Code: "USD",
|
||||
Date: "2021-05-30",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Codes
|
||||
|
||||
Codes returns the supported currency codes for the API
|
||||
@@ -147,3 +118,32 @@ To: "GBP",
|
||||
|
||||
}
|
||||
```
|
||||
## History
|
||||
|
||||
Returns the historic rates for a currency on a given date
|
||||
|
||||
|
||||
[https://m3o.com/currency/api#History](https://m3o.com/currency/api#History)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/currency"
|
||||
)
|
||||
|
||||
// Returns the historic rates for a currency on a given date
|
||||
func HistoricRatesForAcurrency() {
|
||||
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := currencyService.History(¤cy.HistoryRequest{
|
||||
Code: "USD",
|
||||
Date: "2021-05-30",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,6 +4,38 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Db/api](https:
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Update
|
||||
|
||||
Update a record in the database. Include an "id" in the record to update.
|
||||
|
||||
|
||||
[https://m3o.com/db/api#Update](https://m3o.com/db/api#Update)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/db"
|
||||
)
|
||||
|
||||
// Update a record in the database. Include an "id" in the record to update.
|
||||
func UpdateArecord() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.Update(&db.UpdateRequest{
|
||||
Record: map[string]interface{}{
|
||||
"id": "1",
|
||||
"age": 43,
|
||||
},
|
||||
Table: "users",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Read
|
||||
|
||||
Read data from a table. Lookup can be by ID or via querying any field in the record.
|
||||
@@ -31,6 +63,123 @@ 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)
|
||||
|
||||
}
|
||||
```
|
||||
## 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{}{
|
||||
"isActive": true,
|
||||
"id": "1",
|
||||
"name": "Jane",
|
||||
"age": 42,
|
||||
},
|
||||
Table: "users",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Delete
|
||||
@@ -62,12 +211,12 @@ Table: "users",
|
||||
|
||||
}
|
||||
```
|
||||
## Truncate
|
||||
## DropTable
|
||||
|
||||
Truncate the records in a table
|
||||
Drop a table in the DB
|
||||
|
||||
|
||||
[https://m3o.com/db/api#Truncate](https://m3o.com/db/api#Truncate)
|
||||
[https://m3o.com/db/api#DropTable](https://m3o.com/db/api#DropTable)
|
||||
|
||||
```go
|
||||
package example
|
||||
@@ -79,10 +228,10 @@ import(
|
||||
"go.m3o.com/db"
|
||||
)
|
||||
|
||||
// Truncate the records in a table
|
||||
func TruncateTable() {
|
||||
// Drop a table in the DB
|
||||
func DropTable() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.Truncate(&db.TruncateRequest{
|
||||
rsp, err := dbService.DropTable(&db.DropTableRequest{
|
||||
Table: "users",
|
||||
|
||||
})
|
||||
@@ -119,152 +268,3 @@ To: "events_backup",
|
||||
|
||||
}
|
||||
```
|
||||
## Create
|
||||
|
||||
Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
|
||||
|
||||
|
||||
[https://m3o.com/db/api#Create](https://m3o.com/db/api#Create)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/db"
|
||||
)
|
||||
|
||||
// Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
|
||||
func CreateArecord() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.Create(&db.CreateRequest{
|
||||
Record: map[string]interface{}{
|
||||
"id": "1",
|
||||
"name": "Jane",
|
||||
"age": 42,
|
||||
"isActive": true,
|
||||
},
|
||||
Table: "users",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Update
|
||||
|
||||
Update a record in the database. Include an "id" in the record to update.
|
||||
|
||||
|
||||
[https://m3o.com/db/api#Update](https://m3o.com/db/api#Update)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/db"
|
||||
)
|
||||
|
||||
// Update a record in the database. Include an "id" in the record to update.
|
||||
func UpdateArecord() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.Update(&db.UpdateRequest{
|
||||
Record: map[string]interface{}{
|
||||
"id": "1",
|
||||
"age": 43,
|
||||
},
|
||||
Table: "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)
|
||||
|
||||
}
|
||||
```
|
||||
## DropTable
|
||||
|
||||
Drop a table in the DB
|
||||
|
||||
|
||||
[https://m3o.com/db/api#DropTable](https://m3o.com/db/api#DropTable)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/db"
|
||||
)
|
||||
|
||||
// Drop a table in the DB
|
||||
func DropTable() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.DropTable(&db.DropTableRequest{
|
||||
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)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,63 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Emoji/api](htt
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Flag
|
||||
|
||||
Get the flag for a country. Requires country code e.g GB for great britain
|
||||
|
||||
|
||||
[https://m3o.com/emoji/api#Flag](https://m3o.com/emoji/api#Flag)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/emoji"
|
||||
)
|
||||
|
||||
// Get the flag for a country. Requires country code e.g GB for great britain
|
||||
func GetFlagByCountryCode() {
|
||||
emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := emojiService.Flag(&emoji.FlagRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Print
|
||||
|
||||
Print text and renders the emojis with aliases e.g
|
||||
let's grab a :beer: becomes let's grab a 🍺
|
||||
|
||||
|
||||
[https://m3o.com/emoji/api#Print](https://m3o.com/emoji/api#Print)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/emoji"
|
||||
)
|
||||
|
||||
// Print text and renders the emojis with aliases e.g
|
||||
// let's grab a :beer: becomes let's grab a 🍺
|
||||
func PrintTextIncludingEmoji() {
|
||||
emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := emojiService.Print(&emoji.PrintRequest{
|
||||
Text: "let's grab a :beer:",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Send
|
||||
|
||||
Send an emoji to anyone via SMS. Messages are sent in the form '<message> Sent from <from>'
|
||||
@@ -119,3 +62,60 @@ func FindEmoji() {
|
||||
|
||||
}
|
||||
```
|
||||
## Flag
|
||||
|
||||
Get the flag for a country. Requires country code e.g GB for great britain
|
||||
|
||||
|
||||
[https://m3o.com/emoji/api#Flag](https://m3o.com/emoji/api#Flag)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/emoji"
|
||||
)
|
||||
|
||||
// Get the flag for a country. Requires country code e.g GB for great britain
|
||||
func GetFlagByCountryCode() {
|
||||
emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := emojiService.Flag(&emoji.FlagRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Print
|
||||
|
||||
Print text and renders the emojis with aliases e.g
|
||||
let's grab a :beer: becomes let's grab a 🍺
|
||||
|
||||
|
||||
[https://m3o.com/emoji/api#Print](https://m3o.com/emoji/api#Print)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/emoji"
|
||||
)
|
||||
|
||||
// Print text and renders the emojis with aliases e.g
|
||||
// let's grab a :beer: becomes let's grab a 🍺
|
||||
func PrintTextIncludingEmoji() {
|
||||
emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := emojiService.Print(&emoji.PrintRequest{
|
||||
Text: "let's grab a :beer:",
|
||||
|
||||
})
|
||||
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,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Forex/api](htt
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Price
|
||||
|
||||
Get the latest price for a given forex ticker
|
||||
|
||||
|
||||
[https://m3o.com/forex/api#Price](https://m3o.com/forex/api#Price)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/forex"
|
||||
)
|
||||
|
||||
// Get the latest price for a given forex ticker
|
||||
func GetAnFxPrice() {
|
||||
forexService := forex.NewForexService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := forexService.Price(&forex.PriceRequest{
|
||||
Symbol: "GBPUSD",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Quote
|
||||
|
||||
Get the latest quote for the forex
|
||||
@@ -60,31 +88,3 @@ func GetPreviousClose() {
|
||||
|
||||
}
|
||||
```
|
||||
## Price
|
||||
|
||||
Get the latest price for a given forex ticker
|
||||
|
||||
|
||||
[https://m3o.com/forex/api#Price](https://m3o.com/forex/api#Price)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/forex"
|
||||
)
|
||||
|
||||
// Get the latest price for a given forex ticker
|
||||
func GetAnFxPrice() {
|
||||
forexService := forex.NewForexService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := forexService.Price(&forex.PriceRequest{
|
||||
Symbol: "GBPUSD",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,38 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Function/api](
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Deploy
|
||||
|
||||
Deploy a group of functions
|
||||
|
||||
|
||||
[https://m3o.com/function/api#Deploy](https://m3o.com/function/api#Deploy)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/function"
|
||||
)
|
||||
|
||||
// Deploy a group of functions
|
||||
func DeployAfunction() {
|
||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := functionService.Deploy(&function.DeployRequest{
|
||||
Entrypoint: "helloworld",
|
||||
Name: "my-first-func",
|
||||
Project: "tests",
|
||||
Repo: "github.com/m3o/nodejs-function-example",
|
||||
Runtime: "nodejs14",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Call
|
||||
|
||||
Call a function by name
|
||||
@@ -151,3 +119,35 @@ Project: "tests",
|
||||
|
||||
}
|
||||
```
|
||||
## Deploy
|
||||
|
||||
Deploy a group of functions
|
||||
|
||||
|
||||
[https://m3o.com/function/api#Deploy](https://m3o.com/function/api#Deploy)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/function"
|
||||
)
|
||||
|
||||
// Deploy a group of functions
|
||||
func DeployAfunction() {
|
||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := functionService.Deploy(&function.DeployRequest{
|
||||
Entrypoint: "helloworld",
|
||||
Name: "my-first-func",
|
||||
Project: "tests",
|
||||
Repo: "github.com/m3o/nodejs-function-example",
|
||||
Runtime: "nodejs14",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -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,41 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Routing/api](h
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Directions
|
||||
|
||||
Turn by turn directions from a start point to an end point including maneuvers and bearings
|
||||
|
||||
|
||||
[https://m3o.com/routing/api#Directions](https://m3o.com/routing/api#Directions)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/routing"
|
||||
)
|
||||
|
||||
// Turn by turn directions from a start point to an end point including maneuvers and bearings
|
||||
func TurnByTurnDirections() {
|
||||
routingService := routing.NewRoutingService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := routingService.Directions(&routing.DirectionsRequest{
|
||||
Destination: &routing.Point{
|
||||
Latitude: 52.529407,
|
||||
Longitude: 13.397634,
|
||||
},
|
||||
Origin: &routing.Point{
|
||||
Latitude: 52.517037,
|
||||
Longitude: 13.38886,
|
||||
},
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Route
|
||||
|
||||
Retrieve a route as a simple list of gps points along with total distance and estimated duration
|
||||
@@ -74,38 +109,3 @@ Origin: &routing.Point{
|
||||
|
||||
}
|
||||
```
|
||||
## Directions
|
||||
|
||||
Turn by turn directions from a start point to an end point including maneuvers and bearings
|
||||
|
||||
|
||||
[https://m3o.com/routing/api#Directions](https://m3o.com/routing/api#Directions)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/routing"
|
||||
)
|
||||
|
||||
// Turn by turn directions from a start point to an end point including maneuvers and bearings
|
||||
func TurnByTurnDirections() {
|
||||
routingService := routing.NewRoutingService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := routingService.Directions(&routing.DirectionsRequest{
|
||||
Destination: &routing.Point{
|
||||
Latitude: 52.529407,
|
||||
Longitude: 13.397634,
|
||||
},
|
||||
Origin: &routing.Point{
|
||||
Latitude: 52.517037,
|
||||
Longitude: 13.38886,
|
||||
},
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,37 +4,6 @@ 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.
|
||||
@@ -119,3 +88,34 @@ func ListChannels() {
|
||||
|
||||
}
|
||||
```
|
||||
## CreateChannel
|
||||
|
||||
Create a channel with a given name and description. Channels are created automatically but
|
||||
this allows you to specify a description that's persisted for the lifetime of the channel.
|
||||
|
||||
|
||||
[https://m3o.com/stream/api#CreateChannel](https://m3o.com/stream/api#CreateChannel)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/stream"
|
||||
)
|
||||
|
||||
// Create a channel with a given name and description. Channels are created automatically but
|
||||
// this allows you to specify a description that's persisted for the lifetime of the channel.
|
||||
func CreateChannel() {
|
||||
streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := streamService.CreateChannel(&stream.CreateChannelRequest{
|
||||
Description: "The channel for all things",
|
||||
Name: "general",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,6 +4,35 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Sunnah/api](ht
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Collections
|
||||
|
||||
Get a list of available collections. A collection is
|
||||
a compilation of hadiths collected and written by an author.
|
||||
|
||||
|
||||
[https://m3o.com/sunnah/api#Collections](https://m3o.com/sunnah/api#Collections)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/sunnah"
|
||||
)
|
||||
|
||||
// Get a list of available collections. A collection is
|
||||
// a compilation of hadiths collected and written by an author.
|
||||
func ListAvailableCollections() {
|
||||
sunnahService := sunnah.NewSunnahService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := sunnahService.Collections(&sunnah.CollectionsRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Books
|
||||
|
||||
Get a list of books from within a collection. A book can contain many chapters
|
||||
@@ -94,32 +123,3 @@ Collection: "bukhari",
|
||||
|
||||
}
|
||||
```
|
||||
## Collections
|
||||
|
||||
Get a list of available collections. A collection is
|
||||
a compilation of hadiths collected and written by an author.
|
||||
|
||||
|
||||
[https://m3o.com/sunnah/api#Collections](https://m3o.com/sunnah/api#Collections)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/sunnah"
|
||||
)
|
||||
|
||||
// Get a list of available collections. A collection is
|
||||
// a compilation of hadiths collected and written by an author.
|
||||
func ListAvailableCollections() {
|
||||
sunnahService := sunnah.NewSunnahService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := sunnahService.Collections(&sunnah.CollectionsRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,6 +4,33 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Url/api](https
|
||||
|
||||
Endpoints:
|
||||
|
||||
## List
|
||||
|
||||
List information on all the shortened URLs that you have created
|
||||
|
||||
|
||||
[https://m3o.com/url/api#List](https://m3o.com/url/api#List)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/url"
|
||||
)
|
||||
|
||||
// List information on all the shortened URLs that you have created
|
||||
func ListYourShortenedUrls() {
|
||||
urlService := url.NewUrlService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := urlService.List(&url.ListRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Shorten
|
||||
|
||||
Shortens a destination URL and returns a full short URL.
|
||||
@@ -58,30 +85,3 @@ func ResolveAshortUrlToAlongDestinationUrl() {
|
||||
|
||||
}
|
||||
```
|
||||
## List
|
||||
|
||||
List information on all the shortened URLs that you have created
|
||||
|
||||
|
||||
[https://m3o.com/url/api#List](https://m3o.com/url/api#List)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/url"
|
||||
)
|
||||
|
||||
// List information on all the shortened URLs that you have created
|
||||
func ListYourShortenedUrls() {
|
||||
urlService := url.NewUrlService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := urlService.List(&url.ListRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,6 +4,37 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/User/api](http
|
||||
|
||||
Endpoints:
|
||||
|
||||
## 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: "mySecretPass123",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Logout
|
||||
|
||||
Logout a user account
|
||||
@@ -60,12 +91,12 @@ func ReadAsessionByTheSessionId() {
|
||||
|
||||
}
|
||||
```
|
||||
## Update
|
||||
## Create
|
||||
|
||||
Update the account username or email
|
||||
Create a new user account. The email address and username for the account must be unique.
|
||||
|
||||
|
||||
[https://m3o.com/user/api#Update](https://m3o.com/user/api#Update)
|
||||
[https://m3o.com/user/api#Create](https://m3o.com/user/api#Create)
|
||||
|
||||
```go
|
||||
package example
|
||||
@@ -77,12 +108,108 @@ import(
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Update the account username or email
|
||||
func UpdateAnAccount() {
|
||||
// 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.Update(&user.UpdateRequest{
|
||||
Email: "joeotheremail@example.com",
|
||||
rsp, err := userService.Create(&user.CreateRequest{
|
||||
Email: "joe@example.com",
|
||||
Id: "usrid-1",
|
||||
Password: "mySecretPass123",
|
||||
Username: "usrname-1",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## UpdatePassword
|
||||
|
||||
Update the account password
|
||||
|
||||
|
||||
[https://m3o.com/user/api#UpdatePassword](https://m3o.com/user/api#UpdatePassword)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Update the account password
|
||||
func UpdateTheAccountPassword() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.UpdatePassword(&user.UpdatePasswordRequest{
|
||||
ConfirmPassword: "myEvenMoreSecretPass123",
|
||||
NewPassword: "myEvenMoreSecretPass123",
|
||||
OldPassword: "mySecretPass123",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## ResetPassword
|
||||
|
||||
Reset password with the code sent by the "SendPasswordResetEmail" endoint.
|
||||
|
||||
|
||||
[https://m3o.com/user/api#ResetPassword](https://m3o.com/user/api#ResetPassword)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Reset password with the code sent by the "SendPasswordResetEmail" endoint.
|
||||
func ResetPassword() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.ResetPassword(&user.ResetPasswordRequest{
|
||||
Code: "some-code-from-email",
|
||||
ConfirmPassword: "newpass123",
|
||||
NewPassword: "newpass123",
|
||||
|
||||
})
|
||||
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)
|
||||
@@ -115,6 +242,63 @@ func VerifyEmail() {
|
||||
})
|
||||
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: "fdf34f34f34-f34f34-f43f43f34-f4f34f",
|
||||
|
||||
})
|
||||
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: "joeotheremail@example.com",
|
||||
Id: "usrid-1",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Read
|
||||
@@ -248,187 +432,3 @@ Please verify your email by clicking this link: $micro_verification_link`,
|
||||
|
||||
}
|
||||
```
|
||||
## 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.
|
||||
|
||||
|
||||
[https://m3o.com/user/api#ResetPassword](https://m3o.com/user/api#ResetPassword)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Reset password with the code sent by the "SendPasswordResetEmail" endoint.
|
||||
func ResetPassword() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.ResetPassword(&user.ResetPasswordRequest{
|
||||
Code: "some-code-from-email",
|
||||
ConfirmPassword: "newpass123",
|
||||
NewPassword: "newpass123",
|
||||
|
||||
})
|
||||
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: "fdf34f34f34-f34f34-f43f43f34-f4f34f",
|
||||
|
||||
})
|
||||
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: "mySecretPass123",
|
||||
|
||||
})
|
||||
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: "usrid-1",
|
||||
Password: "mySecretPass123",
|
||||
Username: "usrname-1",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## UpdatePassword
|
||||
|
||||
Update the account password
|
||||
|
||||
|
||||
[https://m3o.com/user/api#UpdatePassword](https://m3o.com/user/api#UpdatePassword)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Update the account password
|
||||
func UpdateTheAccountPassword() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.UpdatePassword(&user.UpdatePasswordRequest{
|
||||
ConfirmPassword: "myEvenMoreSecretPass123",
|
||||
NewPassword: "myEvenMoreSecretPass123",
|
||||
OldPassword: "mySecretPass123",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Weather/api](h
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Now
|
||||
|
||||
Get the current weather report for a location by postcode, city, zip code, ip address
|
||||
|
||||
|
||||
[https://m3o.com/weather/api#Now](https://m3o.com/weather/api#Now)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/weather"
|
||||
)
|
||||
|
||||
// Get the current weather report for a location by postcode, city, zip code, ip address
|
||||
func GetCurrentWeather() {
|
||||
weatherService := weather.NewWeatherService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := weatherService.Now(&weather.NowRequest{
|
||||
Location: "london",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Forecast
|
||||
|
||||
Get the weather forecast for the next 1-10 days
|
||||
@@ -61,3 +33,31 @@ Location: "London",
|
||||
|
||||
}
|
||||
```
|
||||
## Now
|
||||
|
||||
Get the current weather report for a location by postcode, city, zip code, ip address
|
||||
|
||||
|
||||
[https://m3o.com/weather/api#Now](https://m3o.com/weather/api#Now)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/weather"
|
||||
)
|
||||
|
||||
// Get the current weather report for a location by postcode, city, zip code, ip address
|
||||
func GetCurrentWeather() {
|
||||
weatherService := weather.NewWeatherService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := weatherService.Now(&weather.NowRequest{
|
||||
Location: "london",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user