shred-api-client 1.9.20 → 1.9.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,12 @@
1
1
  import Context from "../model/Context";
2
- import { Product, Subscription, SubscriptionAPISchema } from "../model/Subscription.schema";
2
+ import { Charge, Product, Subscription, SubscriptionAPISchema } from "../model/Subscription.schema";
3
3
  import Environment from "../model/Env";
4
4
  declare class SubscriptionAPI implements SubscriptionAPISchema {
5
5
  private env;
6
6
  private clientHTTP;
7
7
  constructor(env: Environment);
8
8
  getProduct(id: string, context?: Context): Promise<Product>;
9
+ getCharges(ctx: Context): Promise<Charge[]>;
9
10
  getSubscription(context: Context, userId?: string): Promise<Subscription | null>;
10
11
  charge(ctx: Context): Promise<boolean>;
11
12
  getProducts(ctx?: Context): Promise<Product[]>;
@@ -15,6 +15,11 @@ class SubscriptionAPI {
15
15
  const data = await this.clientHTTP.makeRequest(this.env, `${endpointInfo.uri}/${id}`, endpointInfo.method, null, context);
16
16
  return data;
17
17
  }
18
+ async getCharges(ctx) {
19
+ const endpointInfo = Subscription_schema_1.SubscriptionEndpoints.GetCharges;
20
+ const data = await this.clientHTTP.makeRequest(this.env, `${endpointInfo.uri}`, endpointInfo.method, null, ctx);
21
+ return data;
22
+ }
18
23
  async getSubscription(context, userId) {
19
24
  const endpointInfo = Subscription_schema_1.SubscriptionEndpoints.GetActiveSubscription;
20
25
  let uri = endpointInfo.uri;
@@ -1,5 +1,6 @@
1
1
  import Context from "./Context";
2
2
  interface SubscriptionAPISchema {
3
+ getCharges: (ctx: Context) => Promise<Charge[]>;
3
4
  getSubscription: (context: Context, userId?: string) => Promise<Subscription | null>;
4
5
  getProduct: (id: string, context?: Context) => Promise<Product>;
5
6
  getProducts: (ctx?: Context) => Promise<Product[]>;
@@ -15,6 +16,10 @@ declare const SubscriptionEndpoints: {
15
16
  uri: string;
16
17
  method: string;
17
18
  };
19
+ GetCharges: {
20
+ uri: string;
21
+ method: string;
22
+ };
18
23
  GetUserActiveSubscription: {
19
24
  uri: string;
20
25
  method: string;
@@ -79,4 +84,15 @@ type Subscription = {
79
84
  type?: SubscriptionType;
80
85
  plan?: Plan;
81
86
  };
82
- export { SubscriptionAPISchema, Product, Subscription, SubscriptionEndpoints, Plan, };
87
+ type Charge = {
88
+ id: number;
89
+ created: number;
90
+ paid: boolean;
91
+ receiptUrl: string;
92
+ status: string;
93
+ price: string;
94
+ paymentType: string;
95
+ last4?: string;
96
+ brand?: string;
97
+ };
98
+ export { SubscriptionAPISchema, Product, Subscription, SubscriptionEndpoints, Charge, Plan, };
@@ -10,6 +10,10 @@ const SubscriptionEndpoints = {
10
10
  uri: "/subscriptions/active/",
11
11
  method: "GET",
12
12
  },
13
+ GetCharges: {
14
+ uri: "/subscriptions/payment/charge/list/",
15
+ method: "GET",
16
+ },
13
17
  GetUserActiveSubscription: {
14
18
  uri: "/subscriptions/:userId/find/",
15
19
  method: "GET",
@@ -1,4 +1,4 @@
1
- import { Product as TProduct, Subscription as TSubscription } from "./model/Subscription.schema";
1
+ import { Product as TProduct, Subscription as TSubscription, Charge as TCharge } from "./model/Subscription.schema";
2
2
  import { System as TSystem, User as TUser, Preferences as UserPreferences, Role as TRole } from "./model/User.schema";
3
3
  import { Email as TEmail } from "./model/Email.schema";
4
4
  import { Asset as TAsset } from "./model/Asset.schema";
@@ -12,6 +12,7 @@ export declare namespace Shred {
12
12
  type Tenant = TTenant;
13
13
  type Product = TProduct;
14
14
  type Subscription = TSubscription;
15
+ type Charge = TCharge;
15
16
  type User = TUser;
16
17
  type Email = TEmail;
17
18
  type System = TSystem;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shred-api-client",
3
- "version": "1.9.20",
3
+ "version": "1.9.22",
4
4
  "description": "API Client for Shred",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",