diff --git a/package.json b/package.json index 25594bc..7bca74e 100644 --- a/package.json +++ b/package.json @@ -20,9 +20,7 @@ "url": "https://github.com/code-store-platform/arcxp-sdk-ts" }, "homepage": "https://github.com/code-store-platform/arcxp-sdk-ts", - "files": [ - "dist" - ], + "files": ["dist"], "scripts": { "build": "tsc --noEmit && rollup -c", "format": "npx @biomejs/biome format --write .", @@ -33,11 +31,7 @@ "gen:ts": "npx tsx ./src/scripts/json-schema-to-ts.ts", "cs": "npx changeset && npx changeset version" }, - "keywords": [ - "ArcXP", - "SDK", - "Code.Store" - ], + "keywords": ["ArcXP", "SDK", "Code.Store"], "author": "code.store", "license": "MIT", "dependencies": { diff --git a/src/api/identity/index.ts b/src/api/identity/index.ts index 7fc52da..1406eab 100644 --- a/src/api/identity/index.ts +++ b/src/api/identity/index.ts @@ -38,6 +38,12 @@ export class ArcIdentity extends ArcAbstractAPI { return data; } + async getUserProfile(id: string): Promise { + const { data } = await this.client.get(`/profile/${id}`); + + return data; + } + async updateUserProfile(id: string, payload: Partial): Promise { const { data } = await this.client.patch(`/profile/${id}`, payload); diff --git a/src/api/identity/types.ts b/src/api/identity/types.ts index 69ce050..766d153 100644 --- a/src/api/identity/types.ts +++ b/src/api/identity/types.ts @@ -101,6 +101,11 @@ export interface UserIdentity { } export interface UserProfile { + /** + * @description Unique identifier of the user (UUID) + * @example "3eda4538-9ba3-411a-ac33-ecc93ea22abc" + */ + uuid?: string; /** * Format: date-time * @description Date this was created diff --git a/src/api/sales/index.ts b/src/api/sales/index.ts index 9245148..fa4c733 100644 --- a/src/api/sales/index.ts +++ b/src/api/sales/index.ts @@ -1,9 +1,11 @@ import FormData from 'form-data'; import { type ArcAPIOptions, ArcAbstractAPI } from '../abstract-api.js'; import type { + GetAllSubscriptionsForUserParams, MigrateBatchSubscriptionsParams, MigrateBatchSubscriptionsPayload, MigrateBatchSubscriptionsResponse, + SubscriptionSummary, } from './types.js'; export class ArcSales extends ArcAbstractAPI { @@ -24,4 +26,9 @@ export class ArcSales extends ArcAbstractAPI { return data; } + + async getAllSubscriptionsForUser(params?: GetAllSubscriptionsForUserParams): Promise { + const { data } = await this.client.get('/subscription/all', { params }); + return data; + } } diff --git a/src/api/sales/types.ts b/src/api/sales/types.ts index d76dbeb..16ba047 100644 --- a/src/api/sales/types.ts +++ b/src/api/sales/types.ts @@ -1,5 +1,6 @@ import type { UserAttribute } from '../identity/types'; import type { Website } from '../../types/ans-types'; +export type SubscriptionStatuses = 1 | 2 | 3 | 4 | 5 | 6 | 7; export type MigrateBatchSubscriptionsPayload = { subscriptions: (PaidSubscription | FreeSubscription | SharedSubscription | LinkedSubscription)[]; @@ -92,3 +93,27 @@ export type Refund = { tax: number; providerReference?: string; }; + +export type GetAllSubscriptionsForUserParams = { + id: string; + site?: string; +}; + +export interface SubscriptionSummary { + subscriptionID: number; + statusID: number; + paymentMethod?: PaymentMethod | null; + productName?: string | null; + sku?: string | null; + site?: string | null; +} + +export interface PaymentMethod { + creditCardType: string | null; + firstSix: string | null; + lastFour: string | null; + expiration: string | null; + cardHolderName: string | null; + paymentPartner: string; + paymentMethodID: number; +}