diff --git a/examples/ai/README.md b/examples/ai/README.md index ea2aed8c..5baa4202 100755 --- a/examples/ai/README.md +++ b/examples/ai/README.md @@ -4,6 +4,52 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Ai/api](https: Endpoints: +## Generate + +Generate an image from prompt + + +[https://m3o.com/ai/api#Generate](https://m3o.com/ai/api#Generate) + +```js +const { AiService } = require('m3o/ai'); + +const aiService = new AiService(process.env.M3O_API_TOKEN) + +// Generate an image from prompt +async function generateImage() { + const rsp = await aiService.generate({ + "text": "a cat on a ball" +}) + console.log(rsp) + +} + +generateImage() +``` +## Moderate + +Moderate hate speech + + +[https://m3o.com/ai/api#Moderate](https://m3o.com/ai/api#Moderate) + +```js +const { AiService } = require('m3o/ai'); + +const aiService = new AiService(process.env.M3O_API_TOKEN) + +// Moderate hate speech +async function moderateHateSpeech() { + const rsp = await aiService.moderate({ + "text": "I want to kill him" +}) + console.log(rsp) + +} + +moderateHateSpeech() +``` ## Chat Make a request to ChatGPT @@ -84,49 +130,3 @@ async function editText() { editText() ``` -## Generate - -Generate an image from prompt - - -[https://m3o.com/ai/api#Generate](https://m3o.com/ai/api#Generate) - -```js -const { AiService } = require('m3o/ai'); - -const aiService = new AiService(process.env.M3O_API_TOKEN) - -// Generate an image from prompt -async function generateImage() { - const rsp = await aiService.generate({ - "text": "a cat on a ball" -}) - console.log(rsp) - -} - -generateImage() -``` -## Moderate - -Moderate hate speech - - -[https://m3o.com/ai/api#Moderate](https://m3o.com/ai/api#Moderate) - -```js -const { AiService } = require('m3o/ai'); - -const aiService = new AiService(process.env.M3O_API_TOKEN) - -// Moderate hate speech -async function moderateHateSpeech() { - const rsp = await aiService.moderate({ - "text": "I want to kill him" -}) - console.log(rsp) - -} - -moderateHateSpeech() -``` diff --git a/examples/app/README.md b/examples/app/README.md index e2aca25a..abc274cb 100755 --- a/examples/app/README.md +++ b/examples/app/README.md @@ -4,28 +4,28 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/App/api](https Endpoints: -## Status +## Get -Get the status of an app +Get an app by name -[https://m3o.com/app/api#Status](https://m3o.com/app/api#Status) +[https://m3o.com/app/api#Get](https://m3o.com/app/api#Get) ```js const { AppService } = require('m3o/app'); const appService = new AppService(process.env.M3O_API_TOKEN) -// Get the status of an app -async function getTheStatusOfAnApp() { - const rsp = await appService.status({ +// Get an app by name +async function getAnApp() { + const rsp = await appService.get({ "name": "helloworld" }) console.log(rsp) } -getTheStatusOfAnApp() +getAnApp() ``` ## Update @@ -50,188 +50,188 @@ async function updateAnApp() { updateAnApp() ``` -## Delete +## Logs -Delete an app +Get the logs for an app -[https://m3o.com/app/api#Delete](https://m3o.com/app/api#Delete) +[https://m3o.com/app/api#Logs](https://m3o.com/app/api#Logs) ```js const { AppService } = require('m3o/app'); const appService = new AppService(process.env.M3O_API_TOKEN) -// Delete an app -async function deleteAnApp() { - const rsp = await appService.delete({ +// Get the logs for an app +async function retrieveBuildLogsForAnApp() { + const rsp = await appService.logs({ + "logs_type": "build", "name": "helloworld" }) console.log(rsp) } -deleteAnApp() +retrieveBuildLogsForAnApp() ``` -## Reserve +## Regions -Reserve app names +Return the support regions -[https://m3o.com/app/api#Reserve](https://m3o.com/app/api#Reserve) +[https://m3o.com/app/api#Regions](https://m3o.com/app/api#Regions) ```js const { AppService } = require('m3o/app'); const appService = new AppService(process.env.M3O_API_TOKEN) -// Reserve app names -async function reserveAppName() { - const rsp = await appService.reserve({ - "name": "helloworld" -}) +// Return the support regions +async function listRegions() { + const rsp = await appService.regions({}) console.log(rsp) } -reserveAppName() +listRegions() ``` -## List +## Status -List all the apps +Get the status of an app -[https://m3o.com/app/api#List](https://m3o.com/app/api#List) +[https://m3o.com/app/api#Status](https://m3o.com/app/api#Status) ```js const { AppService } = require('m3o/app'); const appService = new AppService(process.env.M3O_API_TOKEN) -// List all the apps -async function listTheApps() { - const rsp = await appService.list({}) +// Get the status of an app +async function getTheStatusOfAnApp() { + const rsp = await appService.status({ + "name": "helloworld" +}) console.log(rsp) } -listTheApps() +getTheStatusOfAnApp() ``` -## Run +## Resolve -Run an app from source +Resolve an app by id to its raw backend endpoint -[https://m3o.com/app/api#Run](https://m3o.com/app/api#Run) +[https://m3o.com/app/api#Resolve](https://m3o.com/app/api#Resolve) ```js const { AppService } = require('m3o/app'); const appService = new AppService(process.env.M3O_API_TOKEN) -// Run an app from source -async function runAnApp() { - const rsp = await appService.run({ - "branch": "master", - "name": "helloworld", - "port": 8080, - "region": "europe-west1", - "repo": "github.com/asim/helloworld" +// Resolve an app by id to its raw backend endpoint +async function resolveAppById() { + const rsp = await appService.resolve({ + "id": "helloworld" }) console.log(rsp) } -runAnApp() +resolveAppById() ``` -## Regions +## Delete -Return the support regions +Delete an app -[https://m3o.com/app/api#Regions](https://m3o.com/app/api#Regions) +[https://m3o.com/app/api#Delete](https://m3o.com/app/api#Delete) ```js const { AppService } = require('m3o/app'); const appService = new AppService(process.env.M3O_API_TOKEN) -// Return the support regions -async function listRegions() { - const rsp = await appService.regions({}) +// Delete an app +async function deleteAnApp() { + const rsp = await appService.delete({ + "name": "helloworld" +}) console.log(rsp) } -listRegions() +deleteAnApp() ``` -## Resolve +## Reserve -Resolve an app by id to its raw backend endpoint +Reserve app names -[https://m3o.com/app/api#Resolve](https://m3o.com/app/api#Resolve) +[https://m3o.com/app/api#Reserve](https://m3o.com/app/api#Reserve) ```js const { AppService } = require('m3o/app'); const appService = new AppService(process.env.M3O_API_TOKEN) -// Resolve an app by id to its raw backend endpoint -async function resolveAppById() { - const rsp = await appService.resolve({ - "id": "helloworld" +// Reserve app names +async function reserveAppName() { + const rsp = await appService.reserve({ + "name": "helloworld" }) console.log(rsp) } -resolveAppById() +reserveAppName() ``` -## Logs +## List -Get the logs for an app +List all the apps -[https://m3o.com/app/api#Logs](https://m3o.com/app/api#Logs) +[https://m3o.com/app/api#List](https://m3o.com/app/api#List) ```js const { AppService } = require('m3o/app'); const appService = new AppService(process.env.M3O_API_TOKEN) -// Get the logs for an app -async function retrieveBuildLogsForAnApp() { - const rsp = await appService.logs({ - "logs_type": "build", - "name": "helloworld" -}) +// List all the apps +async function listTheApps() { + const rsp = await appService.list({}) console.log(rsp) } -retrieveBuildLogsForAnApp() +listTheApps() ``` -## Get +## Run -Get an app by name +Run an app from source -[https://m3o.com/app/api#Get](https://m3o.com/app/api#Get) +[https://m3o.com/app/api#Run](https://m3o.com/app/api#Run) ```js const { AppService } = require('m3o/app'); const appService = new AppService(process.env.M3O_API_TOKEN) -// Get an app by name -async function getAnApp() { - const rsp = await appService.get({ - "name": "helloworld" +// Run an app from source +async function runAnApp() { + const rsp = await appService.run({ + "branch": "master", + "name": "helloworld", + "port": 8080, + "region": "europe-west1", + "repo": "github.com/asim/helloworld" }) console.log(rsp) } -getAnApp() +runAnApp() ``` diff --git a/examples/cache/README.md b/examples/cache/README.md index 6661d20a..32d3b89f 100755 --- a/examples/cache/README.md +++ b/examples/cache/README.md @@ -4,30 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Cache/api](htt Endpoints: -## Decrement - -Decrement a value (if it's a number). If key not found it is equivalent to set. - - -[https://m3o.com/cache/api#Decrement](https://m3o.com/cache/api#Decrement) - -```js -const { CacheService } = require('m3o/cache'); - -const cacheService = new CacheService(process.env.M3O_API_TOKEN) - -// Decrement a value (if it's a number). If key not found it is equivalent to set. -async function decrementAvalue() { - const rsp = await cacheService.decrement({ - "key": "counter", - "value": 2 -}) - console.log(rsp) - -} - -decrementAvalue() -``` ## ListKeys List all the available keys @@ -143,3 +119,27 @@ async function incrementAvalue() { incrementAvalue() ``` +## Decrement + +Decrement a value (if it's a number). If key not found it is equivalent to set. + + +[https://m3o.com/cache/api#Decrement](https://m3o.com/cache/api#Decrement) + +```js +const { CacheService } = require('m3o/cache'); + +const cacheService = new CacheService(process.env.M3O_API_TOKEN) + +// Decrement a value (if it's a number). If key not found it is equivalent to set. +async function decrementAvalue() { + const rsp = await cacheService.decrement({ + "key": "counter", + "value": 2 +}) + console.log(rsp) + +} + +decrementAvalue() +``` diff --git a/examples/chat/README.md b/examples/chat/README.md index 1c16f097..061d570f 100755 --- a/examples/chat/README.md +++ b/examples/chat/README.md @@ -4,100 +4,99 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Chat/api](http Endpoints: -## Delete +## Create -Delete a group +Create a new group -[https://m3o.com/chat/api#Delete](https://m3o.com/chat/api#Delete) +[https://m3o.com/chat/api#Create](https://m3o.com/chat/api#Create) ```js const { ChatService } = require('m3o/chat'); const chatService = new ChatService(process.env.M3O_API_TOKEN) -// Delete a group -async function deleteAchat() { - const rsp = await chatService.delete({ - "group_id": "d8057208-f81a-4e14-ad7f-c29daa2bb910" +// Create a new group +async function createAnewChat() { + const rsp = await chatService.create({ + "description": "The general group", + "name": "general" }) console.log(rsp) } -deleteAchat() +createAnewChat() ``` -## Kick +## Delete -Kick a user from a group +Delete a group -[https://m3o.com/chat/api#Kick](https://m3o.com/chat/api#Kick) +[https://m3o.com/chat/api#Delete](https://m3o.com/chat/api#Delete) ```js const { ChatService } = require('m3o/chat'); const chatService = new ChatService(process.env.M3O_API_TOKEN) -// Kick a user from a group -async function kickAuserFromAgroup() { - const rsp = await chatService.kick({ - "group_id": "d8057208-f81a-4e14-ad7f-c29daa2bb910", - "user_id": "user-1" +// Delete a group +async function deleteAchat() { + const rsp = await chatService.delete({ + "group_id": "d8057208-f81a-4e14-ad7f-c29daa2bb910" }) console.log(rsp) } -kickAuserFromAgroup() +deleteAchat() ``` -## Leave +## History -Leave a group +List the messages in a chat -[https://m3o.com/chat/api#Leave](https://m3o.com/chat/api#Leave) +[https://m3o.com/chat/api#History](https://m3o.com/chat/api#History) ```js const { ChatService } = require('m3o/chat'); const chatService = new ChatService(process.env.M3O_API_TOKEN) -// Leave a group -async function leaveAgroup() { - const rsp = await chatService.leave({ - "group_id": "d8057208-f81a-4e14-ad7f-c29daa2bb910", - "user_id": "user-1" +// List the messages in a chat +async function getChatHistory() { + const rsp = await chatService.history({ + "group_id": "d8057208-f81a-4e14-ad7f-c29daa2bb910" }) console.log(rsp) } -leaveAgroup() +getChatHistory() ``` -## Create +## Kick -Create a new group +Kick a user from a group -[https://m3o.com/chat/api#Create](https://m3o.com/chat/api#Create) +[https://m3o.com/chat/api#Kick](https://m3o.com/chat/api#Kick) ```js const { ChatService } = require('m3o/chat'); const chatService = new ChatService(process.env.M3O_API_TOKEN) -// Create a new group -async function createAnewChat() { - const rsp = await chatService.create({ - "description": "The general group", - "name": "general" +// Kick a user from a group +async function kickAuserFromAgroup() { + const rsp = await chatService.kick({ + "group_id": "d8057208-f81a-4e14-ad7f-c29daa2bb910", + "user_id": "user-1" }) console.log(rsp) } -createAnewChat() +kickAuserFromAgroup() ``` ## List @@ -173,51 +172,52 @@ async function sendAmessage() { sendAmessage() ``` -## History +## Join -List the messages in a chat +Join a group -[https://m3o.com/chat/api#History](https://m3o.com/chat/api#History) +[https://m3o.com/chat/api#Join](https://m3o.com/chat/api#Join) ```js const { ChatService } = require('m3o/chat'); const chatService = new ChatService(process.env.M3O_API_TOKEN) -// List the messages in a chat -async function getChatHistory() { - const rsp = await chatService.history({ - "group_id": "d8057208-f81a-4e14-ad7f-c29daa2bb910" +// Join a group +async function joinAgroup() { + const rsp = await chatService.join({ + "group_id": "d8057208-f81a-4e14-ad7f-c29daa2bb910", + "user_id": "user-2" }) - console.log(rsp) - + rsp.onMessage(msg => { + console.log(msg) + }) } -getChatHistory() +joinAgroup() ``` -## Join +## Leave -Join a group +Leave a group -[https://m3o.com/chat/api#Join](https://m3o.com/chat/api#Join) +[https://m3o.com/chat/api#Leave](https://m3o.com/chat/api#Leave) ```js const { ChatService } = require('m3o/chat'); const chatService = new ChatService(process.env.M3O_API_TOKEN) -// Join a group -async function joinAgroup() { - const rsp = await chatService.join({ +// Leave a group +async function leaveAgroup() { + const rsp = await chatService.leave({ "group_id": "d8057208-f81a-4e14-ad7f-c29daa2bb910", - "user_id": "user-2" + "user_id": "user-1" }) - rsp.onMessage(msg => { - console.log(msg) - }) + console.log(rsp) + } -joinAgroup() +leaveAgroup() ``` diff --git a/examples/comments/README.md b/examples/comments/README.md index cdb92987..6d2582c5 100755 --- a/examples/comments/README.md +++ b/examples/comments/README.md @@ -4,30 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Comments/api]( Endpoints: -## Create - -Create a new comment - - -[https://m3o.com/comments/api#Create](https://m3o.com/comments/api#Create) - -```js -const { CommentsService } = require('m3o/comments'); - -const commentsService = new CommentsService(process.env.M3O_API_TOKEN) - -// Create a new comment -async function createAcomment() { - const rsp = await commentsService.create({ - "subject": "New Comment", - "text": "This is my comment" -}) - console.log(rsp) - -} - -createAcomment() -``` ## Read Read a comment @@ -146,3 +122,27 @@ async function subscribeToEvents() { subscribeToEvents() ``` +## Create + +Create a new comment + + +[https://m3o.com/comments/api#Create](https://m3o.com/comments/api#Create) + +```js +const { CommentsService } = require('m3o/comments'); + +const commentsService = new CommentsService(process.env.M3O_API_TOKEN) + +// Create a new comment +async function createAcomment() { + const rsp = await commentsService.create({ + "subject": "New Comment", + "text": "This is my comment" +}) + console.log(rsp) + +} + +createAcomment() +``` diff --git a/examples/crypto/README.md b/examples/crypto/README.md index e46b1747..53d040fc 100755 --- a/examples/crypto/README.md +++ b/examples/crypto/README.md @@ -4,29 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Crypto/api](ht Endpoints: -## History - -Returns the history for the previous close - - -[https://m3o.com/crypto/api#History](https://m3o.com/crypto/api#History) - -```js -const { CryptoService } = require('m3o/crypto'); - -const cryptoService = new CryptoService(process.env.M3O_API_TOKEN) - -// Returns the history for the previous close -async function getPreviousClose() { - const rsp = await cryptoService.history({ - "symbol": "BTCUSD" -}) - console.log(rsp) - -} - -getPreviousClose() -``` ## Symbols Returns the full list of supported symbols @@ -117,3 +94,26 @@ async function getAcryptocurrencyQuote() { getAcryptocurrencyQuote() ``` +## History + +Returns the history for the previous close + + +[https://m3o.com/crypto/api#History](https://m3o.com/crypto/api#History) + +```js +const { CryptoService } = require('m3o/crypto'); + +const cryptoService = new CryptoService(process.env.M3O_API_TOKEN) + +// Returns the history for the previous close +async function getPreviousClose() { + const rsp = await cryptoService.history({ + "symbol": "BTCUSD" +}) + console.log(rsp) + +} + +getPreviousClose() +``` diff --git a/examples/db/README.md b/examples/db/README.md index 3fb052da..c94f4431 100755 --- a/examples/db/README.md +++ b/examples/db/README.md @@ -4,221 +4,221 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Db/api](https: Endpoints: -## Truncate +## Create -Truncate the records in a table +Create a record in the database. Optionally include an "id" field otherwise it's set automatically. -[https://m3o.com/db/api#Truncate](https://m3o.com/db/api#Truncate) +[https://m3o.com/db/api#Create](https://m3o.com/db/api#Create) ```js const { DbService } = require('m3o/db'); const dbService = new DbService(process.env.M3O_API_TOKEN) -// Truncate the records in a table -async function truncateTable() { - const rsp = await dbService.truncate({ +// Create a record in the database. Optionally include an "id" field otherwise it's set automatically. +async function createArecord() { + const rsp = await dbService.create({ + "record": { + "age": 42, + "id": "1", + "isActive": true, + "name": "Jane" + }, "table": "example" }) console.log(rsp) } -truncateTable() +createArecord() ``` -## ListTables +## Update -List tables in the DB +Update a record in the database. Include an "id" in the record to update. -[https://m3o.com/db/api#ListTables](https://m3o.com/db/api#ListTables) +[https://m3o.com/db/api#Update](https://m3o.com/db/api#Update) ```js const { DbService } = require('m3o/db'); const dbService = new DbService(process.env.M3O_API_TOKEN) -// List tables in the DB -async function listTables() { - const rsp = await dbService.listTables({}) +// Update a record in the database. Include an "id" in the record to update. +async function updateArecord() { + const rsp = await dbService.update({ + "record": { + "age": 43, + "id": "1" + }, + "table": "example" +}) console.log(rsp) } -listTables() +updateArecord() ``` -## RenameTable +## Delete -Rename a table +Delete a record in the database by id. -[https://m3o.com/db/api#RenameTable](https://m3o.com/db/api#RenameTable) +[https://m3o.com/db/api#Delete](https://m3o.com/db/api#Delete) ```js const { DbService } = require('m3o/db'); const dbService = new DbService(process.env.M3O_API_TOKEN) -// Rename a table -async function renameTable() { - const rsp = await dbService.renameTable({ - "from": "examples2", - "to": "examples3" +// Delete a record in the database by id. +async function deleteArecord() { + const rsp = await dbService.delete({ + "id": "1", + "table": "example" }) console.log(rsp) } -renameTable() +deleteArecord() ``` -## Create +## Truncate -Create a record in the database. Optionally include an "id" field otherwise it's set automatically. +Truncate the records in a table -[https://m3o.com/db/api#Create](https://m3o.com/db/api#Create) +[https://m3o.com/db/api#Truncate](https://m3o.com/db/api#Truncate) ```js const { DbService } = require('m3o/db'); const dbService = new DbService(process.env.M3O_API_TOKEN) -// Create a record in the database. Optionally include an "id" field otherwise it's set automatically. -async function createArecord() { - const rsp = await dbService.create({ - "record": { - "age": 42, - "id": "1", - "isActive": true, - "name": "Jane" - }, +// Truncate the records in a table +async function truncateTable() { + const rsp = await dbService.truncate({ "table": "example" }) console.log(rsp) } -createArecord() +truncateTable() ``` -## Update +## ListTables -Update a record in the database. Include an "id" in the record to update. +List tables in the DB -[https://m3o.com/db/api#Update](https://m3o.com/db/api#Update) +[https://m3o.com/db/api#ListTables](https://m3o.com/db/api#ListTables) ```js const { DbService } = require('m3o/db'); const dbService = new DbService(process.env.M3O_API_TOKEN) -// Update a record in the database. Include an "id" in the record to update. -async function updateArecord() { - const rsp = await dbService.update({ - "record": { - "age": 43, - "id": "1" - }, - "table": "example" -}) +// List tables in the DB +async function listTables() { + const rsp = await dbService.listTables({}) console.log(rsp) } -updateArecord() +listTables() ``` -## DropTable +## Read -Drop a table in the DB +Read data from a table. Lookup can be by ID or via querying any field in the record. -[https://m3o.com/db/api#DropTable](https://m3o.com/db/api#DropTable) +[https://m3o.com/db/api#Read](https://m3o.com/db/api#Read) ```js const { DbService } = require('m3o/db'); const dbService = new DbService(process.env.M3O_API_TOKEN) -// Drop a table in the DB -async function dropTable() { - const rsp = await dbService.dropTable({ +// Read data from a table. Lookup can be by ID or via querying any field in the record. +async function readRecords() { + const rsp = await dbService.read({ + "query": "age == 43", "table": "example" }) console.log(rsp) } -dropTable() +readRecords() ``` -## Count +## DropTable -Count records in a table +Drop a table in the DB -[https://m3o.com/db/api#Count](https://m3o.com/db/api#Count) +[https://m3o.com/db/api#DropTable](https://m3o.com/db/api#DropTable) ```js const { DbService } = require('m3o/db'); const dbService = new DbService(process.env.M3O_API_TOKEN) -// Count records in a table -async function countEntriesInAtable() { - const rsp = await dbService.count({ +// Drop a table in the DB +async function dropTable() { + const rsp = await dbService.dropTable({ "table": "example" }) console.log(rsp) } -countEntriesInAtable() +dropTable() ``` -## Read +## Count -Read data from a table. Lookup can be by ID or via querying any field in the record. +Count records in a table -[https://m3o.com/db/api#Read](https://m3o.com/db/api#Read) +[https://m3o.com/db/api#Count](https://m3o.com/db/api#Count) ```js const { DbService } = require('m3o/db'); const dbService = new DbService(process.env.M3O_API_TOKEN) -// Read data from a table. Lookup can be by ID or via querying any field in the record. -async function readRecords() { - const rsp = await dbService.read({ - "query": "age == 43", +// Count records in a table +async function countEntriesInAtable() { + const rsp = await dbService.count({ "table": "example" }) console.log(rsp) } -readRecords() +countEntriesInAtable() ``` -## Delete +## RenameTable -Delete a record in the database by id. +Rename a table -[https://m3o.com/db/api#Delete](https://m3o.com/db/api#Delete) +[https://m3o.com/db/api#RenameTable](https://m3o.com/db/api#RenameTable) ```js const { DbService } = require('m3o/db'); const dbService = new DbService(process.env.M3O_API_TOKEN) -// Delete a record in the database by id. -async function deleteArecord() { - const rsp = await dbService.delete({ - "id": "1", - "table": "example" +// Rename a table +async function renameTable() { + const rsp = await dbService.renameTable({ + "from": "examples2", + "to": "examples3" }) console.log(rsp) } -deleteArecord() +renameTable() ``` diff --git a/examples/dns/README.md b/examples/dns/README.md index 1ed365f2..56f129af 100755 --- a/examples/dns/README.md +++ b/examples/dns/README.md @@ -4,49 +4,49 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Dns/api](https Endpoints: -## Query +## Whois -Query an addresss +Check who owns a domain -[https://m3o.com/dns/api#Query](https://m3o.com/dns/api#Query) +[https://m3o.com/dns/api#Whois](https://m3o.com/dns/api#Whois) ```js const { DnsService } = require('m3o/dns'); const dnsService = new DnsService(process.env.M3O_API_TOKEN) -// Query an addresss -async function makeAdnsQuery() { - const rsp = await dnsService.query({ - "name": "google.com" +// Check who owns a domain +async function whoisQuery() { + const rsp = await dnsService.whois({ + "domain": "x.com" }) console.log(rsp) } -makeAdnsQuery() +whoisQuery() ``` -## Whois +## Query -Check who owns a domain +Query an addresss -[https://m3o.com/dns/api#Whois](https://m3o.com/dns/api#Whois) +[https://m3o.com/dns/api#Query](https://m3o.com/dns/api#Query) ```js const { DnsService } = require('m3o/dns'); const dnsService = new DnsService(process.env.M3O_API_TOKEN) -// Check who owns a domain -async function whoisQuery() { - const rsp = await dnsService.whois({ - "domain": "x.com" +// Query an addresss +async function makeAdnsQuery() { + const rsp = await dnsService.query({ + "name": "google.com" }) console.log(rsp) } -whoisQuery() +makeAdnsQuery() ``` diff --git a/examples/email/README.md b/examples/email/README.md index ef299299..37e13b39 100755 --- a/examples/email/README.md +++ b/examples/email/README.md @@ -4,31 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Email/api](htt 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) - -```js -const { EmailService } = require('m3o/email'); - -const emailService = new EmailService(process.env.M3O_API_TOKEN) - -// Send an email by passing in from, to, subject, and a text or html body -async function sendEmail() { - const 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) - -} - -sendEmail() -``` ## Parse Parse an RFC5322 address e.g "Joe Blogs " @@ -75,3 +50,28 @@ async function validateEmail() { validateEmail() ``` +## 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) + +```js +const { EmailService } = require('m3o/email'); + +const emailService = new EmailService(process.env.M3O_API_TOKEN) + +// Send an email by passing in from, to, subject, and a text or html body +async function sendEmail() { + const 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) + +} + +sendEmail() +``` diff --git a/examples/event/README.md b/examples/event/README.md index c429dcde..1485d9a4 100755 --- a/examples/event/README.md +++ b/examples/event/README.md @@ -4,29 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Event/api](htt Endpoints: -## Read - -Read stored events - - -[https://m3o.com/event/api#Read](https://m3o.com/event/api#Read) - -```js -const { EventService } = require('m3o/event'); - -const eventService = new EventService(process.env.M3O_API_TOKEN) - -// Read stored events -async function readEventsOnAtopic() { - const rsp = await eventService.read({ - "topic": "user" -}) - console.log(rsp) - -} - -readEventsOnAtopic() -``` ## Publish Publish a event to the event stream. @@ -79,3 +56,26 @@ async function consumeFromAtopic() { consumeFromAtopic() ``` +## Read + +Read stored events + + +[https://m3o.com/event/api#Read](https://m3o.com/event/api#Read) + +```js +const { EventService } = require('m3o/event'); + +const eventService = new EventService(process.env.M3O_API_TOKEN) + +// Read stored events +async function readEventsOnAtopic() { + const rsp = await eventService.read({ + "topic": "user" +}) + console.log(rsp) + +} + +readEventsOnAtopic() +``` diff --git a/examples/file/README.md b/examples/file/README.md index 4300f863..656b0ce0 100755 --- a/examples/file/README.md +++ b/examples/file/README.md @@ -4,101 +4,101 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/File/api](http Endpoints: -## List +## Delete -List files by their project and optionally a path. +Delete a file by project name/path -[https://m3o.com/file/api#List](https://m3o.com/file/api#List) +[https://m3o.com/file/api#Delete](https://m3o.com/file/api#Delete) ```js const { FileService } = require('m3o/file'); const fileService = new FileService(process.env.M3O_API_TOKEN) -// List files by their project and optionally a path. -async function listFiles() { - const rsp = await fileService.list({ +// Delete a file by project name/path +async function deleteFile() { + const rsp = await fileService.delete({ + "path": "/document/text-files/file.txt", "project": "examples" }) console.log(rsp) } -listFiles() +deleteFile() ``` -## Read +## Save -Read a file by path +Save a file -[https://m3o.com/file/api#Read](https://m3o.com/file/api#Read) +[https://m3o.com/file/api#Save](https://m3o.com/file/api#Save) ```js const { FileService } = require('m3o/file'); const fileService = new FileService(process.env.M3O_API_TOKEN) -// Read a file by path -async function readFile() { - const rsp = await fileService.read({ - "path": "/document/text-files/file.txt", - "project": "examples" +// Save a file +async function saveFile() { + const rsp = await fileService.save({ + "file": { + "content": "file content example", + "path": "/document/text-files/file.txt", + "project": "examples" + } }) console.log(rsp) } -readFile() +saveFile() ``` -## Delete +## List -Delete a file by project name/path +List files by their project and optionally a path. -[https://m3o.com/file/api#Delete](https://m3o.com/file/api#Delete) +[https://m3o.com/file/api#List](https://m3o.com/file/api#List) ```js const { FileService } = require('m3o/file'); const fileService = new FileService(process.env.M3O_API_TOKEN) -// Delete a file by project name/path -async function deleteFile() { - const rsp = await fileService.delete({ - "path": "/document/text-files/file.txt", +// List files by their project and optionally a path. +async function listFiles() { + const rsp = await fileService.list({ "project": "examples" }) console.log(rsp) } -deleteFile() +listFiles() ``` -## Save +## Read -Save a file +Read a file by path -[https://m3o.com/file/api#Save](https://m3o.com/file/api#Save) +[https://m3o.com/file/api#Read](https://m3o.com/file/api#Read) ```js const { FileService } = require('m3o/file'); const fileService = new FileService(process.env.M3O_API_TOKEN) -// Save a file -async function saveFile() { - const rsp = await fileService.save({ - "file": { - "content": "file content example", - "path": "/document/text-files/file.txt", - "project": "examples" - } +// Read a file by path +async function readFile() { + const rsp = await fileService.read({ + "path": "/document/text-files/file.txt", + "project": "examples" }) console.log(rsp) } -saveFile() +readFile() ``` diff --git a/examples/forex/README.md b/examples/forex/README.md index 7f35c7dc..e66d166b 100755 --- a/examples/forex/README.md +++ b/examples/forex/README.md @@ -4,72 +4,72 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Forex/api](htt Endpoints: -## Quote +## Price -Get the latest quote for the forex +Get the latest price for a given forex ticker -[https://m3o.com/forex/api#Quote](https://m3o.com/forex/api#Quote) +[https://m3o.com/forex/api#Price](https://m3o.com/forex/api#Price) ```js const { ForexService } = require('m3o/forex'); const forexService = new ForexService(process.env.M3O_API_TOKEN) -// Get the latest quote for the forex -async function getAfxQuote() { - const rsp = await forexService.quote({ +// Get the latest price for a given forex ticker +async function getAnFxPrice() { + const rsp = await forexService.price({ "symbol": "GBPUSD" }) console.log(rsp) } -getAfxQuote() +getAnFxPrice() ``` -## History +## Quote -Returns the data for the previous close +Get the latest quote for the forex -[https://m3o.com/forex/api#History](https://m3o.com/forex/api#History) +[https://m3o.com/forex/api#Quote](https://m3o.com/forex/api#Quote) ```js const { ForexService } = require('m3o/forex'); const forexService = new ForexService(process.env.M3O_API_TOKEN) -// Returns the data for the previous close -async function getPreviousClose() { - const rsp = await forexService.history({ +// Get the latest quote for the forex +async function getAfxQuote() { + const rsp = await forexService.quote({ "symbol": "GBPUSD" }) console.log(rsp) } -getPreviousClose() +getAfxQuote() ``` -## Price +## History -Get the latest price for a given forex ticker +Returns the data for the previous close -[https://m3o.com/forex/api#Price](https://m3o.com/forex/api#Price) +[https://m3o.com/forex/api#History](https://m3o.com/forex/api#History) ```js const { ForexService } = require('m3o/forex'); const forexService = new ForexService(process.env.M3O_API_TOKEN) -// Get the latest price for a given forex ticker -async function getAnFxPrice() { - const rsp = await forexService.price({ +// Returns the data for the previous close +async function getPreviousClose() { + const rsp = await forexService.history({ "symbol": "GBPUSD" }) console.log(rsp) } -getAnFxPrice() +getPreviousClose() ``` diff --git a/examples/function/README.md b/examples/function/README.md index b78fa3eb..9cec4747 100755 --- a/examples/function/README.md +++ b/examples/function/README.md @@ -4,260 +4,260 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Function/api]( Endpoints: -## Describe +## Logs -Get the info for a deployed function +Get the logs for a function -[https://m3o.com/function/api#Describe](https://m3o.com/function/api#Describe) +[https://m3o.com/function/api#Logs](https://m3o.com/function/api#Logs) ```js const { FunctionService } = require('m3o/function'); const functionService = new FunctionService(process.env.M3O_API_TOKEN) -// Get the info for a deployed function -async function describeFunctionStatus() { - const rsp = await functionService.describe({ +// Get the logs for a function +async function retrieveBuildLogsForAfunction() { + const rsp = await functionService.logs({ + "logs_type": "build", "name": "helloworld" }) console.log(rsp) } -describeFunctionStatus() +retrieveBuildLogsForAfunction() ``` -## Regions +## Deploy -Return a list of supported regions +Deploy a group of functions -[https://m3o.com/function/api#Regions](https://m3o.com/function/api#Regions) +[https://m3o.com/function/api#Deploy](https://m3o.com/function/api#Deploy) ```js const { FunctionService } = require('m3o/function'); const functionService = new FunctionService(process.env.M3O_API_TOKEN) -// Return a list of supported regions -async function listRegions() { - const rsp = await functionService.regions({}) +// Deploy a group of functions +async function deployAfunction() { + const rsp = await functionService.deploy({ + "branch": "main", + "entrypoint": "Helloworld", + "name": "helloworld", + "region": "europe-west1", + "repo": "https://github.com/m3o/m3o", + "runtime": "go116", + "subfolder": "examples/go-function" +}) console.log(rsp) } -listRegions() +deployAfunction() ``` -## Proxy +## List -Return the backend url for proxying +List all the deployed functions -[https://m3o.com/function/api#Proxy](https://m3o.com/function/api#Proxy) +[https://m3o.com/function/api#List](https://m3o.com/function/api#List) ```js const { FunctionService } = require('m3o/function'); const functionService = new FunctionService(process.env.M3O_API_TOKEN) -// Return the backend url for proxying -async function proxyUrl() { - const rsp = await functionService.proxy({ - "id": "helloworld" -}) +// List all the deployed functions +async function listFunctions() { + const rsp = await functionService.list({}) console.log(rsp) } -proxyUrl() +listFunctions() ``` -## Logs +## Regions -Get the logs for a function +Return a list of supported regions -[https://m3o.com/function/api#Logs](https://m3o.com/function/api#Logs) +[https://m3o.com/function/api#Regions](https://m3o.com/function/api#Regions) ```js const { FunctionService } = require('m3o/function'); const functionService = new FunctionService(process.env.M3O_API_TOKEN) -// Get the logs for a function -async function retrieveBuildLogsForAfunction() { - const rsp = await functionService.logs({ - "logs_type": "build", - "name": "helloworld" -}) +// Return a list of supported regions +async function listRegions() { + const rsp = await functionService.regions({}) console.log(rsp) } -retrieveBuildLogsForAfunction() +listRegions() ``` -## Deploy +## Reserve -Deploy a group of functions +Reserve function names and resources beyond free quota -[https://m3o.com/function/api#Deploy](https://m3o.com/function/api#Deploy) +[https://m3o.com/function/api#Reserve](https://m3o.com/function/api#Reserve) ```js const { FunctionService } = require('m3o/function'); const functionService = new FunctionService(process.env.M3O_API_TOKEN) -// Deploy a group of functions -async function deployAfunction() { - const rsp = await functionService.deploy({ - "branch": "main", - "entrypoint": "Helloworld", - "name": "helloworld", - "region": "europe-west1", - "repo": "https://github.com/m3o/m3o", - "runtime": "go116", - "subfolder": "examples/go-function" +// Reserve function names and resources beyond free quota +async function reserveAfunction() { + const rsp = await functionService.reserve({ + "name": "helloworld" }) console.log(rsp) } -deployAfunction() +reserveAfunction() ``` -## Call +## Runtimes -Call a function by name +Return a list of supported runtimes -[https://m3o.com/function/api#Call](https://m3o.com/function/api#Call) +[https://m3o.com/function/api#Runtimes](https://m3o.com/function/api#Runtimes) ```js const { FunctionService } = require('m3o/function'); const functionService = new FunctionService(process.env.M3O_API_TOKEN) -// Call a function by name -async function callAfunction() { - const rsp = await functionService.call({ - "name": "helloworld", - "request": { - "name": "Alice" - } -}) +// Return a list of supported runtimes +async function listRuntimes() { + const rsp = await functionService.runtimes({}) console.log(rsp) } -callAfunction() +listRuntimes() ``` -## List +## Update -List all the deployed functions +Update a function. Downloads the source, builds and redeploys -[https://m3o.com/function/api#List](https://m3o.com/function/api#List) +[https://m3o.com/function/api#Update](https://m3o.com/function/api#Update) ```js const { FunctionService } = require('m3o/function'); const functionService = new FunctionService(process.env.M3O_API_TOKEN) -// List all the deployed functions -async function listFunctions() { - const rsp = await functionService.list({}) +// Update a function. Downloads the source, builds and redeploys +async function updateAfunction() { + const rsp = await functionService.update({ + "name": "helloworld" +}) console.log(rsp) } -listFunctions() +updateAfunction() ``` -## Delete +## Call -Delete a function by name +Call a function by name -[https://m3o.com/function/api#Delete](https://m3o.com/function/api#Delete) +[https://m3o.com/function/api#Call](https://m3o.com/function/api#Call) ```js const { FunctionService } = require('m3o/function'); const functionService = new FunctionService(process.env.M3O_API_TOKEN) -// Delete a function by name -async function deleteAfunction() { - const rsp = await functionService.delete({ - "name": "helloworld" +// Call a function by name +async function callAfunction() { + const rsp = await functionService.call({ + "name": "helloworld", + "request": { + "name": "Alice" + } }) console.log(rsp) } -deleteAfunction() +callAfunction() ``` -## Update +## Delete -Update a function. Downloads the source, builds and redeploys +Delete a function by name -[https://m3o.com/function/api#Update](https://m3o.com/function/api#Update) +[https://m3o.com/function/api#Delete](https://m3o.com/function/api#Delete) ```js const { FunctionService } = require('m3o/function'); const functionService = new FunctionService(process.env.M3O_API_TOKEN) -// Update a function. Downloads the source, builds and redeploys -async function updateAfunction() { - const rsp = await functionService.update({ +// Delete a function by name +async function deleteAfunction() { + const rsp = await functionService.delete({ "name": "helloworld" }) console.log(rsp) } -updateAfunction() +deleteAfunction() ``` -## Reserve +## Describe -Reserve function names and resources beyond free quota +Get the info for a deployed function -[https://m3o.com/function/api#Reserve](https://m3o.com/function/api#Reserve) +[https://m3o.com/function/api#Describe](https://m3o.com/function/api#Describe) ```js const { FunctionService } = require('m3o/function'); const functionService = new FunctionService(process.env.M3O_API_TOKEN) -// Reserve function names and resources beyond free quota -async function reserveAfunction() { - const rsp = await functionService.reserve({ +// Get the info for a deployed function +async function describeFunctionStatus() { + const rsp = await functionService.describe({ "name": "helloworld" }) console.log(rsp) } -reserveAfunction() +describeFunctionStatus() ``` -## Runtimes +## Proxy -Return a list of supported runtimes +Return the backend url for proxying -[https://m3o.com/function/api#Runtimes](https://m3o.com/function/api#Runtimes) +[https://m3o.com/function/api#Proxy](https://m3o.com/function/api#Proxy) ```js const { FunctionService } = require('m3o/function'); const functionService = new FunctionService(process.env.M3O_API_TOKEN) -// Return a list of supported runtimes -async function listRuntimes() { - const rsp = await functionService.runtimes({}) +// Return the backend url for proxying +async function proxyUrl() { + const rsp = await functionService.proxy({ + "id": "helloworld" +}) console.log(rsp) } -listRuntimes() +proxyUrl() ``` diff --git a/examples/image/README.md b/examples/image/README.md index d7598adc..cc19cfb4 100755 --- a/examples/image/README.md +++ b/examples/image/README.md @@ -4,222 +4,222 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Image/api](htt Endpoints: -## Convert +## Resize -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. +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. To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json with each parameter as a form field. -[https://m3o.com/image/api#Convert](https://m3o.com/image/api#Convert) +[https://m3o.com/image/api#Resize](https://m3o.com/image/api#Resize) ```js const { ImageService } = require('m3o/image'); const imageService = new ImageService(process.env.M3O_API_TOKEN) -// 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. +// 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. // To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json // with each parameter as a form field. -async function convertApngImageToAjpegTakenFromAurlAndSavedToAurlOnMicrosCdn() { - const rsp = await imageService.convert({ - "name": "cat.jpeg", +async function base64toHostedImage() { + const rsp = await imageService.resize({ + "base64": "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==", + "height": 100, + "name": "cat.png", "outputURL": true, - "url": "somewebsite.com/cat.png" + "width": 100 }) console.log(rsp) } -convertApngImageToAjpegTakenFromAurlAndSavedToAurlOnMicrosCdn() +base64toHostedImage() ``` -## Upload +## Resize -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. +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. To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json with each parameter as a form field. -[https://m3o.com/image/api#Upload](https://m3o.com/image/api#Upload) +[https://m3o.com/image/api#Resize](https://m3o.com/image/api#Resize) ```js const { ImageService } = require('m3o/image'); const imageService = new ImageService(process.env.M3O_API_TOKEN) -// 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. +// 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. // To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json // with each parameter as a form field. -async function uploadAbase64imageToMicrosCdn() { - const rsp = await imageService.upload({ - "base64": "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAx0lEQVR4nOzaMaoDMQyE4ZHj+x82vVdhwQoTkzKQEcwP5r0ihT7sbjUTeAJ4HCegXQJYfOYefOyjDuBiz3yjwJBoCIl6QZOeUjTC1Ix1IxEJXF9+0KWsf2bD4bn37OO/c/wuQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9Sa/NG94Tf3j4WBdaxudMEkn4IM2rZBA0wBrvo7aOcpj2emXvLeVt0IGm0GVXUj91mvAAAA//+V2CZl+4AKXwAAAABJRU5ErkJggg==", - "name": "cat.jpeg" +async function base64toBase64image() { + const rsp = await imageService.resize({ + "base64": "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==", + "height": 100, + "width": 100 }) console.log(rsp) } -uploadAbase64imageToMicrosCdn() +base64toBase64image() ``` -## Upload +## Resize -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. +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. To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json with each parameter as a form field. -[https://m3o.com/image/api#Upload](https://m3o.com/image/api#Upload) +[https://m3o.com/image/api#Resize](https://m3o.com/image/api#Resize) ```js const { ImageService } = require('m3o/image'); const imageService = new ImageService(process.env.M3O_API_TOKEN) -// 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. +// 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. // To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json // with each parameter as a form field. -async function uploadAnImageFromAurlToMicrosCdn() { - const rsp = await imageService.upload({ - "name": "cat.jpeg", - "url": "somewebsite.com/cat.png" +async function base64toBase64imageWithCropping() { + const rsp = await imageService.resize({ + "base64": "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==", + "cropOptions": { + "height": 50, + "width": 50 + }, + "height": 100, + "width": 100 }) console.log(rsp) } -uploadAnImageFromAurlToMicrosCdn() +base64toBase64imageWithCropping() ``` -## Delete +## Convert -Delete an image previously uploaded. +Convert an image from one format (jpeg, png etc.) to an other either on the fly (from base64 to base64), +or by uploading the conversion result. +To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json +with each parameter as a form field. -[https://m3o.com/image/api#Delete](https://m3o.com/image/api#Delete) +[https://m3o.com/image/api#Convert](https://m3o.com/image/api#Convert) ```js const { ImageService } = require('m3o/image'); const imageService = new ImageService(process.env.M3O_API_TOKEN) -// Delete an image previously uploaded. -async function deleteAnUploadedImage() { - const rsp = await imageService.delete({ - "url": "https://cdn.m3ocontent.com/micro/images/micro/41e23b39-48dd-42b6-9738-79a313414bb8/cat.png" +// Convert an image from one format (jpeg, png etc.) to an other either on the fly (from base64 to base64), +// or by uploading the conversion result. +// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json +// with each parameter as a form field. +async function convertApngImageToAjpegTakenFromAurlAndSavedToAurlOnMicrosCdn() { + const rsp = await imageService.convert({ + "name": "cat.jpeg", + "outputURL": true, + "url": "somewebsite.com/cat.png" }) console.log(rsp) } -deleteAnUploadedImage() +convertApngImageToAjpegTakenFromAurlAndSavedToAurlOnMicrosCdn() ``` -## Resize +## Upload -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. +Upload an image by either sending a base64 encoded image to this endpoint or a URL. +To resize an image before uploading, see the Resize endpoint. To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json with each parameter as a form field. -[https://m3o.com/image/api#Resize](https://m3o.com/image/api#Resize) +[https://m3o.com/image/api#Upload](https://m3o.com/image/api#Upload) ```js const { ImageService } = require('m3o/image'); const imageService = new ImageService(process.env.M3O_API_TOKEN) -// 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. +// Upload an image by either sending a base64 encoded image to this endpoint or a URL. +// To resize an image before uploading, see the Resize endpoint. // To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json // with each parameter as a form field. -async function base64toHostedImage() { - const rsp = await imageService.resize({ - "base64": "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==", - "height": 100, - "name": "cat.png", - "outputURL": true, - "width": 100 +async function uploadAbase64imageToMicrosCdn() { + const rsp = await imageService.upload({ + "base64": "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAx0lEQVR4nOzaMaoDMQyE4ZHj+x82vVdhwQoTkzKQEcwP5r0ihT7sbjUTeAJ4HCegXQJYfOYefOyjDuBiz3yjwJBoCIl6QZOeUjTC1Ix1IxEJXF9+0KWsf2bD4bn37OO/c/wuQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9Sa/NG94Tf3j4WBdaxudMEkn4IM2rZBA0wBrvo7aOcpj2emXvLeVt0IGm0GVXUj91mvAAAA//+V2CZl+4AKXwAAAABJRU5ErkJggg==", + "name": "cat.jpeg" }) console.log(rsp) } -base64toHostedImage() +uploadAbase64imageToMicrosCdn() ``` -## Resize +## Upload -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. +Upload an image by either sending a base64 encoded image to this endpoint or a URL. +To resize an image before uploading, see the Resize endpoint. To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json with each parameter as a form field. -[https://m3o.com/image/api#Resize](https://m3o.com/image/api#Resize) +[https://m3o.com/image/api#Upload](https://m3o.com/image/api#Upload) ```js const { ImageService } = require('m3o/image'); const imageService = new ImageService(process.env.M3O_API_TOKEN) -// 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. +// Upload an image by either sending a base64 encoded image to this endpoint or a URL. +// To resize an image before uploading, see the Resize endpoint. // To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json // with each parameter as a form field. -async function base64toBase64image() { - const rsp = await imageService.resize({ - "base64": "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==", - "height": 100, - "width": 100 +async function uploadAnImageFromAurlToMicrosCdn() { + const rsp = await imageService.upload({ + "name": "cat.jpeg", + "url": "somewebsite.com/cat.png" }) console.log(rsp) } -base64toBase64image() +uploadAnImageFromAurlToMicrosCdn() ``` -## Resize +## Delete -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. -To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json -with each parameter as a form field. +Delete an image previously uploaded. -[https://m3o.com/image/api#Resize](https://m3o.com/image/api#Resize) +[https://m3o.com/image/api#Delete](https://m3o.com/image/api#Delete) ```js const { ImageService } = require('m3o/image'); const imageService = new ImageService(process.env.M3O_API_TOKEN) -// 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. -// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json -// with each parameter as a form field. -async function base64toBase64imageWithCropping() { - const rsp = await imageService.resize({ - "base64": "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==", - "cropOptions": { - "height": 50, - "width": 50 - }, - "height": 100, - "width": 100 +// Delete an image previously uploaded. +async function deleteAnUploadedImage() { + const rsp = await imageService.delete({ + "url": "https://cdn.m3ocontent.com/micro/images/micro/41e23b39-48dd-42b6-9738-79a313414bb8/cat.png" }) console.log(rsp) } -base64toBase64imageWithCropping() +deleteAnUploadedImage() ``` diff --git a/examples/lists/README.md b/examples/lists/README.md index 2356aca4..b4529fd9 100755 --- a/examples/lists/README.md +++ b/examples/lists/README.md @@ -4,6 +4,50 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Lists/api](htt Endpoints: +## Read + +Read a list + + +[https://m3o.com/lists/api#Read](https://m3o.com/lists/api#Read) + +```js +const { ListsService } = require('m3o/lists'); + +const listsService = new ListsService(process.env.M3O_API_TOKEN) + +// Read a list +async function readAlist() { + const rsp = await listsService.read({ + "id": "63c0cdf8-2121-11ec-a881-0242e36f037a" +}) + console.log(rsp) + +} + +readAlist() +``` +## List + +List all the lists + + +[https://m3o.com/lists/api#List](https://m3o.com/lists/api#List) + +```js +const { ListsService } = require('m3o/lists'); + +const listsService = new ListsService(process.env.M3O_API_TOKEN) + +// List all the lists +async function listAllLists() { + const rsp = await listsService.list({}) + console.log(rsp) + +} + +listAllLists() +``` ## Update Update a list @@ -106,47 +150,3 @@ async function createAlist() { createAlist() ``` -## Read - -Read a list - - -[https://m3o.com/lists/api#Read](https://m3o.com/lists/api#Read) - -```js -const { ListsService } = require('m3o/lists'); - -const listsService = new ListsService(process.env.M3O_API_TOKEN) - -// Read a list -async function readAlist() { - const rsp = await listsService.read({ - "id": "63c0cdf8-2121-11ec-a881-0242e36f037a" -}) - console.log(rsp) - -} - -readAlist() -``` -## List - -List all the lists - - -[https://m3o.com/lists/api#List](https://m3o.com/lists/api#List) - -```js -const { ListsService } = require('m3o/lists'); - -const listsService = new ListsService(process.env.M3O_API_TOKEN) - -// List all the lists -async function listAllLists() { - const rsp = await listsService.list({}) - console.log(rsp) - -} - -listAllLists() -``` diff --git a/examples/notes/README.md b/examples/notes/README.md index 8eb9ce6e..7fc48a52 100755 --- a/examples/notes/README.md +++ b/examples/notes/README.md @@ -4,6 +4,53 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Notes/api](htt Endpoints: +## Create + +Create a new note + + +[https://m3o.com/notes/api#Create](https://m3o.com/notes/api#Create) + +```js +const { NotesService } = require('m3o/notes'); + +const notesService = new NotesService(process.env.M3O_API_TOKEN) + +// Create a new note +async function createAnote() { + const rsp = await notesService.create({ + "text": "This is my note", + "title": "New Note" +}) + console.log(rsp) + +} + +createAnote() +``` +## Read + +Read a note + + +[https://m3o.com/notes/api#Read](https://m3o.com/notes/api#Read) + +```js +const { NotesService } = require('m3o/notes'); + +const notesService = new NotesService(process.env.M3O_API_TOKEN) + +// Read a note +async function readAnote() { + const rsp = await notesService.read({ + "id": "63c0cdf8-2121-11ec-a881-0242e36f037a" +}) + console.log(rsp) + +} + +readAnote() +``` ## List List all the notes @@ -99,50 +146,3 @@ async function subscribeToEvents() { subscribeToEvents() ``` -## Create - -Create a new note - - -[https://m3o.com/notes/api#Create](https://m3o.com/notes/api#Create) - -```js -const { NotesService } = require('m3o/notes'); - -const notesService = new NotesService(process.env.M3O_API_TOKEN) - -// Create a new note -async function createAnote() { - const rsp = await notesService.create({ - "text": "This is my note", - "title": "New Note" -}) - console.log(rsp) - -} - -createAnote() -``` -## Read - -Read a note - - -[https://m3o.com/notes/api#Read](https://m3o.com/notes/api#Read) - -```js -const { NotesService } = require('m3o/notes'); - -const notesService = new NotesService(process.env.M3O_API_TOKEN) - -// Read a note -async function readAnote() { - const rsp = await notesService.read({ - "id": "63c0cdf8-2121-11ec-a881-0242e36f037a" -}) - console.log(rsp) - -} - -readAnote() -``` diff --git a/examples/otp/README.md b/examples/otp/README.md index e20e59e1..d90b46ce 100755 --- a/examples/otp/README.md +++ b/examples/otp/README.md @@ -4,50 +4,50 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Otp/api](https Endpoints: -## Generate +## Validate -Generate an OTP (one time pass) code +Validate the OTP code -[https://m3o.com/otp/api#Generate](https://m3o.com/otp/api#Generate) +[https://m3o.com/otp/api#Validate](https://m3o.com/otp/api#Validate) ```js const { OtpService } = require('m3o/otp'); const otpService = new OtpService(process.env.M3O_API_TOKEN) -// Generate an OTP (one time pass) code -async function generateOtp() { - const rsp = await otpService.generate({ +// Validate the OTP code +async function validateOtp() { + const rsp = await otpService.validate({ + "code": "656211", "id": "asim@example.com" }) console.log(rsp) } -generateOtp() +validateOtp() ``` -## Validate +## Generate -Validate the OTP code +Generate an OTP (one time pass) code -[https://m3o.com/otp/api#Validate](https://m3o.com/otp/api#Validate) +[https://m3o.com/otp/api#Generate](https://m3o.com/otp/api#Generate) ```js const { OtpService } = require('m3o/otp'); const otpService = new OtpService(process.env.M3O_API_TOKEN) -// Validate the OTP code -async function validateOtp() { - const rsp = await otpService.validate({ - "code": "656211", +// Generate an OTP (one time pass) code +async function generateOtp() { + const rsp = await otpService.generate({ "id": "asim@example.com" }) console.log(rsp) } -validateOtp() +generateOtp() ``` diff --git a/examples/ping/README.md b/examples/ping/README.md index d5d5c19c..5227923c 100755 --- a/examples/ping/README.md +++ b/examples/ping/README.md @@ -4,29 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Ping/api](http Endpoints: -## Ip - -Ping an IP address - - -[https://m3o.com/ping/api#Ip](https://m3o.com/ping/api#Ip) - -```js -const { PingService } = require('m3o/ping'); - -const pingService = new PingService(process.env.M3O_API_TOKEN) - -// Ping an IP address -async function pingAnIp() { - const rsp = await pingService.ip({ - "address": "google.com" -}) - console.log(rsp) - -} - -pingAnIp() -``` ## Tcp Ping a TCP port to check if it's open @@ -73,3 +50,26 @@ async function checkAurl() { checkAurl() ``` +## Ip + +Ping an IP address + + +[https://m3o.com/ping/api#Ip](https://m3o.com/ping/api#Ip) + +```js +const { PingService } = require('m3o/ping'); + +const pingService = new PingService(process.env.M3O_API_TOKEN) + +// Ping an IP address +async function pingAnIp() { + const rsp = await pingService.ip({ + "address": "google.com" +}) + console.log(rsp) + +} + +pingAnIp() +``` diff --git a/examples/postcode/README.md b/examples/postcode/README.md index a9743d00..60b810ba 100755 --- a/examples/postcode/README.md +++ b/examples/postcode/README.md @@ -4,67 +4,67 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Postcode/api]( Endpoints: -## Validate +## Lookup -Validate a postcode. +Lookup a postcode to retrieve the related region, county, etc -[https://m3o.com/postcode/api#Validate](https://m3o.com/postcode/api#Validate) +[https://m3o.com/postcode/api#Lookup](https://m3o.com/postcode/api#Lookup) ```js const { PostcodeService } = require('m3o/postcode'); const postcodeService = new PostcodeService(process.env.M3O_API_TOKEN) -// Validate a postcode. -async function returnArandomPostcodeAndItsInformation() { - const rsp = await postcodeService.validate({ +// Lookup a postcode to retrieve the related region, county, etc +async function lookupPostcode() { + const rsp = await postcodeService.lookup({ "postcode": "SW1A 2AA" }) console.log(rsp) } -returnArandomPostcodeAndItsInformation() +lookupPostcode() ``` -## Lookup +## Random -Lookup a postcode to retrieve the related region, county, etc +Return a random postcode and its related info -[https://m3o.com/postcode/api#Lookup](https://m3o.com/postcode/api#Lookup) +[https://m3o.com/postcode/api#Random](https://m3o.com/postcode/api#Random) ```js const { PostcodeService } = require('m3o/postcode'); const postcodeService = new PostcodeService(process.env.M3O_API_TOKEN) -// Lookup a postcode to retrieve the related region, county, etc -async function lookupPostcode() { - const rsp = await postcodeService.lookup({ - "postcode": "SW1A 2AA" -}) +// Return a random postcode and its related info +async function returnArandomPostcodeAndItsInformation() { + const rsp = await postcodeService.random({}) console.log(rsp) } -lookupPostcode() +returnArandomPostcodeAndItsInformation() ``` -## Random +## Validate -Return a random postcode and its related info +Validate a postcode. -[https://m3o.com/postcode/api#Random](https://m3o.com/postcode/api#Random) +[https://m3o.com/postcode/api#Validate](https://m3o.com/postcode/api#Validate) ```js const { PostcodeService } = require('m3o/postcode'); const postcodeService = new PostcodeService(process.env.M3O_API_TOKEN) -// Return a random postcode and its related info +// Validate a postcode. async function returnArandomPostcodeAndItsInformation() { - const rsp = await postcodeService.random({}) + const rsp = await postcodeService.validate({ + "postcode": "SW1A 2AA" +}) console.log(rsp) } diff --git a/examples/price/README.md b/examples/price/README.md index 7c968b98..c56dba66 100755 --- a/examples/price/README.md +++ b/examples/price/README.md @@ -4,31 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Price/api](htt Endpoints: -## Add - -Add a price - - -[https://m3o.com/price/api#Add](https://m3o.com/price/api#Add) - -```js -const { PriceService } = require('m3o/price'); - -const priceService = new PriceService(process.env.M3O_API_TOKEN) - -// Add a price -async function addAprice() { - const rsp = await priceService.add({ - "currency": "USD", - "name": "bitcoin", - "price": 39037.97 -}) - console.log(rsp) - -} - -addAprice() -``` ## Get Get the price of anything @@ -122,3 +97,28 @@ async function reportAprice() { reportAprice() ``` +## Add + +Add a price + + +[https://m3o.com/price/api#Add](https://m3o.com/price/api#Add) + +```js +const { PriceService } = require('m3o/price'); + +const priceService = new PriceService(process.env.M3O_API_TOKEN) + +// Add a price +async function addAprice() { + const rsp = await priceService.add({ + "currency": "USD", + "name": "bitcoin", + "price": 39037.97 +}) + console.log(rsp) + +} + +addAprice() +``` diff --git a/examples/rss/README.md b/examples/rss/README.md index d9eb549d..ced89e6a 100755 --- a/examples/rss/README.md +++ b/examples/rss/README.md @@ -4,29 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Rss/api](https Endpoints: -## Remove - -Remove an RSS feed by name - - -[https://m3o.com/rss/api#Remove](https://m3o.com/rss/api#Remove) - -```js -const { RssService } = require('m3o/rss'); - -const rssService = new RssService(process.env.M3O_API_TOKEN) - -// Remove an RSS feed by name -async function removeAfeed() { - const rsp = await rssService.remove({ - "name": "bbc" -}) - console.log(rsp) - -} - -removeAfeed() -``` ## Add Add a new RSS feed with a name, url, and category @@ -96,3 +73,26 @@ async function listRssFeeds() { listRssFeeds() ``` +## Remove + +Remove an RSS feed by name + + +[https://m3o.com/rss/api#Remove](https://m3o.com/rss/api#Remove) + +```js +const { RssService } = require('m3o/rss'); + +const rssService = new RssService(process.env.M3O_API_TOKEN) + +// Remove an RSS feed by name +async function removeAfeed() { + const rsp = await rssService.remove({ + "name": "bbc" +}) + console.log(rsp) + +} + +removeAfeed() +``` diff --git a/examples/search/README.md b/examples/search/README.md index 670768ef..8a7f7eca 100755 --- a/examples/search/README.md +++ b/examples/search/README.md @@ -4,52 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Search/api](ht Endpoints: -## CreateIndex - -Create an index by name - - -[https://m3o.com/search/api#CreateIndex](https://m3o.com/search/api#CreateIndex) - -```js -const { SearchService } = require('m3o/search'); - -const searchService = new SearchService(process.env.M3O_API_TOKEN) - -// Create an index by name -async function createAnIndex() { - const rsp = await searchService.createIndex({ - "index": "customers" -}) - console.log(rsp) - -} - -createAnIndex() -``` -## DeleteIndex - -Delete an index by name - - -[https://m3o.com/search/api#DeleteIndex](https://m3o.com/search/api#DeleteIndex) - -```js -const { SearchService } = require('m3o/search'); - -const searchService = new SearchService(process.env.M3O_API_TOKEN) - -// Delete an index by name -async function deleteAnIndex() { - const rsp = await searchService.deleteIndex({ - "index": "customers" -}) - console.log(rsp) - -} - -deleteAnIndex() -``` ## Index Index a record i.e. insert a document to search for. @@ -174,3 +128,49 @@ async function deleteArecord() { deleteArecord() ``` +## CreateIndex + +Create an index by name + + +[https://m3o.com/search/api#CreateIndex](https://m3o.com/search/api#CreateIndex) + +```js +const { SearchService } = require('m3o/search'); + +const searchService = new SearchService(process.env.M3O_API_TOKEN) + +// Create an index by name +async function createAnIndex() { + const rsp = await searchService.createIndex({ + "index": "customers" +}) + console.log(rsp) + +} + +createAnIndex() +``` +## DeleteIndex + +Delete an index by name + + +[https://m3o.com/search/api#DeleteIndex](https://m3o.com/search/api#DeleteIndex) + +```js +const { SearchService } = require('m3o/search'); + +const searchService = new SearchService(process.env.M3O_API_TOKEN) + +// Delete an index by name +async function deleteAnIndex() { + const rsp = await searchService.deleteIndex({ + "index": "customers" +}) + console.log(rsp) + +} + +deleteAnIndex() +``` diff --git a/examples/space/README.md b/examples/space/README.md index 50ec6ce4..4fdbaecb 100755 --- a/examples/space/README.md +++ b/examples/space/README.md @@ -4,52 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Space/api](htt Endpoints: -## Delete - -Delete an object from space - - -[https://m3o.com/space/api#Delete](https://m3o.com/space/api#Delete) - -```js -const { SpaceService } = require('m3o/space'); - -const spaceService = new SpaceService(process.env.M3O_API_TOKEN) - -// Delete an object from space -async function deleteAnObject() { - const rsp = await spaceService.delete({ - "name": "images/file.jpg" -}) - console.log(rsp) - -} - -deleteAnObject() -``` -## List - -List the objects in space - - -[https://m3o.com/space/api#List](https://m3o.com/space/api#List) - -```js -const { SpaceService } = require('m3o/space'); - -const spaceService = new SpaceService(process.env.M3O_API_TOKEN) - -// List the objects in space -async function listObjectsWithPrefix() { - const rsp = await spaceService.list({ - "prefix": "images/" -}) - console.log(rsp) - -} - -listObjectsWithPrefix() -``` ## Head Retrieve meta information about an object @@ -192,3 +146,49 @@ async function updateAnObject() { updateAnObject() ``` +## Delete + +Delete an object from space + + +[https://m3o.com/space/api#Delete](https://m3o.com/space/api#Delete) + +```js +const { SpaceService } = require('m3o/space'); + +const spaceService = new SpaceService(process.env.M3O_API_TOKEN) + +// Delete an object from space +async function deleteAnObject() { + const rsp = await spaceService.delete({ + "name": "images/file.jpg" +}) + console.log(rsp) + +} + +deleteAnObject() +``` +## List + +List the objects in space + + +[https://m3o.com/space/api#List](https://m3o.com/space/api#List) + +```js +const { SpaceService } = require('m3o/space'); + +const spaceService = new SpaceService(process.env.M3O_API_TOKEN) + +// List the objects in space +async function listObjectsWithPrefix() { + const rsp = await spaceService.list({ + "prefix": "images/" +}) + console.log(rsp) + +} + +listObjectsWithPrefix() +``` diff --git a/examples/stock/README.md b/examples/stock/README.md index c2649439..6fadbe06 100755 --- a/examples/stock/README.md +++ b/examples/stock/README.md @@ -4,29 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Stock/api](htt Endpoints: -## Price - -Get the last price for a given stock ticker - - -[https://m3o.com/stock/api#Price](https://m3o.com/stock/api#Price) - -```js -const { StockService } = require('m3o/stock'); - -const stockService = new StockService(process.env.M3O_API_TOKEN) - -// Get the last price for a given stock ticker -async function getAstockPrice() { - const rsp = await stockService.price({ - "symbol": "AAPL" -}) - console.log(rsp) - -} - -getAstockPrice() -``` ## Quote Get the last quote for the stock @@ -74,3 +51,26 @@ async function getHistoricData() { getHistoricData() ``` +## Price + +Get the last price for a given stock ticker + + +[https://m3o.com/stock/api#Price](https://m3o.com/stock/api#Price) + +```js +const { StockService } = require('m3o/stock'); + +const stockService = new StockService(process.env.M3O_API_TOKEN) + +// Get the last price for a given stock ticker +async function getAstockPrice() { + const rsp = await stockService.price({ + "symbol": "AAPL" +}) + console.log(rsp) + +} + +getAstockPrice() +``` diff --git a/examples/stream/README.md b/examples/stream/README.md index 3719f8c2..e57eb59b 100755 --- a/examples/stream/README.md +++ b/examples/stream/README.md @@ -4,95 +4,95 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Stream/api](ht Endpoints: -## ListMessages +## CreateChannel -List messages for a given channel +Create a channel by name -[https://m3o.com/stream/api#ListMessages](https://m3o.com/stream/api#ListMessages) +[https://m3o.com/stream/api#CreateChannel](https://m3o.com/stream/api#CreateChannel) ```js const { StreamService } = require('m3o/stream'); const streamService = new StreamService(process.env.M3O_API_TOKEN) -// List messages for a given channel -async function listMessages() { - const rsp = await streamService.listMessages({ - "channel": "general" +// Create a channel by name +async function createChannel() { + const rsp = await streamService.createChannel({ + "description": "The channel for all things", + "name": "general" }) console.log(rsp) } -listMessages() +createChannel() ``` -## ListChannels +## SendMessage -List all the active channels +Send a message to the stream. -[https://m3o.com/stream/api#ListChannels](https://m3o.com/stream/api#ListChannels) +[https://m3o.com/stream/api#SendMessage](https://m3o.com/stream/api#SendMessage) ```js const { StreamService } = require('m3o/stream'); const streamService = new StreamService(process.env.M3O_API_TOKEN) -// List all the active channels -async function listChannels() { - const rsp = await streamService.listChannels({}) +// Send a message to the stream. +async function sendMessage() { + const rsp = await streamService.sendMessage({ + "channel": "general", + "text": "Hey checkout this tweet https://twitter.com/m3oservices/status/1455291054295498752" +}) console.log(rsp) } -listChannels() +sendMessage() ``` -## CreateChannel +## ListMessages -Create a channel by name +List messages for a given channel -[https://m3o.com/stream/api#CreateChannel](https://m3o.com/stream/api#CreateChannel) +[https://m3o.com/stream/api#ListMessages](https://m3o.com/stream/api#ListMessages) ```js const { StreamService } = require('m3o/stream'); const streamService = new StreamService(process.env.M3O_API_TOKEN) -// Create a channel by name -async function createChannel() { - const rsp = await streamService.createChannel({ - "description": "The channel for all things", - "name": "general" +// List messages for a given channel +async function listMessages() { + const rsp = await streamService.listMessages({ + "channel": "general" }) console.log(rsp) } -createChannel() +listMessages() ``` -## SendMessage +## ListChannels -Send a message to the stream. +List all the active channels -[https://m3o.com/stream/api#SendMessage](https://m3o.com/stream/api#SendMessage) +[https://m3o.com/stream/api#ListChannels](https://m3o.com/stream/api#ListChannels) ```js const { StreamService } = require('m3o/stream'); const streamService = new StreamService(process.env.M3O_API_TOKEN) -// Send a message to the stream. -async function sendMessage() { - const rsp = await streamService.sendMessage({ - "channel": "general", - "text": "Hey checkout this tweet https://twitter.com/m3oservices/status/1455291054295498752" -}) +// List all the active channels +async function listChannels() { + const rsp = await streamService.listChannels({}) console.log(rsp) } -sendMessage() +listChannels() ``` diff --git a/examples/twitter/README.md b/examples/twitter/README.md index 50184cc2..7d6c875d 100755 --- a/examples/twitter/README.md +++ b/examples/twitter/README.md @@ -4,94 +4,94 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Twitter/api](h Endpoints: -## Trends +## Timeline -Get the current global trending topics +Get the timeline for a given user -[https://m3o.com/twitter/api#Trends](https://m3o.com/twitter/api#Trends) +[https://m3o.com/twitter/api#Timeline](https://m3o.com/twitter/api#Timeline) ```js const { TwitterService } = require('m3o/twitter'); const twitterService = new TwitterService(process.env.M3O_API_TOKEN) -// Get the current global trending topics -async function getTheCurrentGlobalTrendingTopics() { - const rsp = await twitterService.trends({}) +// Get the timeline for a given user +async function getAtwitterTimeline() { + const rsp = await twitterService.timeline({ + "limit": 1, + "username": "m3oservices" +}) console.log(rsp) } -getTheCurrentGlobalTrendingTopics() +getAtwitterTimeline() ``` -## User +## Search -Get a user's twitter profile +Search for tweets with a simple query -[https://m3o.com/twitter/api#User](https://m3o.com/twitter/api#User) +[https://m3o.com/twitter/api#Search](https://m3o.com/twitter/api#Search) ```js const { TwitterService } = require('m3o/twitter'); const twitterService = new TwitterService(process.env.M3O_API_TOKEN) -// Get a user's twitter profile -async function getAusersTwitterProfile() { - const rsp = await twitterService.user({ - "username": "crufter" +// Search for tweets with a simple query +async function searchForTweets() { + const rsp = await twitterService.search({ + "query": "cats" }) console.log(rsp) } -getAusersTwitterProfile() +searchForTweets() ``` -## Timeline +## Trends -Get the timeline for a given user +Get the current global trending topics -[https://m3o.com/twitter/api#Timeline](https://m3o.com/twitter/api#Timeline) +[https://m3o.com/twitter/api#Trends](https://m3o.com/twitter/api#Trends) ```js const { TwitterService } = require('m3o/twitter'); const twitterService = new TwitterService(process.env.M3O_API_TOKEN) -// Get the timeline for a given user -async function getAtwitterTimeline() { - const rsp = await twitterService.timeline({ - "limit": 1, - "username": "m3oservices" -}) +// Get the current global trending topics +async function getTheCurrentGlobalTrendingTopics() { + const rsp = await twitterService.trends({}) console.log(rsp) } -getAtwitterTimeline() +getTheCurrentGlobalTrendingTopics() ``` -## Search +## User -Search for tweets with a simple query +Get a user's twitter profile -[https://m3o.com/twitter/api#Search](https://m3o.com/twitter/api#Search) +[https://m3o.com/twitter/api#User](https://m3o.com/twitter/api#User) ```js const { TwitterService } = require('m3o/twitter'); const twitterService = new TwitterService(process.env.M3O_API_TOKEN) -// Search for tweets with a simple query -async function searchForTweets() { - const rsp = await twitterService.search({ - "query": "cats" +// Get a user's twitter profile +async function getAusersTwitterProfile() { + const rsp = await twitterService.user({ + "username": "crufter" }) console.log(rsp) } -searchForTweets() +getAusersTwitterProfile() ``` diff --git a/examples/url/README.md b/examples/url/README.md index 9598cf63..ad218791 100755 --- a/examples/url/README.md +++ b/examples/url/README.md @@ -4,6 +4,51 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Url/api](https Endpoints: +## Create + +Create a URL + + +[https://m3o.com/url/api#Create](https://m3o.com/url/api#Create) + +```js +const { UrlService } = require('m3o/url'); + +const urlService = new UrlService(process.env.M3O_API_TOKEN) + +// Create a URL +async function createAurl() { + const rsp = await urlService.create({ + "destinationURL": "https://mysite.com/this-is-a-rather-long-web-address", + "id": "my-site" +}) + console.log(rsp) + +} + +createAurl() +``` +## List + +List all the shortened URLs + + +[https://m3o.com/url/api#List](https://m3o.com/url/api#List) + +```js +const { UrlService } = require('m3o/url'); + +const urlService = new UrlService(process.env.M3O_API_TOKEN) + +// List all the shortened URLs +async function listYourShortenedUrls() { + const rsp = await urlService.list({}) + console.log(rsp) + +} + +listYourShortenedUrls() +``` ## Update Update the destination for a short URL @@ -97,48 +142,3 @@ async function deleteAshortenedUrl() { deleteAshortenedUrl() ``` -## Create - -Create a URL - - -[https://m3o.com/url/api#Create](https://m3o.com/url/api#Create) - -```js -const { UrlService } = require('m3o/url'); - -const urlService = new UrlService(process.env.M3O_API_TOKEN) - -// Create a URL -async function createAurl() { - const rsp = await urlService.create({ - "destinationURL": "https://mysite.com/this-is-a-rather-long-web-address", - "id": "my-site" -}) - console.log(rsp) - -} - -createAurl() -``` -## List - -List all the shortened URLs - - -[https://m3o.com/url/api#List](https://m3o.com/url/api#List) - -```js -const { UrlService } = require('m3o/url'); - -const urlService = new UrlService(process.env.M3O_API_TOKEN) - -// List all the shortened URLs -async function listYourShortenedUrls() { - const rsp = await urlService.list({}) - console.log(rsp) - -} - -listYourShortenedUrls() -``` diff --git a/examples/user/README.md b/examples/user/README.md index 1cf3b74c..d43fba23 100755 --- a/examples/user/README.md +++ b/examples/user/README.md @@ -4,454 +4,454 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/User/api](http Endpoints: -## Create +## SendMagicLink -Create a new user account. The email address and username for the account must be unique. +Login using email only - Passwordless -[https://m3o.com/user/api#Create](https://m3o.com/user/api#Create) +[https://m3o.com/user/api#SendMagicLink](https://m3o.com/user/api#SendMagicLink) ```js const { UserService } = require('m3o/user'); const userService = new UserService(process.env.M3O_API_TOKEN) -// Create a new user account. The email address and username for the account must be unique. -async function createAnAccount() { - const rsp = await userService.create({ +// Login using email only - Passwordless +async function sendAmagicLink() { + const rsp = await userService.sendMagicLink({ + "address": "www.example.com", "email": "joe@example.com", - "id": "user-1", - "password": "Password1", - "username": "joe" + "endpoint": "verifytoken", + "fromName": "Awesome Dot Com", + "subject": "MagicLink to access your account", + "textContent": "Hi there,\n\nClick here to access your account $micro_verification_link" }) console.log(rsp) } -createAnAccount() +sendAmagicLink() ``` -## Read +## UpdatePassword -Read an account by id, username or email. Only one need to be specified. +Update the account password -[https://m3o.com/user/api#Read](https://m3o.com/user/api#Read) +[https://m3o.com/user/api#UpdatePassword](https://m3o.com/user/api#UpdatePassword) ```js const { UserService } = require('m3o/user'); const userService = new UserService(process.env.M3O_API_TOKEN) -// Read an account by id, username or email. Only one need to be specified. -async function readAnAccountById() { - const rsp = await userService.read({ - "id": "user-1" +// Update the account password +async function updateTheAccountPassword() { + const rsp = await userService.updatePassword({ + "confirmPassword": "Password2", + "newPassword": "Password2", + "oldPassword": "Password1", + "userId": "user-1" }) console.log(rsp) } -readAnAccountById() +updateTheAccountPassword() ``` -## Read +## ResetPassword -Read an account by id, username or email. Only one need to be specified. +Reset password with the code sent by the "SendPasswordResetEmail" endpoint. -[https://m3o.com/user/api#Read](https://m3o.com/user/api#Read) +[https://m3o.com/user/api#ResetPassword](https://m3o.com/user/api#ResetPassword) ```js const { UserService } = require('m3o/user'); const userService = new UserService(process.env.M3O_API_TOKEN) -// Read an account by id, username or email. Only one need to be specified. -async function readAccountByUsernameOrEmail() { - const rsp = await userService.read({ - "username": "joe" +// Reset password with the code sent by the "SendPasswordResetEmail" endpoint. +async function resetPassword() { + const rsp = await userService.resetPassword({ + "code": "012345", + "confirmPassword": "NewPassword1", + "email": "joe@example.com", + "newPassword": "NewPassword1" }) console.log(rsp) } -readAccountByUsernameOrEmail() +resetPassword() ``` -## Read +## Delete -Read an account by id, username or email. Only one need to be specified. +Delete an account by id -[https://m3o.com/user/api#Read](https://m3o.com/user/api#Read) +[https://m3o.com/user/api#Delete](https://m3o.com/user/api#Delete) ```js const { UserService } = require('m3o/user'); const userService = new UserService(process.env.M3O_API_TOKEN) -// Read an account by id, username or email. Only one need to be specified. -async function readAccountByEmail() { - const rsp = await userService.read({ - "email": "joe@example.com" +// Delete an account by id +async function deleteUserAccount() { + const rsp = await userService.delete({ + "id": "8b98acbe-0b6a-4d66-a414-5ffbf666786f" }) console.log(rsp) } -readAccountByEmail() +deleteUserAccount() ``` -## SendPasswordResetEmail +## Login -Send an email with a verification code to reset password. -Call "ResetPassword" endpoint once user provides the code. +Login using username or email. The response will return a new session for successful login, +401 in the case of login failure and 500 for any other error -[https://m3o.com/user/api#SendPasswordResetEmail](https://m3o.com/user/api#SendPasswordResetEmail) +[https://m3o.com/user/api#Login](https://m3o.com/user/api#Login) ```js const { UserService } = require('m3o/user'); const userService = new UserService(process.env.M3O_API_TOKEN) -// Send an email with a verification code to reset password. -// Call "ResetPassword" endpoint once user provides the code. -async function sendPasswordResetEmail() { - const rsp = await userService.sendPasswordResetEmail({ +// Login using username or email. The response will return a new session for successful login, +// 401 in the case of login failure and 500 for any other error +async function logAuserIn() { + const rsp = await userService.login({ "email": "joe@example.com", - "fromName": "Awesome Dot Com", - "subject": "Password reset", - "textContent": "Hi there,\n click here to reset your password: myapp.com/reset/code?=$code" + "password": "Password1" }) console.log(rsp) } -sendPasswordResetEmail() +logAuserIn() ``` -## VerifyToken +## Logout -Check whether the token attached to MagicLink is valid or not. -Ideally, you need to call this endpoint from your http request -handler that handles the endpoint which is specified in the -SendMagicLink request. +Logout a user account -[https://m3o.com/user/api#VerifyToken](https://m3o.com/user/api#VerifyToken) +[https://m3o.com/user/api#Logout](https://m3o.com/user/api#Logout) ```js const { UserService } = require('m3o/user'); const userService = new UserService(process.env.M3O_API_TOKEN) -// Check whether the token attached to MagicLink is valid or not. -// Ideally, you need to call this endpoint from your http request -// handler that handles the endpoint which is specified in the -// SendMagicLink request. -async function verifyAtoken() { - const rsp = await userService.verifyToken({ - "token": "EdsUiidouJJJLldjlloofUiorkojflsWWdld" +// Logout a user account +async function logAuserOut() { + const rsp = await userService.logout({ + "sessionId": "df91a612-5b24-4634-99ff-240220ab8f55" }) console.log(rsp) } -verifyAtoken() +logAuserOut() ``` -## VerifyEmail +## Create -Verify the email address of an account from a token sent in an email to the user. +Create a new user account. The email address and username for the account must be unique. -[https://m3o.com/user/api#VerifyEmail](https://m3o.com/user/api#VerifyEmail) +[https://m3o.com/user/api#Create](https://m3o.com/user/api#Create) ```js const { UserService } = require('m3o/user'); const userService = new UserService(process.env.M3O_API_TOKEN) -// Verify the email address of an account from a token sent in an email to the user. -async function verifyEmail() { - const rsp = await userService.verifyEmail({ +// Create a new user account. The email address and username for the account must be unique. +async function createAnAccount() { + const rsp = await userService.create({ "email": "joe@example.com", - "token": "012345" + "id": "user-1", + "password": "Password1", + "username": "joe" }) console.log(rsp) } -verifyEmail() +createAnAccount() ``` -## Login +## Update -Login using username or email. The response will return a new session for successful login, -401 in the case of login failure and 500 for any other error +Update the account username or email -[https://m3o.com/user/api#Login](https://m3o.com/user/api#Login) +[https://m3o.com/user/api#Update](https://m3o.com/user/api#Update) ```js const { UserService } = require('m3o/user'); const userService = new UserService(process.env.M3O_API_TOKEN) -// Login using username or email. The response will return a new session for successful login, -// 401 in the case of login failure and 500 for any other error -async function logAuserIn() { - const rsp = await userService.login({ - "email": "joe@example.com", - "password": "Password1" +// Update the account username or email +async function updateAnAccount() { + const rsp = await userService.update({ + "email": "joe+2@example.com", + "id": "user-1", + "username": "joe" }) console.log(rsp) } -logAuserIn() +updateAnAccount() ``` -## ReadSession +## Read -Read a session by the session id. In the event it has expired or is not found and error is returned. +Read an account by id, username or email. Only one need to be specified. -[https://m3o.com/user/api#ReadSession](https://m3o.com/user/api#ReadSession) +[https://m3o.com/user/api#Read](https://m3o.com/user/api#Read) ```js const { UserService } = require('m3o/user'); const userService = new UserService(process.env.M3O_API_TOKEN) -// Read a session by the session id. In the event it has expired or is not found and error is returned. -async function readAsessionByTheSessionId() { - const rsp = await userService.readSession({ - "sessionId": "df91a612-5b24-4634-99ff-240220ab8f55" +// Read an account by id, username or email. Only one need to be specified. +async function readAnAccountById() { + const rsp = await userService.read({ + "id": "user-1" }) console.log(rsp) } -readAsessionByTheSessionId() +readAnAccountById() ``` -## List +## Read -List all users. Returns a paged list of results +Read an account by id, username or email. Only one need to be specified. -[https://m3o.com/user/api#List](https://m3o.com/user/api#List) +[https://m3o.com/user/api#Read](https://m3o.com/user/api#Read) ```js const { UserService } = require('m3o/user'); const userService = new UserService(process.env.M3O_API_TOKEN) -// List all users. Returns a paged list of results -async function listAllUsers() { - const rsp = await userService.list({ - "limit": 100, - "offset": 0 +// Read an account by id, username or email. Only one need to be specified. +async function readAccountByUsernameOrEmail() { + const rsp = await userService.read({ + "username": "joe" }) console.log(rsp) } -listAllUsers() +readAccountByUsernameOrEmail() ``` -## Update +## Read -Update the account username or email +Read an account by id, username or email. Only one need to be specified. -[https://m3o.com/user/api#Update](https://m3o.com/user/api#Update) +[https://m3o.com/user/api#Read](https://m3o.com/user/api#Read) ```js const { UserService } = require('m3o/user'); const userService = new UserService(process.env.M3O_API_TOKEN) -// Update the account username or email -async function updateAnAccount() { - const rsp = await userService.update({ - "email": "joe+2@example.com", - "id": "user-1", - "username": "joe" +// Read an account by id, username or email. Only one need to be specified. +async function readAccountByEmail() { + const rsp = await userService.read({ + "email": "joe@example.com" }) console.log(rsp) } -updateAnAccount() +readAccountByEmail() ``` -## UpdatePassword +## ReadSession -Update the account password +Read a session by the session id. In the event it has expired or is not found and error is returned. -[https://m3o.com/user/api#UpdatePassword](https://m3o.com/user/api#UpdatePassword) +[https://m3o.com/user/api#ReadSession](https://m3o.com/user/api#ReadSession) ```js const { UserService } = require('m3o/user'); const userService = new UserService(process.env.M3O_API_TOKEN) -// Update the account password -async function updateTheAccountPassword() { - const rsp = await userService.updatePassword({ - "confirmPassword": "Password2", - "newPassword": "Password2", - "oldPassword": "Password1", - "userId": "user-1" +// Read a session by the session id. In the event it has expired or is not found and error is returned. +async function readAsessionByTheSessionId() { + const rsp = await userService.readSession({ + "sessionId": "df91a612-5b24-4634-99ff-240220ab8f55" }) console.log(rsp) } -updateTheAccountPassword() +readAsessionByTheSessionId() ``` -## SendVerificationEmail +## LogoutAll -Send a verification email to a user. +Logout of all user's sessions -[https://m3o.com/user/api#SendVerificationEmail](https://m3o.com/user/api#SendVerificationEmail) +[https://m3o.com/user/api#LogoutAll](https://m3o.com/user/api#LogoutAll) ```js const { UserService } = require('m3o/user'); const userService = new UserService(process.env.M3O_API_TOKEN) -// Send a verification email to a user. -async function sendVerificationEmail() { - const rsp = await userService.sendVerificationEmail({ - "email": "joe@example.com", - "failureRedirectUrl": "https://m3o.com/verification-failed", - "fromName": "Awesome Dot Com", - "redirectUrl": "https://m3o.com", - "subject": "Email verification", - "textContent": "Hi there,\n\nPlease verify your email by clicking this link: $micro_verification_link" +// Logout of all user's sessions +async function logoutAllSessionsForAuser() { + const rsp = await userService.logoutAll({ + "user_id": "user-1" }) console.log(rsp) } -sendVerificationEmail() +logoutAllSessionsForAuser() ``` -## ResetPassword +## SendVerificationEmail -Reset password with the code sent by the "SendPasswordResetEmail" endpoint. +Send a verification email to a user. -[https://m3o.com/user/api#ResetPassword](https://m3o.com/user/api#ResetPassword) +[https://m3o.com/user/api#SendVerificationEmail](https://m3o.com/user/api#SendVerificationEmail) ```js const { UserService } = require('m3o/user'); const userService = new UserService(process.env.M3O_API_TOKEN) -// Reset password with the code sent by the "SendPasswordResetEmail" endpoint. -async function resetPassword() { - const rsp = await userService.resetPassword({ - "code": "012345", - "confirmPassword": "NewPassword1", +// Send a verification email to a user. +async function sendVerificationEmail() { + const rsp = await userService.sendVerificationEmail({ "email": "joe@example.com", - "newPassword": "NewPassword1" + "failureRedirectUrl": "https://m3o.com/verification-failed", + "fromName": "Awesome Dot Com", + "redirectUrl": "https://m3o.com", + "subject": "Email verification", + "textContent": "Hi there,\n\nPlease verify your email by clicking this link: $micro_verification_link" }) console.log(rsp) } -resetPassword() +sendVerificationEmail() ``` -## Delete +## SendPasswordResetEmail -Delete an account by id +Send an email with a verification code to reset password. +Call "ResetPassword" endpoint once user provides the code. -[https://m3o.com/user/api#Delete](https://m3o.com/user/api#Delete) +[https://m3o.com/user/api#SendPasswordResetEmail](https://m3o.com/user/api#SendPasswordResetEmail) ```js const { UserService } = require('m3o/user'); const userService = new UserService(process.env.M3O_API_TOKEN) -// Delete an account by id -async function deleteUserAccount() { - const rsp = await userService.delete({ - "id": "8b98acbe-0b6a-4d66-a414-5ffbf666786f" +// Send an email with a verification code to reset password. +// Call "ResetPassword" endpoint once user provides the code. +async function sendPasswordResetEmail() { + const rsp = await userService.sendPasswordResetEmail({ + "email": "joe@example.com", + "fromName": "Awesome Dot Com", + "subject": "Password reset", + "textContent": "Hi there,\n click here to reset your password: myapp.com/reset/code?=$code" }) console.log(rsp) } -deleteUserAccount() +sendPasswordResetEmail() ``` -## Logout +## VerifyEmail -Logout a user account +Verify the email address of an account from a token sent in an email to the user. -[https://m3o.com/user/api#Logout](https://m3o.com/user/api#Logout) +[https://m3o.com/user/api#VerifyEmail](https://m3o.com/user/api#VerifyEmail) ```js const { UserService } = require('m3o/user'); const userService = new UserService(process.env.M3O_API_TOKEN) -// Logout a user account -async function logAuserOut() { - const rsp = await userService.logout({ - "sessionId": "df91a612-5b24-4634-99ff-240220ab8f55" +// Verify the email address of an account from a token sent in an email to the user. +async function verifyEmail() { + const rsp = await userService.verifyEmail({ + "email": "joe@example.com", + "token": "012345" }) console.log(rsp) } -logAuserOut() +verifyEmail() ``` -## SendMagicLink +## VerifyToken -Login using email only - Passwordless +Check whether the token attached to MagicLink is valid or not. +Ideally, you need to call this endpoint from your http request +handler that handles the endpoint which is specified in the +SendMagicLink request. -[https://m3o.com/user/api#SendMagicLink](https://m3o.com/user/api#SendMagicLink) +[https://m3o.com/user/api#VerifyToken](https://m3o.com/user/api#VerifyToken) ```js const { UserService } = require('m3o/user'); const userService = new UserService(process.env.M3O_API_TOKEN) -// Login using email only - Passwordless -async function sendAmagicLink() { - const rsp = await userService.sendMagicLink({ - "address": "www.example.com", - "email": "joe@example.com", - "endpoint": "verifytoken", - "fromName": "Awesome Dot Com", - "subject": "MagicLink to access your account", - "textContent": "Hi there,\n\nClick here to access your account $micro_verification_link" +// Check whether the token attached to MagicLink is valid or not. +// Ideally, you need to call this endpoint from your http request +// handler that handles the endpoint which is specified in the +// SendMagicLink request. +async function verifyAtoken() { + const rsp = await userService.verifyToken({ + "token": "EdsUiidouJJJLldjlloofUiorkojflsWWdld" }) console.log(rsp) } -sendAmagicLink() +verifyAtoken() ``` -## LogoutAll +## List -Logout of all user's sessions +List all users. Returns a paged list of results -[https://m3o.com/user/api#LogoutAll](https://m3o.com/user/api#LogoutAll) +[https://m3o.com/user/api#List](https://m3o.com/user/api#List) ```js const { UserService } = require('m3o/user'); const userService = new UserService(process.env.M3O_API_TOKEN) -// Logout of all user's sessions -async function logoutAllSessionsForAuser() { - const rsp = await userService.logoutAll({ - "user_id": "user-1" +// List all users. Returns a paged list of results +async function listAllUsers() { + const rsp = await userService.list({ + "limit": 100, + "offset": 0 }) console.log(rsp) } -logoutAllSessionsForAuser() +listAllUsers() ``` diff --git a/examples/wallet/README.md b/examples/wallet/README.md index 153ebdea..1991bea2 100755 --- a/examples/wallet/README.md +++ b/examples/wallet/README.md @@ -54,169 +54,169 @@ async function debitWallet() { debitWallet() ``` -## Transactions +## Transfer -List the transactions for a wallet +Make a transfer from one wallet to another -[https://m3o.com/wallet/api#Transactions](https://m3o.com/wallet/api#Transactions) +[https://m3o.com/wallet/api#Transfer](https://m3o.com/wallet/api#Transfer) ```js const { WalletService } = require('m3o/wallet'); const walletService = new WalletService(process.env.M3O_API_TOKEN) -// List the transactions for a wallet -async function listTransactions() { - const rsp = await walletService.transactions({ - "id": "b6407edd-2e26-45c0-9e2c-343689bbe5f6" +// Make a transfer from one wallet to another +async function transferMoney() { + const rsp = await walletService.transfer({ + "amount": "5", + "from_id": "b6407edd-2e26-45c0-9e2c-343689bbe5f6", + "reference": "transfer money", + "to_id": "default", + "visible": true }) console.log(rsp) } -listTransactions() +transferMoney() ``` -## Read +## Balance -Get wallet by id +Get the balance of a wallet -[https://m3o.com/wallet/api#Read](https://m3o.com/wallet/api#Read) +[https://m3o.com/wallet/api#Balance](https://m3o.com/wallet/api#Balance) ```js const { WalletService } = require('m3o/wallet'); const walletService = new WalletService(process.env.M3O_API_TOKEN) -// Get wallet by id -async function readAwallet() { - const rsp = await walletService.read({ +// Get the balance of a wallet +async function getBalance() { + const rsp = await walletService.balance({ "id": "b6407edd-2e26-45c0-9e2c-343689bbe5f6" }) console.log(rsp) } -readAwallet() +getBalance() ``` -## Credit +## Delete -Add credit to a wallet +Delete a wallet -[https://m3o.com/wallet/api#Credit](https://m3o.com/wallet/api#Credit) +[https://m3o.com/wallet/api#Delete](https://m3o.com/wallet/api#Delete) ```js const { WalletService } = require('m3o/wallet'); const walletService = new WalletService(process.env.M3O_API_TOKEN) -// Add credit to a wallet -async function creditWallet() { - const rsp = await walletService.credit({ - "amount": "10", - "id": "b6407edd-2e26-45c0-9e2c-343689bbe5f6", - "reference": "test credit", - "visible": true +// Delete a wallet +async function deleteAwallet() { + const rsp = await walletService.delete({ + "id": "b6407edd-2e26-45c0-9e2c-343689bbe5f6" }) console.log(rsp) } -creditWallet() +deleteAwallet() ``` -## List +## Read -List your wallets +Get wallet by id -[https://m3o.com/wallet/api#List](https://m3o.com/wallet/api#List) +[https://m3o.com/wallet/api#Read](https://m3o.com/wallet/api#Read) ```js const { WalletService } = require('m3o/wallet'); const walletService = new WalletService(process.env.M3O_API_TOKEN) -// List your wallets -async function listWallets() { - const rsp = await walletService.list({}) +// Get wallet by id +async function readAwallet() { + const rsp = await walletService.read({ + "id": "b6407edd-2e26-45c0-9e2c-343689bbe5f6" +}) console.log(rsp) } -listWallets() +readAwallet() ``` -## Transfer +## Credit -Make a transfer from one wallet to another +Add credit to a wallet -[https://m3o.com/wallet/api#Transfer](https://m3o.com/wallet/api#Transfer) +[https://m3o.com/wallet/api#Credit](https://m3o.com/wallet/api#Credit) ```js const { WalletService } = require('m3o/wallet'); const walletService = new WalletService(process.env.M3O_API_TOKEN) -// Make a transfer from one wallet to another -async function transferMoney() { - const rsp = await walletService.transfer({ - "amount": "5", - "from_id": "b6407edd-2e26-45c0-9e2c-343689bbe5f6", - "reference": "transfer money", - "to_id": "default", +// Add credit to a wallet +async function creditWallet() { + const rsp = await walletService.credit({ + "amount": "10", + "id": "b6407edd-2e26-45c0-9e2c-343689bbe5f6", + "reference": "test credit", "visible": true }) console.log(rsp) } -transferMoney() +creditWallet() ``` -## Balance +## List -Get the balance of a wallet +List your wallets -[https://m3o.com/wallet/api#Balance](https://m3o.com/wallet/api#Balance) +[https://m3o.com/wallet/api#List](https://m3o.com/wallet/api#List) ```js const { WalletService } = require('m3o/wallet'); const walletService = new WalletService(process.env.M3O_API_TOKEN) -// Get the balance of a wallet -async function getBalance() { - const rsp = await walletService.balance({ - "id": "b6407edd-2e26-45c0-9e2c-343689bbe5f6" -}) +// List your wallets +async function listWallets() { + const rsp = await walletService.list({}) console.log(rsp) } -getBalance() +listWallets() ``` -## Delete +## Transactions -Delete a wallet +List the transactions for a wallet -[https://m3o.com/wallet/api#Delete](https://m3o.com/wallet/api#Delete) +[https://m3o.com/wallet/api#Transactions](https://m3o.com/wallet/api#Transactions) ```js const { WalletService } = require('m3o/wallet'); const walletService = new WalletService(process.env.M3O_API_TOKEN) -// Delete a wallet -async function deleteAwallet() { - const rsp = await walletService.delete({ +// List the transactions for a wallet +async function listTransactions() { + const rsp = await walletService.transactions({ "id": "b6407edd-2e26-45c0-9e2c-343689bbe5f6" }) console.log(rsp) } -deleteAwallet() +listTransactions() ``` diff --git a/package.json b/package.json index 83c6c911..51968e68 100644 --- a/package.json +++ b/package.json @@ -101,5 +101,5 @@ "prepare": "npm run build" }, "typings": "index.d.ts", - "version": "1.0.1767" + "version": "1.0.1768" } \ No newline at end of file