🚨 Active Supply Chain Attack:node-ipc Package Compromised.Learn More
Socket
Book a DemoSign in
Socket

@getevy/stately

Package Overview
Dependencies
Maintainers
4
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@getevy/stately

The Javascript helper library to manage Evy offers

latest
npmnpm
Version
0.0.32
Version published
Maintainers
4
Created
Source

Evy Stately

Stately is a headless library to help you build your Evy UI in Javascript or Typescript.

Stately provides methods for key actions in the lifecycle of insurance in the UI:

  • getting offers
  • attaching offers
  • retrieving offers from the cart (stored in local storage)

Installation

npm i @getevy/stately

Initialization

import { Evy as Stately } from '@getevy/stately';

const stately = new Stately({ apiKey, apiURL });

The configuration is an object.

KeyRequiredDescription
apiKeyyesyour API key
apiURLnothe URL of the API to target

stately is an EventEmitter. The methods are used to modify the state and request values from the Evy API. Once the data are up to date, events are triggered to allow you to update the UI.

During the initialization, stately will retrieve previous data from the local storage.

Methods

addProduct

Fetches offers for a specific product.

Parameters

stately.addProduct(productId: string, price: number) => Promise<void>
ParameterRequiredDescription
productIdyesID of the product as provided to Evy
priceyesPrice of the product

This method will emit OFFERS_LOADED when the offer data is retrieved from the server.

setAttachedOffer

Attaches an offer to a product.

stately.setAttachedOffer(offerId: string, productId: string, quantity: number) => void

Parameters

ParameterRequiredDescription
offerIdyesID of the offer
productIdyesID of the product as provided to Evy
quantityyesPrice of the product

This method will emit ATTACH_OFFER when the offer data is attached and synchronized with the local storage.

getAttachedOffers

Provides all the offers attached to products.

stately.getAttachedOffers() => Record<AttachedOfferIdentifier, AttachedOffer>

AttachedOffer

KeytypeDescription
offerIOfferThe complete offer object
quantitynumberThe number of times the offer is attached to the product

clearOffers

Removes the offers attached on all the products.

stately.clearOffers() => void

cancelAttachedOffer

Removes the offers for a single product.

stately.cancelAttachedOffer(productId: string) => void

Events

OFFERS_LOADED

This event is triggered when the offers are updated.

ATTACH_OFFER

This event is triggered when an offer is attached to a product.

Keywords

sdk

FAQs

Package last updated on 06 Dec 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts