mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-20 06:25:07 +00:00
Generate clients (#206)
This commit is contained in:
6
examples/address/lookupPostcode/curl/lookupPostcode.sh
Executable file
6
examples/address/lookupPostcode/curl/lookupPostcode.sh
Executable file
@@ -0,0 +1,6 @@
|
||||
curl "https://api.m3o.com/v1/address/LookupPostcode" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer $MICRO_API_TOKEN" \
|
||||
-d '{
|
||||
"postcode": "SW1A 2AA"
|
||||
}'
|
||||
16
examples/address/lookupPostcode/go/lookupPostcode.go
Executable file
16
examples/address/lookupPostcode/go/lookupPostcode.go
Executable file
@@ -0,0 +1,16 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/micro/services/clients/go/address"
|
||||
"os"
|
||||
)
|
||||
|
||||
// Lookup a list of UK addresses by postcode
|
||||
func LookupPostcode() {
|
||||
addressService := address.NewAddressService(os.Getenv("MICRO_API_TOKEN"))
|
||||
rsp, err := addressService.LookupPostcode(&address.LookupPostcodeRequest{
|
||||
Postcode: "SW1A 2AA",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
12
examples/address/lookupPostcode/node/lookupPostcode.js
Executable file
12
examples/address/lookupPostcode/node/lookupPostcode.js
Executable file
@@ -0,0 +1,12 @@
|
||||
import * as address from "m3o/address";
|
||||
|
||||
// Lookup a list of UK addresses by postcode
|
||||
async function LookupPostcode() {
|
||||
let addressService = new address.AddressService(process.env.MICRO_API_TOKEN);
|
||||
let rsp = await addressService.lookupPostcode({
|
||||
postcode: "SW1A 2AA",
|
||||
});
|
||||
console.log(rsp);
|
||||
}
|
||||
|
||||
await LookupPostcode();
|
||||
6
examples/answer/question/curl/askAQuestion.sh
Executable file
6
examples/answer/question/curl/askAQuestion.sh
Executable file
@@ -0,0 +1,6 @@
|
||||
curl "https://api.m3o.com/v1/answer/Question" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer $MICRO_API_TOKEN" \
|
||||
-d '{
|
||||
"query": "google"
|
||||
}'
|
||||
16
examples/answer/question/go/askAQuestion.go
Executable file
16
examples/answer/question/go/askAQuestion.go
Executable file
@@ -0,0 +1,16 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/micro/services/clients/go/answer"
|
||||
"os"
|
||||
)
|
||||
|
||||
// Ask a question and receive an instant answer
|
||||
func AskAquestion() {
|
||||
answerService := answer.NewAnswerService(os.Getenv("MICRO_API_TOKEN"))
|
||||
rsp, err := answerService.Question(&answer.QuestionRequest{
|
||||
Query: "google",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
12
examples/answer/question/node/askAQuestion.js
Executable file
12
examples/answer/question/node/askAQuestion.js
Executable file
@@ -0,0 +1,12 @@
|
||||
import * as answer from "m3o/answer";
|
||||
|
||||
// Ask a question and receive an instant answer
|
||||
async function AskAquestion() {
|
||||
let answerService = new answer.AnswerService(process.env.MICRO_API_TOKEN);
|
||||
let rsp = await answerService.question({
|
||||
query: "google",
|
||||
});
|
||||
console.log(rsp);
|
||||
}
|
||||
|
||||
await AskAquestion();
|
||||
7
examples/cache/decrement/curl/decrementAValue.sh
vendored
Executable file
7
examples/cache/decrement/curl/decrementAValue.sh
vendored
Executable file
@@ -0,0 +1,7 @@
|
||||
curl "https://api.m3o.com/v1/cache/Decrement" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer $MICRO_API_TOKEN" \
|
||||
-d '{
|
||||
"key": "counter",
|
||||
"value": 2
|
||||
}'
|
||||
17
examples/cache/decrement/go/decrementAValue.go
vendored
Executable file
17
examples/cache/decrement/go/decrementAValue.go
vendored
Executable file
@@ -0,0 +1,17 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/micro/services/clients/go/cache"
|
||||
"os"
|
||||
)
|
||||
|
||||
// Decrement a value (if it's a number)
|
||||
func DecrementAvalue() {
|
||||
cacheService := cache.NewCacheService(os.Getenv("MICRO_API_TOKEN"))
|
||||
rsp, err := cacheService.Decrement(&cache.DecrementRequest{
|
||||
Key: "counter",
|
||||
Value: 2,
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
13
examples/cache/decrement/node/decrementAValue.js
vendored
Executable file
13
examples/cache/decrement/node/decrementAValue.js
vendored
Executable file
@@ -0,0 +1,13 @@
|
||||
import * as cache from "m3o/cache";
|
||||
|
||||
// Decrement a value (if it's a number)
|
||||
async function DecrementAvalue() {
|
||||
let cacheService = new cache.CacheService(process.env.MICRO_API_TOKEN);
|
||||
let rsp = await cacheService.decrement({
|
||||
key: "counter",
|
||||
value: 2,
|
||||
});
|
||||
console.log(rsp);
|
||||
}
|
||||
|
||||
await DecrementAvalue();
|
||||
6
examples/cache/delete/curl/deleteAValue.sh
vendored
Executable file
6
examples/cache/delete/curl/deleteAValue.sh
vendored
Executable file
@@ -0,0 +1,6 @@
|
||||
curl "https://api.m3o.com/v1/cache/Delete" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer $MICRO_API_TOKEN" \
|
||||
-d '{
|
||||
"key": "foo"
|
||||
}'
|
||||
16
examples/cache/delete/go/deleteAValue.go
vendored
Executable file
16
examples/cache/delete/go/deleteAValue.go
vendored
Executable file
@@ -0,0 +1,16 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/micro/services/clients/go/cache"
|
||||
"os"
|
||||
)
|
||||
|
||||
// Delete a value from the cache
|
||||
func DeleteAvalue() {
|
||||
cacheService := cache.NewCacheService(os.Getenv("MICRO_API_TOKEN"))
|
||||
rsp, err := cacheService.Delete(&cache.DeleteRequest{
|
||||
Key: "foo",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
12
examples/cache/delete/node/deleteAValue.js
vendored
Executable file
12
examples/cache/delete/node/deleteAValue.js
vendored
Executable file
@@ -0,0 +1,12 @@
|
||||
import * as cache from "m3o/cache";
|
||||
|
||||
// Delete a value from the cache
|
||||
async function DeleteAvalue() {
|
||||
let cacheService = new cache.CacheService(process.env.MICRO_API_TOKEN);
|
||||
let rsp = await cacheService.delete({
|
||||
key: "foo",
|
||||
});
|
||||
console.log(rsp);
|
||||
}
|
||||
|
||||
await DeleteAvalue();
|
||||
6
examples/cache/get/curl/getAValue.sh
vendored
Executable file
6
examples/cache/get/curl/getAValue.sh
vendored
Executable file
@@ -0,0 +1,6 @@
|
||||
curl "https://api.m3o.com/v1/cache/Get" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer $MICRO_API_TOKEN" \
|
||||
-d '{
|
||||
"key": "foo"
|
||||
}'
|
||||
16
examples/cache/get/go/getAValue.go
vendored
Executable file
16
examples/cache/get/go/getAValue.go
vendored
Executable file
@@ -0,0 +1,16 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/micro/services/clients/go/cache"
|
||||
"os"
|
||||
)
|
||||
|
||||
// Get an item from the cache by key
|
||||
func GetAvalue() {
|
||||
cacheService := cache.NewCacheService(os.Getenv("MICRO_API_TOKEN"))
|
||||
rsp, err := cacheService.Get(&cache.GetRequest{
|
||||
Key: "foo",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
12
examples/cache/get/node/getAValue.js
vendored
Executable file
12
examples/cache/get/node/getAValue.js
vendored
Executable file
@@ -0,0 +1,12 @@
|
||||
import * as cache from "m3o/cache";
|
||||
|
||||
// Get an item from the cache by key
|
||||
async function GetAvalue() {
|
||||
let cacheService = new cache.CacheService(process.env.MICRO_API_TOKEN);
|
||||
let rsp = await cacheService.get({
|
||||
key: "foo",
|
||||
});
|
||||
console.log(rsp);
|
||||
}
|
||||
|
||||
await GetAvalue();
|
||||
7
examples/cache/increment/curl/incrementAValue.sh
vendored
Executable file
7
examples/cache/increment/curl/incrementAValue.sh
vendored
Executable file
@@ -0,0 +1,7 @@
|
||||
curl "https://api.m3o.com/v1/cache/Increment" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer $MICRO_API_TOKEN" \
|
||||
-d '{
|
||||
"key": "counter",
|
||||
"value": 2
|
||||
}'
|
||||
17
examples/cache/increment/go/incrementAValue.go
vendored
Executable file
17
examples/cache/increment/go/incrementAValue.go
vendored
Executable file
@@ -0,0 +1,17 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/micro/services/clients/go/cache"
|
||||
"os"
|
||||
)
|
||||
|
||||
// Increment a value (if it's a number)
|
||||
func IncrementAvalue() {
|
||||
cacheService := cache.NewCacheService(os.Getenv("MICRO_API_TOKEN"))
|
||||
rsp, err := cacheService.Increment(&cache.IncrementRequest{
|
||||
Key: "counter",
|
||||
Value: 2,
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
13
examples/cache/increment/node/incrementAValue.js
vendored
Executable file
13
examples/cache/increment/node/incrementAValue.js
vendored
Executable file
@@ -0,0 +1,13 @@
|
||||
import * as cache from "m3o/cache";
|
||||
|
||||
// Increment a value (if it's a number)
|
||||
async function IncrementAvalue() {
|
||||
let cacheService = new cache.CacheService(process.env.MICRO_API_TOKEN);
|
||||
let rsp = await cacheService.increment({
|
||||
key: "counter",
|
||||
value: 2,
|
||||
});
|
||||
console.log(rsp);
|
||||
}
|
||||
|
||||
await IncrementAvalue();
|
||||
7
examples/cache/set/curl/setAValue.sh
vendored
Executable file
7
examples/cache/set/curl/setAValue.sh
vendored
Executable file
@@ -0,0 +1,7 @@
|
||||
curl "https://api.m3o.com/v1/cache/Set" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer $MICRO_API_TOKEN" \
|
||||
-d '{
|
||||
"key": "foo",
|
||||
"value": "bar"
|
||||
}'
|
||||
17
examples/cache/set/go/setAValue.go
vendored
Executable file
17
examples/cache/set/go/setAValue.go
vendored
Executable file
@@ -0,0 +1,17 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/micro/services/clients/go/cache"
|
||||
"os"
|
||||
)
|
||||
|
||||
// Set an item in the cache. Overwrites any existing value already set.
|
||||
func SetAvalue() {
|
||||
cacheService := cache.NewCacheService(os.Getenv("MICRO_API_TOKEN"))
|
||||
rsp, err := cacheService.Set(&cache.SetRequest{
|
||||
Key: "foo",
|
||||
Value: "bar",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
13
examples/cache/set/node/setAValue.js
vendored
Executable file
13
examples/cache/set/node/setAValue.js
vendored
Executable file
@@ -0,0 +1,13 @@
|
||||
import * as cache from "m3o/cache";
|
||||
|
||||
// Set an item in the cache. Overwrites any existing value already set.
|
||||
async function SetAvalue() {
|
||||
let cacheService = new cache.CacheService(process.env.MICRO_API_TOKEN);
|
||||
let rsp = await cacheService.set({
|
||||
key: "foo",
|
||||
value: "bar",
|
||||
});
|
||||
console.log(rsp);
|
||||
}
|
||||
|
||||
await SetAvalue();
|
||||
6
examples/crypto/history/curl/getPreviousClose.sh
Executable file
6
examples/crypto/history/curl/getPreviousClose.sh
Executable file
@@ -0,0 +1,6 @@
|
||||
curl "https://api.m3o.com/v1/crypto/History" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer $MICRO_API_TOKEN" \
|
||||
-d '{
|
||||
"symbol": "BTCUSD"
|
||||
}'
|
||||
16
examples/crypto/history/go/getPreviousClose.go
Executable file
16
examples/crypto/history/go/getPreviousClose.go
Executable file
@@ -0,0 +1,16 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/micro/services/clients/go/crypto"
|
||||
"os"
|
||||
)
|
||||
|
||||
// Returns the history for the previous close
|
||||
func GetPreviousClose() {
|
||||
cryptoService := crypto.NewCryptoService(os.Getenv("MICRO_API_TOKEN"))
|
||||
rsp, err := cryptoService.History(&crypto.HistoryRequest{
|
||||
Symbol: "BTCUSD",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
12
examples/crypto/history/node/getPreviousClose.js
Executable file
12
examples/crypto/history/node/getPreviousClose.js
Executable file
@@ -0,0 +1,12 @@
|
||||
import * as crypto from "m3o/crypto";
|
||||
|
||||
// Returns the history for the previous close
|
||||
async function GetPreviousClose() {
|
||||
let cryptoService = new crypto.CryptoService(process.env.MICRO_API_TOKEN);
|
||||
let rsp = await cryptoService.history({
|
||||
symbol: "BTCUSD",
|
||||
});
|
||||
console.log(rsp);
|
||||
}
|
||||
|
||||
await GetPreviousClose();
|
||||
6
examples/crypto/price/curl/getCryptocurrencyPrice.sh
Executable file
6
examples/crypto/price/curl/getCryptocurrencyPrice.sh
Executable file
@@ -0,0 +1,6 @@
|
||||
curl "https://api.m3o.com/v1/crypto/Price" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer $MICRO_API_TOKEN" \
|
||||
-d '{
|
||||
"symbol": "BTCUSD"
|
||||
}'
|
||||
16
examples/crypto/price/go/getCryptocurrencyPrice.go
Executable file
16
examples/crypto/price/go/getCryptocurrencyPrice.go
Executable file
@@ -0,0 +1,16 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/micro/services/clients/go/crypto"
|
||||
"os"
|
||||
)
|
||||
|
||||
// Get the last price for a given crypto ticker
|
||||
func GetCryptocurrencyPrice() {
|
||||
cryptoService := crypto.NewCryptoService(os.Getenv("MICRO_API_TOKEN"))
|
||||
rsp, err := cryptoService.Price(&crypto.PriceRequest{
|
||||
Symbol: "BTCUSD",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
12
examples/crypto/price/node/getCryptocurrencyPrice.js
Executable file
12
examples/crypto/price/node/getCryptocurrencyPrice.js
Executable file
@@ -0,0 +1,12 @@
|
||||
import * as crypto from "m3o/crypto";
|
||||
|
||||
// Get the last price for a given crypto ticker
|
||||
async function GetCryptocurrencyPrice() {
|
||||
let cryptoService = new crypto.CryptoService(process.env.MICRO_API_TOKEN);
|
||||
let rsp = await cryptoService.price({
|
||||
symbol: "BTCUSD",
|
||||
});
|
||||
console.log(rsp);
|
||||
}
|
||||
|
||||
await GetCryptocurrencyPrice();
|
||||
6
examples/crypto/quote/curl/getACryptocurrencyQuote.sh
Executable file
6
examples/crypto/quote/curl/getACryptocurrencyQuote.sh
Executable file
@@ -0,0 +1,6 @@
|
||||
curl "https://api.m3o.com/v1/crypto/Quote" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer $MICRO_API_TOKEN" \
|
||||
-d '{
|
||||
"symbol": "BTCUSD"
|
||||
}'
|
||||
16
examples/crypto/quote/go/getACryptocurrencyQuote.go
Executable file
16
examples/crypto/quote/go/getACryptocurrencyQuote.go
Executable file
@@ -0,0 +1,16 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/micro/services/clients/go/crypto"
|
||||
"os"
|
||||
)
|
||||
|
||||
// Get the last quote for a given crypto ticker
|
||||
func GetAcryptocurrencyQuote() {
|
||||
cryptoService := crypto.NewCryptoService(os.Getenv("MICRO_API_TOKEN"))
|
||||
rsp, err := cryptoService.Quote(&crypto.QuoteRequest{
|
||||
Symbol: "BTCUSD",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
12
examples/crypto/quote/node/getACryptocurrencyQuote.js
Executable file
12
examples/crypto/quote/node/getACryptocurrencyQuote.js
Executable file
@@ -0,0 +1,12 @@
|
||||
import * as crypto from "m3o/crypto";
|
||||
|
||||
// Get the last quote for a given crypto ticker
|
||||
async function GetAcryptocurrencyQuote() {
|
||||
let cryptoService = new crypto.CryptoService(process.env.MICRO_API_TOKEN);
|
||||
let rsp = await cryptoService.quote({
|
||||
symbol: "BTCUSD",
|
||||
});
|
||||
console.log(rsp);
|
||||
}
|
||||
|
||||
await GetAcryptocurrencyQuote();
|
||||
4
examples/currency/codes/curl/getSupportedCodes.sh
Executable file
4
examples/currency/codes/curl/getSupportedCodes.sh
Executable file
@@ -0,0 +1,4 @@
|
||||
curl "https://api.m3o.com/v1/currency/Codes" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer $MICRO_API_TOKEN" \
|
||||
-d '{}'
|
||||
14
examples/currency/codes/go/getSupportedCodes.go
Executable file
14
examples/currency/codes/go/getSupportedCodes.go
Executable file
@@ -0,0 +1,14 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/micro/services/clients/go/currency"
|
||||
"os"
|
||||
)
|
||||
|
||||
// Codes returns the supported currency codes for the API
|
||||
func GetSupportedCodes() {
|
||||
currencyService := currency.NewCurrencyService(os.Getenv("MICRO_API_TOKEN"))
|
||||
rsp, err := currencyService.Codes(¤cy.CodesRequest{})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
12
examples/currency/codes/node/getSupportedCodes.js
Executable file
12
examples/currency/codes/node/getSupportedCodes.js
Executable file
@@ -0,0 +1,12 @@
|
||||
import * as currency from "m3o/currency";
|
||||
|
||||
// Codes returns the supported currency codes for the API
|
||||
async function GetSupportedCodes() {
|
||||
let currencyService = new currency.CurrencyService(
|
||||
process.env.MICRO_API_TOKEN
|
||||
);
|
||||
let rsp = await currencyService.codes({});
|
||||
console.log(rsp);
|
||||
}
|
||||
|
||||
await GetSupportedCodes();
|
||||
8
examples/currency/convert/curl/convert10UsdToGbp.sh
Executable file
8
examples/currency/convert/curl/convert10UsdToGbp.sh
Executable file
@@ -0,0 +1,8 @@
|
||||
curl "https://api.m3o.com/v1/currency/Convert" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer $MICRO_API_TOKEN" \
|
||||
-d '{
|
||||
"amount": 10,
|
||||
"from": "USD",
|
||||
"to": "GBP"
|
||||
}'
|
||||
7
examples/currency/convert/curl/convertUsdToGbp.sh
Executable file
7
examples/currency/convert/curl/convertUsdToGbp.sh
Executable file
@@ -0,0 +1,7 @@
|
||||
curl "https://api.m3o.com/v1/currency/Convert" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer $MICRO_API_TOKEN" \
|
||||
-d '{
|
||||
"from": "USD",
|
||||
"to": "GBP"
|
||||
}'
|
||||
18
examples/currency/convert/go/convert10UsdToGbp.go
Executable file
18
examples/currency/convert/go/convert10UsdToGbp.go
Executable file
@@ -0,0 +1,18 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/micro/services/clients/go/currency"
|
||||
"os"
|
||||
)
|
||||
|
||||
// Convert returns the currency conversion rate between two pairs e.g USD/GBP
|
||||
func Convert10usdToGbp() {
|
||||
currencyService := currency.NewCurrencyService(os.Getenv("MICRO_API_TOKEN"))
|
||||
rsp, err := currencyService.Convert(¤cy.ConvertRequest{
|
||||
Amount: 10,
|
||||
From: "USD",
|
||||
To: "GBP",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
17
examples/currency/convert/go/convertUsdToGbp.go
Executable file
17
examples/currency/convert/go/convertUsdToGbp.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/micro/services/clients/go/currency"
|
||||
"os"
|
||||
)
|
||||
|
||||
// Convert returns the currency conversion rate between two pairs e.g USD/GBP
|
||||
func ConvertUsdToGbp() {
|
||||
currencyService := currency.NewCurrencyService(os.Getenv("MICRO_API_TOKEN"))
|
||||
rsp, err := currencyService.Convert(¤cy.ConvertRequest{
|
||||
From: "USD",
|
||||
To: "GBP",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
16
examples/currency/convert/node/convert10UsdToGbp.js
Executable file
16
examples/currency/convert/node/convert10UsdToGbp.js
Executable file
@@ -0,0 +1,16 @@
|
||||
import * as currency from "m3o/currency";
|
||||
|
||||
// Convert returns the currency conversion rate between two pairs e.g USD/GBP
|
||||
async function Convert10usdToGbp() {
|
||||
let currencyService = new currency.CurrencyService(
|
||||
process.env.MICRO_API_TOKEN
|
||||
);
|
||||
let rsp = await currencyService.convert({
|
||||
amount: 10,
|
||||
from: "USD",
|
||||
to: "GBP",
|
||||
});
|
||||
console.log(rsp);
|
||||
}
|
||||
|
||||
await Convert10usdToGbp();
|
||||
15
examples/currency/convert/node/convertUsdToGbp.js
Executable file
15
examples/currency/convert/node/convertUsdToGbp.js
Executable file
@@ -0,0 +1,15 @@
|
||||
import * as currency from "m3o/currency";
|
||||
|
||||
// Convert returns the currency conversion rate between two pairs e.g USD/GBP
|
||||
async function ConvertUsdToGbp() {
|
||||
let currencyService = new currency.CurrencyService(
|
||||
process.env.MICRO_API_TOKEN
|
||||
);
|
||||
let rsp = await currencyService.convert({
|
||||
from: "USD",
|
||||
to: "GBP",
|
||||
});
|
||||
console.log(rsp);
|
||||
}
|
||||
|
||||
await ConvertUsdToGbp();
|
||||
6
examples/currency/rates/curl/getRatesForUsd.sh
Executable file
6
examples/currency/rates/curl/getRatesForUsd.sh
Executable file
@@ -0,0 +1,6 @@
|
||||
curl "https://api.m3o.com/v1/currency/Rates" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer $MICRO_API_TOKEN" \
|
||||
-d '{
|
||||
"code": "USD"
|
||||
}'
|
||||
16
examples/currency/rates/go/getRatesForUsd.go
Executable file
16
examples/currency/rates/go/getRatesForUsd.go
Executable file
@@ -0,0 +1,16 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/micro/services/clients/go/currency"
|
||||
"os"
|
||||
)
|
||||
|
||||
// Rates returns the currency rates for a given code e.g USD
|
||||
func GetRatesForUsd() {
|
||||
currencyService := currency.NewCurrencyService(os.Getenv("MICRO_API_TOKEN"))
|
||||
rsp, err := currencyService.Rates(¤cy.RatesRequest{
|
||||
Code: "USD",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
14
examples/currency/rates/node/getRatesForUsd.js
Executable file
14
examples/currency/rates/node/getRatesForUsd.js
Executable file
@@ -0,0 +1,14 @@
|
||||
import * as currency from "m3o/currency";
|
||||
|
||||
// Rates returns the currency rates for a given code e.g USD
|
||||
async function GetRatesForUsd() {
|
||||
let currencyService = new currency.CurrencyService(
|
||||
process.env.MICRO_API_TOKEN
|
||||
);
|
||||
let rsp = await currencyService.rates({
|
||||
code: "USD",
|
||||
});
|
||||
console.log(rsp);
|
||||
}
|
||||
|
||||
await GetRatesForUsd();
|
||||
12
examples/db/create/curl/createARecord.sh
Executable file
12
examples/db/create/curl/createARecord.sh
Executable file
@@ -0,0 +1,12 @@
|
||||
curl "https://api.m3o.com/v1/db/Create" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer $MICRO_API_TOKEN" \
|
||||
-d '{
|
||||
"record": {
|
||||
"age": 42,
|
||||
"id": "1",
|
||||
"isActive": true,
|
||||
"name": "Jane"
|
||||
},
|
||||
"table": "users"
|
||||
}'
|
||||
22
examples/db/create/go/createARecord.go
Executable file
22
examples/db/create/go/createARecord.go
Executable file
@@ -0,0 +1,22 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/micro/services/clients/go/db"
|
||||
"os"
|
||||
)
|
||||
|
||||
// Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
|
||||
func CreateArecord() {
|
||||
dbService := db.NewDbService(os.Getenv("MICRO_API_TOKEN"))
|
||||
rsp, err := dbService.Create(&db.CreateRequest{
|
||||
Record: map[string]interface{}{
|
||||
"age": 42,
|
||||
"isActive": true,
|
||||
"id": "1",
|
||||
"name": "Jane",
|
||||
},
|
||||
Table: "users",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
18
examples/db/create/node/createARecord.js
Executable file
18
examples/db/create/node/createARecord.js
Executable file
@@ -0,0 +1,18 @@
|
||||
import * as db from "m3o/db";
|
||||
|
||||
// Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
|
||||
async function CreateArecord() {
|
||||
let dbService = new db.DbService(process.env.MICRO_API_TOKEN);
|
||||
let rsp = await dbService.create({
|
||||
record: {
|
||||
age: 42,
|
||||
id: "1",
|
||||
isActive: true,
|
||||
name: "Jane",
|
||||
},
|
||||
table: "users",
|
||||
});
|
||||
console.log(rsp);
|
||||
}
|
||||
|
||||
await CreateArecord();
|
||||
7
examples/db/delete/curl/deleteARecord.sh
Executable file
7
examples/db/delete/curl/deleteARecord.sh
Executable file
@@ -0,0 +1,7 @@
|
||||
curl "https://api.m3o.com/v1/db/Delete" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer $MICRO_API_TOKEN" \
|
||||
-d '{
|
||||
"id": "1",
|
||||
"table": "users"
|
||||
}'
|
||||
17
examples/db/delete/go/deleteARecord.go
Executable file
17
examples/db/delete/go/deleteARecord.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/micro/services/clients/go/db"
|
||||
"os"
|
||||
)
|
||||
|
||||
// Delete a record in the database by id.
|
||||
func DeleteArecord() {
|
||||
dbService := db.NewDbService(os.Getenv("MICRO_API_TOKEN"))
|
||||
rsp, err := dbService.Delete(&db.DeleteRequest{
|
||||
Id: "1",
|
||||
Table: "users",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
13
examples/db/delete/node/deleteARecord.js
Executable file
13
examples/db/delete/node/deleteARecord.js
Executable file
@@ -0,0 +1,13 @@
|
||||
import * as db from "m3o/db";
|
||||
|
||||
// Delete a record in the database by id.
|
||||
async function DeleteArecord() {
|
||||
let dbService = new db.DbService(process.env.MICRO_API_TOKEN);
|
||||
let rsp = await dbService.delete({
|
||||
id: "1",
|
||||
table: "users",
|
||||
});
|
||||
console.log(rsp);
|
||||
}
|
||||
|
||||
await DeleteArecord();
|
||||
7
examples/db/read/curl/readRecords.sh
Executable file
7
examples/db/read/curl/readRecords.sh
Executable file
@@ -0,0 +1,7 @@
|
||||
curl "https://api.m3o.com/v1/db/Read" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer $MICRO_API_TOKEN" \
|
||||
-d '{
|
||||
"query": "age == 43",
|
||||
"table": "users"
|
||||
}'
|
||||
17
examples/db/read/go/readRecords.go
Executable file
17
examples/db/read/go/readRecords.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/micro/services/clients/go/db"
|
||||
"os"
|
||||
)
|
||||
|
||||
// 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("MICRO_API_TOKEN"))
|
||||
rsp, err := dbService.Read(&db.ReadRequest{
|
||||
Query: "age == 43",
|
||||
Table: "users",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
13
examples/db/read/node/readRecords.js
Executable file
13
examples/db/read/node/readRecords.js
Executable file
@@ -0,0 +1,13 @@
|
||||
import * as db from "m3o/db";
|
||||
|
||||
// Read data from a table. Lookup can be by ID or via querying any field in the record.
|
||||
async function ReadRecords() {
|
||||
let dbService = new db.DbService(process.env.MICRO_API_TOKEN);
|
||||
let rsp = await dbService.read({
|
||||
query: "age == 43",
|
||||
table: "users",
|
||||
});
|
||||
console.log(rsp);
|
||||
}
|
||||
|
||||
await ReadRecords();
|
||||
6
examples/db/truncate/curl/truncateTable.sh
Executable file
6
examples/db/truncate/curl/truncateTable.sh
Executable file
@@ -0,0 +1,6 @@
|
||||
curl "https://api.m3o.com/v1/db/Truncate" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer $MICRO_API_TOKEN" \
|
||||
-d '{
|
||||
"table": "users"
|
||||
}'
|
||||
16
examples/db/truncate/go/truncateTable.go
Executable file
16
examples/db/truncate/go/truncateTable.go
Executable file
@@ -0,0 +1,16 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/micro/services/clients/go/db"
|
||||
"os"
|
||||
)
|
||||
|
||||
// Truncate the records in a table
|
||||
func TruncateTable() {
|
||||
dbService := db.NewDbService(os.Getenv("MICRO_API_TOKEN"))
|
||||
rsp, err := dbService.Truncate(&db.TruncateRequest{
|
||||
Table: "users",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
12
examples/db/truncate/node/truncateTable.js
Executable file
12
examples/db/truncate/node/truncateTable.js
Executable file
@@ -0,0 +1,12 @@
|
||||
import * as db from "m3o/db";
|
||||
|
||||
// Truncate the records in a table
|
||||
async function TruncateTable() {
|
||||
let dbService = new db.DbService(process.env.MICRO_API_TOKEN);
|
||||
let rsp = await dbService.truncate({
|
||||
table: "users",
|
||||
});
|
||||
console.log(rsp);
|
||||
}
|
||||
|
||||
await TruncateTable();
|
||||
10
examples/db/update/curl/updateARecord.sh
Executable file
10
examples/db/update/curl/updateARecord.sh
Executable file
@@ -0,0 +1,10 @@
|
||||
curl "https://api.m3o.com/v1/db/Update" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer $MICRO_API_TOKEN" \
|
||||
-d '{
|
||||
"record": {
|
||||
"age": 43,
|
||||
"id": "1"
|
||||
},
|
||||
"table": "users"
|
||||
}'
|
||||
20
examples/db/update/go/updateARecord.go
Executable file
20
examples/db/update/go/updateARecord.go
Executable file
@@ -0,0 +1,20 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/micro/services/clients/go/db"
|
||||
"os"
|
||||
)
|
||||
|
||||
// Update a record in the database. Include an "id" in the record to update.
|
||||
func UpdateArecord() {
|
||||
dbService := db.NewDbService(os.Getenv("MICRO_API_TOKEN"))
|
||||
rsp, err := dbService.Update(&db.UpdateRequest{
|
||||
Record: map[string]interface{}{
|
||||
"age": 43,
|
||||
"id": "1",
|
||||
},
|
||||
Table: "users",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
16
examples/db/update/node/updateARecord.js
Executable file
16
examples/db/update/node/updateARecord.js
Executable file
@@ -0,0 +1,16 @@
|
||||
import * as db from "m3o/db";
|
||||
|
||||
// Update a record in the database. Include an "id" in the record to update.
|
||||
async function UpdateArecord() {
|
||||
let dbService = new db.DbService(process.env.MICRO_API_TOKEN);
|
||||
let rsp = await dbService.update({
|
||||
record: {
|
||||
age: 43,
|
||||
id: "1",
|
||||
},
|
||||
table: "users",
|
||||
});
|
||||
console.log(rsp);
|
||||
}
|
||||
|
||||
await UpdateArecord();
|
||||
8
examples/email/send/curl/sendEmail.sh
Executable file
8
examples/email/send/curl/sendEmail.sh
Executable file
@@ -0,0 +1,8 @@
|
||||
curl "https://api.m3o.com/v1/email/Send" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer $MICRO_API_TOKEN" \
|
||||
-d '{
|
||||
"from": "Awesome Dot Com",
|
||||
"subject": "Email verification",
|
||||
"textBody": "Hi there,\n\nPlease verify your email by clicking this link: $micro_verification_link"
|
||||
}'
|
||||
20
examples/email/send/go/sendEmail.go
Executable file
20
examples/email/send/go/sendEmail.go
Executable file
@@ -0,0 +1,20 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/micro/services/clients/go/email"
|
||||
"os"
|
||||
)
|
||||
|
||||
// Send an email by passing in from, to, subject, and a text or html body
|
||||
func SendEmail() {
|
||||
emailService := email.NewEmailService(os.Getenv("MICRO_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)
|
||||
}
|
||||
15
examples/email/send/node/sendEmail.js
Executable file
15
examples/email/send/node/sendEmail.js
Executable file
@@ -0,0 +1,15 @@
|
||||
import * as email from "m3o/email";
|
||||
|
||||
// Send an email by passing in from, to, subject, and a text or html body
|
||||
async function SendEmail() {
|
||||
let emailService = new email.EmailService(process.env.MICRO_API_TOKEN);
|
||||
let rsp = await emailService.send({
|
||||
from: "Awesome Dot Com",
|
||||
subject: "Email verification",
|
||||
textBody:
|
||||
"Hi there,\n\nPlease verify your email by clicking this link: $micro_verification_link",
|
||||
});
|
||||
console.log(rsp);
|
||||
}
|
||||
|
||||
await SendEmail();
|
||||
6
examples/emoji/find/curl/findEmoji.sh
Executable file
6
examples/emoji/find/curl/findEmoji.sh
Executable file
@@ -0,0 +1,6 @@
|
||||
curl "https://api.m3o.com/v1/emoji/Find" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer $MICRO_API_TOKEN" \
|
||||
-d '{
|
||||
"alias": ":beer:"
|
||||
}'
|
||||
16
examples/emoji/find/go/findEmoji.go
Executable file
16
examples/emoji/find/go/findEmoji.go
Executable file
@@ -0,0 +1,16 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/micro/services/clients/go/emoji"
|
||||
"os"
|
||||
)
|
||||
|
||||
// Find an emoji by its alias e.g :beer:
|
||||
func FindEmoji() {
|
||||
emojiService := emoji.NewEmojiService(os.Getenv("MICRO_API_TOKEN"))
|
||||
rsp, err := emojiService.Find(&emoji.FindRequest{
|
||||
Alias: ":beer:",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
12
examples/emoji/find/node/findEmoji.js
Executable file
12
examples/emoji/find/node/findEmoji.js
Executable file
@@ -0,0 +1,12 @@
|
||||
import * as emoji from "m3o/emoji";
|
||||
|
||||
// Find an emoji by its alias e.g :beer:
|
||||
async function FindEmoji() {
|
||||
let emojiService = new emoji.EmojiService(process.env.MICRO_API_TOKEN);
|
||||
let rsp = await emojiService.find({
|
||||
alias: ":beer:",
|
||||
});
|
||||
console.log(rsp);
|
||||
}
|
||||
|
||||
await FindEmoji();
|
||||
6
examples/emoji/flag/curl/getFlagByCountryCode.sh
Executable file
6
examples/emoji/flag/curl/getFlagByCountryCode.sh
Executable file
@@ -0,0 +1,6 @@
|
||||
curl "https://api.m3o.com/v1/emoji/Flag" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer $MICRO_API_TOKEN" \
|
||||
-d '{
|
||||
"alias": "GB"
|
||||
}'
|
||||
14
examples/emoji/flag/go/getFlagByCountryCode.go
Executable file
14
examples/emoji/flag/go/getFlagByCountryCode.go
Executable file
@@ -0,0 +1,14 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/micro/services/clients/go/emoji"
|
||||
"os"
|
||||
)
|
||||
|
||||
// Get the flag for a country. Requires country code e.g GB for great britain
|
||||
func GetFlagByCountryCode() {
|
||||
emojiService := emoji.NewEmojiService(os.Getenv("MICRO_API_TOKEN"))
|
||||
rsp, err := emojiService.Flag(&emoji.FlagRequest{})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
12
examples/emoji/flag/node/getFlagByCountryCode.js
Executable file
12
examples/emoji/flag/node/getFlagByCountryCode.js
Executable file
@@ -0,0 +1,12 @@
|
||||
import * as emoji from "m3o/emoji";
|
||||
|
||||
// Get the flag for a country. Requires country code e.g GB for great britain
|
||||
async function GetFlagByCountryCode() {
|
||||
let emojiService = new emoji.EmojiService(process.env.MICRO_API_TOKEN);
|
||||
let rsp = await emojiService.flag({
|
||||
alias: "GB",
|
||||
});
|
||||
console.log(rsp);
|
||||
}
|
||||
|
||||
await GetFlagByCountryCode();
|
||||
6
examples/emoji/print/curl/printTextIncludingEmoji.sh
Executable file
6
examples/emoji/print/curl/printTextIncludingEmoji.sh
Executable file
@@ -0,0 +1,6 @@
|
||||
curl "https://api.m3o.com/v1/emoji/Print" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer $MICRO_API_TOKEN" \
|
||||
-d '{
|
||||
"text": "let's grab a :beer:"
|
||||
}'
|
||||
17
examples/emoji/print/go/printTextIncludingEmoji.go
Executable file
17
examples/emoji/print/go/printTextIncludingEmoji.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/micro/services/clients/go/emoji"
|
||||
"os"
|
||||
)
|
||||
|
||||
// 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("MICRO_API_TOKEN"))
|
||||
rsp, err := emojiService.Print(&emoji.PrintRequest{
|
||||
Text: "let's grab a :beer:",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
13
examples/emoji/print/node/printTextIncludingEmoji.js
Executable file
13
examples/emoji/print/node/printTextIncludingEmoji.js
Executable file
@@ -0,0 +1,13 @@
|
||||
import * as emoji from "m3o/emoji";
|
||||
|
||||
// Print text and renders the emojis with aliases e.g
|
||||
// let's grab a :beer: becomes let's grab a 🍺
|
||||
async function PrintTextIncludingEmoji() {
|
||||
let emojiService = new emoji.EmojiService(process.env.MICRO_API_TOKEN);
|
||||
let rsp = await emojiService.print({
|
||||
text: "let's grab a :beer:",
|
||||
});
|
||||
console.log(rsp);
|
||||
}
|
||||
|
||||
await PrintTextIncludingEmoji();
|
||||
8
examples/emoji/send/curl/sendATextContainingAnEmojiToAnyoneViaSms.sh
Executable file
8
examples/emoji/send/curl/sendATextContainingAnEmojiToAnyoneViaSms.sh
Executable file
@@ -0,0 +1,8 @@
|
||||
curl "https://api.m3o.com/v1/emoji/Send" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer $MICRO_API_TOKEN" \
|
||||
-d '{
|
||||
"from": "Alice",
|
||||
"message": "let's grab a :beer:",
|
||||
"to": "+44782669123"
|
||||
}'
|
||||
18
examples/emoji/send/go/sendATextContainingAnEmojiToAnyoneViaSms.go
Executable file
18
examples/emoji/send/go/sendATextContainingAnEmojiToAnyoneViaSms.go
Executable file
@@ -0,0 +1,18 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/micro/services/clients/go/emoji"
|
||||
"os"
|
||||
)
|
||||
|
||||
// Send an emoji to anyone via SMS. Messages are sent in the form '<message> Sent from <from>'
|
||||
func SendAtextContainingAnEmojiToAnyoneViaSms() {
|
||||
emojiService := emoji.NewEmojiService(os.Getenv("MICRO_API_TOKEN"))
|
||||
rsp, err := emojiService.Send(&emoji.SendRequest{
|
||||
From: "Alice",
|
||||
Message: "let's grab a :beer:",
|
||||
To: "+44782669123",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
14
examples/emoji/send/node/sendATextContainingAnEmojiToAnyoneViaSms.js
Executable file
14
examples/emoji/send/node/sendATextContainingAnEmojiToAnyoneViaSms.js
Executable file
@@ -0,0 +1,14 @@
|
||||
import * as emoji from "m3o/emoji";
|
||||
|
||||
// Send an emoji to anyone via SMS. Messages are sent in the form '<message> Sent from <from>'
|
||||
async function SendAtextContainingAnEmojiToAnyoneViaSms() {
|
||||
let emojiService = new emoji.EmojiService(process.env.MICRO_API_TOKEN);
|
||||
let rsp = await emojiService.send({
|
||||
from: "Alice",
|
||||
message: "let's grab a :beer:",
|
||||
to: "+44782669123",
|
||||
});
|
||||
console.log(rsp);
|
||||
}
|
||||
|
||||
await SendAtextContainingAnEmojiToAnyoneViaSms();
|
||||
7
examples/file/delete/curl/deleteFile.sh
Executable file
7
examples/file/delete/curl/deleteFile.sh
Executable file
@@ -0,0 +1,7 @@
|
||||
curl "https://api.m3o.com/v1/file/Delete" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer $MICRO_API_TOKEN" \
|
||||
-d '{
|
||||
"path": "/document/text-files/file.txt",
|
||||
"project": "examples"
|
||||
}'
|
||||
17
examples/file/delete/go/deleteFile.go
Executable file
17
examples/file/delete/go/deleteFile.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/micro/services/clients/go/file"
|
||||
"os"
|
||||
)
|
||||
|
||||
// Delete a file by project name/path
|
||||
func DeleteFile() {
|
||||
fileService := file.NewFileService(os.Getenv("MICRO_API_TOKEN"))
|
||||
rsp, err := fileService.Delete(&file.DeleteRequest{
|
||||
Path: "/document/text-files/file.txt",
|
||||
Project: "examples",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
13
examples/file/delete/node/deleteFile.js
Executable file
13
examples/file/delete/node/deleteFile.js
Executable file
@@ -0,0 +1,13 @@
|
||||
import * as file from "m3o/file";
|
||||
|
||||
// Delete a file by project name/path
|
||||
async function DeleteFile() {
|
||||
let fileService = new file.FileService(process.env.MICRO_API_TOKEN);
|
||||
let rsp = await fileService.delete({
|
||||
path: "/document/text-files/file.txt",
|
||||
project: "examples",
|
||||
});
|
||||
console.log(rsp);
|
||||
}
|
||||
|
||||
await DeleteFile();
|
||||
6
examples/file/list/curl/listFiles.sh
Executable file
6
examples/file/list/curl/listFiles.sh
Executable file
@@ -0,0 +1,6 @@
|
||||
curl "https://api.m3o.com/v1/file/List" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer $MICRO_API_TOKEN" \
|
||||
-d '{
|
||||
"project": "examples"
|
||||
}'
|
||||
16
examples/file/list/go/listFiles.go
Executable file
16
examples/file/list/go/listFiles.go
Executable file
@@ -0,0 +1,16 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/micro/services/clients/go/file"
|
||||
"os"
|
||||
)
|
||||
|
||||
// List files by their project and optionally a path.
|
||||
func ListFiles() {
|
||||
fileService := file.NewFileService(os.Getenv("MICRO_API_TOKEN"))
|
||||
rsp, err := fileService.List(&file.ListRequest{
|
||||
Project: "examples",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
12
examples/file/list/node/listFiles.js
Executable file
12
examples/file/list/node/listFiles.js
Executable file
@@ -0,0 +1,12 @@
|
||||
import * as file from "m3o/file";
|
||||
|
||||
// List files by their project and optionally a path.
|
||||
async function ListFiles() {
|
||||
let fileService = new file.FileService(process.env.MICRO_API_TOKEN);
|
||||
let rsp = await fileService.list({
|
||||
project: "examples",
|
||||
});
|
||||
console.log(rsp);
|
||||
}
|
||||
|
||||
await ListFiles();
|
||||
7
examples/file/read/curl/readFile.sh
Executable file
7
examples/file/read/curl/readFile.sh
Executable file
@@ -0,0 +1,7 @@
|
||||
curl "https://api.m3o.com/v1/file/Read" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer $MICRO_API_TOKEN" \
|
||||
-d '{
|
||||
"path": "/document/text-files/file.txt",
|
||||
"project": "examples"
|
||||
}'
|
||||
17
examples/file/read/go/readFile.go
Executable file
17
examples/file/read/go/readFile.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/micro/services/clients/go/file"
|
||||
"os"
|
||||
)
|
||||
|
||||
// Read a file by path
|
||||
func ReadFile() {
|
||||
fileService := file.NewFileService(os.Getenv("MICRO_API_TOKEN"))
|
||||
rsp, err := fileService.Read(&file.ReadRequest{
|
||||
Path: "/document/text-files/file.txt",
|
||||
Project: "examples",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
13
examples/file/read/node/readFile.js
Executable file
13
examples/file/read/node/readFile.js
Executable file
@@ -0,0 +1,13 @@
|
||||
import * as file from "m3o/file";
|
||||
|
||||
// Read a file by path
|
||||
async function ReadFile() {
|
||||
let fileService = new file.FileService(process.env.MICRO_API_TOKEN);
|
||||
let rsp = await fileService.read({
|
||||
path: "/document/text-files/file.txt",
|
||||
project: "examples",
|
||||
});
|
||||
console.log(rsp);
|
||||
}
|
||||
|
||||
await ReadFile();
|
||||
10
examples/file/save/curl/saveFile.sh
Executable file
10
examples/file/save/curl/saveFile.sh
Executable file
@@ -0,0 +1,10 @@
|
||||
curl "https://api.m3o.com/v1/file/Save" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer $MICRO_API_TOKEN" \
|
||||
-d '{
|
||||
"file": {
|
||||
"content": "file content example",
|
||||
"path": "/document/text-files/file.txt",
|
||||
"project": "examples"
|
||||
}
|
||||
}'
|
||||
20
examples/file/save/go/saveFile.go
Executable file
20
examples/file/save/go/saveFile.go
Executable file
@@ -0,0 +1,20 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/micro/services/clients/go/file"
|
||||
"os"
|
||||
)
|
||||
|
||||
// Save a file
|
||||
func SaveFile() {
|
||||
fileService := file.NewFileService(os.Getenv("MICRO_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)
|
||||
}
|
||||
16
examples/file/save/node/saveFile.js
Executable file
16
examples/file/save/node/saveFile.js
Executable file
@@ -0,0 +1,16 @@
|
||||
import * as file from "m3o/file";
|
||||
|
||||
// Save a file
|
||||
async function SaveFile() {
|
||||
let fileService = new file.FileService(process.env.MICRO_API_TOKEN);
|
||||
let rsp = await fileService.save({
|
||||
file: {
|
||||
content: "file content example",
|
||||
path: "/document/text-files/file.txt",
|
||||
project: "examples",
|
||||
},
|
||||
});
|
||||
console.log(rsp);
|
||||
}
|
||||
|
||||
await SaveFile();
|
||||
6
examples/forex/history/curl/getPreviousClose.sh
Executable file
6
examples/forex/history/curl/getPreviousClose.sh
Executable file
@@ -0,0 +1,6 @@
|
||||
curl "https://api.m3o.com/v1/forex/History" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer $MICRO_API_TOKEN" \
|
||||
-d '{
|
||||
"symbol": "GBPUSD"
|
||||
}'
|
||||
16
examples/forex/history/go/getPreviousClose.go
Executable file
16
examples/forex/history/go/getPreviousClose.go
Executable file
@@ -0,0 +1,16 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/micro/services/clients/go/forex"
|
||||
"os"
|
||||
)
|
||||
|
||||
// Returns the data for the previous close
|
||||
func GetPreviousClose() {
|
||||
forexService := forex.NewForexService(os.Getenv("MICRO_API_TOKEN"))
|
||||
rsp, err := forexService.History(&forex.HistoryRequest{
|
||||
Symbol: "GBPUSD",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
12
examples/forex/history/node/getPreviousClose.js
Executable file
12
examples/forex/history/node/getPreviousClose.js
Executable file
@@ -0,0 +1,12 @@
|
||||
import * as forex from "m3o/forex";
|
||||
|
||||
// Returns the data for the previous close
|
||||
async function GetPreviousClose() {
|
||||
let forexService = new forex.ForexService(process.env.MICRO_API_TOKEN);
|
||||
let rsp = await forexService.history({
|
||||
symbol: "GBPUSD",
|
||||
});
|
||||
console.log(rsp);
|
||||
}
|
||||
|
||||
await GetPreviousClose();
|
||||
6
examples/forex/price/curl/getAnFxPrice.sh
Executable file
6
examples/forex/price/curl/getAnFxPrice.sh
Executable file
@@ -0,0 +1,6 @@
|
||||
curl "https://api.m3o.com/v1/forex/Price" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer $MICRO_API_TOKEN" \
|
||||
-d '{
|
||||
"symbol": "GBPUSD"
|
||||
}'
|
||||
16
examples/forex/price/go/getAnFxPrice.go
Executable file
16
examples/forex/price/go/getAnFxPrice.go
Executable file
@@ -0,0 +1,16 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/micro/services/clients/go/forex"
|
||||
"os"
|
||||
)
|
||||
|
||||
// Get the latest price for a given forex ticker
|
||||
func GetAnFxPrice() {
|
||||
forexService := forex.NewForexService(os.Getenv("MICRO_API_TOKEN"))
|
||||
rsp, err := forexService.Price(&forex.PriceRequest{
|
||||
Symbol: "GBPUSD",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
12
examples/forex/price/node/getAnFxPrice.js
Executable file
12
examples/forex/price/node/getAnFxPrice.js
Executable file
@@ -0,0 +1,12 @@
|
||||
import * as forex from "m3o/forex";
|
||||
|
||||
// Get the latest price for a given forex ticker
|
||||
async function GetAnFxPrice() {
|
||||
let forexService = new forex.ForexService(process.env.MICRO_API_TOKEN);
|
||||
let rsp = await forexService.price({
|
||||
symbol: "GBPUSD",
|
||||
});
|
||||
console.log(rsp);
|
||||
}
|
||||
|
||||
await GetAnFxPrice();
|
||||
6
examples/forex/quote/curl/getAFxQuote.sh
Executable file
6
examples/forex/quote/curl/getAFxQuote.sh
Executable file
@@ -0,0 +1,6 @@
|
||||
curl "https://api.m3o.com/v1/forex/Quote" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer $MICRO_API_TOKEN" \
|
||||
-d '{
|
||||
"symbol": "GBPUSD"
|
||||
}'
|
||||
16
examples/forex/quote/go/getAFxQuote.go
Executable file
16
examples/forex/quote/go/getAFxQuote.go
Executable file
@@ -0,0 +1,16 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/micro/services/clients/go/forex"
|
||||
"os"
|
||||
)
|
||||
|
||||
// Get the latest quote for the forex
|
||||
func GetAfxQuote() {
|
||||
forexService := forex.NewForexService(os.Getenv("MICRO_API_TOKEN"))
|
||||
rsp, err := forexService.Quote(&forex.QuoteRequest{
|
||||
Symbol: "GBPUSD",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
12
examples/forex/quote/node/getAFxQuote.js
Executable file
12
examples/forex/quote/node/getAFxQuote.js
Executable file
@@ -0,0 +1,12 @@
|
||||
import * as forex from "m3o/forex";
|
||||
|
||||
// Get the latest quote for the forex
|
||||
async function GetAfxQuote() {
|
||||
let forexService = new forex.ForexService(process.env.MICRO_API_TOKEN);
|
||||
let rsp = await forexService.quote({
|
||||
symbol: "GBPUSD",
|
||||
});
|
||||
console.log(rsp);
|
||||
}
|
||||
|
||||
await GetAfxQuote();
|
||||
9
examples/geocoding/lookup/curl/geocodeAnAddress.sh
Executable file
9
examples/geocoding/lookup/curl/geocodeAnAddress.sh
Executable file
@@ -0,0 +1,9 @@
|
||||
curl "https://api.m3o.com/v1/geocoding/Lookup" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer $MICRO_API_TOKEN" \
|
||||
-d '{
|
||||
"address": "10 russell st",
|
||||
"city": "london",
|
||||
"country": "uk",
|
||||
"postcode": "wc2b"
|
||||
}'
|
||||
19
examples/geocoding/lookup/go/geocodeAnAddress.go
Executable file
19
examples/geocoding/lookup/go/geocodeAnAddress.go
Executable file
@@ -0,0 +1,19 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/micro/services/clients/go/geocoding"
|
||||
"os"
|
||||
)
|
||||
|
||||
// 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("MICRO_API_TOKEN"))
|
||||
rsp, err := geocodingService.Lookup(&geocoding.LookupRequest{
|
||||
Address: "10 russell st",
|
||||
City: "london",
|
||||
Country: "uk",
|
||||
Postcode: "wc2b",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
17
examples/geocoding/lookup/node/geocodeAnAddress.js
Executable file
17
examples/geocoding/lookup/node/geocodeAnAddress.js
Executable file
@@ -0,0 +1,17 @@
|
||||
import * as geocoding from "m3o/geocoding";
|
||||
|
||||
// Lookup returns a geocoded address including normalized address and gps coordinates. All fields are optional, provide more to get more accurate results
|
||||
async function GeocodeAnAddress() {
|
||||
let geocodingService = new geocoding.GeocodingService(
|
||||
process.env.MICRO_API_TOKEN
|
||||
);
|
||||
let rsp = await geocodingService.lookup({
|
||||
address: "10 russell st",
|
||||
city: "london",
|
||||
country: "uk",
|
||||
postcode: "wc2b",
|
||||
});
|
||||
console.log(rsp);
|
||||
}
|
||||
|
||||
await GeocodeAnAddress();
|
||||
7
examples/geocoding/reverse/curl/reverseGeocodeLocation.sh
Executable file
7
examples/geocoding/reverse/curl/reverseGeocodeLocation.sh
Executable file
@@ -0,0 +1,7 @@
|
||||
curl "https://api.m3o.com/v1/geocoding/Reverse" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer $MICRO_API_TOKEN" \
|
||||
-d '{
|
||||
"latitude": 51.5123064,
|
||||
"longitude": -0.1216235
|
||||
}'
|
||||
17
examples/geocoding/reverse/go/reverseGeocodeLocation.go
Executable file
17
examples/geocoding/reverse/go/reverseGeocodeLocation.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/micro/services/clients/go/geocoding"
|
||||
"os"
|
||||
)
|
||||
|
||||
// Reverse lookup an address from gps coordinates
|
||||
func ReverseGeocodeLocation() {
|
||||
geocodingService := geocoding.NewGeocodingService(os.Getenv("MICRO_API_TOKEN"))
|
||||
rsp, err := geocodingService.Reverse(&geocoding.ReverseRequest{
|
||||
Latitude: 51.5123064,
|
||||
Longitude: -0.1216235,
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
15
examples/geocoding/reverse/node/reverseGeocodeLocation.js
Executable file
15
examples/geocoding/reverse/node/reverseGeocodeLocation.js
Executable file
@@ -0,0 +1,15 @@
|
||||
import * as geocoding from "m3o/geocoding";
|
||||
|
||||
// Reverse lookup an address from gps coordinates
|
||||
async function ReverseGeocodeLocation() {
|
||||
let geocodingService = new geocoding.GeocodingService(
|
||||
process.env.MICRO_API_TOKEN
|
||||
);
|
||||
let rsp = await geocodingService.reverse({
|
||||
latitude: 51.5123064,
|
||||
longitude: -0.1216235,
|
||||
});
|
||||
console.log(rsp);
|
||||
}
|
||||
|
||||
await ReverseGeocodeLocation();
|
||||
6
examples/helloworld/call/curl/callTheHelloworldService.sh
Executable file
6
examples/helloworld/call/curl/callTheHelloworldService.sh
Executable file
@@ -0,0 +1,6 @@
|
||||
curl "https://api.m3o.com/v1/helloworld/Call" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer $MICRO_API_TOKEN" \
|
||||
-d '{
|
||||
"name": "John"
|
||||
}'
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user