From 53d92d161328643674ee0821247e8a46ceb8e2ed Mon Sep 17 00:00:00 2001 From: m3o-actions <> Date: Tue, 4 Jul 2023 17:27:43 +0000 Subject: [PATCH] Commit from m3o/m3o action --- examples/app/README.md | 148 ++++++++-------- examples/bitcoin/README.md | 46 ++--- examples/cache/README.md | 48 ++--- examples/chat/README.md | 164 ++++++++--------- examples/comments/README.md | 96 +++++----- examples/contact/README.md | 182 +++++++++---------- examples/cron/README.md | 52 +++--- examples/db/README.md | 128 +++++++------- examples/evchargers/README.md | 42 ++--- examples/event/README.md | 46 ++--- examples/forex/README.md | 42 ++--- examples/function/README.md | 90 +++++----- examples/holidays/README.md | 34 ++-- examples/image/README.md | 62 +++---- examples/lists/README.md | 98 +++++------ examples/location/README.md | 58 +++--- examples/nft/README.md | 46 ++--- examples/notes/README.md | 94 +++++----- examples/price/README.md | 50 +++--- examples/rss/README.md | 64 +++---- examples/search/README.md | 46 ++--- examples/secret/README.md | 66 +++---- examples/space/README.md | 132 +++++++------- examples/stock/README.md | 46 ++--- examples/stream/README.md | 48 ++--- examples/twitter/README.md | 46 ++--- examples/url/README.md | 94 +++++----- examples/user/README.md | 320 +++++++++++++++++----------------- examples/wallet/README.md | 156 ++++++++--------- examples/youtube/README.md | 32 ++-- 30 files changed, 1288 insertions(+), 1288 deletions(-) diff --git a/examples/app/README.md b/examples/app/README.md index 5bee889c..80a0a52a 100755 --- a/examples/app/README.md +++ b/examples/app/README.md @@ -4,169 +4,168 @@ 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 +## List -Update the app. The latest source code will be downloaded, built and deployed. +List all the apps -[https://m3o.com/app/api#Update](https://m3o.com/app/api#Update) +[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) -// Update the app. The latest source code will be downloaded, built and deployed. -async function updateAnApp() { - const rsp = await appService.update({ - "name": "helloworld" -}) +// List all the apps +async function listTheApps() { + const rsp = await appService.list({}) console.log(rsp) } -updateAnApp() +listTheApps() ``` -## Logs +## Run -Get the logs for an app +Run an app from source -[https://m3o.com/app/api#Logs](https://m3o.com/app/api#Logs) +[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 the logs for an app -async function retrieveBuildLogsForAnApp() { - const rsp = await appService.logs({ - "logs_type": "build", - "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) } -retrieveBuildLogsForAnApp() +runAnApp() ``` -## Reserve +## Status -Reserve app names +Get the status of an app -[https://m3o.com/app/api#Reserve](https://m3o.com/app/api#Reserve) +[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) -// Reserve app names -async function reserveAppName() { - const rsp = await appService.reserve({ +// Get the status of an app +async function getTheStatusOfAnApp() { + const rsp = await appService.status({ "name": "helloworld" }) console.log(rsp) } -reserveAppName() +getTheStatusOfAnApp() ``` -## Get +## Resolve -Get an app by name +Resolve an app by id to its raw backend endpoint -[https://m3o.com/app/api#Get](https://m3o.com/app/api#Get) +[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 an app by name -async function getAnApp() { - const rsp = await appService.get({ - "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) } -getAnApp() +resolveAppById() ``` -## List +## Update -List all the apps +Update the app. The latest source code will be downloaded, built and deployed. -[https://m3o.com/app/api#List](https://m3o.com/app/api#List) +[https://m3o.com/app/api#Update](https://m3o.com/app/api#Update) ```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({}) +// Update the app. The latest source code will be downloaded, built and deployed. +async function updateAnApp() { + const rsp = await appService.update({ + "name": "helloworld" +}) console.log(rsp) } -listTheApps() +updateAnApp() ``` -## Run +## Reserve -Run an app from source +Reserve app names -[https://m3o.com/app/api#Run](https://m3o.com/app/api#Run) +[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) -// 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" +// Reserve app names +async function reserveAppName() { + const rsp = await appService.reserve({ + "name": "helloworld" }) console.log(rsp) } -runAnApp() +reserveAppName() ``` ## Regions @@ -189,49 +188,50 @@ async function listRegions() { listRegions() ``` -## Resolve +## Delete -Resolve an app by id to its raw backend endpoint +Delete an app -[https://m3o.com/app/api#Resolve](https://m3o.com/app/api#Resolve) +[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) -// Resolve an app by id to its raw backend endpoint -async function resolveAppById() { - const rsp = await appService.resolve({ - "id": "helloworld" +// Delete an app +async function deleteAnApp() { + const rsp = await appService.delete({ + "name": "helloworld" }) console.log(rsp) } -resolveAppById() +deleteAnApp() ``` -## 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() ``` diff --git a/examples/bitcoin/README.md b/examples/bitcoin/README.md index 827c3ba6..fd98d2a9 100755 --- a/examples/bitcoin/README.md +++ b/examples/bitcoin/README.md @@ -4,29 +4,6 @@ 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 @@ -96,3 +73,26 @@ 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 6661d20a..f8ee9f41 100755 --- a/examples/cache/README.md +++ b/examples/cache/README.md @@ -4,6 +4,30 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Cache/api](htt Endpoints: +## Increment + +Increment a value (if it's a number). If key not found it is equivalent to set. + + +[https://m3o.com/cache/api#Increment](https://m3o.com/cache/api#Increment) + +```js +const { CacheService } = require('m3o/cache'); + +const cacheService = new CacheService(process.env.M3O_API_TOKEN) + +// Increment a value (if it's a number). If key not found it is equivalent to set. +async function incrementAvalue() { + const rsp = await cacheService.increment({ + "key": "counter", + "value": 2 +}) + console.log(rsp) + +} + +incrementAvalue() +``` ## Decrement Decrement a value (if it's a number). If key not found it is equivalent to set. @@ -119,27 +143,3 @@ async function deleteAvalue() { deleteAvalue() ``` -## Increment - -Increment a value (if it's a number). If key not found it is equivalent to set. - - -[https://m3o.com/cache/api#Increment](https://m3o.com/cache/api#Increment) - -```js -const { CacheService } = require('m3o/cache'); - -const cacheService = new CacheService(process.env.M3O_API_TOKEN) - -// Increment a value (if it's a number). If key not found it is equivalent to set. -async function incrementAvalue() { - const rsp = await cacheService.increment({ - "key": "counter", - "value": 2 -}) - console.log(rsp) - -} - -incrementAvalue() -``` diff --git a/examples/chat/README.md b/examples/chat/README.md index e7cf0e0a..e7202ac7 100755 --- a/examples/chat/README.md +++ b/examples/chat/README.md @@ -4,29 +4,49 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Chat/api](http Endpoints: -## Invite +## List -Invite a user to a group +List available chats -[https://m3o.com/chat/api#Invite](https://m3o.com/chat/api#Invite) +[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) -// Invite a user to a group -async function inviteAuser() { - const rsp = await chatService.invite({ - "group_id": "d8057208-f81a-4e14-ad7f-c29daa2bb910", - "user_id": "user-1" +// List available chats +async function listGroups() { + const rsp = await chatService.list({}) + console.log(rsp) + +} + +listGroups() +``` +## 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) } -inviteAuser() +getChatHistory() ``` ## Join @@ -53,141 +73,116 @@ async function joinAgroup() { joinAgroup() ``` -## 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() -``` -## 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() +kickAuserFromAgroup() ``` -## Delete +## Leave -Delete a group +Leave a group -[https://m3o.com/chat/api#Delete](https://m3o.com/chat/api#Delete) +[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) -// Delete a group -async function deleteAchat() { - const rsp = await chatService.delete({ - "group_id": "d8057208-f81a-4e14-ad7f-c29daa2bb910" +// Leave a group +async function leaveAgroup() { + const rsp = await chatService.leave({ + "group_id": "d8057208-f81a-4e14-ad7f-c29daa2bb910", + "user_id": "user-1" }) console.log(rsp) } -deleteAchat() +leaveAgroup() ``` -## Send +## Create -Connect to a chat to receive a stream of messages -Send a message to a chat +Create a new group -[https://m3o.com/chat/api#Send](https://m3o.com/chat/api#Send) +[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) -// Connect to a chat to receive a stream of messages -// Send a message to a chat -async function sendAmessage() { - const rsp = await chatService.send({ - "client": "web", - "group_id": "d8057208-f81a-4e14-ad7f-c29daa2bb910", - "subject": "Random", - "text": "Hey whats up?", - "user_id": "user-1" +// Create a new group +async function createAnewChat() { + const rsp = await chatService.create({ + "description": "The general group", + "name": "general" }) console.log(rsp) } -sendAmessage() +createAnewChat() ``` -## History +## Delete -List the messages in a chat +Delete a group -[https://m3o.com/chat/api#History](https://m3o.com/chat/api#History) +[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) -// List the messages in a chat -async function getChatHistory() { - const rsp = await chatService.history({ +// Delete a group +async function deleteAchat() { + const rsp = await chatService.delete({ "group_id": "d8057208-f81a-4e14-ad7f-c29daa2bb910" }) console.log(rsp) } -getChatHistory() +deleteAchat() ``` -## Kick +## Invite -Kick a user from a group +Invite a user to a group -[https://m3o.com/chat/api#Kick](https://m3o.com/chat/api#Kick) +[https://m3o.com/chat/api#Invite](https://m3o.com/chat/api#Invite) ```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({ +// Invite a user to a group +async function inviteAuser() { + const rsp = await chatService.invite({ "group_id": "d8057208-f81a-4e14-ad7f-c29daa2bb910", "user_id": "user-1" }) @@ -195,29 +190,34 @@ async function kickAuserFromAgroup() { } -kickAuserFromAgroup() +inviteAuser() ``` -## Leave +## Send -Leave a group +Connect to a chat to receive a stream of messages +Send a message to a chat -[https://m3o.com/chat/api#Leave](https://m3o.com/chat/api#Leave) +[https://m3o.com/chat/api#Send](https://m3o.com/chat/api#Send) ```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({ +// Connect to a chat to receive a stream of messages +// Send a message to a chat +async function sendAmessage() { + const rsp = await chatService.send({ + "client": "web", "group_id": "d8057208-f81a-4e14-ad7f-c29daa2bb910", + "subject": "Random", + "text": "Hey whats up?", "user_id": "user-1" }) console.log(rsp) } -leaveAgroup() +sendAmessage() ``` diff --git a/examples/comments/README.md b/examples/comments/README.md index 6d2582c5..ad68812a 100755 --- a/examples/comments/README.md +++ b/examples/comments/README.md @@ -4,6 +4,54 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Comments/api]( Endpoints: +## Events + +Subscribe to comments events + + +[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) + +// Subscribe to comments events +async function subscribeToEvents() { + const rsp = await commentsService.events({ + "id": "63c0cdf8-2121-11ec-a881-0242e36f037a" +}) + rsp.onMessage(msg => { + console.log(msg) + }) +} + +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() +``` ## Read Read a comment @@ -98,51 +146,3 @@ async function deleteAcomment() { deleteAcomment() ``` -## Events - -Subscribe to comments events - - -[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) - -// Subscribe to comments events -async function subscribeToEvents() { - const rsp = await commentsService.events({ - "id": "63c0cdf8-2121-11ec-a881-0242e36f037a" -}) - rsp.onMessage(msg => { - console.log(msg) - }) -} - -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/contact/README.md b/examples/contact/README.md index a1ad58d2..b57305a3 100755 --- a/examples/contact/README.md +++ b/examples/contact/README.md @@ -4,97 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Contact/api](h Endpoints: -## Read - -Read contact details - - -[https://m3o.com/contact/api#Read](https://m3o.com/contact/api#Read) - -```js -const { ContactService } = require('m3o/contact'); - -const contactService = new ContactService(process.env.M3O_API_TOKEN) - -// Read contact details -async function getAcontact() { - const rsp = await contactService.read({ - "id": "42e48a3c-6221-11ec-96d2-acde48001122" -}) - console.log(rsp) - -} - -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() -``` ## Create Create a contact @@ -230,3 +139,94 @@ async function updateAcontact() { updateAcontact() ``` +## Read + +Read contact details + + +[https://m3o.com/contact/api#Read](https://m3o.com/contact/api#Read) + +```js +const { ContactService } = require('m3o/contact'); + +const contactService = new ContactService(process.env.M3O_API_TOKEN) + +// Read contact details +async function getAcontact() { + const rsp = await contactService.read({ + "id": "42e48a3c-6221-11ec-96d2-acde48001122" +}) + console.log(rsp) + +} + +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 6794e6d0..5d3b8f8d 100755 --- a/examples/cron/README.md +++ b/examples/cron/README.md @@ -4,6 +4,32 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Cron/api](http Endpoints: +## Schedule + +Schedule a cron job + + +[https://m3o.com/cron/api#Schedule](https://m3o.com/cron/api#Schedule) + +```js +const { CronService } = require('m3o/cron'); + +const cronService = new CronService(process.env.M3O_API_TOKEN) + +// Schedule a cron job +async function scheduleAjob() { + const rsp = await cronService.schedule({ + "callback": "https://google.com", + "description": "testing", + "interval": "* * * * *", + "name": "test" +}) + console.log(rsp) + +} + +scheduleAjob() +``` ## Delete Delete a cron job @@ -48,29 +74,3 @@ async function listJobs() { listJobs() ``` -## Schedule - -Schedule a cron job - - -[https://m3o.com/cron/api#Schedule](https://m3o.com/cron/api#Schedule) - -```js -const { CronService } = require('m3o/cron'); - -const cronService = new CronService(process.env.M3O_API_TOKEN) - -// Schedule a cron job -async function scheduleAjob() { - const rsp = await cronService.schedule({ - "callback": "https://google.com", - "description": "testing", - "interval": "* * * * *", - "name": "test" -}) - console.log(rsp) - -} - -scheduleAjob() -``` diff --git a/examples/db/README.md b/examples/db/README.md index af398b87..37e041f9 100755 --- a/examples/db/README.md +++ b/examples/db/README.md @@ -4,27 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Db/api](https: Endpoints: -## ListTables - -List tables in the DB - - -[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) - -// List tables in the DB -async function listTables() { - const rsp = await dbService.listTables({}) - console.log(rsp) - -} - -listTables() -``` ## RenameTable Rename a table @@ -49,28 +28,34 @@ async function renameTable() { renameTable() ``` -## Count +## Create -Count 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#Count](https://m3o.com/db/api#Count) +[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) -// Count records in a table -async function countEntriesInAtable() { - const rsp = await dbService.count({ +// 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) } -countEntriesInAtable() +createArecord() ``` ## Update @@ -99,76 +84,97 @@ async function updateArecord() { updateArecord() ``` -## Read +## Delete -Read data from a table. Lookup can be by ID or via querying any field in the record. +Delete a record in the database by id. -[https://m3o.com/db/api#Read](https://m3o.com/db/api#Read) +[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) -// 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", +// Delete a record in the database by id. +async function deleteArecord() { + const rsp = await dbService.delete({ + "id": "1", "table": "example" }) console.log(rsp) } -readRecords() +deleteArecord() ``` -## Delete +## Truncate -Delete a record in the database by id. +Truncate the records in a table -[https://m3o.com/db/api#Delete](https://m3o.com/db/api#Delete) +[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) -// Delete a record in the database by id. -async function deleteArecord() { - const rsp = await dbService.delete({ - "id": "1", +// Truncate the records in a table +async function truncateTable() { + const rsp = await dbService.truncate({ "table": "example" }) console.log(rsp) } -deleteArecord() +truncateTable() ``` -## Truncate +## ListTables -Truncate the records in a table +List tables in the DB -[https://m3o.com/db/api#Truncate](https://m3o.com/db/api#Truncate) +[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) -// Truncate the records in a table -async function truncateTable() { - const rsp = await dbService.truncate({ +// List tables in the DB +async function listTables() { + const rsp = await dbService.listTables({}) + console.log(rsp) + +} + +listTables() +``` +## Read + +Read data from a table. Lookup can be by ID or via querying any field in the record. + + +[https://m3o.com/db/api#Read](https://m3o.com/db/api#Read) + +```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", "table": "example" }) console.log(rsp) } -truncateTable() +readRecords() ``` ## DropTable @@ -193,32 +199,26 @@ async function dropTable() { dropTable() ``` -## Create +## Count -Create a record in the database. Optionally include an "id" field otherwise it's set automatically. +Count records in a table -[https://m3o.com/db/api#Create](https://m3o.com/db/api#Create) +[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) -// 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" - }, +// Count records in a table +async function countEntriesInAtable() { + const rsp = await dbService.count({ "table": "example" }) console.log(rsp) } -createArecord() +countEntriesInAtable() ``` diff --git a/examples/evchargers/README.md b/examples/evchargers/README.md index a4e49f39..56eccdf3 100755 --- a/examples/evchargers/README.md +++ b/examples/evchargers/README.md @@ -4,6 +4,27 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Evchargers/api Endpoints: +## ReferenceData + +Retrieve reference data as used by this API and in conjunction with the Search endpoint + + +[https://m3o.com/evchargers/api#ReferenceData](https://m3o.com/evchargers/api#ReferenceData) + +```js +const { EvchargersService } = require('m3o/evchargers'); + +const evchargersService = new EvchargersService(process.env.M3O_API_TOKEN) + +// Retrieve reference data as used by this API and in conjunction with the Search endpoint +async function getReferenceData() { + const rsp = await evchargersService.referenceData({}) + console.log(rsp) + +} + +getReferenceData() +``` ## Search Search by giving a coordinate and a max distance, or bounding box and optional filters @@ -96,24 +117,3 @@ async function searchWithFiltersFastChargersOnly() { searchWithFiltersFastChargersOnly() ``` -## ReferenceData - -Retrieve reference data as used by this API and in conjunction with the Search endpoint - - -[https://m3o.com/evchargers/api#ReferenceData](https://m3o.com/evchargers/api#ReferenceData) - -```js -const { EvchargersService } = require('m3o/evchargers'); - -const evchargersService = new EvchargersService(process.env.M3O_API_TOKEN) - -// Retrieve reference data as used by this API and in conjunction with the Search endpoint -async function getReferenceData() { - const rsp = await evchargersService.referenceData({}) - console.log(rsp) - -} - -getReferenceData() -``` diff --git a/examples/event/README.md b/examples/event/README.md index 1485d9a4..c429dcde 100755 --- a/examples/event/README.md +++ b/examples/event/README.md @@ -4,6 +4,29 @@ 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. @@ -56,26 +79,3 @@ 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/forex/README.md b/examples/forex/README.md index 43a888dd..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: -## History +## Price -Returns the data for the previous close +Get the latest price for a given forex ticker -[https://m3o.com/forex/api#History](https://m3o.com/forex/api#History) +[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) -// Returns the data for the previous close -async function getPreviousClose() { - const rsp = await forexService.history({ +// Get the latest price for a given forex ticker +async function getAnFxPrice() { + const rsp = await forexService.price({ "symbol": "GBPUSD" }) console.log(rsp) } -getPreviousClose() +getAnFxPrice() ``` -## Price +## Quote -Get the latest price for a given forex ticker +Get the latest quote for the forex -[https://m3o.com/forex/api#Price](https://m3o.com/forex/api#Price) +[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) -// Get the latest price for a given forex ticker -async function getAnFxPrice() { - const rsp = await forexService.price({ +// Get the latest quote for the forex +async function getAfxQuote() { + const rsp = await forexService.quote({ "symbol": "GBPUSD" }) console.log(rsp) } -getAnFxPrice() +getAfxQuote() ``` -## Quote +## History -Get the latest quote for the forex +Returns the data for the previous close -[https://m3o.com/forex/api#Quote](https://m3o.com/forex/api#Quote) +[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 quote for the forex -async function getAfxQuote() { - const rsp = await forexService.quote({ +// Returns the data for the previous close +async function getPreviousClose() { + const rsp = await forexService.history({ "symbol": "GBPUSD" }) console.log(rsp) } -getAfxQuote() +getPreviousClose() ``` diff --git a/examples/function/README.md b/examples/function/README.md index 020bc3d9..1f48431d 100755 --- a/examples/function/README.md +++ b/examples/function/README.md @@ -30,28 +30,49 @@ async function callAfunction() { callAfunction() ``` -## Delete +## List -Delete a function by name +List all the deployed functions -[https://m3o.com/function/api#Delete](https://m3o.com/function/api#Delete) +[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) -// Delete a function by name -async function deleteAfunction() { - const rsp = await functionService.delete({ - "name": "helloworld" +// List all the deployed functions +async function listFunctions() { + const rsp = await functionService.list({}) + console.log(rsp) + +} + +listFunctions() +``` +## Proxy + +Return the backend url for proxying + + +[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 the backend url for proxying +async function proxyUrl() { + const rsp = await functionService.proxy({ + "id": "helloworld" }) console.log(rsp) } -deleteAfunction() +proxyUrl() ``` ## Describe @@ -141,28 +162,29 @@ async function listRuntimes() { listRuntimes() ``` -## Proxy +## Logs -Return the backend url for proxying +Get the logs for a function -[https://m3o.com/function/api#Proxy](https://m3o.com/function/api#Proxy) +[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) -// Return the backend url for proxying -async function proxyUrl() { - const rsp = await functionService.proxy({ - "id": "helloworld" +// Get the logs for a function +async function retrieveBuildLogsForAfunction() { + const rsp = await functionService.logs({ + "logs_type": "build", + "name": "helloworld" }) console.log(rsp) } -proxyUrl() +retrieveBuildLogsForAfunction() ``` ## Deploy @@ -216,48 +238,26 @@ async function updateAfunction() { updateAfunction() ``` -## List - -List all the deployed functions - - -[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) - -// List all the deployed functions -async function listFunctions() { - const rsp = await functionService.list({}) - console.log(rsp) - -} - -listFunctions() -``` -## Logs +## Delete -Get the logs for a function +Delete a function by name -[https://m3o.com/function/api#Logs](https://m3o.com/function/api#Logs) +[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) -// Get the logs for a function -async function retrieveBuildLogsForAfunction() { - const rsp = await functionService.logs({ - "logs_type": "build", +// Delete a function by name +async function deleteAfunction() { + const rsp = await functionService.delete({ "name": "helloworld" }) console.log(rsp) } -retrieveBuildLogsForAfunction() +deleteAfunction() ``` 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 d7598adc..e35b2a5c 100755 --- a/examples/image/README.md +++ b/examples/image/README.md @@ -4,37 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Image/api](htt Endpoints: -## Convert - -Convert an image from one format (jpeg, png etc.) to an other either on the fly (from base64 to base64), -or by uploading the conversion result. -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) - -```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. -// 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) - -} - -convertApngImageToAjpegTakenFromAurlAndSavedToAurlOnMicrosCdn() -``` ## Upload Upload an image by either sending a base64 encoded image to this endpoint or a URL. @@ -223,3 +192,34 @@ async function base64toBase64imageWithCropping() { base64toBase64imageWithCropping() ``` +## Convert + +Convert an image from one format (jpeg, png etc.) to an other either on the fly (from base64 to base64), +or by uploading the conversion result. +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) + +```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. +// 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) + +} + +convertApngImageToAjpegTakenFromAurlAndSavedToAurlOnMicrosCdn() +``` diff --git a/examples/lists/README.md b/examples/lists/README.md index 810805e7..3a3b5511 100755 --- a/examples/lists/README.md +++ b/examples/lists/README.md @@ -4,6 +4,55 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Lists/api](htt Endpoints: +## Create + +Create a new list + + +[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) + +// Create a new list +async function createAlist() { + const rsp = await listsService.create({ + "items": [ + "This is my list" + ], + "name": "New List" +}) + console.log(rsp) + +} + +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 @@ -101,52 +150,3 @@ async function subscribeToEvents() { subscribeToEvents() ``` -## Create - -Create a new list - - -[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) - -// Create a new list -async function createAlist() { - const rsp = await listsService.create({ - "items": [ - "This is my list" - ], - "name": "New List" -}) - console.log(rsp) - -} - -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() -``` diff --git a/examples/location/README.md b/examples/location/README.md index 60cafca8..2098c1e4 100755 --- a/examples/location/README.md +++ b/examples/location/README.md @@ -4,6 +4,35 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Location/api]( Endpoints: +## Search + +Search for entities in a given radius + + +[https://m3o.com/location/api#Search](https://m3o.com/location/api#Search) + +```js +const { LocationService } = require('m3o/location'); + +const locationService = new LocationService(process.env.M3O_API_TOKEN) + +// Search for entities in a given radius +async function searchForLocations() { + const rsp = await locationService.search({ + "center": { + "latitude": 51.511061, + "longitude": -0.120022 + }, + "limit": 10, + "radius": 100, + "type": "bike" +}) + console.log(rsp) + +} + +searchForLocations() +``` ## Save Save an entity's current position @@ -58,32 +87,3 @@ async function getLocationById() { getLocationById() ``` -## Search - -Search for entities in a given radius - - -[https://m3o.com/location/api#Search](https://m3o.com/location/api#Search) - -```js -const { LocationService } = require('m3o/location'); - -const locationService = new LocationService(process.env.M3O_API_TOKEN) - -// Search for entities in a given radius -async function searchForLocations() { - const rsp = await locationService.search({ - "center": { - "latitude": 51.511061, - "longitude": -0.120022 - }, - "limit": 10, - "radius": 100, - "type": "bike" -}) - console.log(rsp) - -} - -searchForLocations() -``` diff --git a/examples/nft/README.md b/examples/nft/README.md index bcc318ec..727b7f01 100755 --- a/examples/nft/README.md +++ b/examples/nft/README.md @@ -4,6 +4,29 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Nft/api](https Endpoints: +## Collection + +Get a collection by its slug + + +[https://m3o.com/nft/api#Collection](https://m3o.com/nft/api#Collection) + +```js +const { NftService } = require('m3o/nft'); + +const nftService = new NftService(process.env.M3O_API_TOKEN) + +// Get a collection by its slug +async function getAsingleCollection() { + const rsp = await nftService.collection({ + "slug": "doodles-official" +}) + console.log(rsp) + +} + +getAsingleCollection() +``` ## Assets Return a list of assets @@ -99,26 +122,3 @@ async function getAsingleAsset() { getAsingleAsset() ``` -## Collection - -Get a collection by its slug - - -[https://m3o.com/nft/api#Collection](https://m3o.com/nft/api#Collection) - -```js -const { NftService } = require('m3o/nft'); - -const nftService = new NftService(process.env.M3O_API_TOKEN) - -// Get a collection by its slug -async function getAsingleCollection() { - const rsp = await nftService.collection({ - "slug": "doodles-official" -}) - console.log(rsp) - -} - -getAsingleCollection() -``` diff --git a/examples/notes/README.md b/examples/notes/README.md index 7fc48a52..8eb9ce6e 100755 --- a/examples/notes/README.md +++ b/examples/notes/README.md @@ -4,53 +4,6 @@ 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 @@ -146,3 +99,50 @@ 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/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 093309f2..ced89e6a 100755 --- a/examples/rss/README.md +++ b/examples/rss/README.md @@ -4,95 +4,95 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Rss/api](https Endpoints: -## List +## Add -List the saved RSS fields +Add a new RSS feed with a name, url, and category -[https://m3o.com/rss/api#List](https://m3o.com/rss/api#List) +[https://m3o.com/rss/api#Add](https://m3o.com/rss/api#Add) ```js const { RssService } = require('m3o/rss'); const rssService = new RssService(process.env.M3O_API_TOKEN) -// List the saved RSS fields -async function listRssFeeds() { - const rsp = await rssService.list({}) +// Add a new RSS feed with a name, url, and category +async function addAnewFeed() { + const rsp = await rssService.add({ + "category": "news", + "name": "bbc", + "url": "http://feeds.bbci.co.uk/news/rss.xml" +}) console.log(rsp) } -listRssFeeds() +addAnewFeed() ``` -## Remove +## Feed -Remove an RSS feed by name +Get an RSS feed by name. If no name is given, all feeds are returned. Default limit is 25 entries. -[https://m3o.com/rss/api#Remove](https://m3o.com/rss/api#Remove) +[https://m3o.com/rss/api#Feed](https://m3o.com/rss/api#Feed) ```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({ +// Get an RSS feed by name. If no name is given, all feeds are returned. Default limit is 25 entries. +async function readAfeed() { + const rsp = await rssService.feed({ "name": "bbc" }) console.log(rsp) } -removeAfeed() +readAfeed() ``` -## Add +## List -Add a new RSS feed with a name, url, and category +List the saved RSS fields -[https://m3o.com/rss/api#Add](https://m3o.com/rss/api#Add) +[https://m3o.com/rss/api#List](https://m3o.com/rss/api#List) ```js const { RssService } = require('m3o/rss'); const rssService = new RssService(process.env.M3O_API_TOKEN) -// Add a new RSS feed with a name, url, and category -async function addAnewFeed() { - const rsp = await rssService.add({ - "category": "news", - "name": "bbc", - "url": "http://feeds.bbci.co.uk/news/rss.xml" -}) +// List the saved RSS fields +async function listRssFeeds() { + const rsp = await rssService.list({}) console.log(rsp) } -addAnewFeed() +listRssFeeds() ``` -## Feed +## Remove -Get an RSS feed by name. If no name is given, all feeds are returned. Default limit is 25 entries. +Remove an RSS feed by name -[https://m3o.com/rss/api#Feed](https://m3o.com/rss/api#Feed) +[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) -// Get an RSS feed by name. If no name is given, all feeds are returned. Default limit is 25 entries. -async function readAfeed() { - const rsp = await rssService.feed({ +// Remove an RSS feed by name +async function removeAfeed() { + const rsp = await rssService.remove({ "name": "bbc" }) console.log(rsp) } -readAfeed() +removeAfeed() ``` diff --git a/examples/search/README.md b/examples/search/README.md index 670768ef..7cc79d42 100755 --- a/examples/search/README.md +++ b/examples/search/README.md @@ -4,29 +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 @@ -174,3 +151,26 @@ 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() +``` diff --git a/examples/secret/README.md b/examples/secret/README.md index bcc5dd8a..44dfa37a 100755 --- a/examples/secret/README.md +++ b/examples/secret/README.md @@ -4,94 +4,94 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Secret/api](ht Endpoints: -## Set +## Delete -Set a secret. Overwrites any existing value already set. +Delete a secret. If key not found a success response is returned. -[https://m3o.com/secret/api#Set](https://m3o.com/secret/api#Set) +[https://m3o.com/secret/api#Delete](https://m3o.com/secret/api#Delete) ```js const { SecretService } = require('m3o/secret'); const secretService = new SecretService(process.env.M3O_API_TOKEN) -// Set a secret. Overwrites any existing value already set. -async function setAvalue() { - const rsp = await secretService.set({ - "key": "foo", - "value": "bar" +// Delete a secret. If key not found a success response is returned. +async function deleteAvalue() { + const rsp = await secretService.delete({ + "key": "foo" }) console.log(rsp) } -setAvalue() +deleteAvalue() ``` -## Get +## List -Get a secret by key. +List all the available secrets -[https://m3o.com/secret/api#Get](https://m3o.com/secret/api#Get) +[https://m3o.com/secret/api#List](https://m3o.com/secret/api#List) ```js const { SecretService } = require('m3o/secret'); const secretService = new SecretService(process.env.M3O_API_TOKEN) -// Get a secret by key. -async function getAvalue() { - const rsp = await secretService.get({ - "key": "foo" -}) +// List all the available secrets +async function listAllSecrets() { + const rsp = await secretService.list({}) console.log(rsp) } -getAvalue() +listAllSecrets() ``` -## Delete +## Set -Delete a secret. If key not found a success response is returned. +Set a secret. Overwrites any existing value already set. -[https://m3o.com/secret/api#Delete](https://m3o.com/secret/api#Delete) +[https://m3o.com/secret/api#Set](https://m3o.com/secret/api#Set) ```js const { SecretService } = require('m3o/secret'); const secretService = new SecretService(process.env.M3O_API_TOKEN) -// Delete a secret. If key not found a success response is returned. -async function deleteAvalue() { - const rsp = await secretService.delete({ - "key": "foo" +// Set a secret. Overwrites any existing value already set. +async function setAvalue() { + const rsp = await secretService.set({ + "key": "foo", + "value": "bar" }) console.log(rsp) } -deleteAvalue() +setAvalue() ``` -## List +## Get -List all the available secrets +Get a secret by key. -[https://m3o.com/secret/api#List](https://m3o.com/secret/api#List) +[https://m3o.com/secret/api#Get](https://m3o.com/secret/api#Get) ```js const { SecretService } = require('m3o/secret'); const secretService = new SecretService(process.env.M3O_API_TOKEN) -// List all the available secrets -async function listAllSecrets() { - const rsp = await secretService.list({}) +// Get a secret by key. +async function getAvalue() { + const rsp = await secretService.get({ + "key": "foo" +}) console.log(rsp) } -listAllSecrets() +getAvalue() ``` diff --git a/examples/space/README.md b/examples/space/README.md index 6cc54331..af558ad4 100755 --- a/examples/space/README.md +++ b/examples/space/README.md @@ -4,191 +4,191 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Space/api](htt Endpoints: -## Read +## Update -Read an object in space +Update an object. If an object with this name does not exist, creates a new one. -[https://m3o.com/space/api#Read](https://m3o.com/space/api#Read) +[https://m3o.com/space/api#Update](https://m3o.com/space/api#Update) ```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" +// Update an object. If an object with this name does not exist, creates a new one. +async function updateAnObject() { + const rsp = await spaceService.update({ + "name": "images/file.jpg", + "object": "\u003cfile bytes\u003e", + "visibility": "public" }) console.log(rsp) } -readAnObject() +updateAnObject() ``` -## Download +## Delete -Download an object via a presigned url +Delete an object from space -[https://m3o.com/space/api#Download](https://m3o.com/space/api#Download) +[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) -// Download an object via a presigned url -async function downloadAnObject() { - const rsp = await spaceService.download({ +// Delete an object from space +async function deleteAnObject() { + const rsp = await spaceService.delete({ "name": "images/file.jpg" }) console.log(rsp) } -downloadAnObject() +deleteAnObject() ``` -## Upload +## List -Upload a large object (> 10MB). Returns a time limited presigned URL to be used for uploading the object +List the objects in space -[https://m3o.com/space/api#Upload](https://m3o.com/space/api#Upload) +[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) -// Upload a large object (> 10MB). Returns a time limited presigned URL to be used for uploading the object -async function uploadAnObject() { - const rsp = await spaceService.upload({ - "name": "images/file.jpg" +// List the objects in space +async function listObjectsWithPrefix() { + const rsp = await spaceService.list({ + "prefix": "images/" }) console.log(rsp) } -uploadAnObject() +listObjectsWithPrefix() ``` -## Create +## Head -Create an object. Returns error if object with this name already exists. Max object size of 10MB, see Upload endpoint for larger objects. If you want to update an existing object use the `Update` endpoint +Retrieve meta information about an object -[https://m3o.com/space/api#Create](https://m3o.com/space/api#Create) +[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) -// Create an object. Returns error if object with this name already exists. Max object size of 10MB, see Upload endpoint for larger objects. If you want to update an existing object use the `Update` endpoint -async function createAnObject() { - const rsp = await spaceService.create({ - "name": "images/file.jpg", - "object": "\u003cfile bytes\u003e", - "visibility": "public" +// Retrieve meta information about an object +async function headAnObject() { + const rsp = await spaceService.head({ + "name": "images/file.jpg" }) console.log(rsp) } -createAnObject() +headAnObject() ``` -## Update +## Read -Update an object. If an object with this name does not exist, creates a new one. +Read an object in space -[https://m3o.com/space/api#Update](https://m3o.com/space/api#Update) +[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) -// Update an object. If an object with this name does not exist, creates a new one. -async function updateAnObject() { - const rsp = await spaceService.update({ - "name": "images/file.jpg", - "object": "\u003cfile bytes\u003e", - "visibility": "public" +// Read an object in space +async function readAnObject() { + const rsp = await spaceService.read({ + "name": "images/file.jpg" }) console.log(rsp) } -updateAnObject() +readAnObject() ``` -## Delete +## Download -Delete an object from space +Download an object via a presigned url -[https://m3o.com/space/api#Delete](https://m3o.com/space/api#Delete) +[https://m3o.com/space/api#Download](https://m3o.com/space/api#Download) ```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({ +// Download an object via a presigned url +async function downloadAnObject() { + const rsp = await spaceService.download({ "name": "images/file.jpg" }) console.log(rsp) } -deleteAnObject() +downloadAnObject() ``` -## List +## Upload -List the objects in space +Upload a large object (> 10MB). Returns a time limited presigned URL to be used for uploading the object -[https://m3o.com/space/api#List](https://m3o.com/space/api#List) +[https://m3o.com/space/api#Upload](https://m3o.com/space/api#Upload) ```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/" +// Upload a large object (> 10MB). Returns a time limited presigned URL to be used for uploading the object +async function uploadAnObject() { + const rsp = await spaceService.upload({ + "name": "images/file.jpg" }) console.log(rsp) } -listObjectsWithPrefix() +uploadAnObject() ``` -## Head +## Create -Retrieve meta information about an object +Create an object. Returns error if object with this name already exists. Max object size of 10MB, see Upload endpoint for larger objects. If you want to update an existing object use the `Update` endpoint -[https://m3o.com/space/api#Head](https://m3o.com/space/api#Head) +[https://m3o.com/space/api#Create](https://m3o.com/space/api#Create) ```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" +// Create an object. Returns error if object with this name already exists. Max object size of 10MB, see Upload endpoint for larger objects. If you want to update an existing object use the `Update` endpoint +async function createAnObject() { + const rsp = await spaceService.create({ + "name": "images/file.jpg", + "object": "\u003cfile bytes\u003e", + "visibility": "public" }) console.log(rsp) } -headAnObject() +createAnObject() ``` 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 e57eb59b..0e2822f2 100755 --- a/examples/stream/README.md +++ b/examples/stream/README.md @@ -4,30 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Stream/api](ht Endpoints: -## CreateChannel - -Create a channel by name - - -[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) - -// Create a channel by name -async function createChannel() { - const rsp = await streamService.createChannel({ - "description": "The channel for all things", - "name": "general" -}) - console.log(rsp) - -} - -createChannel() -``` ## SendMessage Send a message to the stream. @@ -96,3 +72,27 @@ async function listChannels() { listChannels() ``` +## CreateChannel + +Create a channel by name + + +[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) + +// Create a channel by name +async function createChannel() { + const rsp = await streamService.createChannel({ + "description": "The channel for all things", + "name": "general" +}) + console.log(rsp) + +} + +createChannel() +``` diff --git a/examples/twitter/README.md b/examples/twitter/README.md index 7d6c875d..1a98ed83 100755 --- a/examples/twitter/README.md +++ b/examples/twitter/README.md @@ -4,6 +4,29 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Twitter/api](h Endpoints: +## User + +Get a user's twitter profile + + +[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) + +// Get a user's twitter profile +async function getAusersTwitterProfile() { + const rsp = await twitterService.user({ + "username": "crufter" +}) + console.log(rsp) + +} + +getAusersTwitterProfile() +``` ## Timeline Get the timeline for a given user @@ -72,26 +95,3 @@ async function getTheCurrentGlobalTrendingTopics() { getTheCurrentGlobalTrendingTopics() ``` -## User - -Get a user's twitter profile - - -[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) - -// Get a user's twitter profile -async function getAusersTwitterProfile() { - const rsp = await twitterService.user({ - "username": "crufter" -}) - console.log(rsp) - -} - -getAusersTwitterProfile() -``` diff --git a/examples/url/README.md b/examples/url/README.md index 06127cea..9598cf63 100755 --- a/examples/url/README.md +++ b/examples/url/README.md @@ -4,6 +4,53 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Url/api](https Endpoints: +## 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 + + +[https://m3o.com/url/api#Shorten](https://m3o.com/url/api#Shorten) + +```js +const { UrlService } = require('m3o/url'); + +const urlService = new UrlService(process.env.M3O_API_TOKEN) + +// Shorten a URL +async function shortenAlongUrl() { + const rsp = await urlService.shorten({ + "destinationURL": "https://mysite.com/this-is-a-rather-long-web-address" +}) + console.log(rsp) + +} + +shortenAlongUrl() +``` ## Resolve Resolve returns the destination URL of a short URL. @@ -95,50 +142,3 @@ async function listYourShortenedUrls() { 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 - - -[https://m3o.com/url/api#Shorten](https://m3o.com/url/api#Shorten) - -```js -const { UrlService } = require('m3o/url'); - -const urlService = new UrlService(process.env.M3O_API_TOKEN) - -// Shorten a URL -async function shortenAlongUrl() { - const rsp = await urlService.shorten({ - "destinationURL": "https://mysite.com/this-is-a-rather-long-web-address" -}) - console.log(rsp) - -} - -shortenAlongUrl() -``` diff --git a/examples/user/README.md b/examples/user/README.md index 394bb339..4bac0a32 100755 --- a/examples/user/README.md +++ b/examples/user/README.md @@ -4,56 +4,77 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/User/api](http Endpoints: -## SendPasswordResetEmail +## Delete -Send an email with a verification code to reset password. -Call "ResetPassword" endpoint once user provides the code. +Delete an account by id -[https://m3o.com/user/api#SendPasswordResetEmail](https://m3o.com/user/api#SendPasswordResetEmail) +[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) -// 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({ +// Delete an account by id +async function deleteUserAccount() { + const rsp = await userService.delete({ + "id": "8b98acbe-0b6a-4d66-a414-5ffbf666786f" +}) + console.log(rsp) + +} + +deleteUserAccount() +``` +## Login + +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#Login](https://m3o.com/user/api#Login) + +```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", - "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() ``` -## ReadSession +## Logout -Read a session by the session id. In the event it has expired or is not found and error is returned. +Logout a user account -[https://m3o.com/user/api#ReadSession](https://m3o.com/user/api#ReadSession) +[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) -// 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({ +// Logout a user account +async function logAuserOut() { + const rsp = await userService.logout({ "sessionId": "df91a612-5b24-4634-99ff-240220ab8f55" }) console.log(rsp) } -readAsessionByTheSessionId() +logAuserOut() ``` ## List @@ -79,232 +100,232 @@ async function listAllUsers() { listAllUsers() ``` -## VerifyToken +## Create -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. +Create a new user account. The email address and username for the account must be unique. -[https://m3o.com/user/api#VerifyToken](https://m3o.com/user/api#VerifyToken) +[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) -// 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" +// 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) } -verifyAtoken() +createAnAccount() ``` -## LogoutAll +## Read -Logout of all user's sessions +Read an account by id, username or email. Only one need to be specified. -[https://m3o.com/user/api#LogoutAll](https://m3o.com/user/api#LogoutAll) +[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) -// Logout of all user's sessions -async function logoutAllSessionsForAuser() { - const rsp = await userService.logoutAll({ - "user_id": "user-1" +// 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) } -logoutAllSessionsForAuser() +readAnAccountById() ``` -## 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", +// 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) } -updateAnAccount() +readAccountByUsernameOrEmail() ``` -## SendVerificationEmail +## Read -Send a verification email to a user. +Read an account by id, username or email. Only one need to be specified. -[https://m3o.com/user/api#SendVerificationEmail](https://m3o.com/user/api#SendVerificationEmail) +[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) -// 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" +// 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) } -sendVerificationEmail() +readAccountByEmail() ``` -## VerifyEmail +## SendPasswordResetEmail -Verify the email address of an account from a token sent in an email to the user. +Send an email with a verification code to reset password. +Call "ResetPassword" endpoint once user provides the code. -[https://m3o.com/user/api#VerifyEmail](https://m3o.com/user/api#VerifyEmail) +[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) -// 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({ +// 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", - "token": "012345" + "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) } -verifyEmail() +sendPasswordResetEmail() ``` -## Delete +## VerifyEmail -Delete an account by id +Verify the email address of an account from a token sent in an email to the user. -[https://m3o.com/user/api#Delete](https://m3o.com/user/api#Delete) +[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) -// Delete an account by id -async function deleteUserAccount() { - const rsp = await userService.delete({ - "id": "8b98acbe-0b6a-4d66-a414-5ffbf666786f" +// 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) } -deleteUserAccount() +verifyEmail() ``` -## Create +## LogoutAll -Create a new user account. The email address and username for the account must be unique. +Logout of all user's sessions -[https://m3o.com/user/api#Create](https://m3o.com/user/api#Create) +[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) -// 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" +// Logout of all user's sessions +async function logoutAllSessionsForAuser() { + const rsp = await userService.logoutAll({ + "user_id": "user-1" }) console.log(rsp) } -createAnAccount() +logoutAllSessionsForAuser() ``` -## Login +## SendVerificationEmail -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 +Send a verification email to a user. -[https://m3o.com/user/api#Login](https://m3o.com/user/api#Login) +[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) -// 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({ +// Send a verification email to a user. +async function sendVerificationEmail() { + const rsp = await userService.sendVerificationEmail({ "email": "joe@example.com", - "password": "Password1" + "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) } -logAuserIn() +sendVerificationEmail() ``` -## Logout +## VerifyToken -Logout a user account +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#Logout](https://m3o.com/user/api#Logout) +[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) -// Logout a user account -async function logAuserOut() { - const rsp = await userService.logout({ - "sessionId": "df91a612-5b24-4634-99ff-240220ab8f55" +// 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) } -logAuserOut() +verifyAtoken() ``` ## UpdatePassword @@ -332,74 +353,81 @@ async function updateTheAccountPassword() { updateTheAccountPassword() ``` -## Read +## ReadSession -Read an account by id, username or email. Only one need to be specified. +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#Read](https://m3o.com/user/api#Read) +[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) -// 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" +// 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) } -readAnAccountById() +readAsessionByTheSessionId() ``` -## 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 +## Update -Read an account by id, username or email. Only one need to be specified. +Update the account username or email -[https://m3o.com/user/api#Read](https://m3o.com/user/api#Read) +[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) -// 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" +// 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) } -readAccountByEmail() +updateAnAccount() ``` ## ResetPassword @@ -427,31 +455,3 @@ async function resetPassword() { resetPassword() ``` -## SendMagicLink - -Login using email only - Passwordless - - -[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) - -// 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) - -} - -sendAmagicLink() -``` diff --git a/examples/wallet/README.md b/examples/wallet/README.md index 2b2df39e..93339d57 100755 --- a/examples/wallet/README.md +++ b/examples/wallet/README.md @@ -4,219 +4,219 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Wallet/api](ht Endpoints: -## Credit +## Debit -Add credit to a wallet +Debit a wallet -[https://m3o.com/wallet/api#Credit](https://m3o.com/wallet/api#Credit) +[https://m3o.com/wallet/api#Debit](https://m3o.com/wallet/api#Debit) ```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", +// Debit a wallet +async function debitWallet() { + const rsp = await walletService.debit({ + "amount": "5", "id": "b6407edd-2e26-45c0-9e2c-343689bbe5f6", - "reference": "test credit", + "reference": "test debit", "visible": true }) console.log(rsp) } -creditWallet() +debitWallet() ``` -## Transactions +## List -List the transactions for a wallet +List your wallets -[https://m3o.com/wallet/api#Transactions](https://m3o.com/wallet/api#Transactions) +[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) -// List the transactions for a wallet -async function listTransactions() { - const rsp = await walletService.transactions({ - "id": "b6407edd-2e26-45c0-9e2c-343689bbe5f6" -}) +// List your wallets +async function listWallets() { + const rsp = await walletService.list({}) console.log(rsp) } -listTransactions() +listWallets() ``` -## Delete +## Transfer -Delete a wallet +Make a transfer from one wallet to another -[https://m3o.com/wallet/api#Delete](https://m3o.com/wallet/api#Delete) +[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) -// Delete a wallet -async function deleteAwallet() { - const rsp = await walletService.delete({ - "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) } -deleteAwallet() +transferMoney() ``` -## Create +## Balance -Create a new wallet +Get the balance of a wallet -[https://m3o.com/wallet/api#Create](https://m3o.com/wallet/api#Create) +[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) -// Create a new wallet -async function createAnewWallet() { - const rsp = await walletService.create({ - "description": "No explanation needed", - "name": "Greatness" +// Get the balance of a wallet +async function getBalance() { + const rsp = await walletService.balance({ + "id": "b6407edd-2e26-45c0-9e2c-343689bbe5f6" }) console.log(rsp) } -createAnewWallet() +getBalance() ``` -## Debit +## Create -Debit a wallet +Create a new wallet -[https://m3o.com/wallet/api#Debit](https://m3o.com/wallet/api#Debit) +[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) -// Debit a wallet -async function debitWallet() { - const rsp = await walletService.debit({ - "amount": "5", - "id": "b6407edd-2e26-45c0-9e2c-343689bbe5f6", - "reference": "test debit", - "visible": true +// Create a new wallet +async function createAnewWallet() { + const rsp = await walletService.create({ + "description": "No explanation needed", + "name": "Greatness" }) console.log(rsp) } -debitWallet() +createAnewWallet() ``` -## 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 +## Transactions -Get the balance of a wallet +List the transactions for a wallet -[https://m3o.com/wallet/api#Balance](https://m3o.com/wallet/api#Balance) +[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) -// Get the balance of a wallet -async function getBalance() { - const rsp = await walletService.balance({ +// List the transactions for a wallet +async function listTransactions() { + const rsp = await walletService.transactions({ "id": "b6407edd-2e26-45c0-9e2c-343689bbe5f6" }) console.log(rsp) } -getBalance() +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() ``` diff --git a/examples/youtube/README.md b/examples/youtube/README.md index 729bc334..4b740b17 100755 --- a/examples/youtube/README.md +++ b/examples/youtube/README.md @@ -4,49 +4,49 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Youtube/api](h Endpoints: -## Search +## Embed -Search for videos on YouTube +Embed a YouTube video -[https://m3o.com/youtube/api#Search](https://m3o.com/youtube/api#Search) +[https://m3o.com/youtube/api#Embed](https://m3o.com/youtube/api#Embed) ```js const { YoutubeService } = require('m3o/youtube'); const youtubeService = new YoutubeService(process.env.M3O_API_TOKEN) -// Search for videos on YouTube -async function searchForVideos() { - const rsp = await youtubeService.search({ - "query": "donuts" +// Embed a YouTube video +async function embedAyoutubeVideo() { + const rsp = await youtubeService.embed({ + "url": "https://www.youtube.com/watch?v=GWRWZu7XsJ0" }) console.log(rsp) } -searchForVideos() +embedAyoutubeVideo() ``` -## Embed +## Search -Embed a YouTube video +Search for videos on YouTube -[https://m3o.com/youtube/api#Embed](https://m3o.com/youtube/api#Embed) +[https://m3o.com/youtube/api#Search](https://m3o.com/youtube/api#Search) ```js const { YoutubeService } = require('m3o/youtube'); const youtubeService = new YoutubeService(process.env.M3O_API_TOKEN) -// Embed a YouTube video -async function embedAyoutubeVideo() { - const rsp = await youtubeService.embed({ - "url": "https://www.youtube.com/watch?v=GWRWZu7XsJ0" +// Search for videos on YouTube +async function searchForVideos() { + const rsp = await youtubeService.search({ + "query": "donuts" }) console.log(rsp) } -embedAyoutubeVideo() +searchForVideos() ```