1.0.25 • Published 4 years ago

@huzapi/subscription-connector v1.0.25

Weekly downloads
-
License
ISC
Repository
gitlab
Last release
4 years ago

Huz Api / Subscription Connector

Subscription microservices can connect to huz api

  • TDD (Test driven)
  • Fully JsDoc
  • index.d.ts included (built-in @types support)

Test

npm sample

Install

npm i @huzapi/subscription-connector

USAGE

Please look ./src/Simulate.ts

import {connector, orderService, planService, profileService, projectService, subscriptionService, userService} from "@huzapi/subscription-connector";

// Init system await connector.initAsync({ auth0Domain: env.AUTH0_DOMAIN, auth0Audience: env.AUTH0_AUDIENCE, auth0ClientId: env.AUTH0_CLIENT_ID, auth0ClientSecret: env.AUTH0_CLIENT_SECRET, apiInterval: env.API_INTERVAL, // optional apiUrl: env.API_URL, apiSilent: env.API_SILENT, // optional });

let projectDoc;

// get project by id projectDoc = await projectService.getByIdAsync(req, 'project-id');

// get project by code projectDoc = await projectService.getByCodeAsync(req, 'project-code');

let planDoc, planDocs;

// list assigned plans by project planDocs = await planService.listAsync(req, 'project-id');

// get plan by id planDoc = await planService.getByIdAsync(req, 'plan-id', 'project-id');

// get plan by code planDoc = await planService.getByCodeAsync(req, 'plan-code', 'project-id');

let userDoc;

// get user by iam id userDoc = await userService.getByIamId(req, 'iam-id');

// upsert user with iam-id and project id userDoc = await userService.upsertAsync(req, 'iam-id', 'project-id', 'email-address');

// get user by id userDoc = await userService.getByIdAsync(req, 'user-id');

let profileDoc;

// get profile by user and project profileDoc = await profileService.getByUserAsync(req, 'user-id', 'project-id');

// upsert profile with user and project profileDoc = await profileService.upsertAsync(req, 'user-id', 'project-id');

// get profile by id and project profileDoc = await profileService.getByIdAsync(req, 'profile-id', 'project-id');

// log login history profileDoc = await profileService.loginAsync(req, 'profile-id', 'reason');

// log logout history profileDoc = await profileService.logoutAsync(req, 'profile-id', 'reason');

// subscribe to a subscription profileDoc = await profileService.subscribeAsync(req, 'profile-id', 'subscription-id', 'reason');

// cancel current subscription of profile profileDoc = await profileService.cancelAsync(req, 'profile-id', 'reason');

// unsubscribe from current subscription of profile profileDoc = await profileService.unsubscribeAsync(req, 'profile-id', 'reason');

let subscriptionDoc, subscriptionDetailDoc, subscriptionDocs;

// get subscription of profile subscriptionDoc = await subscriptionService.getByProfileAsync(req, 'profile-id');

// get subscription details of profile subscriptionDetailDoc = await subscriptionService.getDetailedByProfileAsync(req, 'profile-id');

// get subscription by id subscriptionDoc = await subscriptionService.getByIdAsync(req, 'subscription-id');

// create subscription subscriptionDoc = await subscriptionService.createAsync(req, 'profile-id', 'plan-id', 'order-id', 'started-at');

// lists subscriptions of profile subscriptionDocs = await subscriptionService.listAsync(req, 'profile-id');

// lists subscription history of profile const historyItems = await subscriptionService.historyAsync(req, 'profile-id');

let orderDoc;

// create an order orderDoc = await orderService.createAsync(req, 'profile-id', 'plan-id', {key1: 'value-1'});

// Assign a subscription to an order orderDoc = await orderService.updateSubscriptionAsync(req, 'order-id', 'subscription-id', {key1: 'value-1'});

// Set order state as active orderDoc = await orderService.setStatusActiveAsync(req, 'order-id', {key1: 'value-1'});

// Set order state as cancelled orderDoc = await orderService.setStatusCancelAsync(req, 'order-id', {key1: 'value-1'});

// Set order state as idle orderDoc = await orderService.setStatusIdleAsync(req, 'order-id', {key1: 'value-1'});

// Set order state as timeout orderDoc = await orderService.setStatusTimeoutAsync(req, 'order-id', {key1: 'value-1'});

// Set order state as error orderDoc = await orderService.setStatusErrorAsync(req, 'order-id', {key1: 'value-1'});

// Get order by id orderDoc = await orderService.getByIdAsync(req, 'order-id');

1.0.25

4 years ago

1.0.24

4 years ago

1.0.22

4 years ago

1.0.23

4 years ago

1.0.21

4 years ago

1.0.20

4 years ago

1.0.19

4 years ago

1.0.18

4 years ago

1.0.17

4 years ago

1.0.16

4 years ago

1.0.15

4 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.1

5 years ago