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:
33
examples/address/README.md
Executable file
33
examples/address/README.md
Executable file
@@ -0,0 +1,33 @@
|
||||
# Address
|
||||
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Address/api](https://m3o.com/Address/api).
|
||||
|
||||
Endpoints:
|
||||
|
||||
## LookupPostcode
|
||||
|
||||
Lookup a list of UK addresses by postcode
|
||||
|
||||
|
||||
[https://m3o.com/address/api#LookupPostcode](https://m3o.com/address/api#LookupPostcode)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/address"
|
||||
)
|
||||
|
||||
// Lookup a list of UK addresses by postcode
|
||||
func LookupPostcode() {
|
||||
addressService := address.NewAddressService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := addressService.LookupPostcode(&address.LookupPostcodeRequest{
|
||||
Postcode: "SW1A 2AA",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
17
examples/address/lookupPostcode/lookupPostcode.go
Executable file
17
examples/address/lookupPostcode/lookupPostcode.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/address"
|
||||
)
|
||||
|
||||
// Lookup a list of UK addresses by postcode
|
||||
func LookupPostcode() {
|
||||
addressService := address.NewAddressService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := addressService.LookupPostcode(&address.LookupPostcodeRequest{
|
||||
Postcode: "SW1A 2AA",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
33
examples/answer/README.md
Executable file
33
examples/answer/README.md
Executable file
@@ -0,0 +1,33 @@
|
||||
# Answer
|
||||
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Answer/api](https://m3o.com/Answer/api).
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Question
|
||||
|
||||
Ask a question and receive an instant answer
|
||||
|
||||
|
||||
[https://m3o.com/answer/api#Question](https://m3o.com/answer/api#Question)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/answer"
|
||||
)
|
||||
|
||||
// Ask a question and receive an instant answer
|
||||
func AskAquestion() {
|
||||
answerService := answer.NewAnswerService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := answerService.Question(&answer.QuestionRequest{
|
||||
Query: "microsoft",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
17
examples/answer/question/askAQuestion.go
Executable file
17
examples/answer/question/askAQuestion.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/answer"
|
||||
)
|
||||
|
||||
// Ask a question and receive an instant answer
|
||||
func AskAquestion() {
|
||||
answerService := answer.NewAnswerService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := answerService.Question(&answer.QuestionRequest{
|
||||
Query: "microsoft",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
144
examples/cache/README.md
vendored
Executable file
144
examples/cache/README.md
vendored
Executable file
@@ -0,0 +1,144 @@
|
||||
# Cache
|
||||
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Cache/api](https://m3o.com/Cache/api).
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Set
|
||||
|
||||
Set an item in the cache. Overwrites any existing value already set.
|
||||
|
||||
|
||||
[https://m3o.com/cache/api#Set](https://m3o.com/cache/api#Set)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/cache"
|
||||
)
|
||||
|
||||
// Set an item in the cache. Overwrites any existing value already set.
|
||||
func SetAvalue() {
|
||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := cacheService.Set(&cache.SetRequest{
|
||||
Key: "foo",
|
||||
Value: "bar",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## Get
|
||||
|
||||
Get an item from the cache by key
|
||||
|
||||
|
||||
[https://m3o.com/cache/api#Get](https://m3o.com/cache/api#Get)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/cache"
|
||||
)
|
||||
|
||||
// Get an item from the cache by key
|
||||
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
|
||||
|
||||
|
||||
[https://m3o.com/cache/api#Delete](https://m3o.com/cache/api#Delete)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/cache"
|
||||
)
|
||||
|
||||
// Delete a value from the cache
|
||||
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)
|
||||
|
||||
|
||||
[https://m3o.com/cache/api#Increment](https://m3o.com/cache/api#Increment)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/cache"
|
||||
)
|
||||
|
||||
// Increment a value (if it's a number)
|
||||
func IncrementAvalue() {
|
||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := cacheService.Increment(&cache.IncrementRequest{
|
||||
Key: "counter",
|
||||
Value: 2,
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## Decrement
|
||||
|
||||
Decrement a value (if it's a number)
|
||||
|
||||
|
||||
[https://m3o.com/cache/api#Decrement](https://m3o.com/cache/api#Decrement)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/cache"
|
||||
)
|
||||
|
||||
// Decrement a value (if it's a number)
|
||||
func DecrementAvalue() {
|
||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := cacheService.Decrement(&cache.DecrementRequest{
|
||||
Key: "counter",
|
||||
Value: 2,
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
18
examples/cache/decrement/decrementAValue.go
vendored
Executable file
18
examples/cache/decrement/decrementAValue.go
vendored
Executable file
@@ -0,0 +1,18 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/cache"
|
||||
)
|
||||
|
||||
// Decrement a value (if it's a number)
|
||||
func DecrementAvalue() {
|
||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := cacheService.Decrement(&cache.DecrementRequest{
|
||||
Key: "counter",
|
||||
Value: 2,
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
17
examples/cache/delete/deleteAValue.go
vendored
Executable file
17
examples/cache/delete/deleteAValue.go
vendored
Executable file
@@ -0,0 +1,17 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/cache"
|
||||
)
|
||||
|
||||
// Delete a value from the cache
|
||||
func DeleteAvalue() {
|
||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := cacheService.Delete(&cache.DeleteRequest{
|
||||
Key: "foo",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
17
examples/cache/get/getAValue.go
vendored
Executable file
17
examples/cache/get/getAValue.go
vendored
Executable file
@@ -0,0 +1,17 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/cache"
|
||||
)
|
||||
|
||||
// Get an item from the cache by key
|
||||
func GetAvalue() {
|
||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := cacheService.Get(&cache.GetRequest{
|
||||
Key: "foo",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
18
examples/cache/increment/incrementAValue.go
vendored
Executable file
18
examples/cache/increment/incrementAValue.go
vendored
Executable file
@@ -0,0 +1,18 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/cache"
|
||||
)
|
||||
|
||||
// Increment a value (if it's a number)
|
||||
func IncrementAvalue() {
|
||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := cacheService.Increment(&cache.IncrementRequest{
|
||||
Key: "counter",
|
||||
Value: 2,
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
18
examples/cache/set/setAValue.go
vendored
Executable file
18
examples/cache/set/setAValue.go
vendored
Executable file
@@ -0,0 +1,18 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/cache"
|
||||
)
|
||||
|
||||
// Set an item in the cache. Overwrites any existing value already set.
|
||||
func SetAvalue() {
|
||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := cacheService.Set(&cache.SetRequest{
|
||||
Key: "foo",
|
||||
Value: "bar",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
114
examples/crypto/README.md
Executable file
114
examples/crypto/README.md
Executable file
@@ -0,0 +1,114 @@
|
||||
# Crypto
|
||||
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Crypto/api](https://m3o.com/Crypto/api).
|
||||
|
||||
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"
|
||||
|
||||
"github.com/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"
|
||||
|
||||
"github.com/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
|
||||
|
||||
|
||||
[https://m3o.com/crypto/api#News](https://m3o.com/crypto/api#News)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/crypto"
|
||||
)
|
||||
|
||||
// Get news related to a currency
|
||||
func GetCryptocurrencyNews() {
|
||||
cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := cryptoService.News(&crypto.NewsRequest{
|
||||
Symbol: "BTCUSD",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## Price
|
||||
|
||||
Get the last price for a given crypto ticker
|
||||
|
||||
|
||||
[https://m3o.com/crypto/api#Price](https://m3o.com/crypto/api#Price)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/crypto"
|
||||
)
|
||||
|
||||
// Get the last price for a given crypto ticker
|
||||
func GetCryptocurrencyPrice() {
|
||||
cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := cryptoService.Price(&crypto.PriceRequest{
|
||||
Symbol: "BTCUSD",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
17
examples/crypto/history/getPreviousClose.go
Executable file
17
examples/crypto/history/getPreviousClose.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/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)
|
||||
}
|
||||
17
examples/crypto/news/getCryptocurrencyNews.go
Executable file
17
examples/crypto/news/getCryptocurrencyNews.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/crypto"
|
||||
)
|
||||
|
||||
// Get news related to a currency
|
||||
func GetCryptocurrencyNews() {
|
||||
cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := cryptoService.News(&crypto.NewsRequest{
|
||||
Symbol: "BTCUSD",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
17
examples/crypto/price/getCryptocurrencyPrice.go
Executable file
17
examples/crypto/price/getCryptocurrencyPrice.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/crypto"
|
||||
)
|
||||
|
||||
// Get the last price for a given crypto ticker
|
||||
func GetCryptocurrencyPrice() {
|
||||
cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := cryptoService.Price(&crypto.PriceRequest{
|
||||
Symbol: "BTCUSD",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
17
examples/crypto/quote/getACryptocurrencyQuote.go
Executable file
17
examples/crypto/quote/getACryptocurrencyQuote.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/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)
|
||||
}
|
||||
144
examples/currency/README.md
Executable file
144
examples/currency/README.md
Executable file
@@ -0,0 +1,144 @@
|
||||
# Currency
|
||||
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Currency/api](https://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"
|
||||
|
||||
"github.com/go.m3o.com/currency"
|
||||
)
|
||||
|
||||
// Codes returns the supported currency codes for the API
|
||||
func GetSupportedCodes() {
|
||||
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := currencyService.Codes(¤cy.CodesRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## Rates
|
||||
|
||||
Rates returns the currency rates for a given code e.g USD
|
||||
|
||||
|
||||
[https://m3o.com/currency/api#Rates](https://m3o.com/currency/api#Rates)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/currency"
|
||||
)
|
||||
|
||||
// Rates returns the currency rates for a given code e.g USD
|
||||
func GetRatesForUsd() {
|
||||
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := currencyService.Rates(¤cy.RatesRequest{
|
||||
Code: "USD",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## Convert
|
||||
|
||||
Convert returns the currency conversion rate between two pairs e.g USD/GBP
|
||||
|
||||
|
||||
[https://m3o.com/currency/api#Convert](https://m3o.com/currency/api#Convert)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/currency"
|
||||
)
|
||||
|
||||
// Convert returns the currency conversion rate between two pairs e.g USD/GBP
|
||||
func ConvertUsdToGbp() {
|
||||
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := currencyService.Convert(¤cy.ConvertRequest{
|
||||
From: "USD",
|
||||
To: "GBP",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## Convert
|
||||
|
||||
Convert returns the currency conversion rate between two pairs e.g USD/GBP
|
||||
|
||||
|
||||
[https://m3o.com/currency/api#Convert](https://m3o.com/currency/api#Convert)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/currency"
|
||||
)
|
||||
|
||||
// Convert returns the currency conversion rate between two pairs e.g USD/GBP
|
||||
func Convert10usdToGbp() {
|
||||
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := currencyService.Convert(¤cy.ConvertRequest{
|
||||
Amount: 10,
|
||||
From: "USD",
|
||||
To: "GBP",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## 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"
|
||||
|
||||
"github.com/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)
|
||||
}
|
||||
```
|
||||
15
examples/currency/codes/getSupportedCodes.go
Executable file
15
examples/currency/codes/getSupportedCodes.go
Executable file
@@ -0,0 +1,15 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/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)
|
||||
}
|
||||
19
examples/currency/convert/convert10UsdToGbp.go
Executable file
19
examples/currency/convert/convert10UsdToGbp.go
Executable file
@@ -0,0 +1,19 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/currency"
|
||||
)
|
||||
|
||||
// Convert returns the currency conversion rate between two pairs e.g USD/GBP
|
||||
func Convert10usdToGbp() {
|
||||
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := currencyService.Convert(¤cy.ConvertRequest{
|
||||
Amount: 10,
|
||||
From: "USD",
|
||||
To: "GBP",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
18
examples/currency/convert/convertUsdToGbp.go
Executable file
18
examples/currency/convert/convertUsdToGbp.go
Executable file
@@ -0,0 +1,18 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/currency"
|
||||
)
|
||||
|
||||
// Convert returns the currency conversion rate between two pairs e.g USD/GBP
|
||||
func ConvertUsdToGbp() {
|
||||
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := currencyService.Convert(¤cy.ConvertRequest{
|
||||
From: "USD",
|
||||
To: "GBP",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
18
examples/currency/history/historicRatesForACurrency.go
Executable file
18
examples/currency/history/historicRatesForACurrency.go
Executable file
@@ -0,0 +1,18 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/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)
|
||||
}
|
||||
17
examples/currency/rates/getRatesForUsd.go
Executable file
17
examples/currency/rates/getRatesForUsd.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/currency"
|
||||
)
|
||||
|
||||
// Rates returns the currency rates for a given code e.g USD
|
||||
func GetRatesForUsd() {
|
||||
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := currencyService.Rates(¤cy.RatesRequest{
|
||||
Code: "USD",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
180
examples/db/README.md
Executable file
180
examples/db/README.md
Executable file
@@ -0,0 +1,180 @@
|
||||
# Db
|
||||
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Db/api](https://m3o.com/Db/api).
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Create
|
||||
|
||||
Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
|
||||
|
||||
|
||||
[https://m3o.com/db/api#Create](https://m3o.com/db/api#Create)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/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"
|
||||
|
||||
"github.com/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{}{
|
||||
"age": 43,
|
||||
"id": "1",
|
||||
},
|
||||
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.
|
||||
|
||||
|
||||
[https://m3o.com/db/api#Read](https://m3o.com/db/api#Read)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/db"
|
||||
)
|
||||
|
||||
// Read data from a table. Lookup can be by ID or via querying any field in the record.
|
||||
func ReadRecords() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.Read(&db.ReadRequest{
|
||||
Query: "age == 43",
|
||||
Table: "users",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## Delete
|
||||
|
||||
Delete a record in the database by id.
|
||||
|
||||
|
||||
[https://m3o.com/db/api#Delete](https://m3o.com/db/api#Delete)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/db"
|
||||
)
|
||||
|
||||
// Delete a record in the database by id.
|
||||
func DeleteArecord() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.Delete(&db.DeleteRequest{
|
||||
Id: "1",
|
||||
Table: "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"
|
||||
|
||||
"github.com/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"
|
||||
|
||||
"github.com/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)
|
||||
}
|
||||
```
|
||||
17
examples/db/count/countEntriesInATable.go
Executable file
17
examples/db/count/countEntriesInATable.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/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)
|
||||
}
|
||||
23
examples/db/create/createARecord.go
Executable file
23
examples/db/create/createARecord.go
Executable file
@@ -0,0 +1,23 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/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)
|
||||
}
|
||||
18
examples/db/delete/deleteARecord.go
Executable file
18
examples/db/delete/deleteARecord.go
Executable file
@@ -0,0 +1,18 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/db"
|
||||
)
|
||||
|
||||
// Delete a record in the database by id.
|
||||
func DeleteArecord() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.Delete(&db.DeleteRequest{
|
||||
Id: "1",
|
||||
Table: "users",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
18
examples/db/read/readRecords.go
Executable file
18
examples/db/read/readRecords.go
Executable file
@@ -0,0 +1,18 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/db"
|
||||
)
|
||||
|
||||
// Read data from a table. Lookup can be by ID or via querying any field in the record.
|
||||
func ReadRecords() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.Read(&db.ReadRequest{
|
||||
Query: "age == 43",
|
||||
Table: "users",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
17
examples/db/truncate/truncateTable.go
Executable file
17
examples/db/truncate/truncateTable.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/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)
|
||||
}
|
||||
21
examples/db/update/updateARecord.go
Executable file
21
examples/db/update/updateARecord.go
Executable file
@@ -0,0 +1,21 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/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{}{
|
||||
"age": 43,
|
||||
"id": "1",
|
||||
},
|
||||
Table: "users",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
37
examples/email/README.md
Executable file
37
examples/email/README.md
Executable file
@@ -0,0 +1,37 @@
|
||||
# Email
|
||||
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Email/api](https://m3o.com/Email/api).
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Send
|
||||
|
||||
Send an email by passing in from, to, subject, and a text or html body
|
||||
|
||||
|
||||
[https://m3o.com/email/api#Send](https://m3o.com/email/api#Send)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/email"
|
||||
)
|
||||
|
||||
// Send an email by passing in from, to, subject, and a text or html body
|
||||
func SendEmail() {
|
||||
emailService := email.NewEmailService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := emailService.Send(&email.SendRequest{
|
||||
From: "Awesome Dot Com",
|
||||
Subject: "Email verification",
|
||||
TextBody: `Hi there,
|
||||
|
||||
Please verify your email by clicking this link: $micro_verification_link`,
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
21
examples/email/send/sendEmail.go
Executable file
21
examples/email/send/sendEmail.go
Executable file
@@ -0,0 +1,21 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/email"
|
||||
)
|
||||
|
||||
// Send an email by passing in from, to, subject, and a text or html body
|
||||
func SendEmail() {
|
||||
emailService := email.NewEmailService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := emailService.Send(&email.SendRequest{
|
||||
From: "Awesome Dot Com",
|
||||
Subject: "Email verification",
|
||||
TextBody: `Hi there,
|
||||
|
||||
Please verify your email by clicking this link: $micro_verification_link`,
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
117
examples/emoji/README.md
Executable file
117
examples/emoji/README.md
Executable file
@@ -0,0 +1,117 @@
|
||||
# Emoji
|
||||
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Emoji/api](https://m3o.com/Emoji/api).
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Find
|
||||
|
||||
Find an emoji by its alias e.g :beer:
|
||||
|
||||
|
||||
[https://m3o.com/emoji/api#Find](https://m3o.com/emoji/api#Find)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/emoji"
|
||||
)
|
||||
|
||||
// Find an emoji by its alias e.g :beer:
|
||||
func FindEmoji() {
|
||||
emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := emojiService.Find(&emoji.FindRequest{
|
||||
Alias: ":beer:",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## 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"
|
||||
|
||||
"github.com/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"
|
||||
|
||||
"github.com/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>'
|
||||
|
||||
|
||||
[https://m3o.com/emoji/api#Send](https://m3o.com/emoji/api#Send)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/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)
|
||||
}
|
||||
```
|
||||
17
examples/emoji/find/findEmoji.go
Executable file
17
examples/emoji/find/findEmoji.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/emoji"
|
||||
)
|
||||
|
||||
// Find an emoji by its alias e.g :beer:
|
||||
func FindEmoji() {
|
||||
emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := emojiService.Find(&emoji.FindRequest{
|
||||
Alias: ":beer:",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
15
examples/emoji/flag/getFlagByCountryCode.go
Executable file
15
examples/emoji/flag/getFlagByCountryCode.go
Executable file
@@ -0,0 +1,15 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/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)
|
||||
}
|
||||
18
examples/emoji/print/printTextIncludingEmoji.go
Executable file
18
examples/emoji/print/printTextIncludingEmoji.go
Executable file
@@ -0,0 +1,18 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/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)
|
||||
}
|
||||
19
examples/emoji/send/sendATextContainingAnEmojiToAnyoneViaSms.go
Executable file
19
examples/emoji/send/sendATextContainingAnEmojiToAnyoneViaSms.go
Executable file
@@ -0,0 +1,19 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/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)
|
||||
}
|
||||
123
examples/evchargers/README.md
Executable file
123
examples/evchargers/README.md
Executable file
@@ -0,0 +1,123 @@
|
||||
# Evchargers
|
||||
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Evchargers/api](https://m3o.com/Evchargers/api).
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Search
|
||||
|
||||
Search by giving a coordinate and a max distance, or bounding box and optional filters
|
||||
|
||||
|
||||
[https://m3o.com/evchargers/api#Search](https://m3o.com/evchargers/api#Search)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/evchargers"
|
||||
)
|
||||
|
||||
// Search by giving a coordinate and a max distance, or bounding box and optional filters
|
||||
func SearchByLocation() {
|
||||
evchargersService := evchargers.NewEvchargersService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := evchargersService.Search(&evchargers.SearchRequest{
|
||||
Distance: 2000,
|
||||
Location: &evchargers.Coordinates{
|
||||
Latitude: 51.53336351319885,
|
||||
Longitude: -0.0252,
|
||||
},
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## Search
|
||||
|
||||
Search by giving a coordinate and a max distance, or bounding box and optional filters
|
||||
|
||||
|
||||
[https://m3o.com/evchargers/api#Search](https://m3o.com/evchargers/api#Search)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/evchargers"
|
||||
)
|
||||
|
||||
// Search by giving a coordinate and a max distance, or bounding box and optional filters
|
||||
func SearchByBoundingBox() {
|
||||
evchargersService := evchargers.NewEvchargersService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := evchargersService.Search(&evchargers.SearchRequest{
|
||||
Box: &evchargers.BoundingBox{
|
||||
},
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## Search
|
||||
|
||||
Search by giving a coordinate and a max distance, or bounding box and optional filters
|
||||
|
||||
|
||||
[https://m3o.com/evchargers/api#Search](https://m3o.com/evchargers/api#Search)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/evchargers"
|
||||
)
|
||||
|
||||
// Search by giving a coordinate and a max distance, or bounding box and optional filters
|
||||
func SearchWithFiltersFastChargersOnly() {
|
||||
evchargersService := evchargers.NewEvchargersService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := evchargersService.Search(&evchargers.SearchRequest{
|
||||
Distance: 2000,
|
||||
Levels: []string{"3"},
|
||||
Location: &evchargers.Coordinates{
|
||||
Latitude: 51.53336351319885,
|
||||
Longitude: -0.0252,
|
||||
},
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## ReferenceData
|
||||
|
||||
Retrieve reference data as used by this API and in conjunction with the Search endpoint
|
||||
|
||||
|
||||
[https://m3o.com/evchargers/api#ReferenceData](https://m3o.com/evchargers/api#ReferenceData)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/evchargers"
|
||||
)
|
||||
|
||||
// Retrieve reference data as used by this API and in conjunction with the Search endpoint
|
||||
func GetReferenceData() {
|
||||
evchargersService := evchargers.NewEvchargersService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := evchargersService.ReferenceData(&evchargers.ReferenceDataRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
15
examples/evchargers/referenceData/getReferenceData.go
Executable file
15
examples/evchargers/referenceData/getReferenceData.go
Executable file
@@ -0,0 +1,15 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/evchargers"
|
||||
)
|
||||
|
||||
// Retrieve reference data as used by this API and in conjunction with the Search endpoint
|
||||
func GetReferenceData() {
|
||||
evchargersService := evchargers.NewEvchargersService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := evchargersService.ReferenceData(&evchargers.ReferenceDataRequest{})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
17
examples/evchargers/search/searchByBoundingBox.go
Executable file
17
examples/evchargers/search/searchByBoundingBox.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/evchargers"
|
||||
)
|
||||
|
||||
// Search by giving a coordinate and a max distance, or bounding box and optional filters
|
||||
func SearchByBoundingBox() {
|
||||
evchargersService := evchargers.NewEvchargersService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := evchargersService.Search(&evchargers.SearchRequest{
|
||||
Box: &evchargers.BoundingBox{},
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
21
examples/evchargers/search/searchByLocation.go
Executable file
21
examples/evchargers/search/searchByLocation.go
Executable file
@@ -0,0 +1,21 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/evchargers"
|
||||
)
|
||||
|
||||
// Search by giving a coordinate and a max distance, or bounding box and optional filters
|
||||
func SearchByLocation() {
|
||||
evchargersService := evchargers.NewEvchargersService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := evchargersService.Search(&evchargers.SearchRequest{
|
||||
Distance: 2000,
|
||||
Location: &evchargers.Coordinates{
|
||||
Latitude: 51.53336351319885,
|
||||
Longitude: -0.0252,
|
||||
},
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
22
examples/evchargers/search/searchWithFiltersFastChargersOnly.go
Executable file
22
examples/evchargers/search/searchWithFiltersFastChargersOnly.go
Executable file
@@ -0,0 +1,22 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/evchargers"
|
||||
)
|
||||
|
||||
// Search by giving a coordinate and a max distance, or bounding box and optional filters
|
||||
func SearchWithFiltersFastChargersOnly() {
|
||||
evchargersService := evchargers.NewEvchargersService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := evchargersService.Search(&evchargers.SearchRequest{
|
||||
Distance: 2000,
|
||||
Levels: []string{"3"},
|
||||
Location: &evchargers.Coordinates{
|
||||
Latitude: 51.53336351319885,
|
||||
Longitude: -0.0252,
|
||||
},
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
120
examples/file/README.md
Executable file
120
examples/file/README.md
Executable file
@@ -0,0 +1,120 @@
|
||||
# File
|
||||
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/File/api](https://m3o.com/File/api).
|
||||
|
||||
Endpoints:
|
||||
|
||||
## List
|
||||
|
||||
List files by their project and optionally a path.
|
||||
|
||||
|
||||
[https://m3o.com/file/api#List](https://m3o.com/file/api#List)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/file"
|
||||
)
|
||||
|
||||
// List files by their project and optionally a path.
|
||||
func ListFiles() {
|
||||
fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := fileService.List(&file.ListRequest{
|
||||
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"
|
||||
|
||||
"github.com/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)
|
||||
}
|
||||
```
|
||||
## Read
|
||||
|
||||
Read a file by path
|
||||
|
||||
|
||||
[https://m3o.com/file/api#Read](https://m3o.com/file/api#Read)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/file"
|
||||
)
|
||||
|
||||
// Read a file by path
|
||||
func ReadFile() {
|
||||
fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := fileService.Read(&file.ReadRequest{
|
||||
Path: "/document/text-files/file.txt",
|
||||
Project: "examples",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## Save
|
||||
|
||||
Save a file
|
||||
|
||||
|
||||
[https://m3o.com/file/api#Save](https://m3o.com/file/api#Save)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/file"
|
||||
)
|
||||
|
||||
// Save a file
|
||||
func SaveFile() {
|
||||
fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := fileService.Save(&file.SaveRequest{
|
||||
File: &file.Record{
|
||||
Content: "file content example",
|
||||
Path: "/document/text-files/file.txt",
|
||||
Project: "examples",
|
||||
},
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
18
examples/file/delete/deleteFile.go
Executable file
18
examples/file/delete/deleteFile.go
Executable file
@@ -0,0 +1,18 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/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)
|
||||
}
|
||||
17
examples/file/list/listFiles.go
Executable file
17
examples/file/list/listFiles.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/file"
|
||||
)
|
||||
|
||||
// List files by their project and optionally a path.
|
||||
func ListFiles() {
|
||||
fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := fileService.List(&file.ListRequest{
|
||||
Project: "examples",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
18
examples/file/read/readFile.go
Executable file
18
examples/file/read/readFile.go
Executable file
@@ -0,0 +1,18 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/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)
|
||||
}
|
||||
21
examples/file/save/saveFile.go
Executable file
21
examples/file/save/saveFile.go
Executable file
@@ -0,0 +1,21 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/file"
|
||||
)
|
||||
|
||||
// Save a file
|
||||
func SaveFile() {
|
||||
fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := fileService.Save(&file.SaveRequest{
|
||||
File: &file.Record{
|
||||
Content: "file content example",
|
||||
Path: "/document/text-files/file.txt",
|
||||
Project: "examples",
|
||||
},
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
87
examples/forex/README.md
Executable file
87
examples/forex/README.md
Executable file
@@ -0,0 +1,87 @@
|
||||
# Forex
|
||||
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Forex/api](https://m3o.com/Forex/api).
|
||||
|
||||
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"
|
||||
|
||||
"github.com/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
|
||||
|
||||
|
||||
[https://m3o.com/forex/api#Quote](https://m3o.com/forex/api#Quote)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/forex"
|
||||
)
|
||||
|
||||
// Get the latest quote for the forex
|
||||
func GetAfxQuote() {
|
||||
forexService := forex.NewForexService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := forexService.Quote(&forex.QuoteRequest{
|
||||
Symbol: "GBPUSD",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## History
|
||||
|
||||
Returns the data for the previous close
|
||||
|
||||
|
||||
[https://m3o.com/forex/api#History](https://m3o.com/forex/api#History)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/forex"
|
||||
)
|
||||
|
||||
// Returns the data for the previous close
|
||||
func GetPreviousClose() {
|
||||
forexService := forex.NewForexService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := forexService.History(&forex.HistoryRequest{
|
||||
Symbol: "GBPUSD",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
17
examples/forex/history/getPreviousClose.go
Executable file
17
examples/forex/history/getPreviousClose.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/forex"
|
||||
)
|
||||
|
||||
// Returns the data for the previous close
|
||||
func GetPreviousClose() {
|
||||
forexService := forex.NewForexService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := forexService.History(&forex.HistoryRequest{
|
||||
Symbol: "GBPUSD",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
17
examples/forex/price/getAnFxPrice.go
Executable file
17
examples/forex/price/getAnFxPrice.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/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)
|
||||
}
|
||||
17
examples/forex/quote/getAFxQuote.go
Executable file
17
examples/forex/quote/getAFxQuote.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/forex"
|
||||
)
|
||||
|
||||
// Get the latest quote for the forex
|
||||
func GetAfxQuote() {
|
||||
forexService := forex.NewForexService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := forexService.Quote(&forex.QuoteRequest{
|
||||
Symbol: "GBPUSD",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
148
examples/function/README.md
Executable file
148
examples/function/README.md
Executable file
@@ -0,0 +1,148 @@
|
||||
# Function
|
||||
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Function/api](https://m3o.com/Function/api).
|
||||
|
||||
Endpoints:
|
||||
|
||||
## 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"
|
||||
|
||||
"github.com/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: "my-first-func",
|
||||
Project: "tests",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## Deploy
|
||||
|
||||
Deploy a group of functions
|
||||
|
||||
|
||||
[https://m3o.com/function/api#Deploy](https://m3o.com/function/api#Deploy)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/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
|
||||
|
||||
|
||||
[https://m3o.com/function/api#Call](https://m3o.com/function/api#Call)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/function"
|
||||
)
|
||||
|
||||
// Call a function by name
|
||||
func CallAfunction() {
|
||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := functionService.Call(&function.CallRequest{
|
||||
Name: "my-first-func",
|
||||
Request: map[string]interface{}{
|
||||
},
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## List
|
||||
|
||||
List all the deployed functions
|
||||
|
||||
|
||||
[https://m3o.com/function/api#List](https://m3o.com/function/api#List)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/function"
|
||||
)
|
||||
|
||||
// List all the deployed functions
|
||||
func ListFunctions() {
|
||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := functionService.List(&function.ListRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## Delete
|
||||
|
||||
Delete a function by name
|
||||
|
||||
|
||||
[https://m3o.com/function/api#Delete](https://m3o.com/function/api#Delete)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/function"
|
||||
)
|
||||
|
||||
// Delete a function by name
|
||||
func DeleteAfunction() {
|
||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := functionService.Delete(&function.DeleteRequest{
|
||||
Name: "my-first-func",
|
||||
Project: "tests",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
18
examples/function/call/callAFunction.go
Executable file
18
examples/function/call/callAFunction.go
Executable file
@@ -0,0 +1,18 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/function"
|
||||
)
|
||||
|
||||
// Call a function by name
|
||||
func CallAfunction() {
|
||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := functionService.Call(&function.CallRequest{
|
||||
Name: "my-first-func",
|
||||
Request: map[string]interface{}{},
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
18
examples/function/delete/deleteAFunction.go
Executable file
18
examples/function/delete/deleteAFunction.go
Executable file
@@ -0,0 +1,18 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/function"
|
||||
)
|
||||
|
||||
// Delete a function by name
|
||||
func DeleteAfunction() {
|
||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := functionService.Delete(&function.DeleteRequest{
|
||||
Name: "my-first-func",
|
||||
Project: "tests",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
21
examples/function/deploy/deployAFunction.go
Executable file
21
examples/function/deploy/deployAFunction.go
Executable file
@@ -0,0 +1,21 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/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)
|
||||
}
|
||||
18
examples/function/describe/describeFunctionStatus.go
Executable file
18
examples/function/describe/describeFunctionStatus.go
Executable file
@@ -0,0 +1,18 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/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: "my-first-func",
|
||||
Project: "tests",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
15
examples/function/list/listFunctions.go
Executable file
15
examples/function/list/listFunctions.go
Executable file
@@ -0,0 +1,15 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/function"
|
||||
)
|
||||
|
||||
// List all the deployed functions
|
||||
func ListFunctions() {
|
||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := functionService.List(&function.ListRequest{})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
64
examples/geocoding/README.md
Executable file
64
examples/geocoding/README.md
Executable file
@@ -0,0 +1,64 @@
|
||||
# Geocoding
|
||||
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Geocoding/api](https://m3o.com/Geocoding/api).
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Lookup
|
||||
|
||||
Lookup returns a geocoded address including normalized address and gps coordinates. All fields are optional, provide more to get more accurate results
|
||||
|
||||
|
||||
[https://m3o.com/geocoding/api#Lookup](https://m3o.com/geocoding/api#Lookup)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/geocoding"
|
||||
)
|
||||
|
||||
// Lookup returns a geocoded address including normalized address and gps coordinates. All fields are optional, provide more to get more accurate results
|
||||
func GeocodeAnAddress() {
|
||||
geocodingService := geocoding.NewGeocodingService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := geocodingService.Lookup(&geocoding.LookupRequest{
|
||||
Address: "10 russell st",
|
||||
City: "london",
|
||||
Country: "uk",
|
||||
Postcode: "wc2b",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## 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"
|
||||
|
||||
"github.com/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)
|
||||
}
|
||||
```
|
||||
20
examples/geocoding/lookup/geocodeAnAddress.go
Executable file
20
examples/geocoding/lookup/geocodeAnAddress.go
Executable file
@@ -0,0 +1,20 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/geocoding"
|
||||
)
|
||||
|
||||
// Lookup returns a geocoded address including normalized address and gps coordinates. All fields are optional, provide more to get more accurate results
|
||||
func GeocodeAnAddress() {
|
||||
geocodingService := geocoding.NewGeocodingService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := geocodingService.Lookup(&geocoding.LookupRequest{
|
||||
Address: "10 russell st",
|
||||
City: "london",
|
||||
Country: "uk",
|
||||
Postcode: "wc2b",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
18
examples/geocoding/reverse/reverseGeocodeLocation.go
Executable file
18
examples/geocoding/reverse/reverseGeocodeLocation.go
Executable file
@@ -0,0 +1,18 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/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)
|
||||
}
|
||||
34
examples/gifs/README.md
Executable file
34
examples/gifs/README.md
Executable file
@@ -0,0 +1,34 @@
|
||||
# Gifs
|
||||
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Gifs/api](https://m3o.com/Gifs/api).
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Search
|
||||
|
||||
Search for a GIF
|
||||
|
||||
|
||||
[https://m3o.com/gifs/api#Search](https://m3o.com/gifs/api#Search)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/gifs"
|
||||
)
|
||||
|
||||
// Search for a GIF
|
||||
func Search() {
|
||||
gifsService := gifs.NewGifsService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := gifsService.Search(&gifs.SearchRequest{
|
||||
Limit: 2,
|
||||
Query: "dogs",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
18
examples/gifs/search/search.go
Executable file
18
examples/gifs/search/search.go
Executable file
@@ -0,0 +1,18 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/gifs"
|
||||
)
|
||||
|
||||
// Search for a GIF
|
||||
func Search() {
|
||||
gifsService := gifs.NewGifsService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := gifsService.Search(&gifs.SearchRequest{
|
||||
Limit: 2,
|
||||
Query: "dogs",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
33
examples/google/README.md
Executable file
33
examples/google/README.md
Executable file
@@ -0,0 +1,33 @@
|
||||
# Google
|
||||
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Google/api](https://m3o.com/Google/api).
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Search
|
||||
|
||||
Search for videos on Google
|
||||
|
||||
|
||||
[https://m3o.com/google/api#Search](https://m3o.com/google/api#Search)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/google"
|
||||
)
|
||||
|
||||
// Search for videos on Google
|
||||
func SearchForVideos() {
|
||||
googleService := google.NewGoogleService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := googleService.Search(&google.SearchRequest{
|
||||
Query: "how to make donuts",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
17
examples/google/search/searchForVideos.go
Executable file
17
examples/google/search/searchForVideos.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/google"
|
||||
)
|
||||
|
||||
// Search for videos on Google
|
||||
func SearchForVideos() {
|
||||
googleService := google.NewGoogleService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := googleService.Search(&google.SearchRequest{
|
||||
Query: "how to make donuts",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
60
examples/helloworld/README.md
Executable file
60
examples/helloworld/README.md
Executable file
@@ -0,0 +1,60 @@
|
||||
# Helloworld
|
||||
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Helloworld/api](https://m3o.com/Helloworld/api).
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Call
|
||||
|
||||
Call returns a personalised "Hello $name" response
|
||||
|
||||
|
||||
[https://m3o.com/helloworld/api#Call](https://m3o.com/helloworld/api#Call)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/helloworld"
|
||||
)
|
||||
|
||||
// Call returns a personalised "Hello $name" response
|
||||
func CallTheHelloworldService() {
|
||||
helloworldService := helloworld.NewHelloworldService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := helloworldService.Call(&helloworld.CallRequest{
|
||||
Name: "John",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## Stream
|
||||
|
||||
Stream returns a stream of "Hello $name" responses
|
||||
|
||||
|
||||
[https://m3o.com/helloworld/api#Stream](https://m3o.com/helloworld/api#Stream)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/helloworld"
|
||||
)
|
||||
|
||||
// Stream returns a stream of "Hello $name" responses
|
||||
func StreamsAreCurrentlyTemporarilyNotSupportedInClients() {
|
||||
helloworldService := helloworld.NewHelloworldService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := helloworldService.Stream(&helloworld.StreamRequest{
|
||||
Name: "not supported",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
17
examples/helloworld/call/callTheHelloworldService.go
Executable file
17
examples/helloworld/call/callTheHelloworldService.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/helloworld"
|
||||
)
|
||||
|
||||
// Call returns a personalised "Hello $name" response
|
||||
func CallTheHelloworldService() {
|
||||
helloworldService := helloworld.NewHelloworldService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := helloworldService.Call(&helloworld.CallRequest{
|
||||
Name: "John",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/helloworld"
|
||||
)
|
||||
|
||||
// Stream returns a stream of "Hello $name" responses
|
||||
func StreamsAreCurrentlyTemporarilyNotSupportedInClients() {
|
||||
helloworldService := helloworld.NewHelloworldService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := helloworldService.Stream(&helloworld.StreamRequest{
|
||||
Name: "not supported",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
59
examples/holidays/README.md
Executable file
59
examples/holidays/README.md
Executable file
@@ -0,0 +1,59 @@
|
||||
# Holidays
|
||||
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Holidays/api](https://m3o.com/Holidays/api).
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Countries
|
||||
|
||||
Get the list of countries that are supported by this API
|
||||
|
||||
|
||||
[https://m3o.com/holidays/api#Countries](https://m3o.com/holidays/api#Countries)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/holidays"
|
||||
)
|
||||
|
||||
// Get the list of countries that are supported by this API
|
||||
func ListCountries() {
|
||||
holidaysService := holidays.NewHolidaysService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := holidaysService.Countries(&holidays.CountriesRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## List
|
||||
|
||||
List the holiday dates for a given country and year
|
||||
|
||||
|
||||
[https://m3o.com/holidays/api#List](https://m3o.com/holidays/api#List)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/holidays"
|
||||
)
|
||||
|
||||
// List the holiday dates for a given country and year
|
||||
func GetHolidays() {
|
||||
holidaysService := holidays.NewHolidaysService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := holidaysService.List(&holidays.ListRequest{
|
||||
Year: 2022,
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
15
examples/holidays/countries/listCountries.go
Executable file
15
examples/holidays/countries/listCountries.go
Executable file
@@ -0,0 +1,15 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/holidays"
|
||||
)
|
||||
|
||||
// Get the list of countries that are supported by this API
|
||||
func ListCountries() {
|
||||
holidaysService := holidays.NewHolidaysService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := holidaysService.Countries(&holidays.CountriesRequest{})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
17
examples/holidays/list/getHolidays.go
Executable file
17
examples/holidays/list/getHolidays.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/holidays"
|
||||
)
|
||||
|
||||
// List the holiday dates for a given country and year
|
||||
func GetHolidays() {
|
||||
holidaysService := holidays.NewHolidaysService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := holidaysService.List(&holidays.ListRequest{
|
||||
Year: 2022,
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
140
examples/id/README.md
Executable file
140
examples/id/README.md
Executable file
@@ -0,0 +1,140 @@
|
||||
# Id
|
||||
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Id/api](https://m3o.com/Id/api).
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Generate
|
||||
|
||||
Generate a unique ID. Defaults to uuid.
|
||||
|
||||
|
||||
[https://m3o.com/id/api#Generate](https://m3o.com/id/api#Generate)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/id"
|
||||
)
|
||||
|
||||
// Generate a unique ID. Defaults to uuid.
|
||||
func GenerateAuniqueId() {
|
||||
idService := id.NewIdService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := idService.Generate(&id.GenerateRequest{
|
||||
Type: "uuid",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## Generate
|
||||
|
||||
Generate a unique ID. Defaults to uuid.
|
||||
|
||||
|
||||
[https://m3o.com/id/api#Generate](https://m3o.com/id/api#Generate)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/id"
|
||||
)
|
||||
|
||||
// Generate a unique ID. Defaults to uuid.
|
||||
func GenerateAshortId() {
|
||||
idService := id.NewIdService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := idService.Generate(&id.GenerateRequest{
|
||||
Type: "shortid",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## Generate
|
||||
|
||||
Generate a unique ID. Defaults to uuid.
|
||||
|
||||
|
||||
[https://m3o.com/id/api#Generate](https://m3o.com/id/api#Generate)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/id"
|
||||
)
|
||||
|
||||
// Generate a unique ID. Defaults to uuid.
|
||||
func GenerateAsnowflakeId() {
|
||||
idService := id.NewIdService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := idService.Generate(&id.GenerateRequest{
|
||||
Type: "snowflake",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## Generate
|
||||
|
||||
Generate a unique ID. Defaults to uuid.
|
||||
|
||||
|
||||
[https://m3o.com/id/api#Generate](https://m3o.com/id/api#Generate)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/id"
|
||||
)
|
||||
|
||||
// Generate a unique ID. Defaults to uuid.
|
||||
func GenerateAbigflakeId() {
|
||||
idService := id.NewIdService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := idService.Generate(&id.GenerateRequest{
|
||||
Type: "bigflake",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## Types
|
||||
|
||||
List the types of IDs available. No query params needed.
|
||||
|
||||
|
||||
[https://m3o.com/id/api#Types](https://m3o.com/id/api#Types)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/id"
|
||||
)
|
||||
|
||||
// List the types of IDs available. No query params needed.
|
||||
func ListTheTypesOfIdsAvailable() {
|
||||
idService := id.NewIdService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := idService.Types(&id.TypesRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
17
examples/id/generate/generateABigflakeId.go
Executable file
17
examples/id/generate/generateABigflakeId.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/id"
|
||||
)
|
||||
|
||||
// Generate a unique ID. Defaults to uuid.
|
||||
func GenerateAbigflakeId() {
|
||||
idService := id.NewIdService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := idService.Generate(&id.GenerateRequest{
|
||||
Type: "bigflake",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
17
examples/id/generate/generateAShortId.go
Executable file
17
examples/id/generate/generateAShortId.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/id"
|
||||
)
|
||||
|
||||
// Generate a unique ID. Defaults to uuid.
|
||||
func GenerateAshortId() {
|
||||
idService := id.NewIdService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := idService.Generate(&id.GenerateRequest{
|
||||
Type: "shortid",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
17
examples/id/generate/generateASnowflakeId.go
Executable file
17
examples/id/generate/generateASnowflakeId.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/id"
|
||||
)
|
||||
|
||||
// Generate a unique ID. Defaults to uuid.
|
||||
func GenerateAsnowflakeId() {
|
||||
idService := id.NewIdService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := idService.Generate(&id.GenerateRequest{
|
||||
Type: "snowflake",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
17
examples/id/generate/generateAUniqueId.go
Executable file
17
examples/id/generate/generateAUniqueId.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/id"
|
||||
)
|
||||
|
||||
// Generate a unique ID. Defaults to uuid.
|
||||
func GenerateAuniqueId() {
|
||||
idService := id.NewIdService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := idService.Generate(&id.GenerateRequest{
|
||||
Type: "uuid",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
15
examples/id/types/listTheTypesOfIdsAvailable.go
Executable file
15
examples/id/types/listTheTypesOfIdsAvailable.go
Executable file
@@ -0,0 +1,15 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/id"
|
||||
)
|
||||
|
||||
// List the types of IDs available. No query params needed.
|
||||
func ListTheTypesOfIdsAvailable() {
|
||||
idService := id.NewIdService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := idService.Types(&id.TypesRequest{})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
200
examples/image/README.md
Executable file
200
examples/image/README.md
Executable file
@@ -0,0 +1,200 @@
|
||||
# Image
|
||||
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Image/api](https://m3o.com/Image/api).
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Resize
|
||||
|
||||
Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters.
|
||||
If one of width or height is 0, the image aspect ratio is preserved.
|
||||
Optional cropping.
|
||||
|
||||
|
||||
[https://m3o.com/image/api#Resize](https://m3o.com/image/api#Resize)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/image"
|
||||
)
|
||||
|
||||
// Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters.
|
||||
// If one of width or height is 0, the image aspect ratio is preserved.
|
||||
// Optional cropping.
|
||||
func Base64toHostedImage() {
|
||||
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := imageService.Resize(&image.ResizeRequest{
|
||||
Base64: "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==",
|
||||
Height: 100,
|
||||
Name: "cat.png",
|
||||
Width: 100,
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## Resize
|
||||
|
||||
Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters.
|
||||
If one of width or height is 0, the image aspect ratio is preserved.
|
||||
Optional cropping.
|
||||
|
||||
|
||||
[https://m3o.com/image/api#Resize](https://m3o.com/image/api#Resize)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/image"
|
||||
)
|
||||
|
||||
// Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters.
|
||||
// If one of width or height is 0, the image aspect ratio is preserved.
|
||||
// Optional cropping.
|
||||
func Base64toBase64image() {
|
||||
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := imageService.Resize(&image.ResizeRequest{
|
||||
Base64: "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==",
|
||||
Height: 100,
|
||||
Width: 100,
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## Resize
|
||||
|
||||
Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters.
|
||||
If one of width or height is 0, the image aspect ratio is preserved.
|
||||
Optional cropping.
|
||||
|
||||
|
||||
[https://m3o.com/image/api#Resize](https://m3o.com/image/api#Resize)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/image"
|
||||
)
|
||||
|
||||
// Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters.
|
||||
// If one of width or height is 0, the image aspect ratio is preserved.
|
||||
// Optional cropping.
|
||||
func Base64toBase64imageWithCropping() {
|
||||
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := imageService.Resize(&image.ResizeRequest{
|
||||
Base64: "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==",
|
||||
CropOptions: &image.CropOptions{
|
||||
Height: 50,
|
||||
Width: 50,
|
||||
},
|
||||
Height: 100,
|
||||
Width: 100,
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## 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.
|
||||
|
||||
|
||||
[https://m3o.com/image/api#Convert](https://m3o.com/image/api#Convert)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/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.
|
||||
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.
|
||||
|
||||
|
||||
[https://m3o.com/image/api#Upload](https://m3o.com/image/api#Upload)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/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.
|
||||
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.
|
||||
|
||||
|
||||
[https://m3o.com/image/api#Upload](https://m3o.com/image/api#Upload)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/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.
|
||||
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)
|
||||
}
|
||||
```
|
||||
@@ -0,0 +1,19 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/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.
|
||||
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)
|
||||
}
|
||||
21
examples/image/resize/base64ToBase64Image.go
Executable file
21
examples/image/resize/base64ToBase64Image.go
Executable file
@@ -0,0 +1,21 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/image"
|
||||
)
|
||||
|
||||
// Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters.
|
||||
// If one of width or height is 0, the image aspect ratio is preserved.
|
||||
// Optional cropping.
|
||||
func Base64toBase64image() {
|
||||
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := imageService.Resize(&image.ResizeRequest{
|
||||
Base64: "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==",
|
||||
Height: 100,
|
||||
Width: 100,
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
25
examples/image/resize/base64ToBase64ImageWithCropping.go
Executable file
25
examples/image/resize/base64ToBase64ImageWithCropping.go
Executable file
@@ -0,0 +1,25 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/image"
|
||||
)
|
||||
|
||||
// Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters.
|
||||
// If one of width or height is 0, the image aspect ratio is preserved.
|
||||
// Optional cropping.
|
||||
func Base64toBase64imageWithCropping() {
|
||||
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := imageService.Resize(&image.ResizeRequest{
|
||||
Base64: "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==",
|
||||
CropOptions: &image.CropOptions{
|
||||
Height: 50,
|
||||
Width: 50,
|
||||
},
|
||||
Height: 100,
|
||||
Width: 100,
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
22
examples/image/resize/base64ToHostedImage.go
Executable file
22
examples/image/resize/base64ToHostedImage.go
Executable file
@@ -0,0 +1,22 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/image"
|
||||
)
|
||||
|
||||
// Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters.
|
||||
// If one of width or height is 0, the image aspect ratio is preserved.
|
||||
// Optional cropping.
|
||||
func Base64toHostedImage() {
|
||||
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := imageService.Resize(&image.ResizeRequest{
|
||||
Base64: "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==",
|
||||
Height: 100,
|
||||
Name: "cat.png",
|
||||
Width: 100,
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
19
examples/image/upload/uploadABase64ImageToMicrosCdn.go
Executable file
19
examples/image/upload/uploadABase64ImageToMicrosCdn.go
Executable file
@@ -0,0 +1,19 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/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.
|
||||
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)
|
||||
}
|
||||
19
examples/image/upload/uploadAnImageFromAUrlToMicrosCdn.go
Executable file
19
examples/image/upload/uploadAnImageFromAUrlToMicrosCdn.go
Executable file
@@ -0,0 +1,19 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/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.
|
||||
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)
|
||||
}
|
||||
33
examples/ip/README.md
Executable file
33
examples/ip/README.md
Executable file
@@ -0,0 +1,33 @@
|
||||
# Ip
|
||||
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Ip/api](https://m3o.com/Ip/api).
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Lookup
|
||||
|
||||
Lookup the geolocation information for an IP address
|
||||
|
||||
|
||||
[https://m3o.com/ip/api#Lookup](https://m3o.com/ip/api#Lookup)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/ip"
|
||||
)
|
||||
|
||||
// Lookup the geolocation information for an IP address
|
||||
func LookupIpInfo() {
|
||||
ipService := ip.NewIpService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := ipService.Lookup(&ip.LookupRequest{
|
||||
Ip: "93.148.214.31",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
17
examples/ip/lookup/lookupIpInfo.go
Executable file
17
examples/ip/lookup/lookupIpInfo.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/ip"
|
||||
)
|
||||
|
||||
// Lookup the geolocation information for an IP address
|
||||
func LookupIpInfo() {
|
||||
ipService := ip.NewIpService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := ipService.Lookup(&ip.LookupRequest{
|
||||
Ip: "93.148.214.31",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
101
examples/location/README.md
Executable file
101
examples/location/README.md
Executable file
@@ -0,0 +1,101 @@
|
||||
# Location
|
||||
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Location/api](https://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"
|
||||
|
||||
"github.com/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
|
||||
|
||||
|
||||
[https://m3o.com/location/api#Read](https://m3o.com/location/api#Read)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/location"
|
||||
)
|
||||
|
||||
// Read an entity by its ID
|
||||
func GetLocationById() {
|
||||
locationService := location.NewLocationService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := locationService.Read(&location.ReadRequest{
|
||||
Id: "1",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## Search
|
||||
|
||||
Search for entities in a given radius
|
||||
|
||||
|
||||
[https://m3o.com/location/api#Search](https://m3o.com/location/api#Search)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/location"
|
||||
)
|
||||
|
||||
// Search for entities in a given radius
|
||||
func SearchForLocations() {
|
||||
locationService := location.NewLocationService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := locationService.Search(&location.SearchRequest{
|
||||
Center: &location.Point{
|
||||
Latitude: 51.511061,
|
||||
Longitude: -0.120022,
|
||||
},
|
||||
NumEntities: 10,
|
||||
Radius: 100,
|
||||
Type: "bike",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
17
examples/location/read/getLocationById.go
Executable file
17
examples/location/read/getLocationById.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/location"
|
||||
)
|
||||
|
||||
// Read an entity by its ID
|
||||
func GetLocationById() {
|
||||
locationService := location.NewLocationService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := locationService.Read(&location.ReadRequest{
|
||||
Id: "1",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
25
examples/location/save/saveAnEntity.go
Executable file
25
examples/location/save/saveAnEntity.go
Executable file
@@ -0,0 +1,25 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/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)
|
||||
}
|
||||
23
examples/location/search/searchForLocations.go
Executable file
23
examples/location/search/searchForLocations.go
Executable file
@@ -0,0 +1,23 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/location"
|
||||
)
|
||||
|
||||
// Search for entities in a given radius
|
||||
func SearchForLocations() {
|
||||
locationService := location.NewLocationService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := locationService.Search(&location.SearchRequest{
|
||||
Center: &location.Point{
|
||||
Latitude: 51.511061,
|
||||
Longitude: -0.120022,
|
||||
},
|
||||
NumEntities: 10,
|
||||
Radius: 100,
|
||||
Type: "bike",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
145
examples/notes/README.md
Executable file
145
examples/notes/README.md
Executable file
@@ -0,0 +1,145 @@
|
||||
# Notes
|
||||
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Notes/api](https://m3o.com/Notes/api).
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Read
|
||||
|
||||
Read a note
|
||||
|
||||
|
||||
[https://m3o.com/notes/api#Read](https://m3o.com/notes/api#Read)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/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"
|
||||
|
||||
"github.com/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"
|
||||
|
||||
"github.com/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
|
||||
|
||||
|
||||
[https://m3o.com/notes/api#Delete](https://m3o.com/notes/api#Delete)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/notes"
|
||||
)
|
||||
|
||||
// Delete a note
|
||||
func DeleteAnote() {
|
||||
notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := notesService.Delete(¬es.DeleteRequest{
|
||||
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## Create
|
||||
|
||||
Create a new note
|
||||
|
||||
|
||||
[https://m3o.com/notes/api#Create](https://m3o.com/notes/api#Create)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/notes"
|
||||
)
|
||||
|
||||
// Create a new note
|
||||
func CreateAnote() {
|
||||
notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := notesService.Create(¬es.CreateRequest{
|
||||
Text: "This is my note",
|
||||
Title: "New Note",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
18
examples/notes/create/createANote.go
Executable file
18
examples/notes/create/createANote.go
Executable file
@@ -0,0 +1,18 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/notes"
|
||||
)
|
||||
|
||||
// Create a new note
|
||||
func CreateAnote() {
|
||||
notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := notesService.Create(¬es.CreateRequest{
|
||||
Text: "This is my note",
|
||||
Title: "New Note",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
17
examples/notes/delete/deleteANote.go
Executable file
17
examples/notes/delete/deleteANote.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/notes"
|
||||
)
|
||||
|
||||
// Delete a note
|
||||
func DeleteAnote() {
|
||||
notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := notesService.Delete(¬es.DeleteRequest{
|
||||
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
15
examples/notes/list/listAllNotes.go
Executable file
15
examples/notes/list/listAllNotes.go
Executable file
@@ -0,0 +1,15 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/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)
|
||||
}
|
||||
17
examples/notes/read/readANote.go
Executable file
17
examples/notes/read/readANote.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/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)
|
||||
}
|
||||
21
examples/notes/update/updateANote.go
Executable file
21
examples/notes/update/updateANote.go
Executable file
@@ -0,0 +1,21 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/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)
|
||||
}
|
||||
61
examples/otp/README.md
Executable file
61
examples/otp/README.md
Executable file
@@ -0,0 +1,61 @@
|
||||
# Otp
|
||||
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Otp/api](https://m3o.com/Otp/api).
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Generate
|
||||
|
||||
Generate an OTP (one time pass) code
|
||||
|
||||
|
||||
[https://m3o.com/otp/api#Generate](https://m3o.com/otp/api#Generate)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/otp"
|
||||
)
|
||||
|
||||
// Generate an OTP (one time pass) code
|
||||
func GenerateOtp() {
|
||||
otpService := otp.NewOtpService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := otpService.Generate(&otp.GenerateRequest{
|
||||
Id: "asim@example.com",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## Validate
|
||||
|
||||
Validate the OTP code
|
||||
|
||||
|
||||
[https://m3o.com/otp/api#Validate](https://m3o.com/otp/api#Validate)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/otp"
|
||||
)
|
||||
|
||||
// Validate the OTP code
|
||||
func ValidateOtp() {
|
||||
otpService := otp.NewOtpService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := otpService.Validate(&otp.ValidateRequest{
|
||||
Code: "656211",
|
||||
Id: "asim@example.com",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
17
examples/otp/generate/generateOtp.go
Executable file
17
examples/otp/generate/generateOtp.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/otp"
|
||||
)
|
||||
|
||||
// Generate an OTP (one time pass) code
|
||||
func GenerateOtp() {
|
||||
otpService := otp.NewOtpService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := otpService.Generate(&otp.GenerateRequest{
|
||||
Id: "asim@example.com",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
18
examples/otp/validate/validateOtp.go
Executable file
18
examples/otp/validate/validateOtp.go
Executable file
@@ -0,0 +1,18 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/otp"
|
||||
)
|
||||
|
||||
// Validate the OTP code
|
||||
func ValidateOtp() {
|
||||
otpService := otp.NewOtpService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := otpService.Validate(&otp.ValidateRequest{
|
||||
Code: "656211",
|
||||
Id: "asim@example.com",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
86
examples/postcode/README.md
Executable file
86
examples/postcode/README.md
Executable file
@@ -0,0 +1,86 @@
|
||||
# Postcode
|
||||
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Postcode/api](https://m3o.com/Postcode/api).
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Lookup
|
||||
|
||||
Lookup a postcode to retrieve the related region, county, etc
|
||||
|
||||
|
||||
[https://m3o.com/postcode/api#Lookup](https://m3o.com/postcode/api#Lookup)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/postcode"
|
||||
)
|
||||
|
||||
// Lookup a postcode to retrieve the related region, county, etc
|
||||
func LookupPostcode() {
|
||||
postcodeService := postcode.NewPostcodeService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := postcodeService.Lookup(&postcode.LookupRequest{
|
||||
Postcode: "SW1A 2AA",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## Random
|
||||
|
||||
Return a random postcode and its related info
|
||||
|
||||
|
||||
[https://m3o.com/postcode/api#Random](https://m3o.com/postcode/api#Random)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/postcode"
|
||||
)
|
||||
|
||||
// Return a random postcode and its related info
|
||||
func ReturnArandomPostcodeAndItsInformation() {
|
||||
postcodeService := postcode.NewPostcodeService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := postcodeService.Random(&postcode.RandomRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## Validate
|
||||
|
||||
Validate a postcode.
|
||||
|
||||
|
||||
[https://m3o.com/postcode/api#Validate](https://m3o.com/postcode/api#Validate)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/postcode"
|
||||
)
|
||||
|
||||
// Validate a postcode.
|
||||
func ReturnArandomPostcodeAndItsInformation() {
|
||||
postcodeService := postcode.NewPostcodeService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := postcodeService.Validate(&postcode.ValidateRequest{
|
||||
Postcode: "SW1A 2AA",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
17
examples/postcode/lookup/lookupPostcode.go
Executable file
17
examples/postcode/lookup/lookupPostcode.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/postcode"
|
||||
)
|
||||
|
||||
// Lookup a postcode to retrieve the related region, county, etc
|
||||
func LookupPostcode() {
|
||||
postcodeService := postcode.NewPostcodeService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := postcodeService.Lookup(&postcode.LookupRequest{
|
||||
Postcode: "SW1A 2AA",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
15
examples/postcode/random/returnARandomPostcodeAndItsInformation.go
Executable file
15
examples/postcode/random/returnARandomPostcodeAndItsInformation.go
Executable file
@@ -0,0 +1,15 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/postcode"
|
||||
)
|
||||
|
||||
// Return a random postcode and its related info
|
||||
func ReturnArandomPostcodeAndItsInformation() {
|
||||
postcodeService := postcode.NewPostcodeService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := postcodeService.Random(&postcode.RandomRequest{})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
17
examples/postcode/validate/returnARandomPostcodeAndItsInformation.go
Executable file
17
examples/postcode/validate/returnARandomPostcodeAndItsInformation.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go.m3o.com/postcode"
|
||||
)
|
||||
|
||||
// Validate a postcode.
|
||||
func ReturnArandomPostcodeAndItsInformation() {
|
||||
postcodeService := postcode.NewPostcodeService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := postcodeService.Validate(&postcode.ValidateRequest{
|
||||
Postcode: "SW1A 2AA",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user