Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @code.store/arcxp-sdk-ts

## 5.1.2

### Patch Changes

- Added "site" param to Sales migration method

## 5.1.1

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@code.store/arcxp-sdk-ts",
"version": "5.1.1",
"version": "5.1.2",
"description": "A strongly typed set of ArcXP API's and utilities reduce the amount of work required to develop with ArcXP, starting with reducing the boilerplate code you have to write.",
"type": "module",
"main": "./dist/index.js",
Expand Down
9 changes: 7 additions & 2 deletions src/api/sales/index.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
import FormData from 'form-data';
import { type ArcAPIOptions, ArcAbstractAPI } from '../abstract-api.js';
import type { MigrateBatchSubscriptionsPayload, MigrateBatchSubscriptionsResponse } from './types.js';
import type {
MigrateBatchSubscriptionsParams,
MigrateBatchSubscriptionsPayload,
MigrateBatchSubscriptionsResponse,
} from './types.js';

export class ArcSales extends ArcAbstractAPI {
constructor(options: ArcAPIOptions) {
super({ ...options, apiPath: 'sales/api/v1' });
}

async migrate(payload: MigrateBatchSubscriptionsPayload) {
async migrate(params: MigrateBatchSubscriptionsParams, payload: MigrateBatchSubscriptionsPayload) {
const form = new FormData();
form.append('file', JSON.stringify(payload), { filename: 'subs.json', contentType: 'application/json' });

const { data } = await this.client.post<MigrateBatchSubscriptionsResponse>('/migrate', form, {
params,
headers: {
...form.getHeaders(),
},
Expand Down
5 changes: 5 additions & 0 deletions src/api/sales/types.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import type { UserAttribute } from '../identity/types';
import type { Website } from '../../types/ans-types';

export type MigrateBatchSubscriptionsPayload = {
subscriptions: (PaidSubscription | FreeSubscription | SharedSubscription | LinkedSubscription)[];
payments: PaymentInfo[];
};

export type MigrateBatchSubscriptionsParams = {
site: Website;
};

export type MigrateBatchSubscriptionsResponse = {
subscriptionsInBatch?: number;
batchID?: string;
Expand Down
Loading