@code.store/arcxp-sdk-ts 5.1.3 → 5.1.6
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.
- package/dist/api/abstract-api.d.ts +1 -0
- package/dist/api/sales/index.d.ts +4 -2
- package/dist/api/sales/types.d.ts +8 -1
- package/dist/index.cjs +22 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +22 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { type ArcAPIOptions, ArcAbstractAPI } from '../abstract-api.js';
|
|
2
|
-
import type { CreateEnterpriseGroupPayload, CreateEnterpriseGroupResponse, MigrateBatchSubscriptionsParams, MigrateBatchSubscriptionsPayload, MigrateBatchSubscriptionsResponse } from './types.js';
|
|
2
|
+
import type { CreateEnterpriseGroupParams, CreateEnterpriseGroupPayload, CreateEnterpriseGroupResponse, CreateNonceResponse, MigrateBatchSubscriptionsParams, MigrateBatchSubscriptionsPayload, MigrateBatchSubscriptionsResponse } from './types.js';
|
|
3
3
|
export declare class ArcSales extends ArcAbstractAPI {
|
|
4
4
|
constructor(options: ArcAPIOptions);
|
|
5
5
|
migrate(params: MigrateBatchSubscriptionsParams, payload: MigrateBatchSubscriptionsPayload): Promise<MigrateBatchSubscriptionsResponse>;
|
|
6
6
|
}
|
|
7
7
|
export declare class ArcSalesV2 extends ArcAbstractAPI {
|
|
8
8
|
constructor(options: ArcAPIOptions);
|
|
9
|
-
|
|
9
|
+
getEnterpriseGroups(params: CreateEnterpriseGroupParams): Promise<CreateEnterpriseGroupResponse>;
|
|
10
|
+
createEnterpriseGroup(params: CreateEnterpriseGroupParams, payload: CreateEnterpriseGroupPayload): Promise<CreateEnterpriseGroupResponse>;
|
|
11
|
+
createNonce(website: string, enterpriseGroupId: number): Promise<CreateNonceResponse>;
|
|
10
12
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { UserAttribute } from '../identity/types';
|
|
2
1
|
import type { Website } from '../../types/ans-types';
|
|
2
|
+
import type { UserAttribute } from '../identity/types';
|
|
3
3
|
export type MigrateBatchSubscriptionsPayload = {
|
|
4
4
|
subscriptions: (PaidSubscription | FreeSubscription | SharedSubscription | LinkedSubscription)[];
|
|
5
5
|
payments: PaymentInfo[];
|
|
@@ -83,6 +83,9 @@ export type Refund = {
|
|
|
83
83
|
tax: number;
|
|
84
84
|
providerReference?: string;
|
|
85
85
|
};
|
|
86
|
+
export type CreateEnterpriseGroupParams = {
|
|
87
|
+
site: string;
|
|
88
|
+
};
|
|
86
89
|
export type CreateEnterpriseGroupPayload = {
|
|
87
90
|
name: string;
|
|
88
91
|
sku: string;
|
|
@@ -93,4 +96,8 @@ export type CreateEnterpriseGroupResponse = {
|
|
|
93
96
|
nonceExpirationInDays: number;
|
|
94
97
|
id: number;
|
|
95
98
|
};
|
|
99
|
+
export type CreateNonceResponse = {
|
|
100
|
+
nonce: string;
|
|
101
|
+
expires: string;
|
|
102
|
+
};
|
|
96
103
|
export {};
|
package/dist/index.cjs
CHANGED
|
@@ -6,7 +6,6 @@ var axios = require('axios');
|
|
|
6
6
|
var rateLimit = require('axios-rate-limit');
|
|
7
7
|
var axiosRetry = require('axios-retry');
|
|
8
8
|
var ws = require('ws');
|
|
9
|
-
var FormData = require('form-data');
|
|
10
9
|
var encode = require('base32-encode');
|
|
11
10
|
var uuid = require('uuid');
|
|
12
11
|
var assert = require('node:assert');
|
|
@@ -91,7 +90,7 @@ class ArcAbstractAPI {
|
|
|
91
90
|
// apply retry
|
|
92
91
|
const retry = typeof axiosRetry === 'function' ? axiosRetry : axiosRetry.default;
|
|
93
92
|
retry(this.client, {
|
|
94
|
-
retries:
|
|
93
|
+
retries: options.maxRetries || 10,
|
|
95
94
|
retryDelay: axiosRetry.exponentialDelay,
|
|
96
95
|
retryCondition: (err) => this.retryCondition(err),
|
|
97
96
|
});
|
|
@@ -711,6 +710,7 @@ class ArcSales extends ArcAbstractAPI {
|
|
|
711
710
|
super({ ...options, apiPath: 'sales/api/v1' });
|
|
712
711
|
}
|
|
713
712
|
async migrate(params, payload) {
|
|
713
|
+
const FormData = await platform.form_data();
|
|
714
714
|
const form = new FormData();
|
|
715
715
|
form.append('file', JSON.stringify(payload), { filename: 'subs.json', contentType: 'application/json' });
|
|
716
716
|
const { data } = await this.client.post('/migrate', form, {
|
|
@@ -726,8 +726,26 @@ class ArcSalesV2 extends ArcAbstractAPI {
|
|
|
726
726
|
constructor(options) {
|
|
727
727
|
super({ ...options, apiPath: 'sales/api/v2' });
|
|
728
728
|
}
|
|
729
|
-
async
|
|
730
|
-
const { data } = await this.client.
|
|
729
|
+
async getEnterpriseGroups(params) {
|
|
730
|
+
const { data } = await this.client.get('/subscriptions/enterprise', {
|
|
731
|
+
params: {
|
|
732
|
+
'arc-site': params.site,
|
|
733
|
+
},
|
|
734
|
+
});
|
|
735
|
+
return data;
|
|
736
|
+
}
|
|
737
|
+
async createEnterpriseGroup(params, payload) {
|
|
738
|
+
const { data } = await this.client.post('/subscriptions/enterprise', payload, {
|
|
739
|
+
params: {
|
|
740
|
+
'arc-site': params.site,
|
|
741
|
+
},
|
|
742
|
+
});
|
|
743
|
+
return data;
|
|
744
|
+
}
|
|
745
|
+
async createNonce(website, enterpriseGroupId) {
|
|
746
|
+
const { data } = await this.client.get(`/subscriptions/enterprise/${enterpriseGroupId}`, {
|
|
747
|
+
params: { 'arc-site': website },
|
|
748
|
+
});
|
|
731
749
|
return data;
|
|
732
750
|
}
|
|
733
751
|
}
|