Tepui SDK Documentation - v0.0.7

Index

Classes

Interfaces

Type aliases

Variables

Functions

Object literals

Type aliases

BalanceEventType

Ƭ BalanceEventType: "Allocate" | "Consume" | "Fund" | "Withdraw"

Events that impact the balance of an account in a plan

  • Allocate means that a merchant has been asigned consumption revenue

  • Consume means that a subscriber has consumed a service

  • Fund means that an account has deposited funds in the contract

  • Withdraw means that an account has withdrawn funds from the contract

ClientAuthMethod

Ƭ ClientAuthMethod: "client_secret_basic" | "client_secret_post" | "client_secret_jwt" | "private_key_jwt" | "tls_client_auth" | "self_signed_tls_client_auth" | "none"

CycleFeature

Ƭ CycleFeature: "day" | "week" | "month" | "quarter" | "year"

These composite cycles are all the options available to generate recurring periods

CycleType

Ƭ CycleType: "none" | "day" | "month"

These are the basic cycles used for processing of recurring charges

EventType

Ƭ EventType: BalanceEventType | SubscriptionEventType

These are the types of events associated with a smart contract associated with a plan

OperatorType

Ƭ OperatorType: "plan" | "user"

These are the types of operators for plans

  • plan is another plan that can perform operations like

    subscribe, consume, and cancel. These are necessary when

    certain plans are connected to others

  • user consists of an end user that needs the ability

    to perform operator tasks

PlanConnectionType

Ƭ PlanConnectionType: "addon" | "bundle" | "wholesale"

These are the types of connections for plans

  • addon is a plan that extends the features that a

    subscriber would derive from a plan. Add-ons are optional,

    chosen by the subscriber when they sign-up for a plan.

  • bundle consists of a plan that also extends the

    subscriber features. However, in this case it's not optional

  • wholesale plans are not visible to subscribers. They

    track the use of features that they support and calculate

    appropriate consumption.

SubscriptionEventType

Ƭ SubscriptionEventType: "Cancel" | "Subscribe"

Events that impact plan subscriptions

TransactionCallback

Ƭ TransactionCallback: function

A callback function that can be passed to some operations to retrieve the transaction hash before the transaction is mined. since mining can take some time, this is a useful way to track the transaction and allow other operations to proceed before mining is completed

Type declaration:

▸ (hash: string): void

Parameters:

Name

Type

hash

string

Variables

Const ZEROADDRESS

ZEROADDRESS: "0x0000000000000000000000000000000000000000" = "0x0000000000000000000000000000000000000000"

Const cycleFeatures

cycleFeatures: CycleFeature[] = [ "day", "week", "month", "quarter", "year", ]

Functions

Const addTimeSpans

addTimeSpans(startDate: Date, timeSpans: ITimeSpan[]): Date

Parameters:

Name

Type

Description

startDate

Date

start date to use in the calculation

timeSpans

a list of periods to be added

Returns: Date

the date at which a list of periods ends. This operation is useful to calculate the upcoming expiration of a subscription, or the number of periods since it expired

Const checkResponse

checkResponse(response: Response, message: string): Promise‹void›

Checks the response status and throws an appropriate error if the status is not ok

Parameters:

Name

Type

Description

response

Response

the response to be checked

message

string

a context message included if an error is thrown

Returns: Promise‹void›

Const fromConnectionType

fromConnectionType(connectedPlans: IEthConnectedPlan[]): object[]

Converts from PlanConnectionType to a number

Parameters:

Name

Type

connectedPlans

Returns: object[]

Const fromCycleType

fromCycleType(cycleType: CycleType): string

Converts from CycleType to a number

Parameters:

Name

Type

cycleType

Returns: string

Const fromFeature

fromFeature(feature: string): ICycleDefinition

Parameters:

Name

Type

feature

string

Returns: ICycleDefinition

Const getPeriodForDate

getPeriodForDate(date: Date, startDate: Date, timeSpans: ITimeSpan[]): IPeriod | undefined

Parameters:

Name

Type

date

Date

startDate

Date

timeSpans

Returns: IPeriod | undefined

Const toConnectionType

toConnectionType(connectedPlans: object[]): IEthConnectedPlan[]

Converts from number to a PlanConnectionType

Parameters:

Name

Type

connectedPlans

object[]

Returns: IEthConnectedPlan[]

Const toCycleType

toCycleType(cycleType: string): CycleType

Converts from number to a CycleType

Parameters:

Name

Type

cycleType

string

Returns: CycleType

Const toFeature

toFeature(cycle: ICycleDefinition): ITimeSpan | undefined

Parameters:

Name

Type

Returns: ITimeSpan | undefined

Object literals

Const connectionTypes

connectionTypes: object

In blockchains the connection type is stored as a number

addon

addon: string = "0"

bundle

bundle: string = "1"

wholesale

wholesale: string = "2"

Const cycleDefinitions

cycleDefinitions: object

A mapping that resolves a cycle feature to a combination of a time unit and a quantity

day: object

  • cycleLength: number = 1

  • cycleType: "day" = "day"

month: object

  • cycleLength: number = 1

  • cycleType: "month" = "month"

quarter: object

  • cycleLength: number = 3

  • cycleType: "month" = "month"

week: object

  • cycleLength: number = 7

  • cycleType: "day" = "day"

year: object

  • cycleLength: number = 12

  • cycleType: "month" = "month"

Const cycleToUnit

cycleToUnit: object

day

day: "days" = "days"

month

month: "months" = "months"

none

none: undefined = undefined

Const cycleTypes

cycleTypes: object

In blockchains the cycle type is stored as a number

day

day: string = "1"

month

month: string = "2"

none

none: string = "0"

Last updated

Was this helpful?