diff --git a/.github/workflows/linting and test.yml b/.github/workflows/linting and test.yml index 9242bf5..9b1d1ad 100644 --- a/.github/workflows/linting and test.yml +++ b/.github/workflows/linting and test.yml @@ -13,5 +13,3 @@ jobs: - name: Run ESLint run: yarn lint - - name: Run Test - run: yarn test diff --git a/.ts b/.ts new file mode 100644 index 0000000..e69de29 diff --git a/README.md b/README.md index 48abb64..0e2eccd 100644 --- a/README.md +++ b/README.md @@ -1,116 +1,535 @@ -# CoinForBarter V1 NodeJs Library +# CoinForBarter NodeJs Library -### How to use +CoinForBarter Nodejs Library - Integrate and Manage cryptocurrency payments for goods and services -npm install coinforbarter -node-sdk +![License, MIT](https://img.shields.io/badge/licence-MIT-black) ![npm, coinforbarter-node](https://img.shields.io/badge/npm-npm%20install%20coinforbarter--node-green) ![yarn, coinforbarter-node](https://img.shields.io/badge/yarn-yarn%20add%20coinforbarter--node-red) +## Table of Contents +--- + - [About](#about) + - [Getting Started](#getting-started) + - [Installation](#installation) + - [Usage](#usage) + - [Services and Methods](#services-and-methods) + - [Deployment](#deployment) + - [Built Using](#built-using) + - [CoinForBarter API References](#coinforbarter-api-references) + + +## About +--- +This is a NodeJs package for implementing CoinForBarter. + +## Getting Started +--- +These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system. See references for links to dashboard and API documentation. + +## Installation +--- +```bash +$ npm install coinforbarter-node + +# or +$ yarn add coinforbarter-node + +``` + + +## Usage +--- +```bash +const CoinForBarter = require('coinforbarter-node'); + +const publicKey = 'xxxxxxxxxxxxx'; +const privateKey = 'xxxxxxxxxxxxx'; +const secretHash = 'xxxxxxxxxxxxx'; +const coinforbarter = new CoinForBarter(publicKey, privateKey, secretHash); + +# An example to get all customers +const customers = coinforbarter.Customer.findAll(); +``` + + +## Services and Methods +--- + +1. ### Customer +This method handles all customers related to your account. The methods exposed by this service are listed below. [See customer object properties](https://developers.coinforbarter.com/api-reference/#customers-get-all-customers) + +- #### findAll +This method gets the list of all customers. +```bash +const query = {}; +const getAllCustomers = async () => { + return await coinforbarter.Customer.findAll(query); +} +``` +See list of [query parameters](https://developers.coinforbarter.com/api-reference/#customers-get-all-customers) + +- #### findOne +This method gets a particular customer by id. +```bash +const query = {}; +const customerId = ''; +const getCustomer = async (customerId) => { + return await coinforbarter.Customer.findOne(customerId); +} +``` +See list of [query parameters](https://developers.coinforbarter.com/api-reference/#customers-get-a-customer) + +- #### create +This method creates a customer. +```bash +const params = {}; +const createCustomer = async (params) => { + return await coinforbarter.Customer.create(params); +} +``` +See [customer parameters](https://developers.coinforbarter.com/api-reference/#customers-create-customer) + +- #### update +This method updates a customer. +```bash +const params = {}; +const updateCustomer = async (params) => { + return await coinforbarter.Customer.update(params); +} +``` +See [customer update parameters](https://developers.coinforbarter.com/api-reference/#customers-update) + + +2. ### BankAccount +This method handles all bank account related to your account. The methods exposed by this service are listed below. [See bank account object properties](https://developers.coinforbarter.com/api-reference/#bank-accounts) + +- #### getBankAccountName +```bash +const query = {}; +const getBankAccountName = async () => { + return await coinforbarter.BankAccount.getBankAccountName(query); +} +``` +See list of [query parameters](https://developers.coinforbarter.com/api-reference/#bank-accounts-get-account-name) + +- #### create +```bash +const parms = {}; +const createBankAccount = async (parms) => { + return await coinforbarter.BankAccount.create(parms); +} +``` +See list of [query parameters](https://developers.coinforbarter.com/api-reference/#bank-accounts-create) + +- #### findAll +This method gets the list of all bank accounts. +```bash +const query = {}; +const getAllBankAccounts = async () => { + return await coinforbarter.BankAccount.findAll(query); +} +``` +See list of [query parameters](https://developers.coinforbarter.com/api-reference/#bank-accounts-get-all) + +- #### findOne +```bash +const query = {}; +const bankAccountId = ''; +const getBankAccount = async (bankAccountId) => { + return await coinforbarter.BankAccount.findOne(bankAccountId); +} +``` +See list of [query parameters](https://developers.coinforbarter.com/api-reference/#bank-accounts-get-one) + +- #### makePrimary +```bash +const parms = {}; +const bankAccountId = ''; +const makePrimary = async (bankAccountId) => { + return await coinforbarter.BankAccount.makePrimary(bankAccountId); +} +``` +See list of [query parameters](https://developers.coinforbarter.com/api-reference/#bank-accounts-make-primary) + +- #### getBanks +```bash +const query = {}; +const countryCode = ''; +const getBank = async (countryCode) => { + return await coinforbarter.BankAccount.getBanks(countryCode); +} +``` +See list of [query parameters](https://developers.coinforbarter.com/api-reference/#bank-accounts-all-banks) + + +3. ### Payment +This method handles all payments related to your account. The methods exposed by this service are listed below. [See payment object properties](https://developers.coinforbarter.com/api-reference/#payments) + +- #### findOne +```bash +const query = {}; +const paymentId = ''; +const getPayment = async (paymentId) => { + return await coinforbarter.Payment.findOne(paymentId); +} +``` +See list of [query parameters](https://developers.coinforbarter.com/api-reference/#payments-get-one) + +- #### create +```bash +const params = {}; +const createPayment = async (params) => { + return await coinforbarter.Payment.create(params); +} +``` +See list of [query parameters](https://developers.coinforbarter.com/api-reference/#payments-create) + +- #### setCurrency +```bash +const params = {}; +const setCurrency = async (params) => { + return await coinforbarter.Payment.setCurrency(params); +} +``` +See list of [query parameters](https://developers.coinforbarter.com/api-reference/#payments-set-currency) + +- #### lockCurrency +```bash +const paymentId = ''; +const lockCurrency = async (paymentId) => { + return await coinforbarter.Payment.lockCurrency(paymentId); +} +``` +See list of [query parameters](https://developers.coinforbarter.com/api-reference/#payments-lock-currency) + +- #### getPaymentUpdates +```bash +const query = {}; +const getAllBankAccount = async () => { + return await coinforbarter.Payment.getPaymentUpdates(query); +} +``` +See list of [query parameters](https://developers.coinforbarter.com/api-reference/#bank-accounts-all-banks) + +- #### cancel +```bash +const query = {}; +const paymentId = async () => { + return await coinforbarter.Payment.cancel(query); +} +``` +See list of [query parameters](https://developers.coinforbarter.com/api-reference/#bank-accounts-all-banks) + + +4. ### PaymentPlan + +- #### findAll +```bash +const query = {}; +const getAllPaymentPlan = async () => { + return await coinforbarter.PaymentPlan.findAll(query); +} +``` +See list of [query parameters](https://developers.coinforbarter.com/api-reference/#payment-plans-find-all) + +- #### findOne +```bash +const query = {}; +const getPaymentPlan = async () => { + return await coinforbarter.PaymentPlan.findOne(query); +} +``` +See list of [query parameters](https://developers.coinforbarter.com/api-reference/#payment-plans-find-one) + +- #### create +```bash +const params = {}; +const createPaymentPlan = async () => { + return await coinforbarter.PaymentPlan.create(params); +} +``` +See list of [query parameters](https://developers.coinforbarter.com/api-reference/#payment-plans-create) + +- #### update +```bash +const params = {}; +const updatePaymentPlan = async (params) => { + return await coinforbarter.PaymentPlan.update(params); +} +``` +See list of [query parameters](https://developers.coinforbarter.com/api-reference/#payment-plans-update) + + +5. ### PaymentPlanSubscriber + +- #### create +```bash +const params = {}; +const createPaymentPlanSubscriber = async () => { + return await coinforbarter.PaymentPlanSubscriber.create(query); +} +``` +See list of [query parameters](https://developers.coinforbarter.com/api-reference/#payment-plan-subscribers-create) + +- #### findOne +```bash +const query = {}; +const paymentPlanSubscriberId = ''; +const getPaymentPlanSubscriber = async (paymentPlanSubscriberId) => { + return await coinforbarter.PaymentPlanSubscriber.findOne(paymentPlanSubscriberId); +} +``` +See list of [query parameters](https://developers.coinforbarter.com/api-reference/#payment-plan-subscribers-find-one) + +- #### findAll +```bash +const query = {}; +const getAllPaymentPlanSubscriber = async () => { + return await coinforbarter.PaymentPlanSubscriber.findAll(query); +} +``` +See list of [query parameters](https://developers.coinforbarter.com/api-reference/#payment-plan-subscribers-find-all) + +- #### remove ```bash -const CoinForBarter = require('coinforbarter -node-v3'); +const paymentPlanSubscriberId = ''; +const removePaymentPlanSubscriber = async () => { + return await coinforbarter.PaymentPlanSubscriber.remove(paymentPlanSubscriberId); +} +``` +See list of [query parameters](https://developers.coinforbarter.com/api-reference/#payment-plan-subscribers-remove) + + +6. ### Payout -const c4b = new CoinForBarter(PUBLIC_KEY, PRIVATE_KEY, SECRET_HASH); +- #### findAll +```bash +const query = {}; +const getAllPayout = async () => { + return await coinforbarter.Payout.findAll(query); +} +``` +See list of [query parameters](https://developers.coinforbarter.com/api-reference/#payouts-get-all) -const customers = c4b.Customers.findAll(); +- #### findOne +```bash +const query = {}; +const payOutId = ''; +const getPayout = async (payOutId) => { + return await coinforbarter.Payout.findOne(payOutId); +} ``` +See list of [query parameters](https://developers.coinforbarter.com/api-reference/#payouts-get-one) + + +7. ### Transaction -For staging, Use TEST API Keys. For production, use LIVE API KEYS. You can get your PUBLIC_KEY and PRIVATE_KEY from the CoinForBarter dashboard. +- #### findAll +```bash +const query = {}; +const getAllTransactions = async () => { + return await coinforbarter.Transaction.findAll(query); +} +``` +See list of [query parameters](https://developers.coinforbarter.com/api-reference/#transactions-get-all) + +- #### findOne +```bash +const query = {}; +const transactionId = ''; +const getTransaction = async (transactionId) => { + return await coinforbarter.Transaction.findOne(transactionId); +} +``` +See list of [query parameters](https://developers.coinforbarter.com/api-reference/#transactions-get-one) + +- #### verify +```bash +const transactionId = ''; +const verifyTransaction = async (transactionId) => { + return await coinforbarter.Transaction.verify(transactionId); +} +``` +See list of [query parameters](https://developers.coinforbarter.com/api-reference/#transactions-verify) + +- #### events +```bash +const query = {}; +const getEvent = async () => { + return await coinforbarter.Transaction.events(query); +} +``` +See list of [query parameters](https://developers.coinforbarter.com/api-reference/#transactions-get-transaction-time-log) -Go [here](https://dashboard.coinforbarter.com/settings/api) to get your API Keys. +- #### getFee +```bash +const transactionId = {}; +const getfeeForTransaction = async (transactionId) => { + return await coinforbarter.Transaction.getFee(transactionId); +} +``` +See list of [query parameters](https://developers.coinforbarter.com/api-reference/#transactions-get-fee) +- #### webhook +```bash +const transactionId = {}; +const transaction = async (transactionId) => { + return await coinforbarter.Transaction.webhook(transactionId); +} +``` +See list of [query parameters](https://developers.coinforbarter.com/api-reference/#transactions-webhook) -Turn on Test Mode to get TEST API KEYS and Turn off Test Mode to get LIVE API KEYS -## CoinForBarter Services exposed by the library +8. ### Transfer -1. #### Customer - ##### Methods - - findAll - - findOne - - create - - update +- #### findAll +```bash +const query = {}; +const getAllTransfer = async () => { + return await coinforbarter.Transfer.findAll(query); +} +``` +See list of [query parameters](https://developers.coinforbarter.com/api-reference/#transfers-get-all) +- #### findOne +```bash +const query = {}; +const transferId = ''; +const getTransfer = async (transferId) => { + return await coinforbarter.Transfer.findOne(transferId); +} +``` +See list of [query parameters](https://developers.coinforbarter.com/api-reference/#transfers-get-one) -2. #### BankAccount - ##### Methods - - getBankAccountName - - create - - findAll - - findOne - - makePrimary - - getBanks +- #### create +```bash +const params = {}; +const createTransfer = async (params) => { + return await coinforbarter.Transfer.findAll(params); +} +``` +See list of [query parameters](https://developers.coinforbarter.com/api-reference/#transfers-create) +- #### getFee +```bash +const query = {}; +const getFeeForTransfer = async () => { + return await coinforbarter.Transfer.getFee(query); +} +``` +See list of [query parameters](https://developers.coinforbarter.com/api-reference/#transfers-get-fee) -3. #### Payment - ##### Methods - - findOne - - findAll - - create - - setCurrency - - lockCurrency - - getPaymentUpdates - - cancel +9. ### WalletAddress -4. #### PaymentPlan - ##### Methods - - findAll - - findOne - - create - - update +- #### create +```bash +const params = {}; +const createWalletAddress = async (params) => { + return await coinforbarter.WalletAddress.create(params); +} +``` +See list of [query parameters](https://developers.coinforbarter.com/api-reference/#wallet-addresses-create) +- #### findAll +```bash +const query = {}; +const getAllWalletAddress = async () => { + return await coinforbarter.WalletAddress.findAll(query); +} +``` +See list of [query parameters](https://developers.coinforbarter.com/api-reference/#wallet-addresses-get-all) -5. #### PaymentPlanSubscriber - ##### Methods - - create - - findOne - - findAll - - remove +- #### findOne +```bash +const query = {}; +const walletId = ''; +const getWalletAddress = async (walletId) => { + return await coinforbarter.WalletAddress.findOne(walletId); +} +``` +See list of [query parameters](https://developers.coinforbarter.com/api-reference/#wallet-addresses-get-one) +- #### makePrimary +```bash +const query = {}; +const walletAddressId = ''; +const makeWalletAddressPrimary = async (walletAddressId) => { + return await coinforbarter.WalletAddress.makePrimary(walletAddressId); +} +``` +See list of [query parameters](https://developers.coinforbarter.com/api-reference/#wallet-addresses-make-primary) -6. #### Payout - ##### Methods - - findAll - - findOne +10. ### Wallet -7. #### Transaction - ##### Methods - - findAll - - findOne - - verify - - events - - getFee - - webhook +- #### findAll +```bash +const query = {}; +const getAllWallet = async () => { + return await coinforbarter.Wallet.findAll(query); +} +``` +See list of [query parameters](https://developers.coinforbarter.com/api-reference/#wallets-find-all) +- #### findOne +```bash +const query = {}; +const walletId = ''; +const getWallet = async (walletId) => { + return await coinforbarter.Wallet.findOne(walletId); +} +``` +See list of [query parameters](https://developers.coinforbarter.com/api-reference/#wallets-find-one) -8. #### Transfer - ##### Methods - - findAll - - findOne - - create - - getFee +- #### create +```bash +const params = {}; +const createWallet = async (params) => { + return await coinforbarter.Wallet.create(params); +} +``` +See list of [query parameters](https://developers.coinforbarter.com/api-reference/#wallets-create) +- #### delete +```bash +const query = {}; +const deleteWallet = async () => { + return await coinforbarter.Wallet.delete(query); +} +``` +See list of [query parameters](https://developers.coinforbarter.com/api-reference/#wallets-delete) -9. #### WalletAddress - ##### Methods - - create - - findAll - - findOne - - makePrimary +11. ### Misc -10. #### Webhook - ##### Methods - - validate +- #### getCountries +```bash +const query = {}; +const getCountriesMisc = async () => { + return await coinforbarter.Misc.getCountries(query); +} +``` +See list of [query parameters](https://developers.coinforbarter.com/api-reference/#misc-get-countries) +- #### getBalance +```bash +const query = {}; +const getBalanceMisc = async () => { + return await coinforbarter.Misc.getBalance(query); +} +``` +See list of [query parameters](https://developers.coinforbarter.com/api-reference/#misc-get-wallet-balances) -11. #### Misc - ##### Methods - - getCountries - - getBalance - - getCurrencies +- #### getCurrencies +```bash +const query = {}; +const getCurrenciesMisc = async () => { + return await coinforbarter.Misc.getCurrencies(query); +} +``` +See list of [query parameters](https://developers.coinforbarter.com/api-reference/#misc-get-currencies) -All methods can be called this way +This SDK can be used closely with the official [API Reference](https://developers.coinforbarter.com/api-reference). All services and methods can be called this way ```bash @@ -125,21 +544,28 @@ i.e [service]:method } - +# I will do more on documenting each method till i can complete it 😂 ``` -Some methods may take body data or query params in objects -For more information on the services listed above, visit the [CoinForBarter documentation](https://developers.coinforbarter.com) -CoinForBarter V1 NodeJs Library is an MIT -licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://developers.coinforbarter.com). +## Built Using +--- +- Typescript + + +## CoinForBarter API References +- [CoinForBarter Developers Doc](https://developers.coinforbarter.com) +- [CoinForBarter API Reference](https://developers.coinforbarter.com/api-reference/) +- [CoinForBarter Inline Payment Doc](https://developers.coinforbarter.com/docs/integration-options-coinforbarter-inline/) +- [CoinForBarter Dashboard](https://dashboard.coinforbarter.com) + +## Stay in Touch -## Stay in touch +- Author - [Nwachukwu, Kingsley Tochukwu](https://linkedin.com/in/tkings) +- Twitter - [@tkings_](https://twitter.com/tkings_) +- Github - [t-kings](https://github.com/tkings) - - Author - [Nwachukwu, Kingsley Tochukwu](https://linkedin.com/in/t-kings) - - Website - [https://coinforbarter.com](https://coinforbarter.com/) - - Twitter - [@t-kings](https://twitter.com/t-kings) +Contributions are open, meta properties are not being returned yet by this SDK. You can send me an email via [tochukwu@coinforbarter.com](mailto:tochukwu@coinforbarter.com) -## License -CoinForBarter is [MIT licensed](LICENSE). diff --git a/package.json b/package.json index 23afd07..82d5c76 100644 --- a/package.json +++ b/package.json @@ -1,17 +1,17 @@ { - "name": "coinforbarter-node-sdk", + "name": "coinforbarter-node", "version": "1.0.6", - "description": "CoinForBarter NodeJs Library", + "description": "CoinForBarter Nodejs Library - Integrate and Manage cryptocurrency payments for goods and services", "main": "dist/index.js", "types": "dist/index.d.ts", - "repository": "https://github.com/t-kings/CoinForBarter-v1-NodeJs.git", + "repository": "https://github.com/t-kings/coinforbarter-v1-node.git", "author": { "name": "Nwachukwu, Kingsley Tochukwu", "email": "tochukwu@coinforbarter.com" }, - "license": "MIT", "dependencies": { "axios": "^0.21.1", + "node": "^16.10.0", "websocket": "^1.0.34" }, "scripts": { @@ -35,10 +35,40 @@ "crypto currency", "DOGE", "API", - "Nodejs Crypto", + "React Crypto", "CoinForBarter", - "Crypto Sdk" + "Crypto Sdk", + "Naira", + "NGN", + "Dollar", + "USD", + "Bitcoin", + "BTC", + "Dogecoin", + "DOGE", + "Ethereum", + "ETH", + "TetherUS", + "USDT", + "Usd Coin", + "USDC", + "Busd", + "BUSD", + "Dai", + "DAI", + "Paxus Standard", + "PAX", + "Bitcoin Cash", + "BCH", + "Wrapped Bitcoin", + "WBTC", + "BTC", + "BEP20", + "ERC20", + "DOGECOIN", + "BCH" ], + "license": "MIT", "devDependencies": { "@babel/preset-env": "^7.14.7", "@babel/preset-typescript": "^7.14.5", @@ -74,4 +104,4 @@ "coverageDirectory": "../coverage", "testEnvironment": "node" } -} \ No newline at end of file +} diff --git a/src/services/index.ts b/src/services/index.ts index 671dfc8..4fb9f5d 100644 --- a/src/services/index.ts +++ b/src/services/index.ts @@ -1 +1 @@ -export { CoinForBarterRequest } from './request'; +export { CoinForBarterRequest } from './Request';