npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@acrosure/js-sdk

v1.0.6

Published

Acrosure JavaScript SDK

Downloads

91

Readme

Acrosure JavaScript SDK

Acrosure

JavaScript SDK for connecting with Acrosure Insurance Gateway

Installation

Install via npm:

npm install --save @acrosure/js-sdk

Or if you're using yarn:

yarn add @acrosure/js-sdk

Getting Started

Import AcrosureClient into your project.

import AcrosureClient from '@acrosure/js-sdk'

// es5
const AcrosureClient = require('@acrosure/js-sdk')

or use cdn:

<script src="https://cdn.jsdelivr.net/npm/@acrosure/[email protected]/dist/acrosure-sdk.js"></script>

Instantiate with an API key from Acrosure Dashboard.

If you're using this on client-side, DO NOT use your secret token.

const acrosureClient = new AcrosureClient({
  token: '<your_api_key>'
})

Basic Usage

AcrosureClient provides several objects such as application, product, etc. and associated APIs.

Any data will be inside an response object with data key, along with meta data, such as:

{
  "data": { ... },
  "status": "ok",
  ...
}

Application

Get

Get application with specified id.

const application = acrosureClient.application.get('<application_id>')

Create

Create an application.

const createdApplication = await acrosureClient.application.create({
  productId: '<product_id>', // required
  basic_data: {},
  package_options: {},
  additional_data: {},
  package_code: '<package_code>',
  attachments: []
})

Update

Update an application.

const updatedApplication = await acrosureClient.application.update({
  application_id: '<application_id>', // required
  basic_data: {},
  package_options: {},
  additional_data: {},
  package_code: '<package_code>',
  attachments: []
})

Get packages

Get current application available packages.

const packages = await acrosureClient.application.getPackages(
  '<application_id>'
)

Select package

Select package for current application.

const updatedApplication = await acrosureClient.application.selectPackage({
  application_id: '<application_id>',
  package_code: '<package_code>'
})

Get package

Get selected package of current application.

const currentPackage = await acrosureClient.application.getPackage(
  '<application_id>'
)

Redirect to payment page

Redirect user to 2C2P payment page (Browser only).

await acrosureClient.application.redirectToPayment({
  application_id: '<application_id>',
  frontend_url: '<redirect_url>'
})

Submit

Submit current application.

const submittedApplication = await acrosureClient.application.submit(
  '<application_id>'
)

Confirm

Confirm current application.

This function needs secret API key.

const confirmedApplication = await acrosureClient.application.confirm(
  '<application_id>'
)

List

List your applications (with or without query).

const applications = await acrosureClient.application.list(query)

Product

Get

Get product with specified id.

const product = await acrosureClient.product.get('<product_id>')

List

List your products (with or without query).

const products = await acrosureClient.product.list(query)

Policy

Get

Get policy with specified id.

const policy = await acrosureClient.policy.get('<policy_id>')

List

List your policies (with or without query).

const policies = await acrosureClient.policy.list(query)

Data

Get

Get values for a handler (with or without dependencies, please refer to Acrosure API Document).

// Without dependencies
const values = await acrosureClient.data.get({
  handler: '<some_handler>'
})

// With dependencies
const values = await acrosureClient.data.get({
  handler: '<some_handler>',
  dependencies: ['<dependency_1>', '<dependency_2>']
})

Team

Get info

Get current team information.

const teamInfo = await acrosureClient.team.getInfo()

Other functionality

Verify webhook signature

Verify webhook signature by specify signature and raw data string. (Only Node.js environment)

const isSignatureValid = acrosureClient.verifySignature(
  '<signature>',
  '<raw_data>'
)

Advanced Usage

Please refer to this document for AcrosureClient usage.

And refer to Acrosure API Document for more details on Acrosure API.

Associated Acrosure API endpoints

Application

/applications/get
/applications/list
/applications/create
/applications/update
/applications/get-packages
/applications/get-package
/applications/select-package
/applications/submit
/applications/confirm
/applications/get-hash

Product

/products/get
/products/list

Policy

/policies/get
/policies/list

Data

/data/get

Team

/teams/get-info