diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..d8707f3 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,281 @@ +name: CI/CD Workflow + +on: + workflow_dispatch: + push: + branches: + - '**' + # pull_request: + # types: + # - closed + +jobs: + run_tests: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + - uses: ponicode/azure-devops-npm-action@master + with: + organisation: precise-finance + project: precise-finance + registry: precise-npm + user: danshapir + password: ${{ secrets.AZURE_PAT }} + email: dan@precisefinance.ai + # scope: ponicode + - run: cp `pwd`/.npmrc ~ # We need the .npmrc file in the $HOME directory + - name: Setup Node.js + uses: actions/setup-node@v4.0.0 + with: + node-version: '18' # Adjust as necessary + + - name: Cache node_modules + id: cache-node-modules # Added an ID for this step + uses: actions/cache@v3 + with: + path: node_modules # caching node_modules directly + key: ${{ runner.os }}-node-modules-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node-modules- + + - name: Install Dependencies + if: steps.cache-node-modules.outputs.cache-hit != 'true' # Only run if cache was a miss + run: npm ci + + - name: Run tests + run: | + npx prisma generate + npm run test:ci + + - name: Test Report + uses: dorny/test-reporter@v1 + if: success() || failure() # run this step even if previous step failed + with: + name: JEST Tests # Name of the check run which will be created + path: reports/jest-*.xml # Path to test results + reporter: jest-junit # Format of test results + + build_image: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Checkout Helm repo + uses: actions/checkout@v4 + with: + repository: Precise-Finance/charts + path: helm-repo + ref: main + token: ${{ secrets.GH_SECRET }} + + - name: Install yq + run: | + sudo wget -O /usr/local/bin/yq https://github.com/mikefarah/yq/releases/download/v4.12.2/yq_linux_amd64 + sudo chmod +x /usr/local/bin/yq + + - name: Get current image tag + id: get_current_tag + run: | + CURRENT_TAG=$(yq eval ".image.tag" helm-repo/${{ github.event.repository.name }}/values.yaml) + echo "current_tag=$CURRENT_TAG" >> $GITHUB_OUTPUT + + - name: Check if tag needs update + id: check_tag + run: | + if [[ "${{ steps.get_current_tag.outputs.current_tag }}" == "$GITHUB_SHA" ]]; then + echo "Image tag is already up-to-date. Skipping." + echo "skip=true" >> $GITHUB_OUTPUT + else + echo "skip=false" >> $GITHUB_OUTPUT + fi + + - name: Azure npm auth + if: steps.check_tag.outputs.skip == 'false' + uses: ponicode/azure-devops-npm-action@master + with: + organisation: precise-finance + project: precise-finance + registry: precise-npm + user: danshapir + password: ${{ secrets.AZURE_PAT }} + email: dan@precisefinance.ai + # scope: ponicode + - run: cp `pwd`/.npmrc ~ # We need the .npmrc file in the $HOME directory + - name: Setup Node.js + if: steps.check_tag.outputs.skip == 'false' + uses: actions/setup-node@v4.0.0 + with: + node-version: '18' # Adjust as necessary + + - name: Configure AWS credentials + if: steps.check_tag.outputs.skip == 'false' + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: eu-west-1 + + - name: Login to Amazon ECR Private + if: steps.check_tag.outputs.skip == 'false' + id: login-ecr + uses: aws-actions/amazon-ecr-login@v2 + + - name: Set up Docker Buildx + if: steps.check_tag.outputs.skip == 'false' + uses: docker/setup-buildx-action@v3 + + - name: Cache Docker layers + if: steps.check_tag.outputs.skip == 'false' + uses: actions/cache@v3.3.2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ hashFiles('**/Dockerfile', '**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-buildx-${{ hashFiles('**/package-lock.json') }} + ${{ runner.os }}-buildx- + + + - name: Build, tag, and push docker image to Amazon ECR using Buildx + if: steps.check_tag.outputs.skip == 'false' + env: + REGISTRY: ${{ steps.login-ecr.outputs.registry }} + REPOSITORY: precise/${{ github.event.repository.name }} + IMAGE_TAG: ${{ github.sha }} + run: | + docker buildx create --use + docker buildx build --push \ + --cache-from=type=local,src=/tmp/.buildx-cache \ + --cache-to=type=local,dest=/tmp/.buildx-cache,mode=max \ + --build-arg BUILDKIT_INLINE_CACHE=1 \ + -t $REGISTRY/$REPOSITORY:$IMAGE_TAG . + + + + + - name: Update values.yaml + if: steps.check_tag.outputs.skip == 'false' + run: | + yq eval ".image.tag = \"$(echo $GITHUB_SHA )\"" -i helm-repo/${{ github.event.repository.name }}/values.yaml + cat helm-repo/${{ github.event.repository.name }}/values.yaml + + + - name: Set up Git + if: steps.check_tag.outputs.skip == 'false' + run: | + git config --global user.name "GitHub Action" + git config --global user.email "action@github.com" + + - name: Commit and Push Changes + if: steps.check_tag.outputs.skip == 'false' + run: | + cd helm-repo + git add . + git commit -m "Update image tag after commit" + git push + + - name: Generate File + run: | + cd helm-repo + echo $(git rev-parse HEAD) > ../helm_commit.txt + + - name: Upload artifact + uses: actions/upload-artifact@v3.1.3 + with: + name: helm-commit + path: helm_commit.txt + + + approval_and_tag_dev: + needs: [run_tests, build_image] # Change the dependency to the newly separated jobs + if: contains(github.ref, 'refs/pull/') || startsWith(github.ref, 'refs/heads/feature/') + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Download artifact + uses: actions/download-artifact@v3.0.2 + with: + name: helm-commit + path: helm-commit + - name: Set output + id: get_commit_id + run: | + echo $(cat helm-commit/helm_commit.txt) + echo "commit_id=$(cat helm-commit/helm_commit.txt)" >> $GITHUB_OUTPUT + + - name: Get Commit Details + id: get_commit_details + run: | + echo $(git log -1 --pretty=format:'%s') + echo "commit_message=$(git log -1 --pretty=format:'%s')" >> $GITHUB_OUTPUT + + - name: Get PR Details + id: get_pr_details + run: | + if [[ "${{ github.event_name }}" == "pull_request" ]]; then + echo "pr_link=${{ github.event.pull_request.html_url }}" >> $GITHUB_OUTPUT + else + echo "Not a PR event, skipping PR details extraction." + fi + + - name: send approval + uses: Precise-Finance/slack-approval@v2.8 + env: + SLACK_APP_TOKEN: ${{ secrets.SLACK_APP_TOKEN }} + SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} + SLACK_SIGNING_SECRET: ${{ secrets.SLACK_SIGNING_SECRET }} + SLACK_CHANNEL_ID: deployment-approvals-dev #${{ secrets.SLACK_CHANNEL_ID }} + DEPLOYMENT_ENV: DEV + COMMIT_SHA: ${{ steps.get_commit_id.outputs.commit_id }} + GH_SECRET: ${{ secrets.GH_SECRET }} + PR_LINK: ${{ steps.get_pr_details.outputs.pr_link }} + COMMIT_MESSAGE: ${{ steps.get_commit_details.outputs.commit_message }} + timeout-minutes: 10 + + approval_and_tag_prod: + needs: [run_tests, build_image] # Change the dependency to the newly separated jobs + if: (github.ref == 'refs/heads/main') || (github.ref == 'refs/heads/master') + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Download artifact + uses: actions/download-artifact@v3.0.2 + with: + name: helm-commit + path: helm-commit + - name: Set output + id: get_commit_id + run: | + echo $(cat helm-commit/helm_commit.txt) + echo "commit_id=$(cat helm-commit/helm_commit.txt)" >> $GITHUB_OUTPUT + + - name: Get Commit Details + id: get_commit_details + run: | + echo $(git log -1 --pretty=format:'%s') + echo "commit_message=$(git log -1 --pretty=format:'%s')" >> $GITHUB_OUTPUT + + - name: Get PR Details + id: get_pr_details + run: | + if [[ "${{ github.event_name }}" == "pull_request" ]]; then + echo "pr_link=${{ github.event.pull_request.html_url }}" >> $GITHUB_OUTPUT + else + echo "Not a PR event, skipping PR details extraction." + fi + + - name: send approval + uses: Precise-Finance/slack-approval@v2.8 + env: + SLACK_APP_TOKEN: ${{ secrets.SLACK_APP_TOKEN }} + SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} + SLACK_SIGNING_SECRET: ${{ secrets.SLACK_SIGNING_SECRET }} + SLACK_CHANNEL_ID: deployment-approvals #${{ secrets.SLACK_CHANNEL_ID }} + DEPLOYMENT_ENV: Production + COMMIT_SHA: ${{ steps.get_commit_id.outputs.commit_id }} + GH_SECRET: ${{ secrets.GH_SECRET }} + PR_LINK: ${{ steps.get_pr_details.outputs.pr_link }} + COMMIT_MESSAGE: ${{ steps.get_commit_details.outputs.commit_message }} + timeout-minutes: 10 diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml new file mode 100644 index 0000000..5b2508b --- /dev/null +++ b/.github/workflows/deploy.yaml @@ -0,0 +1,32 @@ +name: Continue Deployment after Approval + +on: + repository_dispatch: + types: [deployment-approved] + +jobs: + post_approval_prod: + runs-on: ubuntu-latest + steps: + - name: Deploy to environment + run: | + echo "Deploying to ${{ github.event.client_payload.env }}" + + - name: Deploy commit + run: | + echo "Deploying commit ${{ github.event.client_payload.sha }}" + - name: Checkout Helm repo at specific SHA + uses: actions/checkout@v4 + with: + repository: Precise-Finance/charts + path: helm-repo + ref: ${{ github.event.client_payload.sha }} + token: ${{ secrets.GH_SECRET }} + + + - name: Tag with SHA and ENV + run: | + cd helm-repo + git tag ${{ github.event.client_payload.env }}-${{ github.event.repository.name }} + git push origin refs/tags/${{ github.event.client_payload.env }}-${{ github.event.repository.name }} -f --tags + diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml new file mode 100644 index 0000000..4aeb444 --- /dev/null +++ b/.github/workflows/pr.yaml @@ -0,0 +1,38 @@ +name: Code Review + +permissions: + contents: read + pull-requests: write + +on: + pull_request: + types: [opened, reopened, synchronize, labeled, unlabeled] + +jobs: + chatgpt_review: + if: ${{ !contains(github.event.*.labels.*.name, 'no gpt review') }} # Optional; to run only when a label is attached + runs-on: ubuntu-latest + steps: + - uses: anc95/ChatGPT-CodeReview@main + env: + GITHUB_TOKEN: ${{ secrets.GH_SECRET }} + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} + # Optional + LANGUAGE: English + MODEL: gpt-3.5-turbo # https://platform.openai.com/docs/models + # OPENAI_API_ENDPOINT: https://api.openai.com/v1 + # PROMPT: Please check if there are any confusions, irregularities, security issues or performance issues in the following code diff: + # top_p: 1 # https://platform.openai.com/docs/api-reference/chat/create#chat/create-top_p + # temperature: 1 # https://platform.openai.com/docs/api-reference/chat/create#chat/create-temperature + # max_tokens: 10000 + # MAX_PATCH_LENGTH: 10000 # if the patch/diff length is large than MAX_PATCH_LENGTH, will be ignored and won't review. By default, with no MAX_PATCH_LENGTH set, there is also no limit for the patch/diff length. + gpt_review_node: + if: ${{ contains(github.event.*.labels.*.name, 'gpt summary') }} # Optional; to run only when a label is attached + runs-on: ubuntu-latest + steps: + - name: gpt-review-node + uses: Precise-Finance/gpt-review@v1.1 + with: + GITHUB_TOKEN: ${{ secrets.GH_SECRET }} + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} + OPENAI_ORG_KEY: ${{ secrets.OPENAI_ORG_KEY }} diff --git a/.gitignore b/.gitignore index 0088af8..2263549 100644 --- a/.gitignore +++ b/.gitignore @@ -62,3 +62,7 @@ typings/ # IDE .idea + + +.history +.DS_Store \ No newline at end of file diff --git a/README.md b/README.md index d20dd17..a507f93 100644 --- a/README.md +++ b/README.md @@ -118,7 +118,8 @@ You can click on the :book: icon to access the detailed API reference for each m * ```delete(bank_id, callback)``` [:book:](https://docs.checkbook.io/reference#delete-bank) * ```instantAccountVerification(params, callback[, idempotencyKey])``` [:book:](https://docs.checkbook.io/reference#post-bank-iav) * ```addBankAccount(params, callback[, idempotencyKey])``` [:book:](https://docs.checkbook.io/reference#post-bank) - * ```verifyMicrodesposits(params, callback)``` [:book:](https://docs.checkbook.io/reference#post-bank-verify) + * ```releaseMicrodeposits(params, callback)``` [:book:](https://docs.checkbook.io/reference#post-bank-release) + * ```verifyMicrodeposits(params, callback)``` [:book:](https://docs.checkbook.io/reference#post-bank-verify) * __Checkbook.users__ * ```create(params, callback[, idempotencyKey])``` [:book:](https://docs.checkbook.io/reference#post-user) diff --git a/dist/index.d.ts b/dist/index.d.ts new file mode 100644 index 0000000..0f1fb70 --- /dev/null +++ b/dist/index.d.ts @@ -0,0 +1,2 @@ +import CheckbookAPI from "./ts/checkbook"; +export default CheckbookAPI; diff --git a/dist/index.js b/dist/index.js new file mode 100644 index 0000000..f757b16 --- /dev/null +++ b/dist/index.js @@ -0,0 +1,5 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const checkbook_1 = require("./ts/checkbook"); +exports.default = checkbook_1.default; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/index.js.map b/dist/index.js.map new file mode 100644 index 0000000..e38cb26 --- /dev/null +++ b/dist/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;AAAA,8CAA0C;AAE1C,kBAAe,mBAAY,CAAC"} \ No newline at end of file diff --git a/dist/ts/checkbook.d.ts b/dist/ts/checkbook.d.ts new file mode 100644 index 0000000..5f85c8e --- /dev/null +++ b/dist/ts/checkbook.d.ts @@ -0,0 +1,25 @@ +import { Resource } from "./resource"; +import { Check } from "./endpoints/check"; +import { Invoice } from "./endpoints/invoice"; +import { Subscription } from "./endpoints/subscription"; +import { Bank } from "./endpoints/bank"; +import { User } from "./endpoints/user"; +import { VirtualCreditCard } from "./endpoints/vcc"; +import { Wallet } from "./endpoints/wallet"; +export default class Checkbook { + checks: Check; + resource: Resource; + invoices: Invoice; + subscriptions: Subscription; + banks: Bank; + users: User; + virtualCreditCards: VirtualCreditCard; + wallet: Wallet; + constructor(config: { + env?: string; + auth?: string; + bearer?: string; + api_key?: string; + api_secret?: string; + }); +} diff --git a/dist/ts/checkbook.js b/dist/ts/checkbook.js new file mode 100644 index 0000000..7146412 --- /dev/null +++ b/dist/ts/checkbook.js @@ -0,0 +1,36 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const resource_1 = require("./resource"); +const check_1 = require("./endpoints/check"); +const invoice_1 = require("./endpoints/invoice"); +const subscription_1 = require("./endpoints/subscription"); +const bank_1 = require("./endpoints/bank"); +const user_1 = require("./endpoints/user"); +const vcc_1 = require("./endpoints/vcc"); +const wallet_1 = require("./endpoints/wallet"); +class Checkbook { + constructor(config) { + if (!config.env || !["demo", "sandbox"].includes(config.env)) { + config.env = "www"; + } + if (config.bearer) { + config.auth = "Bearer " + config.bearer; + } + else if (config.api_key && config.api_secret) { + config.auth = config.api_key + ":" + config.api_secret; + } + else { + throw "Invalid Authorization"; + } + this.resource = new resource_1.Resource(config); + this.checks = new check_1.Check(this.resource); + this.invoices = new invoice_1.Invoice(this.resource); + this.subscriptions = new subscription_1.Subscription(this.resource); + this.banks = new bank_1.Bank(this.resource); + this.users = new user_1.User(this.resource); + this.virtualCreditCards = new vcc_1.VirtualCreditCard(this.resource); + this.wallet = new wallet_1.Wallet(this.resource); + } +} +exports.default = Checkbook; +//# sourceMappingURL=checkbook.js.map \ No newline at end of file diff --git a/dist/ts/checkbook.js.map b/dist/ts/checkbook.js.map new file mode 100644 index 0000000..133a4cc --- /dev/null +++ b/dist/ts/checkbook.js.map @@ -0,0 +1 @@ +{"version":3,"file":"checkbook.js","sourceRoot":"","sources":["../../ts/checkbook.ts"],"names":[],"mappings":";;AAAA,yCAAsC;AACtC,6CAA0C;AAC1C,iDAA8C;AAC9C,2DAAwD;AACxD,2CAAwC;AACxC,2CAAwC;AACxC,yCAAoD;AACpD,+CAA4C;AAC5C,MAAqB,SAAS;IAY5B,YAAY,MAMX;QACC,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE;YAC5D,MAAM,CAAC,GAAG,GAAG,KAAK,CAAC;SACpB;QAED,IAAI,MAAM,CAAC,MAAM,EAAE;YACjB,MAAM,CAAC,IAAI,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC;SACzC;aAAM,IAAI,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,UAAU,EAAE;YAC9C,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC,OAAO,GAAG,GAAG,GAAG,MAAM,CAAC,UAAU,CAAC;SACxD;aAAM;YACL,MAAM,uBAAuB,CAAC;SAC/B;QAED,IAAI,CAAC,QAAQ,GAAG,IAAI,mBAAQ,CAAC,MAAM,CAAC,CAAC;QAErC,IAAI,CAAC,MAAM,GAAG,IAAI,aAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACvC,IAAI,CAAC,QAAQ,GAAG,IAAI,iBAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC3C,IAAI,CAAC,aAAa,GAAG,IAAI,2BAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACrD,IAAI,CAAC,KAAK,GAAG,IAAI,WAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACrC,IAAI,CAAC,KAAK,GAAG,IAAI,WAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACrC,IAAI,CAAC,kBAAkB,GAAG,IAAI,uBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC/D,IAAI,CAAC,MAAM,GAAG,IAAI,eAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC1C,CAAC;CACF;AAzCD,4BAyCC"} \ No newline at end of file diff --git a/dist/ts/endpoints/User.d.ts b/dist/ts/endpoints/User.d.ts new file mode 100644 index 0000000..55eae5b --- /dev/null +++ b/dist/ts/endpoints/User.d.ts @@ -0,0 +1,11 @@ +import { Resource } from "../resource"; +export declare class User { + private readonly resource; + constructor(resource: Resource); + create(params: any, callback: any, idempotencyKey?: any): void; + update(params: any, callback: (err: any, response: any) => void): void; + get(callback: (err: any, response: any) => void): void; + list(query: any, callback: (err: any, response: any) => void): void; + delete(user_id: any, callback: (err: any, response: any) => void): void; + addSignature(params: any, callback: (err: any, response: any) => void): void; +} diff --git a/dist/ts/endpoints/User.js b/dist/ts/endpoints/User.js new file mode 100644 index 0000000..dc14c7b --- /dev/null +++ b/dist/ts/endpoints/User.js @@ -0,0 +1,50 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.User = void 0; +class User { + constructor(resource) { + this.resource = resource; + } + create(params, callback, idempotencyKey) { + return this.resource.request({ + method: 'POST', + uri: '/user', + body: params + }, callback, idempotencyKey); + } + update(params, callback) { + return this.resource.request({ + method: 'PUT', + uri: '/user', + body: params + }, callback); + } + get(callback) { + return this.resource.request({ + method: 'GET', + uri: '/user' + }, callback); + } + list(query, callback) { + return this.resource.request({ + method: 'GET', + uri: '/user/list', + qs: query + }, callback); + } + delete(user_id, callback) { + return this.resource.request({ + method: 'DELETE', + uri: '/user/' + user_id + }, callback); + } + addSignature(params, callback) { + return this.resource.request({ + method: 'POST', + uri: '/user/signature', + body: params + }, callback); + } +} +exports.User = User; +//# sourceMappingURL=user.js.map \ No newline at end of file diff --git a/dist/ts/endpoints/User.js.map b/dist/ts/endpoints/User.js.map new file mode 100644 index 0000000..2d09eda --- /dev/null +++ b/dist/ts/endpoints/User.js.map @@ -0,0 +1 @@ +{"version":3,"file":"user.js","sourceRoot":"","sources":["../../../ts/endpoints/user.ts"],"names":[],"mappings":";;;AAEA,MAAa,IAAI;IAIb,YAA6B,QAAkB;QAAlB,aAAQ,GAAR,QAAQ,CAAU;IAE/C,CAAC;IAED,MAAM,CAAC,MAAM,EAAE,QAAQ,EAAE,cAAe;QACpC,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;YACzB,MAAM,EAAE,MAAM;YACd,GAAG,EAAE,OAAO;YACZ,IAAI,EAAE,MAAM;SACf,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC;IACjC,CAAC;IAED,MAAM,CAAC,MAAM,EAAE,QAAiC;QAC5C,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;YACzB,MAAM,EAAE,KAAK;YACb,GAAG,EAAE,OAAO;YACZ,IAAI,EAAE,MAAM;SACf,EAAE,QAAQ,CAAC,CAAC;IACjB,CAAC;IAED,GAAG,CAAC,QAAiC;QACjC,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;YACzB,MAAM,EAAE,KAAK;YACb,GAAG,EAAE,OAAO;SACf,EAAE,QAAQ,CAAC,CAAC;IACjB,CAAC;IAED,IAAI,CAAC,KAAK,EAAE,QAAiC;QACzC,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;YACzB,MAAM,EAAE,KAAK;YACb,GAAG,EAAE,YAAY;YACjB,EAAE,EAAE,KAAK;SACZ,EAAE,QAAQ,CAAC,CAAC;IACjB,CAAC;IAED,MAAM,CAAC,OAAO,EAAE,QAAiC;QAC7C,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;YACzB,MAAM,EAAE,QAAQ;YAChB,GAAG,EAAE,QAAQ,GAAG,OAAO;SAC1B,EAAE,QAAQ,CAAC,CAAC;IACjB,CAAC;IAED,YAAY,CAAC,MAAM,EAAE,QAAiC;QAClD,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;YACzB,MAAM,EAAE,MAAM;YACd,GAAG,EAAE,iBAAiB;YACtB,IAAI,EAAE,MAAM;SACf,EAAE,QAAQ,CAAC,CAAC;IACjB,CAAC;CAEJ;AAtDD,oBAsDC"} \ No newline at end of file diff --git a/dist/ts/endpoints/bank.d.ts b/dist/ts/endpoints/bank.d.ts new file mode 100644 index 0000000..377ab6a --- /dev/null +++ b/dist/ts/endpoints/bank.d.ts @@ -0,0 +1,16 @@ +import { Resource } from "../resource"; +export declare class Bank { + private readonly resource; + constructor(resource: Resource); + list(callback: (err: any, response: any) => void): void; + institutions(callback: (err: any, response: any) => void): void; + delete(bank_id: any, callback: (err: any, response: any) => void): void; + instantAccountVerification(params: any, callback: (err: any, response: any) => void, idempotencyKey?: any): void; + instantAccountVerificationPlaid(params: { + processor_token: string; + }, callback: (err: any, response: any) => void, idempotencyKey?: any): void; + addBankAccount(params: any, callback: (err: any, response: any) => void, idempotencyKey?: any): void; + releaseMicrodeposits(params: any, callback: (err: any, response: any) => void): void; + verifyMicrodeposits(params: any, callback: (err: any, response: any) => void): void; + update(bank_id: any, params: any, callback: (err: any, response: any) => void): void; +} diff --git a/dist/ts/endpoints/bank.js b/dist/ts/endpoints/bank.js new file mode 100644 index 0000000..6aa0276 --- /dev/null +++ b/dist/ts/endpoints/bank.js @@ -0,0 +1,70 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Bank = void 0; +class Bank { + constructor(resource) { + this.resource = resource; + } + list(callback) { + return this.resource.request({ + method: "GET", + uri: "/account/bank", + }, callback); + } + institutions(callback) { + return this.resource.request({ + method: "GET", + uri: "/account/bank/institutions", + }, callback); + } + delete(bank_id, callback) { + return this.resource.request({ + method: "DELETE", + uri: "/account/bank/" + bank_id, + }, callback); + } + instantAccountVerification(params, callback, idempotencyKey) { + return this.resource.request({ + method: "POST", + uri: "/account/bank/iav", + body: params, + }, callback, idempotencyKey); + } + instantAccountVerificationPlaid(params, callback, idempotencyKey) { + return this.resource.request({ + method: "POST", + uri: "/account/bank/iav/plaid", + body: params, + }, callback, idempotencyKey); + } + addBankAccount(params, callback, idempotencyKey) { + return this.resource.request({ + method: "POST", + uri: "/account/bank", + body: params, + }, callback, idempotencyKey); + } + releaseMicrodeposits(params, callback) { + return this.resource.request({ + method: "POST", + uri: "/account/bank/release", + body: params, + }, callback); + } + verifyMicrodeposits(params, callback) { + return this.resource.request({ + method: "POST", + uri: "/account/bank/verify", + body: params, + }, callback); + } + update(bank_id, params, callback) { + return this.resource.request({ + method: "PUT", + uri: "/account/bank/" + bank_id, + body: params, + }, callback); + } +} +exports.Bank = Bank; +//# sourceMappingURL=bank.js.map \ No newline at end of file diff --git a/dist/ts/endpoints/bank.js.map b/dist/ts/endpoints/bank.js.map new file mode 100644 index 0000000..1cc29bc --- /dev/null +++ b/dist/ts/endpoints/bank.js.map @@ -0,0 +1 @@ +{"version":3,"file":"bank.js","sourceRoot":"","sources":["../../../ts/endpoints/bank.ts"],"names":[],"mappings":";;;AAEA,MAAa,IAAI;IAIf,YAA6B,QAAkB;QAAlB,aAAQ,GAAR,QAAQ,CAAU;IAAG,CAAC;IAEnD,IAAI,CAAC,QAAiC;QACpC,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAC1B;YACE,MAAM,EAAE,KAAK;YACb,GAAG,EAAE,eAAe;SACrB,EACD,QAAQ,CACT,CAAC;IACJ,CAAC;IAED,YAAY,CAAC,QAAiC;QAC5C,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAC1B;YACE,MAAM,EAAE,KAAK;YACb,GAAG,EAAE,4BAA4B;SAClC,EACD,QAAQ,CACT,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,OAAO,EAAE,QAAiC;QAC/C,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAC1B;YACE,MAAM,EAAE,QAAQ;YAChB,GAAG,EAAE,gBAAgB,GAAG,OAAO;SAChC,EACD,QAAQ,CACT,CAAC;IACJ,CAAC;IAED,0BAA0B,CACxB,MAAM,EACN,QAAiC,EACjC,cAAe;QAEf,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAC1B;YACE,MAAM,EAAE,MAAM;YACd,GAAG,EAAE,mBAAmB;YACxB,IAAI,EAAE,MAAM;SACb,EACD,QAAQ,EACR,cAAc,CACf,CAAC;IACJ,CAAC;IAED,+BAA+B,CAC7B,MAAmC,EACnC,QAAiC,EACjC,cAAe;QAEf,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAC1B;YACE,MAAM,EAAE,MAAM;YACd,GAAG,EAAE,yBAAyB;YAC9B,IAAI,EAAE,MAAM;SACb,EACD,QAAQ,EACR,cAAc,CACf,CAAC;IACJ,CAAC;IAED,cAAc,CAAC,MAAM,EAAE,QAAiC,EAAE,cAAe;QACvE,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAC1B;YACE,MAAM,EAAE,MAAM;YACd,GAAG,EAAE,eAAe;YACpB,IAAI,EAAE,MAAM;SACb,EACD,QAAQ,EACR,cAAc,CACf,CAAC;IACJ,CAAC;IAED,oBAAoB,CAAC,MAAM,EAAE,QAAiC;QAC5D,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAC1B;YACE,MAAM,EAAE,MAAM;YACd,GAAG,EAAE,uBAAuB;YAC5B,IAAI,EAAE,MAAM;SACb,EACD,QAAQ,CACT,CAAC;IACJ,CAAC;IACD,mBAAmB,CAAC,MAAM,EAAE,QAAiC;QAC3D,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAC1B;YACE,MAAM,EAAE,MAAM;YACd,GAAG,EAAE,sBAAsB;YAC3B,IAAI,EAAE,MAAM;SACb,EACD,QAAQ,CACT,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,QAAiC;QACvD,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAC1B;YACE,MAAM,EAAE,KAAK;YACb,GAAG,EAAE,gBAAgB,GAAG,OAAO;YAC/B,IAAI,EAAE,MAAM;SACb,EACD,QAAQ,CACT,CAAC;IACJ,CAAC;CACF;AA/GD,oBA+GC"} \ No newline at end of file diff --git a/dist/ts/endpoints/check.d.ts b/dist/ts/endpoints/check.d.ts new file mode 100644 index 0000000..f2c1d87 --- /dev/null +++ b/dist/ts/endpoints/check.d.ts @@ -0,0 +1,20 @@ +import { Resource } from "../resource"; +export declare class Check { + private readonly resource; + constructor(resource: Resource); + list(query: any, callback: (err: any, response: any) => void): void; + get(check_id: any, callback: (err: any, response: any) => void): void; + delete(check_id: any, callback: (err: any, response: any) => void): void; + deposit(check_id: string, params: { + account: string; + }, callback: (err: any, response: any) => void): void; + sendDigitalCheck(params: any, callback: (err: any, response: any) => void, idempotencyKey?: any): void; + sendPhysicalCheck(params: any, callback: (err: any, response: any) => void, idempotencyKey?: any): void; + sendDirectCheck(params: any, callback: (err: any, response: any) => void, idempotencyKey?: any): void; + sendMultipleChecksCSV(params: any, callback: (err: any, response: any) => void, idempotencyKey?: any): void; + triggerWebhook(params: { + check_id: string; + status: string; + return_code?: string; + }, callback: (err: any, response: any) => void): void; +} diff --git a/dist/ts/endpoints/check.js b/dist/ts/endpoints/check.js new file mode 100644 index 0000000..311dee0 --- /dev/null +++ b/dist/ts/endpoints/check.js @@ -0,0 +1,74 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Check = void 0; +class Check { + constructor(resource) { + this.resource = resource; + } + list(query, callback) { + return this.resource.request({ + method: "GET", + uri: "/check", + qs: query, + }, callback); + } + get(check_id, callback) { + return this.resource.request({ + method: "GET", + uri: "/check/" + check_id, + }, callback); + } + delete(check_id, callback) { + return this.resource.request({ + method: "DELETE", + uri: "/check/" + check_id, + }, callback); + } + deposit(check_id, params, callback) { + return this.resource.request({ + method: "POST", + uri: "/check/deposit/" + check_id, + body: params, + }, callback); + } + sendDigitalCheck(params, callback, idempotencyKey) { + return this.resource.request({ + method: "POST", + uri: "/check/digital", + body: params, + }, callback, idempotencyKey); + } + sendPhysicalCheck(params, callback, idempotencyKey) { + return this.resource.request({ + method: "POST", + uri: "/check/physical", + body: params, + }, callback, idempotencyKey); + } + sendDirectCheck(params, callback, idempotencyKey) { + return this.resource.request({ + method: "POST", + uri: "/check/direct", + body: params, + }, callback, idempotencyKey); + } + sendMultipleChecksCSV(params, callback, idempotencyKey) { + return this.resource.request({ + method: "POST", + uri: "/check/csv", + body: params, + }, callback, idempotencyKey); + } + triggerWebhook(params, callback) { + return this.resource.request({ + method: "PUT", + uri: "/check/webhook/" + params.check_id, + body: { + status: params.status, + options: params.return_code ? { return_code: params.return_code } : undefined, + }, + }, callback); + } +} +exports.Check = Check; +//# sourceMappingURL=check.js.map \ No newline at end of file diff --git a/dist/ts/endpoints/check.js.map b/dist/ts/endpoints/check.js.map new file mode 100644 index 0000000..97c5d6f --- /dev/null +++ b/dist/ts/endpoints/check.js.map @@ -0,0 +1 @@ +{"version":3,"file":"check.js","sourceRoot":"","sources":["../../../ts/endpoints/check.ts"],"names":[],"mappings":";;;AAEA,MAAa,KAAK;IAIhB,YAA6B,QAAkB;QAAlB,aAAQ,GAAR,QAAQ,CAAU;IAAG,CAAC;IACnD,IAAI,CAAC,KAAK,EAAE,QAAiC;QAC3C,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAC1B;YACE,MAAM,EAAE,KAAK;YACb,GAAG,EAAE,QAAQ;YACb,EAAE,EAAE,KAAK;SACV,EACD,QAAQ,CACT,CAAC;IACJ,CAAC;IAED,GAAG,CAAC,QAAQ,EAAE,QAAiC;QAC7C,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAC1B;YACE,MAAM,EAAE,KAAK;YACb,GAAG,EAAE,SAAS,GAAG,QAAQ;SAC1B,EACD,QAAQ,CACT,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,QAAQ,EAAE,QAAiC;QAChD,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAC1B;YACE,MAAM,EAAE,QAAQ;YAChB,GAAG,EAAE,SAAS,GAAG,QAAQ;SAC1B,EACD,QAAQ,CACT,CAAC;IACJ,CAAC;IAED,OAAO,CACL,QAAgB,EAChB,MAA2B,EAC3B,QAAiC;QAEjC,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAC1B;YACE,MAAM,EAAE,MAAM;YACd,GAAG,EAAE,iBAAiB,GAAG,QAAQ;YACjC,IAAI,EAAE,MAAM;SACb,EACD,QAAQ,CACT,CAAC;IACJ,CAAC;IAED,gBAAgB,CAAC,MAAM,EAAE,QAAiC,EAAE,cAAe;QACzE,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAC1B;YACE,MAAM,EAAE,MAAM;YACd,GAAG,EAAE,gBAAgB;YACrB,IAAI,EAAE,MAAM;SACb,EACD,QAAQ,EACR,cAAc,CACf,CAAC;IACJ,CAAC;IAED,iBAAiB,CACf,MAAM,EACN,QAAiC,EACjC,cAAe;QAEf,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAC1B;YACE,MAAM,EAAE,MAAM;YACd,GAAG,EAAE,iBAAiB;YACtB,IAAI,EAAE,MAAM;SACb,EACD,QAAQ,EACR,cAAc,CACf,CAAC;IACJ,CAAC;IAED,eAAe,CAAC,MAAM,EAAE,QAAiC,EAAE,cAAe;QACxE,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAC1B;YACE,MAAM,EAAE,MAAM;YACd,GAAG,EAAE,eAAe;YACpB,IAAI,EAAE,MAAM;SACb,EACD,QAAQ,EACR,cAAc,CACf,CAAC;IACJ,CAAC;IAED,qBAAqB,CACnB,MAAM,EACN,QAAiC,EACjC,cAAe;QAEf,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAC1B;YACE,MAAM,EAAE,MAAM;YACd,GAAG,EAAE,YAAY;YACjB,IAAI,EAAE,MAAM;SACb,EACD,QAAQ,EACR,cAAc,CACf,CAAC;IACJ,CAAC;IAED,cAAc,CAAC,MAAkE,EAAE,QAAiC;QAClH,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAC1B;YACE,MAAM,EAAE,KAAK;YACb,GAAG,EAAE,iBAAiB,GAAG,MAAM,CAAC,QAAQ;YACxC,IAAI,EAAE;gBACJ,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,OAAO,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,SAAS;aAC9E;SACF,EACD,QAAQ,CACT,CAAC;IACJ,CAAC;CACF;AAxHD,sBAwHC"} \ No newline at end of file diff --git a/dist/ts/endpoints/invoice.d.ts b/dist/ts/endpoints/invoice.d.ts new file mode 100644 index 0000000..3f8cdb7 --- /dev/null +++ b/dist/ts/endpoints/invoice.d.ts @@ -0,0 +1,10 @@ +import { Resource } from "../resource"; +export declare class Invoice { + private readonly resource; + constructor(resource: Resource); + list(query: any, callback: (err: any, response: any) => void): void; + get(invoice_id: any, callback: (err: any, response: any) => void): void; + delete(invoice_id: any, callback: (err: any, response: any) => void): void; + sendInvoice(params: any, callback: (err: any, response: any) => void, idempotencyKey?: any): void; + payInvoice(params: any, callback: (err: any, response: any) => void, idempotencyKey?: any): void; +} diff --git a/dist/ts/endpoints/invoice.js b/dist/ts/endpoints/invoice.js new file mode 100644 index 0000000..c267962 --- /dev/null +++ b/dist/ts/endpoints/invoice.js @@ -0,0 +1,43 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Invoice = void 0; +class Invoice { + constructor(resource) { + this.resource = resource; + } + list(query, callback) { + return this.resource.request({ + method: 'GET', + uri: '/invoice', + qs: query + }, callback); + } + get(invoice_id, callback) { + return this.resource.request({ + method: 'GET', + uri: '/invoice/' + invoice_id + }, callback); + } + delete(invoice_id, callback) { + return this.resource.request({ + method: 'DELETE', + uri: '/invoice/' + invoice_id + }, callback); + } + sendInvoice(params, callback, idempotencyKey) { + return this.resource.request({ + method: 'POST', + uri: '/invoice', + body: params + }, callback, idempotencyKey); + } + payInvoice(params, callback, idempotencyKey) { + return this.resource.request({ + method: 'POST', + uri: '/invoice/payment', + body: params + }, callback, idempotencyKey); + } +} +exports.Invoice = Invoice; +//# sourceMappingURL=invoice.js.map \ No newline at end of file diff --git a/dist/ts/endpoints/invoice.js.map b/dist/ts/endpoints/invoice.js.map new file mode 100644 index 0000000..dbfd354 --- /dev/null +++ b/dist/ts/endpoints/invoice.js.map @@ -0,0 +1 @@ +{"version":3,"file":"invoice.js","sourceRoot":"","sources":["../../../ts/endpoints/invoice.ts"],"names":[],"mappings":";;;AAEA,MAAa,OAAO;IAIhB,YAA6B,QAAkB;QAAlB,aAAQ,GAAR,QAAQ,CAAU;IAE/C,CAAC;IACD,IAAI,CAAC,KAAK,EAAE,QAAiC;QACzC,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;YACzB,MAAM,EAAE,KAAK;YACb,GAAG,EAAE,UAAU;YACf,EAAE,EAAE,KAAK;SACZ,EAAE,QAAQ,CAAC,CAAC;IACjB,CAAC;IAED,GAAG,CAAC,UAAU,EAAE,QAAiC;QAC7C,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;YACzB,MAAM,EAAE,KAAK;YACb,GAAG,EAAE,WAAW,GAAG,UAAU;SAChC,EAAE,QAAQ,CAAC,CAAC;IACjB,CAAC;IAED,MAAM,CAAC,UAAU,EAAE,QAAiC;QAChD,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;YACzB,MAAM,EAAE,QAAQ;YAChB,GAAG,EAAE,WAAW,GAAG,UAAU;SAChC,EAAE,QAAQ,CAAC,CAAC;IACjB,CAAC;IAED,WAAW,CAAC,MAAM,EAAE,QAAiC,EAAE,cAAe;QAClE,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;YACzB,MAAM,EAAE,MAAM;YACd,GAAG,EAAE,UAAU;YACf,IAAI,EAAE,MAAM;SACf,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC;IACjC,CAAC;IAED,UAAU,CAAC,MAAM,EAAE,QAAiC,EAAE,cAAe;QACjE,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;YACzB,MAAM,EAAE,MAAM;YACd,GAAG,EAAE,kBAAkB;YACvB,IAAI,EAAE,MAAM;SACf,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC;IACjC,CAAC;CACJ;AA5CD,0BA4CC"} \ No newline at end of file diff --git a/dist/ts/endpoints/subscription.d.ts b/dist/ts/endpoints/subscription.d.ts new file mode 100644 index 0000000..3684038 --- /dev/null +++ b/dist/ts/endpoints/subscription.d.ts @@ -0,0 +1,11 @@ +import { Resource } from "../resource"; +export declare class Subscription { + private readonly resource; + constructor(resource: Resource); + list(query: any, callback: (err: any, response: any) => void): void; + get(subscription_id: any, callback: (err: any, response: any) => void): void; + delete(subscription_id: any, callback: (err: any, response: any) => void): void; + update(subscription_id: any, params: any, callback: (err: any, response: any) => void): void; + sendRecurringCheck(params: any, callback: (err: any, response: any) => void, idempotencyKey?: any): void; + sendRecurringInvoice(params: any, callback: (err: any, response: any) => void, idempotencyKey?: any): void; +} diff --git a/dist/ts/endpoints/subscription.js b/dist/ts/endpoints/subscription.js new file mode 100644 index 0000000..8f51bf5 --- /dev/null +++ b/dist/ts/endpoints/subscription.js @@ -0,0 +1,50 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Subscription = void 0; +class Subscription { + constructor(resource) { + this.resource = resource; + } + list(query, callback) { + return this.resource.request({ + method: 'GET', + uri: '/subscription', + qs: query + }, callback); + } + get(subscription_id, callback) { + return this.resource.request({ + method: 'GET', + uri: '/subscription/' + subscription_id + }, callback); + } + delete(subscription_id, callback) { + return this.resource.request({ + method: 'DELETE', + uri: '/subscription/' + subscription_id + }, callback); + } + update(subscription_id, params, callback) { + return this.resource.request({ + method: 'PUT', + uri: '/subscription/' + subscription_id, + body: params + }, callback); + } + sendRecurringCheck(params, callback, idempotencyKey) { + return this.resource.request({ + method: 'POST', + uri: '/subscription/check', + body: params + }, callback, idempotencyKey); + } + sendRecurringInvoice(params, callback, idempotencyKey) { + return this.resource.request({ + method: 'POST', + uri: '/subscription/invoice', + body: params + }, callback, idempotencyKey); + } +} +exports.Subscription = Subscription; +//# sourceMappingURL=subscription.js.map \ No newline at end of file diff --git a/dist/ts/endpoints/subscription.js.map b/dist/ts/endpoints/subscription.js.map new file mode 100644 index 0000000..c93b851 --- /dev/null +++ b/dist/ts/endpoints/subscription.js.map @@ -0,0 +1 @@ +{"version":3,"file":"subscription.js","sourceRoot":"","sources":["../../../ts/endpoints/subscription.ts"],"names":[],"mappings":";;;AAEA,MAAa,YAAY;IAIrB,YAA6B,QAAkB;QAAlB,aAAQ,GAAR,QAAQ,CAAU;IAE/C,CAAC;IAED,IAAI,CAAC,KAAK,EAAE,QAAiC;QACzC,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;YACzB,MAAM,EAAE,KAAK;YACb,GAAG,EAAE,eAAe;YACpB,EAAE,EAAE,KAAK;SACZ,EAAE,QAAQ,CAAC,CAAC;IACjB,CAAC;IAED,GAAG,CAAC,eAAe,EAAE,QAAiC;QAClD,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;YACzB,MAAM,EAAE,KAAK;YACb,GAAG,EAAE,gBAAgB,GAAG,eAAe;SAC1C,EAAE,QAAQ,CAAC,CAAC;IACjB,CAAC;IAED,MAAM,CAAC,eAAe,EAAE,QAAiC;QACrD,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;YACzB,MAAM,EAAE,QAAQ;YAChB,GAAG,EAAE,gBAAgB,GAAG,eAAe;SAC1C,EAAE,QAAQ,CAAC,CAAC;IACjB,CAAC;IAED,MAAM,CAAC,eAAe,EAAE,MAAM,EAAE,QAAiC;QAC7D,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;YACzB,MAAM,EAAE,KAAK;YACb,GAAG,EAAE,gBAAgB,GAAG,eAAe;YACvC,IAAI,EAAE,MAAM;SACf,EAAE,QAAQ,CAAC,CAAC;IACjB,CAAC;IAED,kBAAkB,CAAC,MAAM,EAAE,QAAiC,EAAE,cAAe;QACzE,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;YACzB,MAAM,EAAE,MAAM;YACd,GAAG,EAAE,qBAAqB;YAC1B,IAAI,EAAE,MAAM;SACf,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC;IACjC,CAAC;IAED,oBAAoB,CAAC,MAAM,EAAE,QAAiC,EAAE,cAAe;QAC3E,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;YACzB,MAAM,EAAE,MAAM;YACd,GAAG,EAAE,uBAAuB;YAC5B,IAAI,EAAE,MAAM;SACf,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC;IACjC,CAAC;CAEJ;AAtDD,oCAsDC"} \ No newline at end of file diff --git a/dist/ts/endpoints/vcc.d.ts b/dist/ts/endpoints/vcc.d.ts new file mode 100644 index 0000000..0bee606 --- /dev/null +++ b/dist/ts/endpoints/vcc.d.ts @@ -0,0 +1,20 @@ +import { Resource } from "../resource"; +export declare class VirtualCreditCard { + private readonly resource; + constructor(resource: Resource); + add(params: { + address: { + line_1: string; + city: string; + state: string; + zip: string; + }; + }, callback: (err: any, response: any) => void, idempotencyKey?: string): void; + update(vcc_id: string, params: { + name?: string; + default?: boolean; + }, callback: (err: any, response: any) => void): void; + get(callback: (err: any, response: any) => void): void; + getTransactions(vcc_id: string, callback: (err: any, response: any) => void): void; + remove(vcc_id: string, callback: (err: any, response: any) => void): void; +} diff --git a/dist/ts/endpoints/vcc.js b/dist/ts/endpoints/vcc.js new file mode 100644 index 0000000..618f177 --- /dev/null +++ b/dist/ts/endpoints/vcc.js @@ -0,0 +1,42 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.VirtualCreditCard = void 0; +class VirtualCreditCard { + constructor(resource) { + this.resource = resource; + } + add(params, callback, idempotencyKey) { + return this.resource.request({ + method: "POST", + uri: "/account/vcc", + body: params, + }, callback, idempotencyKey); + } + update(vcc_id, params, callback) { + return this.resource.request({ + method: "PUT", + uri: "/account/vcc/" + vcc_id, + body: params, + }, callback); + } + get(callback) { + return this.resource.request({ + method: "GET", + uri: "/account/vcc", + }, callback); + } + getTransactions(vcc_id, callback) { + return this.resource.request({ + method: "GET", + uri: "/account/vcc/" + vcc_id + "/transaction", + }, callback); + } + remove(vcc_id, callback) { + return this.resource.request({ + method: "DELETE", + uri: "/account/vcc/" + vcc_id, + }, callback); + } +} +exports.VirtualCreditCard = VirtualCreditCard; +//# sourceMappingURL=vcc.js.map \ No newline at end of file diff --git a/dist/ts/endpoints/vcc.js.map b/dist/ts/endpoints/vcc.js.map new file mode 100644 index 0000000..6a8b64c --- /dev/null +++ b/dist/ts/endpoints/vcc.js.map @@ -0,0 +1 @@ +{"version":3,"file":"vcc.js","sourceRoot":"","sources":["../../../ts/endpoints/vcc.ts"],"names":[],"mappings":";;;AAEA,MAAa,iBAAiB;IAI5B,YAA6B,QAAkB;QAAlB,aAAQ,GAAR,QAAQ,CAAU;IAAG,CAAC;IAEnD,GAAG,CACD,MAEC,EACD,QAAiC,EACjC,cAAuB;QAEvB,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAC1B;YACE,MAAM,EAAE,MAAM;YACd,GAAG,EAAE,cAAc;YACnB,IAAI,EAAE,MAAM;SACb,EACD,QAAQ,EACR,cAAc,CACf,CAAC;IACJ,CAAC;IAED,MAAM,CACJ,MAAc,EACd,MAA4C,EAC5C,QAAiC;QAEjC,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAC1B;YACE,MAAM,EAAE,KAAK;YACb,GAAG,EAAE,eAAe,GAAG,MAAM;YAC7B,IAAI,EAAE,MAAM;SACb,EACD,QAAQ,CACT,CAAC;IACJ,CAAC;IAED,GAAG,CAAC,QAAiC;QACnC,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAC1B;YACE,MAAM,EAAE,KAAK;YACb,GAAG,EAAE,cAAc;SACpB,EACD,QAAQ,CACT,CAAC;IACJ,CAAC;IAED,eAAe,CAAC,MAAc,EAAE,QAAiC;QAC/D,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAC1B;YACE,MAAM,EAAE,KAAK;YACb,GAAG,EAAE,eAAe,GAAG,MAAM,GAAG,cAAc;SAC/C,EACD,QAAQ,CACT,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,MAAc,EAAE,QAAiC;QACtD,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAC1B;YACE,MAAM,EAAE,QAAQ;YAChB,GAAG,EAAE,eAAe,GAAG,MAAM;SAC9B,EACD,QAAQ,CACT,CAAC;IACJ,CAAC;CACF;AApED,8CAoEC"} \ No newline at end of file diff --git a/dist/ts/endpoints/wallet.d.ts b/dist/ts/endpoints/wallet.d.ts new file mode 100644 index 0000000..2f48db1 --- /dev/null +++ b/dist/ts/endpoints/wallet.d.ts @@ -0,0 +1,13 @@ +import { Resource } from "../resource"; +export declare class Wallet { + private readonly resource; + constructor(resource: Resource); + add(params: { + name: string; + }, callback: (err: any, response: any) => void, idempotencyKey?: string): void; + update(wallet_id: string, params: { + name?: string; + }, callback: (err: any, response: any) => void): void; + get(callback: (err: any, response: any) => void): void; + remove(wallet_id: string, callback: (err: any, response: any) => void): void; +} diff --git a/dist/ts/endpoints/wallet.js b/dist/ts/endpoints/wallet.js new file mode 100644 index 0000000..a57d631 --- /dev/null +++ b/dist/ts/endpoints/wallet.js @@ -0,0 +1,36 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Wallet = void 0; +class Wallet { + constructor(resource) { + this.resource = resource; + } + add(params, callback, idempotencyKey) { + return this.resource.request({ + method: "POST", + uri: "/account/wallet", + body: params, + }, callback, idempotencyKey); + } + update(wallet_id, params, callback) { + return this.resource.request({ + method: "PUT", + uri: "/account/wallet/" + wallet_id, + body: params, + }, callback); + } + get(callback) { + return this.resource.request({ + method: "GET", + uri: "/account/wallet", + }, callback); + } + remove(wallet_id, callback) { + return this.resource.request({ + method: "DELETE", + uri: "/account/wallet/" + wallet_id, + }, callback); + } +} +exports.Wallet = Wallet; +//# sourceMappingURL=wallet.js.map \ No newline at end of file diff --git a/dist/ts/endpoints/wallet.js.map b/dist/ts/endpoints/wallet.js.map new file mode 100644 index 0000000..bde775d --- /dev/null +++ b/dist/ts/endpoints/wallet.js.map @@ -0,0 +1 @@ +{"version":3,"file":"wallet.js","sourceRoot":"","sources":["../../../ts/endpoints/wallet.ts"],"names":[],"mappings":";;;AAEA,MAAa,MAAM;IAIjB,YAA6B,QAAkB;QAAlB,aAAQ,GAAR,QAAQ,CAAU;IAAG,CAAC;IAEnD,GAAG,CACD,MAEC,EACD,QAAiC,EACjC,cAAuB;QAEvB,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAC1B;YACE,MAAM,EAAE,MAAM;YACd,GAAG,EAAE,iBAAiB;YACtB,IAAI,EAAE,MAAM;SACb,EACD,QAAQ,EACR,cAAc,CACf,CAAC;IACJ,CAAC;IAED,MAAM,CACJ,SAAiB,EACjB,MAA0B,EAC1B,QAAiC;QAEjC,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAC1B;YACE,MAAM,EAAE,KAAK;YACb,GAAG,EAAE,kBAAkB,GAAG,SAAS;YACnC,IAAI,EAAE,MAAM;SACb,EACD,QAAQ,CACT,CAAC;IACJ,CAAC;IAED,GAAG,CAAC,QAAiC;QACnC,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAC1B;YACE,MAAM,EAAE,KAAK;YACb,GAAG,EAAE,iBAAiB;SACvB,EACD,QAAQ,CACT,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,SAAiB,EAAE,QAAiC;QACzD,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAC1B;YACE,MAAM,EAAE,QAAQ;YAChB,GAAG,EAAE,kBAAkB,GAAG,SAAS;SACpC,EACD,QAAQ,CACT,CAAC;IACJ,CAAC;CACF;AA1DD,wBA0DC"} \ No newline at end of file diff --git a/dist/ts/resource.d.ts b/dist/ts/resource.d.ts new file mode 100644 index 0000000..b792b88 --- /dev/null +++ b/dist/ts/resource.d.ts @@ -0,0 +1,7 @@ +export declare class Resource { + private readonly baseURI; + private readonly defaultOptions; + constructor(config: any); + request(options: any, callback: (err: any, response: any) => void, idempotencyKey?: any): void; + getRequestOptions(options: any, idempotencyKey?: any): any; +} diff --git a/dist/ts/resource.js b/dist/ts/resource.js new file mode 100644 index 0000000..ad20429 --- /dev/null +++ b/dist/ts/resource.js @@ -0,0 +1,38 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Resource = void 0; +const request = require("request"); +class Resource { + constructor(config) { + this.baseURI = "https://" + config.env + ".checkbook.io/v3"; + this.defaultOptions = { + json: true, + headers: { + Accept: "application/json", + Authorization: config.auth, + }, + }; + } + request(options, callback, idempotencyKey) { + request(this.getRequestOptions(options, idempotencyKey), function (error, response, body) { + if (error) { + return callback.call(this, error, null); + } + if (![200, 201, 204].includes(response.statusCode) || (body === null || body === void 0 ? void 0 : body.error)) { + error = response.statusCode + " " + (body === null || body === void 0 ? void 0 : body.error); + return callback.call(this, error, response); + } + return callback.call(this, null, body); + }); + } + getRequestOptions(options, idempotencyKey) { + options = Object.assign(Object.assign({}, options), this.defaultOptions); + if (idempotencyKey) { + options.headers["Idempotency-Key"] = idempotencyKey; + } + options.uri = this.baseURI + options.uri; + return options; + } +} +exports.Resource = Resource; +//# sourceMappingURL=resource.js.map \ No newline at end of file diff --git a/dist/ts/resource.js.map b/dist/ts/resource.js.map new file mode 100644 index 0000000..88cc01e --- /dev/null +++ b/dist/ts/resource.js.map @@ -0,0 +1 @@ +{"version":3,"file":"resource.js","sourceRoot":"","sources":["../../ts/resource.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAEb,mCAAmC;AACnC,MAAa,QAAQ;IAMnB,YAAY,MAAM;QAChB,IAAI,CAAC,OAAO,GAAG,UAAU,GAAG,MAAM,CAAC,GAAG,GAAG,kBAAkB,CAAC;QAC5D,IAAI,CAAC,cAAc,GAAG;YACpB,IAAI,EAAE,IAAI;YACV,OAAO,EAAE;gBACP,MAAM,EAAE,kBAAkB;gBAC1B,aAAa,EAAE,MAAM,CAAC,IAAI;aAC3B;SACF,CAAC;IACJ,CAAC;IAEM,OAAO,CAAC,OAAO,EAAE,QAAiC,EAAE,cAAe;QACxE,OAAO,CACL,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,cAAc,CAAC,EAC/C,UAAU,KAAK,EAAE,QAAQ,EAAE,IAAI;YAC7B,IAAI,KAAK,EAAE;gBACT,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;aACzC;YAED,IAAI,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,KAAI,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,KAAK,CAAA,EAAE;gBACjE,KAAK,GAAG,QAAQ,CAAC,UAAU,GAAG,GAAG,IAAG,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,KAAK,CAAA,CAAC;gBAChD,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;aAC7C;YAED,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QACzC,CAAC,CACF,CAAC;IACJ,CAAC;IAED,iBAAiB,CAAC,OAAO,EAAE,cAAe;QACxC,OAAO,mCAAQ,OAAO,GAAK,IAAI,CAAC,cAAc,CAAE,CAAC;QAEjD,IAAI,cAAc,EAAE;YAClB,OAAO,CAAC,OAAO,CAAC,iBAAiB,CAAC,GAAG,cAAc,CAAC;SACrD;QAED,OAAO,CAAC,GAAG,GAAG,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC;QAEzC,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AA9CD,4BA8CC"} \ No newline at end of file diff --git a/dist/tsconfig.tsbuildinfo b/dist/tsconfig.tsbuildinfo new file mode 100644 index 0000000..7ee9782 --- /dev/null +++ b/dist/tsconfig.tsbuildinfo @@ -0,0 +1 @@ +{"program":{"fileNames":["../node_modules/typescript/lib/lib.es5.d.ts","../node_modules/typescript/lib/lib.es2015.d.ts","../node_modules/typescript/lib/lib.es2016.d.ts","../node_modules/typescript/lib/lib.es2017.d.ts","../node_modules/typescript/lib/lib.es2015.core.d.ts","../node_modules/typescript/lib/lib.es2015.collection.d.ts","../node_modules/typescript/lib/lib.es2015.generator.d.ts","../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../node_modules/typescript/lib/lib.es2015.promise.d.ts","../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../node_modules/typescript/lib/lib.es2017.date.d.ts","../node_modules/typescript/lib/lib.es2017.object.d.ts","../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../node_modules/typescript/lib/lib.es2017.string.d.ts","../node_modules/typescript/lib/lib.es2017.intl.d.ts","../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../node_modules/typescript/lib/lib.decorators.d.ts","../node_modules/typescript/lib/lib.decorators.legacy.d.ts","../ts/resource.ts","../ts/endpoints/check.ts","../ts/endpoints/invoice.ts","../ts/endpoints/subscription.ts","../ts/endpoints/bank.ts","../ts/endpoints/user.ts","../ts/endpoints/vcc.ts","../ts/endpoints/wallet.ts","../ts/checkbook.ts","../index.ts"],"fileInfos":[{"version":"2ac9cdcfb8f8875c18d14ec5796a8b029c426f73ad6dc3ffb580c228b58d1c44","affectsGlobalScope":true},"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","dc48272d7c333ccf58034c0026162576b7d50ea0e69c3b9292f803fc20720fd5","9a68c0c07ae2fa71b44384a839b7b8d81662a236d4b9ac30916718f7510b1b2d",{"version":"f296963760430fb65b4e5d91f0ed770a91c6e77455bacf8fa23a1501654ede0e","affectsGlobalScope":true},{"version":"09226e53d1cfda217317074a97724da3e71e2c545e18774484b61562afc53cd2","affectsGlobalScope":true},{"version":"4443e68b35f3332f753eacc66a04ac1d2053b8b035a0e0ac1d455392b5e243b3","affectsGlobalScope":true},{"version":"8b41361862022eb72fcc8a7f34680ac842aca802cf4bc1f915e8c620c9ce4331","affectsGlobalScope":true},{"version":"f7bd636ae3a4623c503359ada74510c4005df5b36de7f23e1db8a5c543fd176b","affectsGlobalScope":true},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true},{"version":"0c20f4d2358eb679e4ae8a4432bdd96c857a2960fd6800b21ec4008ec59d60ea","affectsGlobalScope":true},{"version":"93495ff27b8746f55d19fcbcdbaccc99fd95f19d057aed1bd2c0cafe1335fbf0","affectsGlobalScope":true},{"version":"82d0d8e269b9eeac02c3bd1c9e884e85d483fcb2cd168bccd6bc54df663da031","affectsGlobalScope":true},{"version":"38f0219c9e23c915ef9790ab1d680440d95419ad264816fa15009a8851e79119","affectsGlobalScope":true},{"version":"b8deab98702588840be73d67f02412a2d45a417a3c097b2e96f7f3a42ac483d1","affectsGlobalScope":true},{"version":"4738f2420687fd85629c9efb470793bb753709c2379e5f85bc1815d875ceadcd","affectsGlobalScope":true},{"version":"2f11ff796926e0832f9ae148008138ad583bd181899ab7dd768a2666700b1893","affectsGlobalScope":true},{"version":"376d554d042fb409cb55b5cbaf0b2b4b7e669619493c5d18d5fa8bd67273f82a","affectsGlobalScope":true},{"version":"9fc46429fbe091ac5ad2608c657201eb68b6f1b8341bd6d670047d32ed0a88fa","affectsGlobalScope":true},{"version":"f35a831e4f0fe3b3697f4a0fe0e3caa7624c92b78afbecaf142c0f93abfaf379","affectsGlobalScope":true},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true},{"version":"845eeac3e6534197fdc1c94f9626058dc38bb4cf8586fa0c41678dc4d2e88896","signature":"70acd2e3a1aaff11239efe422984b84a77c182d7ddb65b23fab334538614c535"},{"version":"fc2dba97c16094289f4fe2d29a74cbf4192c0e5b3f6dca0fce5e49cec9fa7244","signature":"32479517b734f200765b83dd0548e6d899a3b2f473b2b8768a02ba797e49cb5f"},{"version":"8ae46c299e7d0b9074cd8b1e9574d19dac718b8f6ee6ac9de187a1629f095b75","signature":"d9be70ba9529740f8810654e298331ef1eef206a86572feb1f95b279a27a8d13"},{"version":"6bcea1c0dcec8c462ba1a8e99f73bc3721ec54b9f23577046643f08c487f11d2","signature":"c31752adfa450412582178023941f11f2b811c4c6729464c6d1c92795ea1c249"},{"version":"3069387174a5521a43e9659dd4ee06cb96a029fe3c7fdfcbfae20afb3d50099d","signature":"dc8a038c2028f980cfb0845e38986744f5aa91876bab8b494f20cb29bfb3571f"},{"version":"725f2520ad44e72fc5773b993cf15b9ac320f890c1710ab5f51bdb484815a3e8","signature":"7261a9a50f3f341dbd57427a3081f3e6f290d6a555f049d187512ac1cb844835"},{"version":"0bd48121ac87d0b441b641a4b69eff9327a631484df769b1bfe2870550d23e8c","signature":"c089933810a0ce743e97b53ac015d8f64b71f37e5d0ebf89de1dc9658e591da0"},{"version":"de5606dddfd173d88eb809cb2d3a01fdbf944683d30fc8a8b143d6197a87c0cd","signature":"a4f8a0c03509ff5c91b703f7ff3fc0769795ca033d58f00bf8d7dc528f368723"},{"version":"f38762361b01646ac5514122a5319747a378a63de4e693bbd9d1b1e867661144","signature":"1774c63854a94516033ef11b08f69d56e45fa5e98ad2b0fb00e5e7f63348429d"},{"version":"bc3c4b1c4836b1210d0450d9ad0da0cc4865fc59cf9f2b527410f1cc5d7e9032","signature":"0ccdf2807af1066a89af98800b9a1a69781644981e5581961748a84dd7b25897"}],"root":[[23,32]],"options":{"allowSyntheticDefaultImports":true,"declaration":true,"emitDecoratorMetadata":true,"experimentalDecorators":true,"module":1,"outDir":"./","removeComments":true,"sourceMap":true,"target":4},"fileIdsList":[[31],[23,24,25,26,27,28,29,30],[23]],"referencedMap":[[32,1],[31,2],[27,3],[24,3],[25,3],[26,3],[28,3],[29,3],[30,3]],"exportedModulesMap":[[32,1],[31,2],[27,3],[24,3],[25,3],[26,3],[28,3],[29,3],[30,3]],"semanticDiagnosticsPerFile":[32,21,22,6,5,2,7,8,9,10,11,12,13,14,3,4,15,19,16,17,18,20,1,31,27,24,25,26,28,29,30,23]},"version":"5.2.2"} \ No newline at end of file diff --git a/index.ts b/index.ts new file mode 100644 index 0000000..56704aa --- /dev/null +++ b/index.ts @@ -0,0 +1,3 @@ +import CheckbookAPI from "./ts/checkbook"; + +export default CheckbookAPI; diff --git a/lib/checkbook.js b/lib/checkbook.js index eb70d4d..fef006b 100644 --- a/lib/checkbook.js +++ b/lib/checkbook.js @@ -9,19 +9,20 @@ var Invoice = require('./endpoints/invoice'); var Subscription = require('./endpoints/subscription'); var Bank = require('./endpoints/bank'); var User = require('./endpoints/user'); +var VirtualCreditCard = require('./endpoints/vcc'); function Checkbook(config) { if (!config.env || !_.includes(['demo', 'sandbox'], config.env)) { config.env = 'www'; } - if (config.bearer) { - config.auth = 'Bearer ' + config.bearer; - } else if (config.api_key && config.api_secret){ - config.auth = config.api_key + ':' + config.api_secret; - } else { - throw 'Invalid Authorization'; - } + if (config.bearer) { + config.auth = 'Bearer ' + config.bearer; + } else if (config.api_key && config.api_secret) { + config.auth = config.api_key + ':' + config.api_secret; + } else { + throw 'Invalid Authorization'; + } this.resource = new Resource(config); @@ -30,6 +31,7 @@ function Checkbook(config) { this.subscriptions = new Subscription(this.resource); this.banks = new Bank(this.resource); this.users = new User(this.resource); + this.virtualCreditCards = new VirtualCreditCard(this.resource); } diff --git a/lib/endpoints/bank.js b/lib/endpoints/bank.js index 5171554..136780f 100644 --- a/lib/endpoints/bank.js +++ b/lib/endpoints/bank.js @@ -6,28 +6,28 @@ function Bank(resource) { Bank.prototype = { - list: function(callback) { + list: function (callback) { return this.resource.request({ method: 'GET', uri: '/bank' }, callback); }, - institutions: function(callback) { + institutions: function (callback) { return this.resource.request({ method: 'GET', uri: '/bank/institutions' }, callback); }, - delete: function(bank_id, callback) { + delete: function (bank_id, callback) { return this.resource.request({ method: 'DELETE', uri: '/bank/' + bank_id }, callback); }, - instantAccountVerification: function(params, callback, idempotencyKey) { + instantAccountVerification: function (params, callback, idempotencyKey) { return this.resource.request({ method: 'POST', uri: '/bank/iav', @@ -35,7 +35,7 @@ Bank.prototype = { }, callback, idempotencyKey); }, - addBankAccount: function(params, callback, idempotencyKey) { + addBankAccount: function (params, callback, idempotencyKey) { return this.resource.request({ method: 'POST', uri: '/bank', @@ -43,12 +43,28 @@ Bank.prototype = { }, callback, idempotencyKey); }, - verifyMicrodesposits: function(params, callback) { + releaseMicrodeposits: function (params, callback) { + return this.resource.request({ + method: 'POST', + uri: '/bank/release', + body: params + }, callback); + }, + + verifyMicrodeposits: function (params, callback) { return this.resource.request({ method: 'POST', uri: '/bank/verify', body: params }, callback); + }, + + update: function (bank_id, params, callback) { + return this.resource.request({ + method: 'PUT', + uri: '/bank/' + bank_id, + body: params + }, callback); } }; diff --git a/lib/endpoints/vcc.js b/lib/endpoints/vcc.js new file mode 100644 index 0000000..281536a --- /dev/null +++ b/lib/endpoints/vcc.js @@ -0,0 +1,49 @@ +'use strict'; + +function VirtualCreditCard(resource) { + this.resource = resource; +} + +VirtualCreditCard.prototype = { + + add: function (params, callback, idempotencyKey) { + return this.resource.request({ + method: 'POST', + uri: '/account/vcc', + body: params + }, callback, idempotencyKey); + }, + + update: function (vcc_id, params, callback) { + return this.resource.request({ + method: 'PUT', + uri: '/account/vcc/' + vcc_id, + body: params + }, callback); + }, + + get: function (callback) { + return this.resource.request({ + method: 'GET', + uri: '/account/vcc' + }, callback); + }, + + getTransactions: function (vcc_id, callback) { + return this.resource.request({ + method: 'GET', + uri: '/account/vcc/' + vcc_id + 'transaction', + qs: query + }, callback); + }, + + remove: function (vcc_id, callback) { + return this.resource.request({ + method: 'DELETE', + uri: '/account/vcc/' + vcc_id + }, callback); + }, + +}; + +module.exports = VirtualCreditCard; diff --git a/package-lock.json b/package-lock.json index 61388cc..e19cd68 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,252 +1,459 @@ { - "name": "checkbook-api", - "version": "3.2.4", - "lockfileVersion": 1, + "name": "checkbook-api-ts", + "version": "1.3.2", + "lockfileVersion": 3, "requires": true, - "dependencies": { - "ajv": { - "version": "6.9.1", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.9.1.tgz", - "integrity": "sha512-XDN92U311aINL77ieWHmqCcNlwjoP5cHXDxIxbf2MaPYuCXOHS7gHH8jktxeK5omgd52XbSTX6a4Piwd1pQmzA==", - "requires": { - "fast-deep-equal": "^2.0.1", + "packages": { + "": { + "name": "checkbook-api-ts", + "version": "1.3.2", + "license": "MIT", + "dependencies": { + "request": "^2.88.0" + }, + "devDependencies": { + "rimraf": "^3.0.2", + "typescript": "^5.2.2" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/ajv": { + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "license": "MIT", + "dependencies": { + "fast-deep-equal": "^3.1.1", "fast-json-stable-stringify": "^2.0.0", "json-schema-traverse": "^0.4.1", "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" } }, - "asn1": { + "node_modules/asn1": { "version": "0.2.4", "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", "integrity": "sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg==", - "requires": { + "license": "MIT", + "dependencies": { "safer-buffer": "~2.1.0" } }, - "assert-plus": { + "node_modules/assert-plus": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", - "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", + "license": "MIT", + "engines": { + "node": ">=0.8" + } }, - "asynckit": { + "node_modules/asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=", + "license": "MIT" }, - "aws-sign2": { + "node_modules/aws-sign2": { "version": "0.7.0", "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", - "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=" + "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=", + "license": "Apache-2.0", + "engines": { + "node": "*" + } }, - "aws4": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.8.0.tgz", - "integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==" + "node_modules/aws4": { + "version": "1.11.0", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.11.0.tgz", + "integrity": "sha512-xh1Rl34h6Fi1DC2WWKfxUTVqRsNnr6LsKz2+hfwDxQJWmrx8+c7ylaqBMcHfl1U1r2dsifOvKX3LQuLNZ+XSvA==", + "license": "MIT" }, - "bcrypt-pbkdf": { + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true, + "license": "MIT" + }, + "node_modules/bcrypt-pbkdf": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", "integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=", - "requires": { + "license": "BSD-3-Clause", + "dependencies": { "tweetnacl": "^0.14.3" } }, - "caseless": { + "node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/caseless": { "version": "0.12.0", "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", - "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=" - }, - "combined-stream": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.7.tgz", - "integrity": "sha512-brWl9y6vOB1xYPZcpZde3N9zDByXTosAeMDo4p1wzo6UMOX4vumB+TP1RZ76sfE6Md68Q0NJSrE/gbezd4Ul+w==", - "requires": { + "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=", + "license": "Apache-2.0" + }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "license": "MIT", + "dependencies": { "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" } }, - "core-util-is": { + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true, + "license": "MIT" + }, + "node_modules/core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", + "license": "MIT" }, - "dashdash": { + "node_modules/dashdash": { "version": "1.14.1", "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", - "requires": { + "license": "MIT", + "dependencies": { "assert-plus": "^1.0.0" + }, + "engines": { + "node": ">=0.10" } }, - "delayed-stream": { + "node_modules/delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", + "license": "MIT", + "engines": { + "node": ">=0.4.0" + } }, - "ecc-jsbn": { + "node_modules/ecc-jsbn": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", "integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=", - "requires": { + "license": "MIT", + "dependencies": { "jsbn": "~0.1.0", "safer-buffer": "^2.1.0" } }, - "extend": { + "node_modules/extend": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", - "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==" + "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", + "license": "MIT" }, - "extsprintf": { + "node_modules/extsprintf": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", - "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=" - }, - "fast-deep-equal": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", - "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=" - }, - "fast-json-stable-stringify": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", - "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=" + "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=", + "engines": [ + "node >=0.6.0" + ], + "license": "MIT" + }, + "node_modules/fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "license": "MIT" + }, + "node_modules/fast-json-stable-stringify": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", + "license": "MIT" }, - "forever-agent": { + "node_modules/forever-agent": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", - "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=" + "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=", + "license": "Apache-2.0", + "engines": { + "node": "*" + } }, - "form-data": { + "node_modules/form-data": { "version": "2.3.3", "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz", "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==", - "requires": { + "license": "MIT", + "dependencies": { "asynckit": "^0.4.0", "combined-stream": "^1.0.6", "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 0.12" } }, - "getpass": { + "node_modules/fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true, + "license": "ISC" + }, + "node_modules/getpass": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", - "requires": { + "license": "MIT", + "dependencies": { "assert-plus": "^1.0.0" } }, - "har-schema": { + "node_modules/glob": { + "version": "7.1.7", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.7.tgz", + "integrity": "sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ==", + "dev": true, + "license": "ISC", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/har-schema": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", - "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=" - }, - "har-validator": { - "version": "5.1.3", - "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.3.tgz", - "integrity": "sha512-sNvOCzEQNr/qrvJgc3UG/kD4QtlHycrzwS+6mfTrrSq97BvaYcPZZI1ZSqGSPR73Cxn4LKTD4PttRwfU7jWq5g==", - "requires": { - "ajv": "^6.5.5", + "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=", + "license": "ISC", + "engines": { + "node": ">=4" + } + }, + "node_modules/har-validator": { + "version": "5.1.5", + "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.5.tgz", + "integrity": "sha512-nmT2T0lljbxdQZfspsno9hgrG3Uir6Ks5afism62poxqBM6sDnMEuPmzTq8XN0OEwqKLLdh1jQI3qyE66Nzb3w==", + "license": "MIT", + "dependencies": { + "ajv": "^6.12.3", "har-schema": "^2.0.0" + }, + "engines": { + "node": ">=6" } }, - "http-signature": { + "node_modules/http-signature": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", - "requires": { + "license": "MIT", + "dependencies": { "assert-plus": "^1.0.0", "jsprim": "^1.2.2", "sshpk": "^1.7.0" + }, + "engines": { + "node": ">=0.8", + "npm": ">=1.3.7" + } + }, + "node_modules/inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, + "license": "ISC", + "dependencies": { + "once": "^1.3.0", + "wrappy": "1" } }, - "is-typedarray": { + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/is-typedarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", - "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=" + "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=", + "license": "MIT" }, - "isstream": { + "node_modules/isstream": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", - "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=" + "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=", + "license": "MIT" }, - "jsbn": { + "node_modules/jsbn": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", - "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=" + "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", + "license": "MIT" }, - "json-schema": { + "node_modules/json-schema": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=" }, - "json-schema-traverse": { + "node_modules/json-schema-traverse": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", - "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==" + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "license": "MIT" }, - "json-stringify-safe": { + "node_modules/json-stringify-safe": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", - "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=" + "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=", + "license": "ISC" }, - "jsprim": { + "node_modules/jsprim": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=", - "requires": { + "engines": [ + "node >=0.6.0" + ], + "license": "MIT", + "dependencies": { "assert-plus": "1.0.0", "extsprintf": "1.3.0", "json-schema": "0.2.3", "verror": "1.10.0" } }, - "lodash": { - "version": "4.17.14", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.14.tgz", - "integrity": "sha512-mmKYbW3GLuJeX+iGP+Y7Gp1AiGHGbXHCOh/jZmrawMmsE7MS4znI3RL2FsjbqOyMayHInjOeykW7PEajUk1/xw==" + "node_modules/mime-db": { + "version": "1.49.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.49.0.tgz", + "integrity": "sha512-CIc8j9URtOVApSFCQIF+VBkX1RwXp/oMMOrqdyXSBXq5RWNEsRfyj1kiRnQgmNXmHxPoFIxOroKA3zcU9P+nAA==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } }, - "mime-db": { - "version": "1.37.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.37.0.tgz", - "integrity": "sha512-R3C4db6bgQhlIhPU48fUtdVmKnflq+hRdad7IyKhtFj06VPNVdk2RhiYL3UjQIlso8L+YxAtFkobT0VK+S/ybg==" + "node_modules/mime-types": { + "version": "2.1.32", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.32.tgz", + "integrity": "sha512-hJGaVS4G4c9TSMYh2n6SQAGrC4RnfU+daP8G7cSCmaqNjiOoUY0VHCMS42pxnQmVF1GWwFhbHWn3RIxCqTmZ9A==", + "license": "MIT", + "dependencies": { + "mime-db": "1.49.0" + }, + "engines": { + "node": ">= 0.6" + } }, - "mime-types": { - "version": "2.1.21", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.21.tgz", - "integrity": "sha512-3iL6DbwpyLzjR3xHSFNFeb9Nz/M8WDkX33t1GFQnFOllWk8pOrh/LSrB5OXlnlW5P9LH73X6loW/eogc+F5lJg==", - "requires": { - "mime-db": "~1.37.0" + "node_modules/minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" } }, - "oauth-sign": { + "node_modules/oauth-sign": { "version": "0.9.0", "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", - "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==" + "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==", + "license": "Apache-2.0", + "engines": { + "node": "*" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, + "license": "ISC", + "dependencies": { + "wrappy": "1" + } }, - "performance-now": { + "node_modules/path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/performance-now": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", - "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=" + "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=", + "license": "MIT" }, - "psl": { - "version": "1.1.31", - "resolved": "https://registry.npmjs.org/psl/-/psl-1.1.31.tgz", - "integrity": "sha512-/6pt4+C+T+wZUieKR620OpzN/LlnNKuWjy1iFLQ/UG35JqHlR/89MP1d96dUfkf6Dne3TuLQzOYEYshJ+Hx8mw==" + "node_modules/psl": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/psl/-/psl-1.8.0.tgz", + "integrity": "sha512-RIdOzyoavK+hA18OGGWDqUTsCLhtA7IcZ/6NCs4fFJaHBDab+pDDmDIByWFRQJq2Cd7r1OoQxBGKOaztq+hjIQ==", + "license": "MIT" }, - "punycode": { + "node_modules/punycode": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", - "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", + "license": "MIT", + "engines": { + "node": ">=6" + } }, - "qs": { + "node_modules/qs": { "version": "6.5.2", "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", - "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==" + "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==", + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.6" + } }, - "request": { - "version": "2.88.0", - "resolved": "https://registry.npmjs.org/request/-/request-2.88.0.tgz", - "integrity": "sha512-NAqBSrijGLZdM0WZNsInLJpkJokL72XYjUpnB0iwsRgxh7dB6COrHnTBNwN0E+lHDAJzu7kLAkDeY08z2/A0hg==", - "requires": { + "node_modules/request": { + "version": "2.88.2", + "resolved": "https://registry.npmjs.org/request/-/request-2.88.2.tgz", + "integrity": "sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw==", + "license": "Apache-2.0", + "dependencies": { "aws-sign2": "~0.7.0", "aws4": "^1.8.0", "caseless": "~0.12.0", @@ -254,7 +461,7 @@ "extend": "~3.0.2", "forever-agent": "~0.6.1", "form-data": "~2.3.2", - "har-validator": "~5.1.0", + "har-validator": "~5.1.3", "http-signature": "~1.2.0", "is-typedarray": "~1.0.0", "isstream": "~0.1.2", @@ -264,26 +471,62 @@ "performance-now": "^2.1.0", "qs": "~6.5.2", "safe-buffer": "^5.1.2", - "tough-cookie": "~2.4.3", + "tough-cookie": "~2.5.0", "tunnel-agent": "^0.6.0", "uuid": "^3.3.2" + }, + "engines": { + "node": ">= 6" } }, - "safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + "node_modules/rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "dev": true, + "license": "ISC", + "dependencies": { + "glob": "^7.1.3" + }, + "bin": { + "rimraf": "bin.js" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } }, - "safer-buffer": { + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/safer-buffer": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "license": "MIT" }, - "sshpk": { + "node_modules/sshpk": { "version": "1.16.1", "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.16.1.tgz", "integrity": "sha512-HXXqVUq7+pcKeLqqZj6mHFUMvXtOJt1uoUx09pFW6011inTMxqI8BA8PM95myrIyyKwdnzjdFjLiE6KBPVtJIg==", - "requires": { + "license": "MIT", + "dependencies": { "asn1": "~0.2.3", "assert-plus": "^1.0.0", "bcrypt-pbkdf": "^1.0.0", @@ -293,59 +536,94 @@ "jsbn": "~0.1.0", "safer-buffer": "^2.0.2", "tweetnacl": "~0.14.0" + }, + "engines": { + "node": ">=0.10.0" } }, - "tough-cookie": { - "version": "2.4.3", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz", - "integrity": "sha512-Q5srk/4vDM54WJsJio3XNn6K2sCG+CQ8G5Wz6bZhRZoAe/+TxjWB/GlFAnYEbkYVlON9FMk/fE3h2RLpPXo4lQ==", - "requires": { - "psl": "^1.1.24", - "punycode": "^1.4.1" - }, + "node_modules/tough-cookie": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz", + "integrity": "sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g==", + "license": "BSD-3-Clause", "dependencies": { - "punycode": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", - "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=" - } + "psl": "^1.1.28", + "punycode": "^2.1.1" + }, + "engines": { + "node": ">=0.8" } }, - "tunnel-agent": { + "node_modules/tunnel-agent": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", - "requires": { + "license": "Apache-2.0", + "dependencies": { "safe-buffer": "^5.0.1" + }, + "engines": { + "node": "*" } }, - "tweetnacl": { + "node_modules/tweetnacl": { "version": "0.14.5", "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", - "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=" + "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", + "license": "Unlicense" + }, + "node_modules/typescript": { + "version": "5.2.2", + "resolved": "https://pkgs.dev.azure.com/precise-finance/precise-finance/_packaging/precise-npm/npm/registry/typescript/-/typescript-5.2.2.tgz", + "integrity": "sha1-XrteWlt18IXyK8P4Rg+6MIMQ+ng=", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } }, - "uri-js": { - "version": "4.2.2", - "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", - "integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==", - "requires": { + "node_modules/uri-js": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "license": "BSD-2-Clause", + "dependencies": { "punycode": "^2.1.0" } }, - "uuid": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", - "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==" + "node_modules/uuid": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", + "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", + "license": "MIT", + "bin": { + "uuid": "bin/uuid" + } }, - "verror": { + "node_modules/verror": { "version": "1.10.0", "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", - "requires": { + "engines": [ + "node >=0.6.0" + ], + "license": "MIT", + "dependencies": { "assert-plus": "^1.0.0", "core-util-is": "1.0.2", "extsprintf": "^1.2.0" } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true, + "license": "ISC" } } } diff --git a/package.json b/package.json index 99bd4d1..2d96f92 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { - "name": "checkbook-api", - "version": "3.2.4", - "description": "Node.js library for the Checkbook.io API", + "name": "checkbook-api-ts", + "version": "1.3.5", + "description": "Node.js library for the Checkbook.io API in TS", "keywords": [ "checkbook", "digital checks", @@ -9,17 +9,20 @@ "api", "ach" ], - "main": "lib/checkbook.js", + "main": "dist/index.js", "scripts": { + "prebuild": "rimraf ./dist", + "build": "tsc --outDir ./dist", "test": "echo \"Error: no tests specified\" && exit 1" }, "author": "Checkbook.io (https://checkbook.io/)", "contributors": [ - "Cosmin Molea " + "Cosmin Molea ", + "Dan Shapir " ], "repository": { "type": "git", - "url": "git+https://github.com/CheckbookWeb/checkbook_node.git" + "url": "git+https://github.com/Precise-Finance/checkbook_node.git" }, "license": "MIT", "bugs": { @@ -30,7 +33,10 @@ }, "homepage": "https://github.com/CheckbookWeb/checkbook_node#readme", "dependencies": { - "lodash": "^4.17.14", "request": "^2.88.0" + }, + "devDependencies": { + "rimraf": "^3.0.2", + "typescript": "^5.2.2" } } diff --git a/samples/banks.js b/samples/banks.js index ea159d6..a645f12 100644 --- a/samples/banks.js +++ b/samples/banks.js @@ -76,7 +76,7 @@ Checkbook.banks.addBankAccount({ https://docs.checkbook.io/reference#post-bank-verify */ /* -Checkbook.banks.verifyMicrodesposits({ +Checkbook.banks.verifyMicrodeposits({ amount_1: 0.07, amount_2: 0.15 }, function (error, response) { diff --git a/ts/checkbook.ts b/ts/checkbook.ts new file mode 100644 index 0000000..4570053 --- /dev/null +++ b/ts/checkbook.ts @@ -0,0 +1,50 @@ +import { Resource } from "./resource"; +import { Check } from "./endpoints/check"; +import { Invoice } from "./endpoints/invoice"; +import { Subscription } from "./endpoints/subscription"; +import { Bank } from "./endpoints/bank"; +import { User } from "./endpoints/user"; +import { VirtualCreditCard } from "./endpoints/vcc"; +import { Wallet } from "./endpoints/wallet"; +export default class Checkbook { + checks: Check; + resource: Resource; + invoices: Invoice; + subscriptions: Subscription; + banks: Bank; + users: User; + virtualCreditCards: VirtualCreditCard; + wallet: Wallet; + /** + * + */ + constructor(config: { + env?: string; + auth?: string; + bearer?: string; + api_key?: string; + api_secret?: string; + }) { + if (!config.env || !["demo", "sandbox"].includes(config.env)) { + config.env = "www"; + } + + if (config.bearer) { + config.auth = "Bearer " + config.bearer; + } else if (config.api_key && config.api_secret) { + config.auth = config.api_key + ":" + config.api_secret; + } else { + throw "Invalid Authorization"; + } + + this.resource = new Resource(config); + + this.checks = new Check(this.resource); + this.invoices = new Invoice(this.resource); + this.subscriptions = new Subscription(this.resource); + this.banks = new Bank(this.resource); + this.users = new User(this.resource); + this.virtualCreditCards = new VirtualCreditCard(this.resource); + this.wallet = new Wallet(this.resource); + } +} diff --git a/ts/endpoints/bank.ts b/ts/endpoints/bank.ts new file mode 100644 index 0000000..b0cec95 --- /dev/null +++ b/ts/endpoints/bank.ts @@ -0,0 +1,114 @@ +import { Resource } from "../resource"; + +export class Bank { + /** + * + */ + constructor(private readonly resource: Resource) {} + + list(callback: (err, response) => void) { + return this.resource.request( + { + method: "GET", + uri: "/account/bank", + }, + callback + ); + } + + institutions(callback: (err, response) => void) { + return this.resource.request( + { + method: "GET", + uri: "/account/bank/institutions", + }, + callback + ); + } + + delete(bank_id, callback: (err, response) => void) { + return this.resource.request( + { + method: "DELETE", + uri: "/account/bank/" + bank_id, + }, + callback + ); + } + + instantAccountVerification( + params, + callback: (err, response) => void, + idempotencyKey? + ) { + return this.resource.request( + { + method: "POST", + uri: "/account/bank/iav", + body: params, + }, + callback, + idempotencyKey + ); + } + + instantAccountVerificationPlaid( + params: { processor_token: string }, + callback: (err, response) => void, + idempotencyKey? + ) { + return this.resource.request( + { + method: "POST", + uri: "/account/bank/iav/plaid", + body: params, + }, + callback, + idempotencyKey + ); + } + + addBankAccount(params, callback: (err, response) => void, idempotencyKey?) { + return this.resource.request( + { + method: "POST", + uri: "/account/bank", + body: params, + }, + callback, + idempotencyKey + ); + } + + releaseMicrodeposits(params, callback: (err, response) => void) { + return this.resource.request( + { + method: "POST", + uri: "/account/bank/release", + body: params, + }, + callback + ); + } + verifyMicrodeposits(params, callback: (err, response) => void) { + return this.resource.request( + { + method: "POST", + uri: "/account/bank/verify", + body: params, + }, + callback + ); + } + + update(bank_id, params, callback: (err, response) => void) { + return this.resource.request( + { + method: "PUT", + uri: "/account/bank/" + bank_id, + body: params, + }, + callback + ); + } +} diff --git a/ts/endpoints/check.ts b/ts/endpoints/check.ts new file mode 100644 index 0000000..cc83105 --- /dev/null +++ b/ts/endpoints/check.ts @@ -0,0 +1,123 @@ +import { Resource } from "../resource"; + +export class Check { + /** + * + */ + constructor(private readonly resource: Resource) {} + list(query, callback: (err, response) => void) { + return this.resource.request( + { + method: "GET", + uri: "/check", + qs: query, + }, + callback + ); + } + + get(check_id, callback: (err, response) => void) { + return this.resource.request( + { + method: "GET", + uri: "/check/" + check_id, + }, + callback + ); + } + + delete(check_id, callback: (err, response) => void) { + return this.resource.request( + { + method: "DELETE", + uri: "/check/" + check_id, + }, + callback + ); + } + + deposit( + check_id: string, + params: { account: string }, + callback: (err, response) => void + ) { + return this.resource.request( + { + method: "POST", + uri: "/check/deposit/" + check_id, + body: params, + }, + callback + ); + } + + sendDigitalCheck(params, callback: (err, response) => void, idempotencyKey?) { + return this.resource.request( + { + method: "POST", + uri: "/check/digital", + body: params, + }, + callback, + idempotencyKey + ); + } + + sendPhysicalCheck( + params, + callback: (err, response) => void, + idempotencyKey? + ) { + return this.resource.request( + { + method: "POST", + uri: "/check/physical", + body: params, + }, + callback, + idempotencyKey + ); + } + + sendDirectCheck(params, callback: (err, response) => void, idempotencyKey?) { + return this.resource.request( + { + method: "POST", + uri: "/check/direct", + body: params, + }, + callback, + idempotencyKey + ); + } + + sendMultipleChecksCSV( + params, + callback: (err, response) => void, + idempotencyKey? + ) { + return this.resource.request( + { + method: "POST", + uri: "/check/csv", + body: params, + }, + callback, + idempotencyKey + ); + } + + triggerWebhook(params: { check_id: string, status: string, return_code?: string }, callback: (err, response) => void) { + return this.resource.request( + { + method: "PUT", + uri: "/check/webhook/" + params.check_id, + body: { + status: params.status, + options: params.return_code ? { return_code: params.return_code } : undefined, + }, + }, + callback + ); + } +} diff --git a/ts/endpoints/invoice.ts b/ts/endpoints/invoice.ts new file mode 100644 index 0000000..2aa6b98 --- /dev/null +++ b/ts/endpoints/invoice.ts @@ -0,0 +1,47 @@ +import { Resource } from "../resource"; + +export class Invoice { + /** + * + */ + constructor(private readonly resource: Resource) { + + } + list(query, callback: (err, response) => void) { + return this.resource.request({ + method: 'GET', + uri: '/invoice', + qs: query + }, callback); + } + + get(invoice_id, callback: (err, response) => void) { + return this.resource.request({ + method: 'GET', + uri: '/invoice/' + invoice_id + }, callback); + } + + delete(invoice_id, callback: (err, response) => void) { + return this.resource.request({ + method: 'DELETE', + uri: '/invoice/' + invoice_id + }, callback); + } + + sendInvoice(params, callback: (err, response) => void, idempotencyKey?) { + return this.resource.request({ + method: 'POST', + uri: '/invoice', + body: params + }, callback, idempotencyKey); + } + + payInvoice(params, callback: (err, response) => void, idempotencyKey?) { + return this.resource.request({ + method: 'POST', + uri: '/invoice/payment', + body: params + }, callback, idempotencyKey); + } +} diff --git a/ts/endpoints/subscription.ts b/ts/endpoints/subscription.ts new file mode 100644 index 0000000..32c0f7a --- /dev/null +++ b/ts/endpoints/subscription.ts @@ -0,0 +1,57 @@ +import { Resource } from "../resource"; + +export class Subscription { + /** + * + */ + constructor(private readonly resource: Resource) { + + } + + list(query, callback: (err, response) => void) { + return this.resource.request({ + method: 'GET', + uri: '/subscription', + qs: query + }, callback); + } + + get(subscription_id, callback: (err, response) => void) { + return this.resource.request({ + method: 'GET', + uri: '/subscription/' + subscription_id + }, callback); + } + + delete(subscription_id, callback: (err, response) => void) { + return this.resource.request({ + method: 'DELETE', + uri: '/subscription/' + subscription_id + }, callback); + } + + update(subscription_id, params, callback: (err, response) => void) { + return this.resource.request({ + method: 'PUT', + uri: '/subscription/' + subscription_id, + body: params + }, callback); + } + + sendRecurringCheck(params, callback: (err, response) => void, idempotencyKey?) { + return this.resource.request({ + method: 'POST', + uri: '/subscription/check', + body: params + }, callback, idempotencyKey); + } + + sendRecurringInvoice(params, callback: (err, response) => void, idempotencyKey?) { + return this.resource.request({ + method: 'POST', + uri: '/subscription/invoice', + body: params + }, callback, idempotencyKey); + } + +} \ No newline at end of file diff --git a/ts/endpoints/user.ts b/ts/endpoints/user.ts new file mode 100644 index 0000000..98c2727 --- /dev/null +++ b/ts/endpoints/user.ts @@ -0,0 +1,57 @@ +import { Resource } from "../resource"; + +export class User { + /** + * + */ + constructor(private readonly resource: Resource) { + + } + + create(params, callback, idempotencyKey?) { + return this.resource.request({ + method: 'POST', + uri: '/user', + body: params + }, callback, idempotencyKey); + } + + update(params, callback: (err, response) => void) { + return this.resource.request({ + method: 'PUT', + uri: '/user', + body: params + }, callback); + } + + get(callback: (err, response) => void) { + return this.resource.request({ + method: 'GET', + uri: '/user' + }, callback); + } + + list(query, callback: (err, response) => void) { + return this.resource.request({ + method: 'GET', + uri: '/user/list', + qs: query + }, callback); + } + + delete(user_id, callback: (err, response) => void) { + return this.resource.request({ + method: 'DELETE', + uri: '/user/' + user_id + }, callback); + } + + addSignature(params, callback: (err, response) => void) { + return this.resource.request({ + method: 'POST', + uri: '/user/signature', + body: params + }, callback); + } + +} \ No newline at end of file diff --git a/ts/endpoints/vcc.ts b/ts/endpoints/vcc.ts new file mode 100644 index 0000000..67448e2 --- /dev/null +++ b/ts/endpoints/vcc.ts @@ -0,0 +1,71 @@ +import { Resource } from "../resource"; + +export class VirtualCreditCard { + /** + * + */ + constructor(private readonly resource: Resource) {} + + add( + params: { + address: { line_1: string; city: string; state: string; zip: string }; + }, + callback: (err, response) => void, + idempotencyKey?: string + ) { + return this.resource.request( + { + method: "POST", + uri: "/account/vcc", + body: params, + }, + callback, + idempotencyKey + ); + } + + update( + vcc_id: string, + params: { name?: string; default?: boolean }, + callback: (err, response) => void + ) { + return this.resource.request( + { + method: "PUT", + uri: "/account/vcc/" + vcc_id, + body: params, + }, + callback + ); + } + + get(callback: (err, response) => void) { + return this.resource.request( + { + method: "GET", + uri: "/account/vcc", + }, + callback + ); + } + + getTransactions(vcc_id: string, callback: (err, response) => void) { + return this.resource.request( + { + method: "GET", + uri: "/account/vcc/" + vcc_id + "/transaction", + }, + callback + ); + } + + remove(vcc_id: string, callback: (err, response) => void) { + return this.resource.request( + { + method: "DELETE", + uri: "/account/vcc/" + vcc_id, + }, + callback + ); + } +} diff --git a/ts/endpoints/wallet.ts b/ts/endpoints/wallet.ts new file mode 100644 index 0000000..1d43a6a --- /dev/null +++ b/ts/endpoints/wallet.ts @@ -0,0 +1,61 @@ +import { Resource } from "../resource"; + +export class Wallet { + /** + * + */ + constructor(private readonly resource: Resource) {} + + add( + params: { + name: string; + }, + callback: (err, response) => void, + idempotencyKey?: string + ) { + return this.resource.request( + { + method: "POST", + uri: "/account/wallet", + body: params, + }, + callback, + idempotencyKey + ); + } + + update( + wallet_id: string, + params: { name?: string; }, + callback: (err, response) => void + ) { + return this.resource.request( + { + method: "PUT", + uri: "/account/wallet/" + wallet_id, + body: params, + }, + callback + ); + } + + get(callback: (err, response) => void) { + return this.resource.request( + { + method: "GET", + uri: "/account/wallet", + }, + callback + ); + } + + remove(wallet_id: string, callback: (err, response) => void) { + return this.resource.request( + { + method: "DELETE", + uri: "/account/wallet/" + wallet_id, + }, + callback + ); + } +} diff --git a/ts/resource.ts b/ts/resource.ts new file mode 100644 index 0000000..5302b13 --- /dev/null +++ b/ts/resource.ts @@ -0,0 +1,82 @@ +"use strict"; + +import * as request from "request"; +export class Resource { + private readonly baseURI: string; + private readonly defaultOptions: { + json: boolean; + headers: { Accept: string; Authorization: any }; + }; + constructor(config) { + this.baseURI = "https://" + config.env + ".checkbook.io/v3"; + this.defaultOptions = { + json: true, + headers: { + Accept: "application/json", + Authorization: config.auth, + }, + }; + } + + public request(options, callback: (err, response) => void, idempotencyKey?) { + request( + this.getRequestOptions(options, idempotencyKey), + function (error, response, body) { + if (error) { + return callback.call(this, error, null); + } + + if (![200, 201, 204].includes(response.statusCode) || body?.error) { + error = response.statusCode + " " + body?.error; + return callback.call(this, error, response); + } + + return callback.call(this, null, body); + } + ); + } + + getRequestOptions(options, idempotencyKey?) { + options = { ...options, ...this.defaultOptions }; + + if (idempotencyKey) { + options.headers["Idempotency-Key"] = idempotencyKey; + } + + options.uri = this.baseURI + options.uri; + + return options; + } +} + +// Resource.prototype = { +// request: function (options, callback, idempotencyKey) { +// request( +// this.getRequestOptions(options, idempotencyKey), +// function (error, response, body) { +// if (error) { +// return callback.call(this, error, null); +// } + +// if (!_.includes([200, 201], response.statusCode) || body.error) { +// error = response.statusCode + " " + body.error; +// return callback.call(this, error, null); +// } + +// return callback.call(this, null, body); +// } +// ); +// }, + +// getRequestOptions: function (options, idempotencyKey) { +// _.merge(options, this.defaultOptions); + +// if (idempotencyKey) { +// options.headers["Idempotency-Key"] = idempotencyKey; +// } + +// options.uri = this.baseURI + options.uri; + +// return options; +// }, +// }; diff --git a/tsconfig.build.json b/tsconfig.build.json new file mode 100644 index 0000000..36e395f --- /dev/null +++ b/tsconfig.build.json @@ -0,0 +1,12 @@ +{ + "extends": "./tsconfig.json", + "exclude": [ + "node_modules", + "test", + "dist", + "**/*spec.ts", + "prisma", + "prisma", + "prisma" + ] +} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..8c17c52 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "module": "commonjs", + "declaration": true, + "removeComments": true, + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "allowSyntheticDefaultImports": true, + "target": "es2017", + "sourceMap": true, + "outDir": "./dist", + "baseUrl": "./", + "incremental": true, + "lib": ["ES2017"] + } +}