From 8c5ea72913822cefe471f2f52d1ab9ed2f072406 Mon Sep 17 00:00:00 2001 From: m3o-actions <> Date: Thu, 6 Jul 2023 14:49:48 +0000 Subject: [PATCH] Commit from m3o/m3o action --- examples/ai/README.md | 12 +- examples/ai/chat/chatWithChatGpt.js | 13 +- examples/app/README.md | 94 ++++----- examples/bitcoin/README.md | 46 ++--- examples/cache/README.md | 94 ++++----- examples/chat/README.md | 104 +++++----- examples/comments/README.md | 112 +++++------ examples/contact/README.md | 136 ++++++------- examples/cron/README.md | 42 ++-- examples/crypto/README.md | 42 ++-- examples/db/README.md | 160 +++++++-------- examples/file/README.md | 48 ++--- examples/function/README.md | 162 +++++++-------- examples/geocoding/README.md | 40 ++-- examples/holidays/README.md | 34 ++-- examples/image/README.md | 46 ++--- examples/lists/README.md | 120 ++++++------ examples/location/README.md | 62 +++--- examples/nft/README.md | 48 ++--- examples/notes/README.md | 112 +++++------ examples/routing/README.md | 42 ++-- examples/space/README.md | 92 ++++----- examples/twitter/README.md | 48 ++--- examples/url/README.md | 90 ++++----- examples/user/README.md | 294 ++++++++++++++-------------- examples/wallet/README.md | 126 ++++++------ package.json | 2 +- 27 files changed, 1121 insertions(+), 1100 deletions(-) diff --git a/examples/ai/README.md b/examples/ai/README.md index 8ed5ee7b..ea2aed8c 100755 --- a/examples/ai/README.md +++ b/examples/ai/README.md @@ -19,8 +19,18 @@ const aiService = new AiService(process.env.M3O_API_TOKEN) // Make a request to ChatGPT async function chatWithChatGpt() { const rsp = await aiService.chat({ + "context": [ + { + "prompt": "who is leonardo davinci", + "reply": "Leonardo da Vinci was an Italian polymath during the Renaissance period. He was born in 1452 in Vinci, Italy, and is renowned for his contributions to various fields such as science, engineering, art, and anatomy. Da Vinci's most famous works include the Mona Lisa and The Last Supper. He is often considered one of the greatest artists and thinkers of all time." + }, + { + "prompt": "where is he from?", + "reply": "Leonardo da Vinci was from Vinci, a town in Tuscany, Italy." + } + ], "model": "gpt-3.5-turbo", - "prompt": "who is leonardo davinci" + "prompt": "when did he die?" }) console.log(rsp) diff --git a/examples/ai/chat/chatWithChatGpt.js b/examples/ai/chat/chatWithChatGpt.js index c5da18b5..c7c9e610 100755 --- a/examples/ai/chat/chatWithChatGpt.js +++ b/examples/ai/chat/chatWithChatGpt.js @@ -2,8 +2,19 @@ const m3o = require('m3o').default(process.env.M3O_API_TOKEN) async function main() { let rsp = await m3o.ai.chat({ + context: [ + { + prompt: 'who is leonardo davinci', + reply: + "Leonardo da Vinci was an Italian polymath during the Renaissance period. He was born in 1452 in Vinci, Italy, and is renowned for his contributions to various fields such as science, engineering, art, and anatomy. Da Vinci's most famous works include the Mona Lisa and The Last Supper. He is often considered one of the greatest artists and thinkers of all time." + }, + { + prompt: 'where is he from?', + reply: 'Leonardo da Vinci was from Vinci, a town in Tuscany, Italy.' + } + ], model: 'gpt-3.5-turbo', - prompt: 'who is leonardo davinci' + prompt: 'when did he die?' }) console.log(rsp) } diff --git a/examples/app/README.md b/examples/app/README.md index d75f6c9e..499b45b7 100755 --- a/examples/app/README.md +++ b/examples/app/README.md @@ -4,95 +4,98 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/App/api](https Endpoints: -## Reserve +## Logs -Reserve app names +Get the logs for an app -[https://m3o.com/app/api#Reserve](https://m3o.com/app/api#Reserve) +[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) -// Reserve app names -async function reserveAppName() { - const rsp = await appService.reserve({ +// Get the logs for an app +async function retrieveBuildLogsForAnApp() { + const rsp = await appService.logs({ + "logs_type": "build", "name": "helloworld" }) console.log(rsp) } -reserveAppName() +retrieveBuildLogsForAnApp() ``` -## List +## Reserve -List all the apps +Reserve app names -[https://m3o.com/app/api#List](https://m3o.com/app/api#List) +[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) -// List all the apps -async function listTheApps() { - const rsp = await appService.list({}) +// Reserve app names +async function reserveAppName() { + const rsp = await appService.reserve({ + "name": "helloworld" +}) console.log(rsp) } -listTheApps() +reserveAppName() ``` -## 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() ``` -## Resolve +## Status -Resolve an app by id to its raw backend endpoint +Get the status of an app -[https://m3o.com/app/api#Resolve](https://m3o.com/app/api#Resolve) +[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) -// Resolve an app by id to its raw backend endpoint -async function resolveAppById() { - const rsp = await appService.resolve({ - "id": "helloworld" +// Get the status of an app +async function getTheStatusOfAnApp() { + const rsp = await appService.status({ + "name": "helloworld" }) console.log(rsp) } -resolveAppById() +getTheStatusOfAnApp() ``` ## Update @@ -140,28 +143,26 @@ async function deleteAnApp() { deleteAnApp() ``` -## Get +## List -Get an app by name +List all the apps -[https://m3o.com/app/api#Get](https://m3o.com/app/api#Get) +[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 an app by name -async function getAnApp() { - const rsp = await appService.get({ - "name": "helloworld" -}) +// List all the apps +async function listTheApps() { + const rsp = await appService.list({}) console.log(rsp) } -getAnApp() +listTheApps() ``` ## Run @@ -211,27 +212,26 @@ async function listRegions() { listRegions() ``` -## Logs +## Resolve -Get the logs for an app +Resolve an app by id to its raw backend endpoint -[https://m3o.com/app/api#Logs](https://m3o.com/app/api#Logs) +[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) -// Get the logs for an app -async function retrieveBuildLogsForAnApp() { - const rsp = await appService.logs({ - "logs_type": "build", - "name": "helloworld" +// Resolve an app by id to its raw backend endpoint +async function resolveAppById() { + const rsp = await appService.resolve({ + "id": "helloworld" }) console.log(rsp) } -retrieveBuildLogsForAnApp() +resolveAppById() ``` diff --git a/examples/bitcoin/README.md b/examples/bitcoin/README.md index fd98d2a9..827c3ba6 100755 --- a/examples/bitcoin/README.md +++ b/examples/bitcoin/README.md @@ -4,6 +4,29 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Bitcoin/api](h Endpoints: +## Price + +Get the price of bitcoin + + +[https://m3o.com/bitcoin/api#Price](https://m3o.com/bitcoin/api#Price) + +```js +const { BitcoinService } = require('m3o/bitcoin'); + +const bitcoinService = new BitcoinService(process.env.M3O_API_TOKEN) + +// Get the price of bitcoin +async function getBitcoinPrice() { + const rsp = await bitcoinService.price({ + "symbol": "USD" +}) + console.log(rsp) + +} + +getBitcoinPrice() +``` ## Balance Get the BTC balance of an address @@ -73,26 +96,3 @@ async function getAbitcoinTransaction() { getAbitcoinTransaction() ``` -## Price - -Get the price of bitcoin - - -[https://m3o.com/bitcoin/api#Price](https://m3o.com/bitcoin/api#Price) - -```js -const { BitcoinService } = require('m3o/bitcoin'); - -const bitcoinService = new BitcoinService(process.env.M3O_API_TOKEN) - -// Get the price of bitcoin -async function getBitcoinPrice() { - const rsp = await bitcoinService.price({ - "symbol": "USD" -}) - console.log(rsp) - -} - -getBitcoinPrice() -``` diff --git a/examples/cache/README.md b/examples/cache/README.md index 6cafabec..1353ebff 100755 --- a/examples/cache/README.md +++ b/examples/cache/README.md @@ -4,53 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Cache/api](htt Endpoints: -## Set - -Set an item in the cache. Overwrites any existing value already set. - - -[https://m3o.com/cache/api#Set](https://m3o.com/cache/api#Set) - -```js -const { CacheService } = require('m3o/cache'); - -const cacheService = new CacheService(process.env.M3O_API_TOKEN) - -// Set an item in the cache. Overwrites any existing value already set. -async function setAvalue() { - const rsp = await cacheService.set({ - "key": "foo", - "value": "bar" -}) - console.log(rsp) - -} - -setAvalue() -``` -## Get - -Get an item from the cache by key. If key is not found, an empty response is returned. - - -[https://m3o.com/cache/api#Get](https://m3o.com/cache/api#Get) - -```js -const { CacheService } = require('m3o/cache'); - -const cacheService = new CacheService(process.env.M3O_API_TOKEN) - -// Get an item from the cache by key. If key is not found, an empty response is returned. -async function getAvalue() { - const rsp = await cacheService.get({ - "key": "foo" -}) - console.log(rsp) - -} - -getAvalue() -``` ## Delete Delete a value from the cache. If key not found a success response is returned. @@ -143,3 +96,50 @@ async function listTheKeys() { listTheKeys() ``` +## Set + +Set an item in the cache. Overwrites any existing value already set. + + +[https://m3o.com/cache/api#Set](https://m3o.com/cache/api#Set) + +```js +const { CacheService } = require('m3o/cache'); + +const cacheService = new CacheService(process.env.M3O_API_TOKEN) + +// Set an item in the cache. Overwrites any existing value already set. +async function setAvalue() { + const rsp = await cacheService.set({ + "key": "foo", + "value": "bar" +}) + console.log(rsp) + +} + +setAvalue() +``` +## Get + +Get an item from the cache by key. If key is not found, an empty response is returned. + + +[https://m3o.com/cache/api#Get](https://m3o.com/cache/api#Get) + +```js +const { CacheService } = require('m3o/cache'); + +const cacheService = new CacheService(process.env.M3O_API_TOKEN) + +// Get an item from the cache by key. If key is not found, an empty response is returned. +async function getAvalue() { + const rsp = await cacheService.get({ + "key": "foo" +}) + console.log(rsp) + +} + +getAvalue() +``` diff --git a/examples/chat/README.md b/examples/chat/README.md index 88272d7b..22f52fdf 100755 --- a/examples/chat/README.md +++ b/examples/chat/README.md @@ -4,27 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Chat/api](http Endpoints: -## List - -List available chats - - -[https://m3o.com/chat/api#List](https://m3o.com/chat/api#List) - -```js -const { ChatService } = require('m3o/chat'); - -const chatService = new ChatService(process.env.M3O_API_TOKEN) - -// List available chats -async function listGroups() { - const rsp = await chatService.list({}) - console.log(rsp) - -} - -listGroups() -``` ## Send Connect to a chat to receive a stream of messages @@ -54,28 +33,30 @@ 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() ``` ## Kick @@ -149,28 +130,26 @@ async function createAnewChat() { createAnewChat() ``` -## Delete +## List -Delete a group +List available chats -[https://m3o.com/chat/api#Delete](https://m3o.com/chat/api#Delete) +[https://m3o.com/chat/api#List](https://m3o.com/chat/api#List) ```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" -}) +// List available chats +async function listGroups() { + const rsp = await chatService.list({}) console.log(rsp) } -deleteAchat() +listGroups() ``` ## Invite @@ -196,28 +175,49 @@ async function inviteAuser() { inviteAuser() ``` -## Join +## Delete -Join a group +Delete a group -[https://m3o.com/chat/api#Join](https://m3o.com/chat/api#Join) +[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) -// Join a group -async function joinAgroup() { - const rsp = await chatService.join({ - "group_id": "d8057208-f81a-4e14-ad7f-c29daa2bb910", - "user_id": "user-2" +// Delete a group +async function deleteAchat() { + const rsp = await chatService.delete({ + "group_id": "d8057208-f81a-4e14-ad7f-c29daa2bb910" }) - rsp.onMessage(msg => { - console.log(msg) - }) + console.log(rsp) + } -joinAgroup() +deleteAchat() +``` +## History + +List the messages in a chat + + +[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) + +// List the messages in a chat +async function getChatHistory() { + const rsp = await chatService.history({ + "group_id": "d8057208-f81a-4e14-ad7f-c29daa2bb910" +}) + console.log(rsp) + +} + +getChatHistory() ``` diff --git a/examples/comments/README.md b/examples/comments/README.md index ad68812a..7d36e439 100755 --- a/examples/comments/README.md +++ b/examples/comments/README.md @@ -4,145 +4,145 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Comments/api]( Endpoints: -## Events +## List -Subscribe to comments events +List all the comments -[https://m3o.com/comments/api#Events](https://m3o.com/comments/api#Events) +[https://m3o.com/comments/api#List](https://m3o.com/comments/api#List) ```js const { CommentsService } = require('m3o/comments'); const commentsService = new CommentsService(process.env.M3O_API_TOKEN) -// Subscribe to comments events -async function subscribeToEvents() { - const rsp = await commentsService.events({ - "id": "63c0cdf8-2121-11ec-a881-0242e36f037a" -}) - rsp.onMessage(msg => { - console.log(msg) - }) +// List all the comments +async function listAllComments() { + const rsp = await commentsService.list({}) + console.log(rsp) + } -subscribeToEvents() +listAllComments() ``` -## Create +## Update -Create a new comment +Update a comment -[https://m3o.com/comments/api#Create](https://m3o.com/comments/api#Create) +[https://m3o.com/comments/api#Update](https://m3o.com/comments/api#Update) ```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" +// Update a comment +async function updateAcomment() { + const rsp = await commentsService.update({ + "comment": { + "id": "63c0cdf8-2121-11ec-a881-0242e36f037a", + "subject": "Update Comment", + "text": "Updated comment text" + } }) console.log(rsp) } -createAcomment() +updateAcomment() ``` -## Read +## Delete -Read a comment +Delete a comment -[https://m3o.com/comments/api#Read](https://m3o.com/comments/api#Read) +[https://m3o.com/comments/api#Delete](https://m3o.com/comments/api#Delete) ```js const { CommentsService } = require('m3o/comments'); const commentsService = new CommentsService(process.env.M3O_API_TOKEN) -// Read a comment -async function readAcomment() { - const rsp = await commentsService.read({ +// Delete a comment +async function deleteAcomment() { + const rsp = await commentsService.delete({ "id": "63c0cdf8-2121-11ec-a881-0242e36f037a" }) console.log(rsp) } -readAcomment() +deleteAcomment() ``` -## List +## Events -List all the comments +Subscribe to comments events -[https://m3o.com/comments/api#List](https://m3o.com/comments/api#List) +[https://m3o.com/comments/api#Events](https://m3o.com/comments/api#Events) ```js const { CommentsService } = require('m3o/comments'); const commentsService = new CommentsService(process.env.M3O_API_TOKEN) -// List all the comments -async function listAllComments() { - const rsp = await commentsService.list({}) - console.log(rsp) - +// Subscribe to comments events +async function subscribeToEvents() { + const rsp = await commentsService.events({ + "id": "63c0cdf8-2121-11ec-a881-0242e36f037a" +}) + rsp.onMessage(msg => { + console.log(msg) + }) } -listAllComments() +subscribeToEvents() ``` -## Update +## Create -Update a comment +Create a new comment -[https://m3o.com/comments/api#Update](https://m3o.com/comments/api#Update) +[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) -// Update a comment -async function updateAcomment() { - const rsp = await commentsService.update({ - "comment": { - "id": "63c0cdf8-2121-11ec-a881-0242e36f037a", - "subject": "Update Comment", - "text": "Updated comment text" - } +// Create a new comment +async function createAcomment() { + const rsp = await commentsService.create({ + "subject": "New Comment", + "text": "This is my comment" }) console.log(rsp) } -updateAcomment() +createAcomment() ``` -## Delete +## Read -Delete a comment +Read a comment -[https://m3o.com/comments/api#Delete](https://m3o.com/comments/api#Delete) +[https://m3o.com/comments/api#Read](https://m3o.com/comments/api#Read) ```js const { CommentsService } = require('m3o/comments'); const commentsService = new CommentsService(process.env.M3O_API_TOKEN) -// Delete a comment -async function deleteAcomment() { - const rsp = await commentsService.delete({ +// Read a comment +async function readAcomment() { + const rsp = await commentsService.read({ "id": "63c0cdf8-2121-11ec-a881-0242e36f037a" }) console.log(rsp) } -deleteAcomment() +readAcomment() ``` diff --git a/examples/contact/README.md b/examples/contact/README.md index fe823c8b..b57305a3 100755 --- a/examples/contact/README.md +++ b/examples/contact/README.md @@ -4,74 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Contact/api](h Endpoints: -## Delete - -Delete a contact - - -[https://m3o.com/contact/api#Delete](https://m3o.com/contact/api#Delete) - -```js -const { ContactService } = require('m3o/contact'); - -const contactService = new ContactService(process.env.M3O_API_TOKEN) - -// Delete a contact -async function deleteAcontact() { - const rsp = await contactService.delete({ - "id": "42e48a3c-6221-11ec-96d2-acde48001122" -}) - console.log(rsp) - -} - -deleteAcontact() -``` -## List - -List contacts - - -[https://m3o.com/contact/api#List](https://m3o.com/contact/api#List) - -```js -const { ContactService } = require('m3o/contact'); - -const contactService = new ContactService(process.env.M3O_API_TOKEN) - -// List contacts -async function listContactsWithDefaultOffsetAndLimitDefaultLimitIs20() { - const rsp = await contactService.list({}) - console.log(rsp) - -} - -listContactsWithDefaultOffsetAndLimitDefaultLimitIs20() -``` -## List - -List contacts - - -[https://m3o.com/contact/api#List](https://m3o.com/contact/api#List) - -```js -const { ContactService } = require('m3o/contact'); - -const contactService = new ContactService(process.env.M3O_API_TOKEN) - -// List contacts -async function listContactsWithSpecificOffsetAndLimit() { - const rsp = await contactService.list({ - "limit": 1, - "offset": 1 -}) - console.log(rsp) - -} - -listContactsWithSpecificOffsetAndLimit() -``` ## Create Create a contact @@ -230,3 +162,71 @@ async function getAcontact() { getAcontact() ``` +## Delete + +Delete a contact + + +[https://m3o.com/contact/api#Delete](https://m3o.com/contact/api#Delete) + +```js +const { ContactService } = require('m3o/contact'); + +const contactService = new ContactService(process.env.M3O_API_TOKEN) + +// Delete a contact +async function deleteAcontact() { + const rsp = await contactService.delete({ + "id": "42e48a3c-6221-11ec-96d2-acde48001122" +}) + console.log(rsp) + +} + +deleteAcontact() +``` +## List + +List contacts + + +[https://m3o.com/contact/api#List](https://m3o.com/contact/api#List) + +```js +const { ContactService } = require('m3o/contact'); + +const contactService = new ContactService(process.env.M3O_API_TOKEN) + +// List contacts +async function listContactsWithDefaultOffsetAndLimitDefaultLimitIs20() { + const rsp = await contactService.list({}) + console.log(rsp) + +} + +listContactsWithDefaultOffsetAndLimitDefaultLimitIs20() +``` +## List + +List contacts + + +[https://m3o.com/contact/api#List](https://m3o.com/contact/api#List) + +```js +const { ContactService } = require('m3o/contact'); + +const contactService = new ContactService(process.env.M3O_API_TOKEN) + +// List contacts +async function listContactsWithSpecificOffsetAndLimit() { + const rsp = await contactService.list({ + "limit": 1, + "offset": 1 +}) + console.log(rsp) + +} + +listContactsWithSpecificOffsetAndLimit() +``` diff --git a/examples/cron/README.md b/examples/cron/README.md index 91d42f7a..5d3b8f8d 100755 --- a/examples/cron/README.md +++ b/examples/cron/README.md @@ -4,27 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Cron/api](http Endpoints: -## Jobs - -List all cron jobs - - -[https://m3o.com/cron/api#Jobs](https://m3o.com/cron/api#Jobs) - -```js -const { CronService } = require('m3o/cron'); - -const cronService = new CronService(process.env.M3O_API_TOKEN) - -// List all cron jobs -async function listJobs() { - const rsp = await cronService.jobs({}) - console.log(rsp) - -} - -listJobs() -``` ## Schedule Schedule a cron job @@ -74,3 +53,24 @@ async function deleteAjob() { deleteAjob() ``` +## Jobs + +List all cron jobs + + +[https://m3o.com/cron/api#Jobs](https://m3o.com/cron/api#Jobs) + +```js +const { CronService } = require('m3o/cron'); + +const cronService = new CronService(process.env.M3O_API_TOKEN) + +// List all cron jobs +async function listJobs() { + const rsp = await cronService.jobs({}) + console.log(rsp) + +} + +listJobs() +``` diff --git a/examples/crypto/README.md b/examples/crypto/README.md index 53d040fc..4778a2bc 100755 --- a/examples/crypto/README.md +++ b/examples/crypto/README.md @@ -4,27 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Crypto/api](ht Endpoints: -## Symbols - -Returns the full list of supported symbols - - -[https://m3o.com/crypto/api#Symbols](https://m3o.com/crypto/api#Symbols) - -```js -const { CryptoService } = require('m3o/crypto'); - -const cryptoService = new CryptoService(process.env.M3O_API_TOKEN) - -// Returns the full list of supported symbols -async function getListOfAllSupportedSymbols() { - const rsp = await cryptoService.symbols({}) - console.log(rsp) - -} - -getListOfAllSupportedSymbols() -``` ## News Get news related to a currency @@ -117,3 +96,24 @@ async function getPreviousClose() { getPreviousClose() ``` +## Symbols + +Returns the full list of supported symbols + + +[https://m3o.com/crypto/api#Symbols](https://m3o.com/crypto/api#Symbols) + +```js +const { CryptoService } = require('m3o/crypto'); + +const cryptoService = new CryptoService(process.env.M3O_API_TOKEN) + +// Returns the full list of supported symbols +async function getListOfAllSupportedSymbols() { + const rsp = await cryptoService.symbols({}) + console.log(rsp) + +} + +getListOfAllSupportedSymbols() +``` diff --git a/examples/db/README.md b/examples/db/README.md index 11a26776..5cb5cf0f 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: -## Delete +## Create -Delete a record in the database by id. +Create a record in the database. Optionally include an "id" field otherwise it's set automatically. -[https://m3o.com/db/api#Delete](https://m3o.com/db/api#Delete) +[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) -// Delete a record in the database by id. -async function deleteArecord() { - const rsp = await dbService.delete({ - "id": "1", +// 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) } -deleteArecord() +createArecord() ``` -## ListTables +## Delete -List tables in the DB +Delete a record in the database by id. -[https://m3o.com/db/api#ListTables](https://m3o.com/db/api#ListTables) +[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) -// List tables in the DB -async function listTables() { - const rsp = await dbService.listTables({}) +// Delete a record in the database by id. +async function deleteArecord() { + const rsp = await dbService.delete({ + "id": "1", + "table": "example" +}) console.log(rsp) } -listTables() +deleteArecord() ``` -## Read +## DropTable -Read data from a table. Lookup can be by ID or via querying any field in the record. +Drop a table in the DB -[https://m3o.com/db/api#Read](https://m3o.com/db/api#Read) +[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) -// 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", +// Drop a table in the DB +async function dropTable() { + const rsp = await dbService.dropTable({ "table": "example" }) console.log(rsp) } -readRecords() +dropTable() ``` -## Truncate +## Count -Truncate the records in a table +Count records in a table -[https://m3o.com/db/api#Truncate](https://m3o.com/db/api#Truncate) +[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) -// Truncate the records in a table -async function truncateTable() { - const rsp = await dbService.truncate({ +// Count records in a table +async function countEntriesInAtable() { + const rsp = await dbService.count({ "table": "example" }) console.log(rsp) } -truncateTable() +countEntriesInAtable() ``` -## DropTable +## ListTables -Drop a table in the DB +List tables in the DB -[https://m3o.com/db/api#DropTable](https://m3o.com/db/api#DropTable) +[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) -// Drop a table in the DB -async function dropTable() { - const rsp = await dbService.dropTable({ - "table": "example" -}) +// List tables in the DB +async function listTables() { + const rsp = await dbService.listTables({}) console.log(rsp) } -dropTable() +listTables() ``` -## Count +## RenameTable -Count records in a table +Rename a table -[https://m3o.com/db/api#Count](https://m3o.com/db/api#Count) +[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) -// Count records in a table -async function countEntriesInAtable() { - const rsp = await dbService.count({ - "table": "example" +// Rename a table +async function renameTable() { + const rsp = await dbService.renameTable({ + "from": "examples2", + "to": "examples3" }) console.log(rsp) } -countEntriesInAtable() +renameTable() ``` -## RenameTable +## Update -Rename a table +Update a record in the database. Include an "id" in the record to update. -[https://m3o.com/db/api#RenameTable](https://m3o.com/db/api#RenameTable) +[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) -// Rename a table -async function renameTable() { - const rsp = await dbService.renameTable({ - "from": "examples2", - "to": "examples3" +// 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) } -renameTable() +updateArecord() ``` -## Create +## Read -Create a record in the database. Optionally include an "id" field otherwise it's set automatically. +Read data from a table. Lookup can be by ID or via querying any field in the record. -[https://m3o.com/db/api#Create](https://m3o.com/db/api#Create) +[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) -// 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" - }, +// 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) } -createArecord() +readRecords() ``` -## Update +## Truncate -Update a record in the database. Include an "id" in the record to update. +Truncate the records in a table -[https://m3o.com/db/api#Update](https://m3o.com/db/api#Update) +[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) -// 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" - }, +// Truncate the records in a table +async function truncateTable() { + const rsp = await dbService.truncate({ "table": "example" }) console.log(rsp) } -updateArecord() +truncateTable() ``` diff --git a/examples/file/README.md b/examples/file/README.md index 467f75e5..656b0ce0 100755 --- a/examples/file/README.md +++ b/examples/file/README.md @@ -4,6 +4,30 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/File/api](http Endpoints: +## Delete + +Delete a file by project name/path + + +[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) + +// 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) + +} + +deleteFile() +``` ## Save Save a file @@ -78,27 +102,3 @@ async function readFile() { readFile() ``` -## Delete - -Delete a file by project name/path - - -[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) - -// 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) - -} - -deleteFile() -``` diff --git a/examples/function/README.md b/examples/function/README.md index 4353c2a5..06bb9bea 100755 --- a/examples/function/README.md +++ b/examples/function/README.md @@ -4,193 +4,195 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Function/api]( Endpoints: -## Logs +## Update -Get the logs for a function +Update a function. Downloads the source, builds and redeploys -[https://m3o.com/function/api#Logs](https://m3o.com/function/api#Logs) +[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) -// Get the logs for a function -async function retrieveBuildLogsForAfunction() { - const rsp = await functionService.logs({ - "logs_type": "build", +// Update a function. Downloads the source, builds and redeploys +async function updateAfunction() { + const rsp = await functionService.update({ "name": "helloworld" }) console.log(rsp) } -retrieveBuildLogsForAfunction() +updateAfunction() ``` -## Deploy +## List -Deploy a group of functions +List all the deployed functions -[https://m3o.com/function/api#Deploy](https://m3o.com/function/api#Deploy) +[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) -// 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" -}) +// List all the deployed functions +async function listFunctions() { + const rsp = await functionService.list({}) console.log(rsp) } -deployAfunction() +listFunctions() ``` -## Update +## Regions -Update a function. Downloads the source, builds and redeploys +Return a list of supported regions -[https://m3o.com/function/api#Update](https://m3o.com/function/api#Update) +[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) -// Update a function. Downloads the source, builds and redeploys -async function updateAfunction() { - const rsp = await functionService.update({ - "name": "helloworld" -}) +// Return a list of supported regions +async function listRegions() { + const rsp = await functionService.regions({}) console.log(rsp) } -updateAfunction() +listRegions() ``` -## Call +## Proxy -Call a function by name +Return the backend url for proxying -[https://m3o.com/function/api#Call](https://m3o.com/function/api#Call) +[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) -// Call a function by name -async function callAfunction() { - const rsp = await functionService.call({ - "name": "helloworld", - "request": { - "name": "Alice" - } +// Return the backend url for proxying +async function proxyUrl() { + const rsp = await functionService.proxy({ + "id": "helloworld" }) console.log(rsp) } -callAfunction() +proxyUrl() ``` -## List +## Logs -List all the deployed functions +Get the logs for a function -[https://m3o.com/function/api#List](https://m3o.com/function/api#List) +[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) -// List all the deployed functions -async function listFunctions() { - const rsp = await functionService.list({}) +// Get the logs for a function +async function retrieveBuildLogsForAfunction() { + const rsp = await functionService.logs({ + "logs_type": "build", + "name": "helloworld" +}) console.log(rsp) } -listFunctions() +retrieveBuildLogsForAfunction() ``` -## Delete +## Deploy -Delete a function by name +Deploy a group of functions -[https://m3o.com/function/api#Delete](https://m3o.com/function/api#Delete) +[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) -// Delete a function by name -async function deleteAfunction() { - const rsp = await functionService.delete({ - "name": "helloworld" +// 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) } -deleteAfunction() +deployAfunction() ``` -## Regions +## Call -Return a list of supported regions +Call a function by name -[https://m3o.com/function/api#Regions](https://m3o.com/function/api#Regions) +[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) -// Return a list of supported regions -async function listRegions() { - const rsp = await functionService.regions({}) +// Call a function by name +async function callAfunction() { + const rsp = await functionService.call({ + "name": "helloworld", + "request": { + "name": "Alice" + } +}) console.log(rsp) } -listRegions() +callAfunction() ``` -## Runtimes +## Delete -Return a list of supported runtimes +Delete a function by name -[https://m3o.com/function/api#Runtimes](https://m3o.com/function/api#Runtimes) +[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) -// Return a list of supported runtimes -async function listRuntimes() { - const rsp = await functionService.runtimes({}) +// Delete a function by name +async function deleteAfunction() { + const rsp = await functionService.delete({ + "name": "helloworld" +}) console.log(rsp) } -listRuntimes() +deleteAfunction() ``` ## Describe @@ -238,26 +240,24 @@ async function reserveAfunction() { reserveAfunction() ``` -## Proxy +## Runtimes -Return the backend url for proxying +Return a list of supported runtimes -[https://m3o.com/function/api#Proxy](https://m3o.com/function/api#Proxy) +[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) -// Return the backend url for proxying -async function proxyUrl() { - const rsp = await functionService.proxy({ - "id": "helloworld" -}) +// Return a list of supported runtimes +async function listRuntimes() { + const rsp = await functionService.runtimes({}) console.log(rsp) } -proxyUrl() +listRuntimes() ``` diff --git a/examples/geocoding/README.md b/examples/geocoding/README.md index dfe1b183..f5f005e8 100755 --- a/examples/geocoding/README.md +++ b/examples/geocoding/README.md @@ -4,53 +4,53 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Geocoding/api] Endpoints: -## Reverse +## Lookup -Reverse lookup an address from gps coordinates +Lookup returns a geocoded address including normalized address and gps coordinates. All fields are optional, provide more to get more accurate results -[https://m3o.com/geocoding/api#Reverse](https://m3o.com/geocoding/api#Reverse) +[https://m3o.com/geocoding/api#Lookup](https://m3o.com/geocoding/api#Lookup) ```js const { GeocodingService } = require('m3o/geocoding'); const geocodingService = new GeocodingService(process.env.M3O_API_TOKEN) -// Reverse lookup an address from gps coordinates -async function reverseGeocodeLocation() { - const rsp = await geocodingService.reverse({ - "latitude": 51.5123064, - "longitude": -0.1216235 +// Lookup returns a geocoded address including normalized address and gps coordinates. All fields are optional, provide more to get more accurate results +async function geocodeAnAddress() { + const rsp = await geocodingService.lookup({ + "address": "10 russell st", + "city": "london", + "country": "uk", + "postcode": "wc2b" }) console.log(rsp) } -reverseGeocodeLocation() +geocodeAnAddress() ``` -## Lookup +## Reverse -Lookup returns a geocoded address including normalized address and gps coordinates. All fields are optional, provide more to get more accurate results +Reverse lookup an address from gps coordinates -[https://m3o.com/geocoding/api#Lookup](https://m3o.com/geocoding/api#Lookup) +[https://m3o.com/geocoding/api#Reverse](https://m3o.com/geocoding/api#Reverse) ```js const { GeocodingService } = require('m3o/geocoding'); const geocodingService = new GeocodingService(process.env.M3O_API_TOKEN) -// Lookup returns a geocoded address including normalized address and gps coordinates. All fields are optional, provide more to get more accurate results -async function geocodeAnAddress() { - const rsp = await geocodingService.lookup({ - "address": "10 russell st", - "city": "london", - "country": "uk", - "postcode": "wc2b" +// Reverse lookup an address from gps coordinates +async function reverseGeocodeLocation() { + const rsp = await geocodingService.reverse({ + "latitude": 51.5123064, + "longitude": -0.1216235 }) console.log(rsp) } -geocodeAnAddress() +reverseGeocodeLocation() ``` diff --git a/examples/holidays/README.md b/examples/holidays/README.md index b63dd94d..9d64861b 100755 --- a/examples/holidays/README.md +++ b/examples/holidays/README.md @@ -4,48 +4,48 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Holidays/api]( Endpoints: -## Countries +## List -Get the list of countries that are supported by this API +List the holiday dates for a given country and year -[https://m3o.com/holidays/api#Countries](https://m3o.com/holidays/api#Countries) +[https://m3o.com/holidays/api#List](https://m3o.com/holidays/api#List) ```js const { HolidaysService } = require('m3o/holidays'); const holidaysService = new HolidaysService(process.env.M3O_API_TOKEN) -// Get the list of countries that are supported by this API -async function listCountries() { - const rsp = await holidaysService.countries({}) +// List the holiday dates for a given country and year +async function getHolidays() { + const rsp = await holidaysService.list({ + "country_code": "GB", + "year": 2022 +}) console.log(rsp) } -listCountries() +getHolidays() ``` -## List +## Countries -List the holiday dates for a given country and year +Get the list of countries that are supported by this API -[https://m3o.com/holidays/api#List](https://m3o.com/holidays/api#List) +[https://m3o.com/holidays/api#Countries](https://m3o.com/holidays/api#Countries) ```js const { HolidaysService } = require('m3o/holidays'); const holidaysService = new HolidaysService(process.env.M3O_API_TOKEN) -// List the holiday dates for a given country and year -async function getHolidays() { - const rsp = await holidaysService.list({ - "country_code": "GB", - "year": 2022 -}) +// Get the list of countries that are supported by this API +async function listCountries() { + const rsp = await holidaysService.countries({}) console.log(rsp) } -getHolidays() +listCountries() ``` diff --git a/examples/image/README.md b/examples/image/README.md index cc19cfb4..0e2cc830 100755 --- a/examples/image/README.md +++ b/examples/image/README.md @@ -4,6 +4,29 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Image/api](htt Endpoints: +## Delete + +Delete an image previously uploaded. + + +[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) + +// 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) + +} + +deleteAnUploadedImage() +``` ## Resize Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters. @@ -200,26 +223,3 @@ async function uploadAnImageFromAurlToMicrosCdn() { uploadAnImageFromAurlToMicrosCdn() ``` -## Delete - -Delete an image previously uploaded. - - -[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) - -// 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) - -} - -deleteAnUploadedImage() -``` diff --git a/examples/lists/README.md b/examples/lists/README.md index 2356aca4..3a3b5511 100755 --- a/examples/lists/README.md +++ b/examples/lists/README.md @@ -4,149 +4,149 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Lists/api](htt Endpoints: -## Update +## Create -Update a list +Create a new list -[https://m3o.com/lists/api#Update](https://m3o.com/lists/api#Update) +[https://m3o.com/lists/api#Create](https://m3o.com/lists/api#Create) ```js const { ListsService } = require('m3o/lists'); const listsService = new ListsService(process.env.M3O_API_TOKEN) -// Update a list -async function updateAlist() { - const rsp = await listsService.update({ - "list": { - "id": "63c0cdf8-2121-11ec-a881-0242e36f037a", - "items": [ - "Updated list text" - ], - "name": "Update List" - } +// Create a new list +async function createAlist() { + const rsp = await listsService.create({ + "items": [ + "This is my list" + ], + "name": "New List" }) console.log(rsp) } -updateAlist() +createAlist() ``` -## Delete +## Read -Delete a list +Read a list -[https://m3o.com/lists/api#Delete](https://m3o.com/lists/api#Delete) +[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) -// Delete a list -async function deleteAlist() { - const rsp = await listsService.delete({ +// Read a list +async function readAlist() { + const rsp = await listsService.read({ "id": "63c0cdf8-2121-11ec-a881-0242e36f037a" }) console.log(rsp) } -deleteAlist() +readAlist() ``` -## Events +## List -Subscribe to lists events +List all the lists -[https://m3o.com/lists/api#Events](https://m3o.com/lists/api#Events) +[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) -// Subscribe to lists events -async function subscribeToEvents() { - const rsp = await listsService.events({ - "id": "63c0cdf8-2121-11ec-a881-0242e36f037a" -}) - rsp.onMessage(msg => { - console.log(msg) - }) +// List all the lists +async function listAllLists() { + const rsp = await listsService.list({}) + console.log(rsp) + } -subscribeToEvents() +listAllLists() ``` -## Create +## Update -Create a new list +Update a list -[https://m3o.com/lists/api#Create](https://m3o.com/lists/api#Create) +[https://m3o.com/lists/api#Update](https://m3o.com/lists/api#Update) ```js const { ListsService } = require('m3o/lists'); const listsService = new ListsService(process.env.M3O_API_TOKEN) -// Create a new list -async function createAlist() { - const rsp = await listsService.create({ - "items": [ - "This is my list" - ], - "name": "New List" +// Update a list +async function updateAlist() { + const rsp = await listsService.update({ + "list": { + "id": "63c0cdf8-2121-11ec-a881-0242e36f037a", + "items": [ + "Updated list text" + ], + "name": "Update List" + } }) console.log(rsp) } -createAlist() +updateAlist() ``` -## Read +## Delete -Read a list +Delete a list -[https://m3o.com/lists/api#Read](https://m3o.com/lists/api#Read) +[https://m3o.com/lists/api#Delete](https://m3o.com/lists/api#Delete) ```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({ +// Delete a list +async function deleteAlist() { + const rsp = await listsService.delete({ "id": "63c0cdf8-2121-11ec-a881-0242e36f037a" }) console.log(rsp) } -readAlist() +deleteAlist() ``` -## List +## Events -List all the lists +Subscribe to lists events -[https://m3o.com/lists/api#List](https://m3o.com/lists/api#List) +[https://m3o.com/lists/api#Events](https://m3o.com/lists/api#Events) ```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) - +// Subscribe to lists events +async function subscribeToEvents() { + const rsp = await listsService.events({ + "id": "63c0cdf8-2121-11ec-a881-0242e36f037a" +}) + rsp.onMessage(msg => { + console.log(msg) + }) } -listAllLists() +subscribeToEvents() ``` diff --git a/examples/location/README.md b/examples/location/README.md index 60cafca8..f31c5f37 100755 --- a/examples/location/README.md +++ b/examples/location/README.md @@ -4,37 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Location/api]( Endpoints: -## Save - -Save an entity's current position - - -[https://m3o.com/location/api#Save](https://m3o.com/location/api#Save) - -```js -const { LocationService } = require('m3o/location'); - -const locationService = new LocationService(process.env.M3O_API_TOKEN) - -// Save an entity's current position -async function saveAnEntity() { - const rsp = await locationService.save({ - "entity": { - "id": "1", - "location": { - "latitude": 51.511061, - "longitude": -0.120022, - "timestamp": "1622802761" - }, - "type": "bike" - } -}) - console.log(rsp) - -} - -saveAnEntity() -``` ## Read Read an entity by its ID @@ -87,3 +56,34 @@ async function searchForLocations() { searchForLocations() ``` +## Save + +Save an entity's current position + + +[https://m3o.com/location/api#Save](https://m3o.com/location/api#Save) + +```js +const { LocationService } = require('m3o/location'); + +const locationService = new LocationService(process.env.M3O_API_TOKEN) + +// Save an entity's current position +async function saveAnEntity() { + const rsp = await locationService.save({ + "entity": { + "id": "1", + "location": { + "latitude": 51.511061, + "longitude": -0.120022, + "timestamp": "1622802761" + }, + "type": "bike" + } +}) + console.log(rsp) + +} + +saveAnEntity() +``` diff --git a/examples/nft/README.md b/examples/nft/README.md index 1cdb2c0d..727b7f01 100755 --- a/examples/nft/README.md +++ b/examples/nft/README.md @@ -4,30 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Nft/api](https Endpoints: -## Asset - -Get a single asset by the contract - - -[https://m3o.com/nft/api#Asset](https://m3o.com/nft/api#Asset) - -```js -const { NftService } = require('m3o/nft'); - -const nftService = new NftService(process.env.M3O_API_TOKEN) - -// Get a single asset by the contract -async function getAsingleAsset() { - const rsp = await nftService.asset({ - "contract_address": "0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb", - "token_id": "1" -}) - console.log(rsp) - -} - -getAsingleAsset() -``` ## Collection Get a collection by its slug @@ -122,3 +98,27 @@ async function listCollections() { listCollections() ``` +## Asset + +Get a single asset by the contract + + +[https://m3o.com/nft/api#Asset](https://m3o.com/nft/api#Asset) + +```js +const { NftService } = require('m3o/nft'); + +const nftService = new NftService(process.env.M3O_API_TOKEN) + +// Get a single asset by the contract +async function getAsingleAsset() { + const rsp = await nftService.asset({ + "contract_address": "0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb", + "token_id": "1" +}) + console.log(rsp) + +} + +getAsingleAsset() +``` diff --git a/examples/notes/README.md b/examples/notes/README.md index 325e8fbc..8eb9ce6e 100755 --- a/examples/notes/README.md +++ b/examples/notes/README.md @@ -4,145 +4,145 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Notes/api](htt Endpoints: -## Events +## List -Subscribe to notes events +List all the notes -[https://m3o.com/notes/api#Events](https://m3o.com/notes/api#Events) +[https://m3o.com/notes/api#List](https://m3o.com/notes/api#List) ```js const { NotesService } = require('m3o/notes'); const notesService = new NotesService(process.env.M3O_API_TOKEN) -// Subscribe to notes events -async function subscribeToEvents() { - const rsp = await notesService.events({ - "id": "63c0cdf8-2121-11ec-a881-0242e36f037a" -}) - rsp.onMessage(msg => { - console.log(msg) - }) +// List all the notes +async function listAllNotes() { + const rsp = await notesService.list({}) + console.log(rsp) + } -subscribeToEvents() +listAllNotes() ``` -## Create +## Update -Create a new note +Update a note -[https://m3o.com/notes/api#Create](https://m3o.com/notes/api#Create) +[https://m3o.com/notes/api#Update](https://m3o.com/notes/api#Update) ```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" +// Update a note +async function updateAnote() { + const rsp = await notesService.update({ + "note": { + "id": "63c0cdf8-2121-11ec-a881-0242e36f037a", + "text": "Updated note text", + "title": "Update Note" + } }) console.log(rsp) } -createAnote() +updateAnote() ``` -## Read +## Delete -Read a note +Delete a note -[https://m3o.com/notes/api#Read](https://m3o.com/notes/api#Read) +[https://m3o.com/notes/api#Delete](https://m3o.com/notes/api#Delete) ```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({ +// Delete a note +async function deleteAnote() { + const rsp = await notesService.delete({ "id": "63c0cdf8-2121-11ec-a881-0242e36f037a" }) console.log(rsp) } -readAnote() +deleteAnote() ``` -## List +## Events -List all the notes +Subscribe to notes events -[https://m3o.com/notes/api#List](https://m3o.com/notes/api#List) +[https://m3o.com/notes/api#Events](https://m3o.com/notes/api#Events) ```js const { NotesService } = require('m3o/notes'); const notesService = new NotesService(process.env.M3O_API_TOKEN) -// List all the notes -async function listAllNotes() { - const rsp = await notesService.list({}) - console.log(rsp) - +// Subscribe to notes events +async function subscribeToEvents() { + const rsp = await notesService.events({ + "id": "63c0cdf8-2121-11ec-a881-0242e36f037a" +}) + rsp.onMessage(msg => { + console.log(msg) + }) } -listAllNotes() +subscribeToEvents() ``` -## Update +## Create -Update a note +Create a new note -[https://m3o.com/notes/api#Update](https://m3o.com/notes/api#Update) +[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) -// Update a note -async function updateAnote() { - const rsp = await notesService.update({ - "note": { - "id": "63c0cdf8-2121-11ec-a881-0242e36f037a", - "text": "Updated note text", - "title": "Update Note" - } +// Create a new note +async function createAnote() { + const rsp = await notesService.create({ + "text": "This is my note", + "title": "New Note" }) console.log(rsp) } -updateAnote() +createAnote() ``` -## Delete +## Read -Delete a note +Read a note -[https://m3o.com/notes/api#Delete](https://m3o.com/notes/api#Delete) +[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) -// Delete a note -async function deleteAnote() { - const rsp = await notesService.delete({ +// Read a note +async function readAnote() { + const rsp = await notesService.read({ "id": "63c0cdf8-2121-11ec-a881-0242e36f037a" }) console.log(rsp) } -deleteAnote() +readAnote() ``` diff --git a/examples/routing/README.md b/examples/routing/README.md index ddd34400..224402d8 100755 --- a/examples/routing/README.md +++ b/examples/routing/README.md @@ -4,21 +4,21 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Routing/api](h Endpoints: -## Eta +## Directions -Get the eta for a route from origin to destination. The eta is an estimated time based on car routes +Turn by turn directions from a start point to an end point including maneuvers and bearings -[https://m3o.com/routing/api#Eta](https://m3o.com/routing/api#Eta) +[https://m3o.com/routing/api#Directions](https://m3o.com/routing/api#Directions) ```js const { RoutingService } = require('m3o/routing'); const routingService = new RoutingService(process.env.M3O_API_TOKEN) -// Get the eta for a route from origin to destination. The eta is an estimated time based on car routes -async function etaFromPointAtoPointB() { - const rsp = await routingService.eta({ +// Turn by turn directions from a start point to an end point including maneuvers and bearings +async function turnByTurnDirections() { + const rsp = await routingService.directions({ "destination": { "latitude": 52.529407, "longitude": 13.397634 @@ -32,23 +32,23 @@ async function etaFromPointAtoPointB() { } -etaFromPointAtoPointB() +turnByTurnDirections() ``` -## Directions +## Route -Turn by turn directions from a start point to an end point including maneuvers and bearings +Retrieve a route as a simple list of gps points along with total distance and estimated duration -[https://m3o.com/routing/api#Directions](https://m3o.com/routing/api#Directions) +[https://m3o.com/routing/api#Route](https://m3o.com/routing/api#Route) ```js const { RoutingService } = require('m3o/routing'); const routingService = new RoutingService(process.env.M3O_API_TOKEN) -// Turn by turn directions from a start point to an end point including maneuvers and bearings -async function turnByTurnDirections() { - const rsp = await routingService.directions({ +// Retrieve a route as a simple list of gps points along with total distance and estimated duration +async function gpsPointsForAroute() { + const rsp = await routingService.route({ "destination": { "latitude": 52.529407, "longitude": 13.397634 @@ -62,23 +62,23 @@ async function turnByTurnDirections() { } -turnByTurnDirections() +gpsPointsForAroute() ``` -## Route +## Eta -Retrieve a route as a simple list of gps points along with total distance and estimated duration +Get the eta for a route from origin to destination. The eta is an estimated time based on car routes -[https://m3o.com/routing/api#Route](https://m3o.com/routing/api#Route) +[https://m3o.com/routing/api#Eta](https://m3o.com/routing/api#Eta) ```js const { RoutingService } = require('m3o/routing'); const routingService = new RoutingService(process.env.M3O_API_TOKEN) -// Retrieve a route as a simple list of gps points along with total distance and estimated duration -async function gpsPointsForAroute() { - const rsp = await routingService.route({ +// Get the eta for a route from origin to destination. The eta is an estimated time based on car routes +async function etaFromPointAtoPointB() { + const rsp = await routingService.eta({ "destination": { "latitude": 52.529407, "longitude": 13.397634 @@ -92,5 +92,5 @@ async function gpsPointsForAroute() { } -gpsPointsForAroute() +etaFromPointAtoPointB() ``` diff --git a/examples/space/README.md b/examples/space/README.md index d8819be1..4fdbaecb 100755 --- a/examples/space/README.md +++ b/examples/space/README.md @@ -4,6 +4,52 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Space/api](htt Endpoints: +## Head + +Retrieve meta information about an object + + +[https://m3o.com/space/api#Head](https://m3o.com/space/api#Head) + +```js +const { SpaceService } = require('m3o/space'); + +const spaceService = new SpaceService(process.env.M3O_API_TOKEN) + +// Retrieve meta information about an object +async function headAnObject() { + const rsp = await spaceService.head({ + "name": "images/file.jpg" +}) + console.log(rsp) + +} + +headAnObject() +``` +## Read + +Read an object in space + + +[https://m3o.com/space/api#Read](https://m3o.com/space/api#Read) + +```js +const { SpaceService } = require('m3o/space'); + +const spaceService = new SpaceService(process.env.M3O_API_TOKEN) + +// Read an object in space +async function readAnObject() { + const rsp = await spaceService.read({ + "name": "images/file.jpg" +}) + console.log(rsp) + +} + +readAnObject() +``` ## Download Download an object via a presigned url @@ -146,49 +192,3 @@ async function listObjectsWithPrefix() { listObjectsWithPrefix() ``` -## Head - -Retrieve meta information about an object - - -[https://m3o.com/space/api#Head](https://m3o.com/space/api#Head) - -```js -const { SpaceService } = require('m3o/space'); - -const spaceService = new SpaceService(process.env.M3O_API_TOKEN) - -// Retrieve meta information about an object -async function headAnObject() { - const rsp = await spaceService.head({ - "name": "images/file.jpg" -}) - console.log(rsp) - -} - -headAnObject() -``` -## Read - -Read an object in space - - -[https://m3o.com/space/api#Read](https://m3o.com/space/api#Read) - -```js -const { SpaceService } = require('m3o/space'); - -const spaceService = new SpaceService(process.env.M3O_API_TOKEN) - -// Read an object in space -async function readAnObject() { - const rsp = await spaceService.read({ - "name": "images/file.jpg" -}) - console.log(rsp) - -} - -readAnObject() -``` diff --git a/examples/twitter/README.md b/examples/twitter/README.md index 7d6c875d..4e7a8a74 100755 --- a/examples/twitter/README.md +++ b/examples/twitter/README.md @@ -4,30 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Twitter/api](h Endpoints: -## Timeline - -Get the timeline for a given user - - -[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 timeline for a given user -async function getAtwitterTimeline() { - const rsp = await twitterService.timeline({ - "limit": 1, - "username": "m3oservices" -}) - console.log(rsp) - -} - -getAtwitterTimeline() -``` ## Search Search for tweets with a simple query @@ -95,3 +71,27 @@ async function getAusersTwitterProfile() { getAusersTwitterProfile() ``` +## Timeline + +Get the timeline for a given user + + +[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 timeline for a given user +async function getAtwitterTimeline() { + const rsp = await twitterService.timeline({ + "limit": 1, + "username": "m3oservices" +}) + console.log(rsp) + +} + +getAtwitterTimeline() +``` diff --git a/examples/url/README.md b/examples/url/README.md index 8b88d940..efd94cc9 100755 --- a/examples/url/README.md +++ b/examples/url/README.md @@ -4,51 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Url/api](https Endpoints: -## 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 - - -[https://m3o.com/url/api#Update](https://m3o.com/url/api#Update) - -```js -const { UrlService } = require('m3o/url'); - -const urlService = new UrlService(process.env.M3O_API_TOKEN) - -// Update the destination for a short URL -async function updateAshortUrl() { - const rsp = await urlService.update({ - "destinationURL": "https://mynewsite.com/this-is-a-rather-long-web-address", - "shortURL": "https://m3o.one/url/f8f3f83f3f83g" -}) - console.log(rsp) - -} - -updateAshortUrl() -``` ## Shorten Shorten a URL @@ -142,3 +97,48 @@ async function createAurl() { 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 + + +[https://m3o.com/url/api#Update](https://m3o.com/url/api#Update) + +```js +const { UrlService } = require('m3o/url'); + +const urlService = new UrlService(process.env.M3O_API_TOKEN) + +// Update the destination for a short URL +async function updateAshortUrl() { + const rsp = await urlService.update({ + "destinationURL": "https://mynewsite.com/this-is-a-rather-long-web-address", + "shortURL": "https://m3o.one/url/f8f3f83f3f83g" +}) + console.log(rsp) + +} + +updateAshortUrl() +``` diff --git a/examples/user/README.md b/examples/user/README.md index f157610f..ff471f3e 100755 --- a/examples/user/README.md +++ b/examples/user/README.md @@ -4,87 +4,81 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/User/api](http Endpoints: -## SendVerificationEmail +## UpdatePassword -Send a verification email to a user. +Update the account password -[https://m3o.com/user/api#SendVerificationEmail](https://m3o.com/user/api#SendVerificationEmail) +[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) -// 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" +// Update the account password +async function updateTheAccountPassword() { + const rsp = await userService.updatePassword({ + "confirmPassword": "Password2", + "newPassword": "Password2", + "oldPassword": "Password1", + "userId": "user-1" }) console.log(rsp) } -sendVerificationEmail() +updateTheAccountPassword() ``` -## ResetPassword +## VerifyEmail -Reset password with the code sent by the "SendPasswordResetEmail" endpoint. +Verify the email address of an account from a token sent in an email to the user. -[https://m3o.com/user/api#ResetPassword](https://m3o.com/user/api#ResetPassword) +[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) -// Reset password with the code sent by the "SendPasswordResetEmail" endpoint. -async function resetPassword() { - const rsp = await userService.resetPassword({ - "code": "012345", - "confirmPassword": "NewPassword1", +// 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", - "newPassword": "NewPassword1" + "token": "012345" }) console.log(rsp) } -resetPassword() +verifyEmail() ``` -## SendMagicLink +## Login -Login using email only - Passwordless +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#SendMagicLink](https://m3o.com/user/api#SendMagicLink) +[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) -// Login using email only - Passwordless -async function sendAmagicLink() { - const rsp = await userService.sendMagicLink({ - "address": "www.example.com", +// 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", - "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" + "password": "Password1" }) console.log(rsp) } -sendAmagicLink() +logAuserIn() ``` ## VerifyToken @@ -115,275 +109,281 @@ async function verifyAtoken() { verifyAtoken() ``` -## LogoutAll +## SendPasswordResetEmail -Logout of all user's sessions +Send an email with a verification code to reset password. +Call "ResetPassword" endpoint once user provides the code. -[https://m3o.com/user/api#LogoutAll](https://m3o.com/user/api#LogoutAll) +[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) -// Logout of all user's sessions -async function logoutAllSessionsForAuser() { - const rsp = await userService.logoutAll({ - "user_id": "user-1" +// 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) } -logoutAllSessionsForAuser() +sendPasswordResetEmail() ``` -## Create +## ReadSession -Create a new user account. The email address and username for the account must be unique. +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#Create](https://m3o.com/user/api#Create) +[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) -// 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", - "id": "user-1", - "password": "Password1", - "username": "joe" +// 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) } -createAnAccount() +readAsessionByTheSessionId() ``` -## Update +## SendVerificationEmail -Update the account username or email +Send a verification email to a user. -[https://m3o.com/user/api#Update](https://m3o.com/user/api#Update) +[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) -// Update the account username or email -async function updateAnAccount() { - const rsp = await userService.update({ - "email": "joe+2@example.com", - "id": "user-1", - "username": "joe" +// 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" }) console.log(rsp) } -updateAnAccount() +sendVerificationEmail() ``` -## 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 readAnAccountById() { - const rsp = await userService.read({ - "id": "user-1" +// Delete an account by id +async function deleteUserAccount() { + const rsp = await userService.delete({ + "id": "8b98acbe-0b6a-4d66-a414-5ffbf666786f" }) console.log(rsp) } -readAnAccountById() +deleteUserAccount() ``` -## Read +## SendMagicLink -Read an account by id, username or email. Only one need to be specified. +Login using email only - Passwordless -[https://m3o.com/user/api#Read](https://m3o.com/user/api#Read) +[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) -// Read an account by id, username or email. Only one need to be specified. -async function readAccountByUsernameOrEmail() { - const rsp = await userService.read({ - "username": "joe" +// 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" }) console.log(rsp) } -readAccountByUsernameOrEmail() +sendAmagicLink() ``` -## Read +## Create -Read an account by id, username or email. Only one need to be specified. +Create a new user account. The email address and username for the account must be unique. -[https://m3o.com/user/api#Read](https://m3o.com/user/api#Read) +[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) -// 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" +// 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", + "id": "user-1", + "password": "Password1", + "username": "joe" }) console.log(rsp) } -readAccountByEmail() +createAnAccount() ``` -## SendPasswordResetEmail +## Update -Send an email with a verification code to reset password. -Call "ResetPassword" endpoint once user provides the code. +Update the account username or email -[https://m3o.com/user/api#SendPasswordResetEmail](https://m3o.com/user/api#SendPasswordResetEmail) +[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) -// 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" +// 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) } -sendPasswordResetEmail() +updateAnAccount() ``` -## Login +## Read -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 +Read an account by id, username or email. Only one need to be specified. -[https://m3o.com/user/api#Login](https://m3o.com/user/api#Login) +[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) -// 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" +// 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) } -logAuserIn() +readAnAccountById() ``` -## 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 readAccountByUsernameOrEmail() { + const rsp = await userService.read({ + "username": "joe" }) console.log(rsp) } -readAsessionByTheSessionId() +readAccountByUsernameOrEmail() ``` -## UpdatePassword +## Read -Update the account password +Read an account by id, username or email. Only one need to be specified. -[https://m3o.com/user/api#UpdatePassword](https://m3o.com/user/api#UpdatePassword) +[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 password -async function updateTheAccountPassword() { - const rsp = await userService.updatePassword({ - "confirmPassword": "Password2", - "newPassword": "Password2", - "oldPassword": "Password1", - "userId": "user-1" +// 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) } -updateTheAccountPassword() +readAccountByEmail() ``` -## VerifyEmail +## ResetPassword -Verify the email address of an account from a token sent in an email to the user. +Reset password with the code sent by the "SendPasswordResetEmail" endpoint. -[https://m3o.com/user/api#VerifyEmail](https://m3o.com/user/api#VerifyEmail) +[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) -// 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({ +// 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", - "token": "012345" + "newPassword": "NewPassword1" }) console.log(rsp) } -verifyEmail() +resetPassword() ``` ## Logout @@ -432,26 +432,26 @@ async function listAllUsers() { listAllUsers() ``` -## Delete +## LogoutAll -Delete an account by id +Logout of all user's sessions -[https://m3o.com/user/api#Delete](https://m3o.com/user/api#Delete) +[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) -// Delete an account by id -async function deleteUserAccount() { - const rsp = await userService.delete({ - "id": "8b98acbe-0b6a-4d66-a414-5ffbf666786f" +// Logout of all user's sessions +async function logoutAllSessionsForAuser() { + const rsp = await userService.logoutAll({ + "user_id": "user-1" }) console.log(rsp) } -deleteUserAccount() +logoutAllSessionsForAuser() ``` diff --git a/examples/wallet/README.md b/examples/wallet/README.md index 51ac70c1..8c8a2d1e 100755 --- a/examples/wallet/README.md +++ b/examples/wallet/README.md @@ -30,26 +30,32 @@ async function debitWallet() { debitWallet() ``` -## List +## Transfer -List your wallets +Make a transfer from one wallet to another -[https://m3o.com/wallet/api#List](https://m3o.com/wallet/api#List) +[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 your wallets -async function listWallets() { - const rsp = await walletService.list({}) +// 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) } -listWallets() +transferMoney() ``` ## Balance @@ -74,149 +80,143 @@ async function getBalance() { getBalance() ``` -## Create +## Transactions -Create a new wallet +List the transactions for a wallet -[https://m3o.com/wallet/api#Create](https://m3o.com/wallet/api#Create) +[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) -// Create a new wallet -async function createAnewWallet() { - const rsp = await walletService.create({ - "description": "No explanation needed", - "name": "Greatness" +// List the transactions for a wallet +async function listTransactions() { + const rsp = await walletService.transactions({ + "id": "b6407edd-2e26-45c0-9e2c-343689bbe5f6" }) console.log(rsp) } -createAnewWallet() +listTransactions() ``` -## Read +## Delete -Get wallet by id +Delete a wallet -[https://m3o.com/wallet/api#Read](https://m3o.com/wallet/api#Read) +[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) -// Get wallet by id -async function readAwallet() { - const rsp = await walletService.read({ +// Delete a wallet +async function deleteAwallet() { + const rsp = await walletService.delete({ "id": "b6407edd-2e26-45c0-9e2c-343689bbe5f6" }) console.log(rsp) } -readAwallet() +deleteAwallet() ``` -## Credit +## Create -Add credit to a wallet +Create a new wallet -[https://m3o.com/wallet/api#Credit](https://m3o.com/wallet/api#Credit) +[https://m3o.com/wallet/api#Create](https://m3o.com/wallet/api#Create) ```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 +// Create a new wallet +async function createAnewWallet() { + const rsp = await walletService.create({ + "description": "No explanation needed", + "name": "Greatness" }) console.log(rsp) } -creditWallet() +createAnewWallet() ``` -## Transfer +## Read -Make a transfer from one wallet to another +Get wallet by id -[https://m3o.com/wallet/api#Transfer](https://m3o.com/wallet/api#Transfer) +[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) -// 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 +// Get wallet by id +async function readAwallet() { + const rsp = await walletService.read({ + "id": "b6407edd-2e26-45c0-9e2c-343689bbe5f6" }) console.log(rsp) } -transferMoney() +readAwallet() ``` -## Transactions +## Credit -List the transactions for a wallet +Add credit to a wallet -[https://m3o.com/wallet/api#Transactions](https://m3o.com/wallet/api#Transactions) +[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) -// List the transactions for a wallet -async function listTransactions() { - const rsp = await walletService.transactions({ - "id": "b6407edd-2e26-45c0-9e2c-343689bbe5f6" +// 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) } -listTransactions() +creditWallet() ``` -## Delete +## List -Delete a wallet +List your wallets -[https://m3o.com/wallet/api#Delete](https://m3o.com/wallet/api#Delete) +[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) -// Delete a wallet -async function deleteAwallet() { - const rsp = await walletService.delete({ - "id": "b6407edd-2e26-45c0-9e2c-343689bbe5f6" -}) +// List your wallets +async function listWallets() { + const rsp = await walletService.list({}) console.log(rsp) } -deleteAwallet() +listWallets() ``` diff --git a/package.json b/package.json index f91709fd..ba82ab5a 100644 --- a/package.json +++ b/package.json @@ -101,5 +101,5 @@ "prepare": "npm run build" }, "typings": "index.d.ts", - "version": "1.0.1763" + "version": "1.0.1764" } \ No newline at end of file