Generate clients (#206)

This commit is contained in:
Janos Dobronszki
2021-09-16 12:52:36 +01:00
committed by GitHub
parent 552c321dd7
commit d4d9c1c176
334 changed files with 9334 additions and 45 deletions

View 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"
}'

View 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)
}

View 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();

View 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"
}'

View 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)
}

View 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();

View 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
}'

View 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)
}

View 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
View 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
View 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
View 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
View 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
View 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
View 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();

View 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
}'

View 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)
}

View 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
View 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
View 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
View 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();

View 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"
}'

View 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)
}

View 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();

View 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"
}'

View 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)
}

View 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();

View 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"
}'

View 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)
}

View 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();

View 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 '{}'

View 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(&currency.CodesRequest{})
fmt.Println(rsp, err)
}

View 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();

View 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"
}'

View 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"
}'

View 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(&currency.ConvertRequest{
Amount: 10,
From: "USD",
To: "GBP",
})
fmt.Println(rsp, err)
}

View 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(&currency.ConvertRequest{
From: "USD",
To: "GBP",
})
fmt.Println(rsp, err)
}

View 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();

View 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();

View 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"
}'

View 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(&currency.RatesRequest{
Code: "USD",
})
fmt.Println(rsp, err)
}

View 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();

View 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"
}'

View 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)
}

View 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();

View 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"
}'

View 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)
}

View 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();

View 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"
}'

View 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)
}

View 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();

View 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"
}'

View 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)
}

View 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();

View 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"
}'

View 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)
}

View 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();

View 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"
}'

View 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)
}

View 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();

View 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:"
}'

View 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)
}

View 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();

View 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"
}'

View 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)
}

View 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();

View 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:"
}'

View 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)
}

View 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();

View 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"
}'

View 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)
}

View 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();

View 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"
}'

View 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)
}

View 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();

View 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"
}'

View 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)
}

View 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();

View 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"
}'

View 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)
}

View 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();

View 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"
}
}'

View 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)
}

View 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();

View 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"
}'

View 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)
}

View 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();

View 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"
}'

View 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)
}

View 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();

View 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"
}'

View 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)
}

View 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();

View 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"
}'

View 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)
}

View 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();

View 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
}'

View 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)
}

View 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();

View 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