1.0.11 • Published 4 months ago

@prici/sdk v1.0.11

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

@prici/sdk

SDK to use Prici.io API to manage pricing and SaaS plans for your application.

Go to https://prici.io for more information.

About Prici

Prici is an open source project to manage plans and pricing for any SaaS application.

You can use the standalone service using Docker and run it locally or on your machine.

Getting Started

Create an SDK instance:

import PriciSdk from '@prici/sdk';

const sdk = new PriciSdk({
  token: process.env.PRICI_TOKEN,
  priciUBaseUrl: process.env.PRICI_BASE_URL
});

Create new PlanField

A plan field is a row field inside your application pricing plans. It can be used by all any plans, or not to be used at all.

const jiggleField = await sdk.PlanField.insert({
  name: 'Ability to jiggle jiggle',
  kind: FieldKind.Boolean
})

const wiggleField = await sdk.PlanField.insert({
  name: 'Ability to wiggle wiggle',
  kind: FieldKind.Number
})

Create new Plan

A plan field is a row field inside your application pricing plans. It can be used by all any plans, or not to be used at all.

const basicPlan = await sdk.Plan.insert({
  name: 'Basic',
  fields: [
    { fieldId: jiggleField.id, value: false },
    { fieldId: wiggleField.id, value: 5 },
  ]
})

const advancedPlan = await sdk.PlanField.insert({
  name: 'Advanced',
  fields: [
    { fieldId: jiggleField.id, value: true },
    { fieldId: wiggleField.id, value: 10 },
  ]
})

Create new AccountPlan

An account plan is the actual state of a plan for a specific account

const demoAccount = await sdk.AccountPlan.insert({
  accountId: 'demo-account',
  plan: basicPlan,
  resetMode: ResetMode.Manual,
  state: {
    [wiggleField.id]: {
      targetLimit: 20, // custom change limit
      currentValue: 4 // // custom change initial value
    }
  }
})

Enjoy.

1.0.11

4 months ago

1.0.10

4 months ago

1.0.9

4 months ago

1.0.8

5 months ago

1.0.7

5 months ago

1.0.6

5 months ago

1.0.5

5 months ago

1.0.4

5 months ago

1.0.3

5 months ago

1.0.2

5 months ago

1.0.1

5 months ago

1.0.0

5 months ago