SubscriptionProductClient

common~ SubscriptionProductClient

Create a instance of a Subscription manager based on the contract deployed at the Daisy Dashboard. The important data here is the DAISY_ID.

Constructor

new SubscriptionProductClient(manager, override)

Source:

Create an instance.

Parameters:
Name Type Description
manager Object

Object can be taken from const manager = await instance.getData() but only the identifier is the real important.

Properties
Name Type Description
identifier string

Get it from the Daisy Dashboard as DAISY_ID.

secretKey string

Get it from the Daisy Dashboard as DAISY_SECRET_KEY. THIS SHOULD ONLY BE KEEP SECRET ON A SERVER. DO NOT USE ON BROWSERS.

override Object

Override axios config. This is intended for development purposes.

Extends

Methods

(async) getData() → {Promise.<SubscriptionManager>}

Source:

Get Subscription Manager data and plans.

Example
const subscriptionProduct = new SubscriptionProductClient({
  identifier: process.env.DAISY_ID,
});
const { plans, ...manager } = await subscriptionProduct.getData();
Returns:
  • Subscription Manager and Plans given the manager in the constructor.
Type
Promise.<SubscriptionManager>

getPlans()

Source:
Deprecated:

(async) getReceipts(criteria) → {Promise.<Array.<Receipt>>}

Source:

Get receipts from single subscription.

Parameters:
Name Type Description
criteria Object

Filtering criteria, only one field is required.

Properties
Name Type Description
daisyId string

Find Subscription based on a Daisy ID.

onChainId string

Find Subscription based on a onChainId in the blockchain.

Returns:
  • Receipts.
Type
Promise.<Array.<Receipt>>

(async) getSubscription(criteria) → {Promise.<?Subscription>}

Source:

Get single subscription.

Example
const subscriptionProduct = new SubscriptionProductClient({
  identifier: process.env.DAISY_ID,
});
const subscription = await subscriptionProduct.getSubscription({ id: "" });
Parameters:
Name Type Description
criteria Object

Filtering criteria, only one field is required.

Properties
Name Type Description
daisyId string

Find Subscription based on a Daisy ID.

onChainId string

Find Subscription based on a onChainId in the blockchain.

Returns:
  • Subscription found.
Type
Promise.<?Subscription>

(async) getSubscriptions(filter) → {Promise.<Array.<Subscription>>}

Source:

Get subscriptions.

Example
const subscriptionProduct = new SubscriptionProductClient({
  identifier: process.env.DAISY_ID,
});
const subscriptions = await subscriptionProduct.getSubscriptions({ account: "0x0..." });
Parameters:
Name Type Description
filter Object

Filtering criteria.

Properties
Name Type Description
account string

Filter by Ethereum address.

state string

Filter by subscription state.

Returns:
  • Subscriptions based on the filtering criteria.
Type
Promise.<Array.<Subscription>>

(async) submit(input) → {Promise.<Subscription>}

Source:

Create single subscription.

Example
const subscriptionProduct = new SubscriptionProductClient({
  identifier: process.env.DAISY_ID,
});
const subscription = await subscriptionProduct.submit({ });
Parameters:
Name Type Description
input Object

Input arguments

Properties
Name Type Attributes Description
agreement Object

The agreement is the return of module:browser.DaisySDKToken#sign.

receipt Object <optional>

Optional. The receipt is the return of module:browser.DaisySDKToken#approve.

signature string

The signature is the return of module:browser.DaisySDKToken#sign.

Returns:
Type
Promise.<Subscription>

(async) submitCancel(input) → {Promise.<Subscription>}

Source:

Submit signature and agreement from the beneficiary user to cancel a subscription.

Parameters:
Name Type Description
input Object

Input arguments

Properties
Name Type Description
agreement Object

The agreement is the return of module:browser.DaisySDKToken#signCancel.

signature string

The signature is the return of module:browser.DaisySDKToken#signCancel.

Returns:
Type
Promise.<Subscription>