adapty 0.1.2 → 0.1.3
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/README.md +4 -3
- package/dist/commands/access-levels/create.d.ts +1 -7
- package/dist/commands/access-levels/create.js +2 -3
- package/dist/commands/access-levels/get.js +2 -3
- package/dist/commands/access-levels/list.js +1 -1
- package/dist/commands/access-levels/update.d.ts +1 -7
- package/dist/commands/access-levels/update.js +2 -3
- package/dist/commands/apps/create.d.ts +4 -16
- package/dist/commands/apps/create.js +27 -19
- package/dist/commands/apps/get.d.ts +3 -3
- package/dist/commands/apps/get.js +2 -9
- package/dist/commands/apps/list.d.ts +1 -1
- package/dist/commands/apps/list.js +1 -1
- package/dist/commands/apps/update.d.ts +6 -6
- package/dist/commands/apps/update.js +14 -18
- package/dist/commands/auth/login.js +2 -1
- package/dist/commands/auth/revoke.d.ts +9 -0
- package/dist/commands/auth/revoke.js +21 -0
- package/dist/commands/auth/whoami.d.ts +1 -10
- package/dist/commands/auth/whoami.js +2 -8
- package/dist/commands/paywalls/create.d.ts +2 -7
- package/dist/commands/paywalls/create.js +5 -5
- package/dist/commands/paywalls/get.d.ts +1 -1
- package/dist/commands/paywalls/get.js +2 -3
- package/dist/commands/paywalls/list.d.ts +1 -1
- package/dist/commands/paywalls/list.js +1 -1
- package/dist/commands/paywalls/update.d.ts +2 -7
- package/dist/commands/paywalls/update.js +5 -5
- package/dist/commands/placements/create.d.ts +2 -8
- package/dist/commands/placements/create.js +5 -6
- package/dist/commands/placements/get.d.ts +1 -1
- package/dist/commands/placements/get.js +2 -4
- package/dist/commands/placements/list.d.ts +1 -1
- package/dist/commands/placements/list.js +1 -1
- package/dist/commands/placements/update.d.ts +2 -8
- package/dist/commands/placements/update.js +5 -6
- package/dist/commands/products/create.d.ts +2 -19
- package/dist/commands/products/create.js +7 -14
- package/dist/commands/products/get.d.ts +2 -13
- package/dist/commands/products/get.js +2 -11
- package/dist/commands/products/list.d.ts +2 -13
- package/dist/commands/products/list.js +1 -12
- package/dist/commands/products/update.d.ts +2 -23
- package/dist/commands/products/update.js +6 -37
- package/dist/lib/output.d.ts +1 -1
- package/dist/lib/output.js +35 -4
- package/oclif.manifest.json +183 -180
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Args, Command, Flags } from '@oclif/core';
|
|
2
2
|
import { createAuthenticatedClient } from '../../lib/client-from-config.js';
|
|
3
3
|
import { appFlag, isValidUuid } from '../../lib/flags.js';
|
|
4
|
+
import { printResponse } from '../../lib/output.js';
|
|
4
5
|
export default class PaywallsUpdate extends Command {
|
|
5
6
|
static args = {
|
|
6
7
|
paywall_id: Args.string({ description: 'Paywall ID (UUID)', required: true }),
|
|
@@ -8,16 +9,16 @@ export default class PaywallsUpdate extends Command {
|
|
|
8
9
|
static description = 'Update a paywall';
|
|
9
10
|
static enableJsonFlag = true;
|
|
10
11
|
static examples = [
|
|
11
|
-
'<%= config.bin %> paywalls update --app UUID 550e8400-... --
|
|
12
|
+
'<%= config.bin %> paywalls update --app UUID 550e8400-... --title "Default Paywall" --product-id UUID1 --product-id UUID2',
|
|
12
13
|
];
|
|
13
14
|
static flags = {
|
|
14
15
|
...appFlag,
|
|
15
|
-
name: Flags.string({ description: 'Paywall name', required: true }),
|
|
16
16
|
'product-id': Flags.string({
|
|
17
17
|
description: 'Product ID (UUID). Repeat for multiple.',
|
|
18
18
|
multiple: true,
|
|
19
19
|
required: true,
|
|
20
20
|
}),
|
|
21
|
+
title: Flags.string({ description: 'Paywall title', required: true }),
|
|
21
22
|
};
|
|
22
23
|
async run() {
|
|
23
24
|
const { args, flags } = await this.parse(PaywallsUpdate);
|
|
@@ -26,12 +27,11 @@ export default class PaywallsUpdate extends Command {
|
|
|
26
27
|
}
|
|
27
28
|
const client = await createAuthenticatedClient(this.config);
|
|
28
29
|
const result = await client.put(`/apps/${flags.app}/paywalls/${args.paywall_id}`, {
|
|
29
|
-
name: flags.name,
|
|
30
30
|
product_ids: flags['product-id'],
|
|
31
|
+
title: flags.title,
|
|
31
32
|
});
|
|
32
33
|
this.log('Paywall updated!');
|
|
33
|
-
this.log(
|
|
34
|
-
this.log(`Name: ${result.name}`);
|
|
34
|
+
printResponse(result, this.log.bind(this));
|
|
35
35
|
return result;
|
|
36
36
|
}
|
|
37
37
|
}
|
|
@@ -1,19 +1,13 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
|
-
interface PlacementResponse {
|
|
3
|
-
developer_id: string;
|
|
4
|
-
id: string;
|
|
5
|
-
name: string;
|
|
6
|
-
}
|
|
7
2
|
export default class PlacementsCreate extends Command {
|
|
8
3
|
static description: string;
|
|
9
4
|
static enableJsonFlag: boolean;
|
|
10
5
|
static examples: string[];
|
|
11
6
|
static flags: {
|
|
12
7
|
'developer-id': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
-
name: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
8
|
'paywall-id': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
title: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
10
|
app: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
11
|
};
|
|
17
|
-
run(): Promise<
|
|
12
|
+
run(): Promise<Record<string, unknown>>;
|
|
18
13
|
}
|
|
19
|
-
export {};
|
|
@@ -1,30 +1,29 @@
|
|
|
1
1
|
import { Command, Flags } from '@oclif/core';
|
|
2
2
|
import { createAuthenticatedClient } from '../../lib/client-from-config.js';
|
|
3
3
|
import { appFlag } from '../../lib/flags.js';
|
|
4
|
+
import { printResponse } from '../../lib/output.js';
|
|
4
5
|
export default class PlacementsCreate extends Command {
|
|
5
6
|
static description = 'Create a placement with a paywall';
|
|
6
7
|
static enableJsonFlag = true;
|
|
7
8
|
static examples = [
|
|
8
|
-
'<%= config.bin %> placements create --app UUID --
|
|
9
|
+
'<%= config.bin %> placements create --app UUID --title "Default" --developer-id default --paywall-id UUID',
|
|
9
10
|
];
|
|
10
11
|
static flags = {
|
|
11
12
|
...appFlag,
|
|
12
13
|
'developer-id': Flags.string({ description: 'Developer ID for the placement', required: true }),
|
|
13
|
-
name: Flags.string({ description: 'Placement name', required: true }),
|
|
14
14
|
'paywall-id': Flags.string({ description: 'Paywall ID (UUID)', required: true }),
|
|
15
|
+
title: Flags.string({ description: 'Placement title', required: true }),
|
|
15
16
|
};
|
|
16
17
|
async run() {
|
|
17
18
|
const { flags } = await this.parse(PlacementsCreate);
|
|
18
19
|
const client = await createAuthenticatedClient(this.config);
|
|
19
20
|
const result = await client.post(`/apps/${flags.app}/placements`, {
|
|
20
21
|
developer_id: flags['developer-id'],
|
|
21
|
-
name: flags.name,
|
|
22
22
|
paywall_id: flags['paywall-id'],
|
|
23
|
+
title: flags.title,
|
|
23
24
|
});
|
|
24
25
|
this.log('Placement created!');
|
|
25
|
-
this.log(
|
|
26
|
-
this.log(`Developer ID: ${result.developer_id}`);
|
|
27
|
-
this.log(`Name: ${result.name}`);
|
|
26
|
+
printResponse(result, this.log.bind(this));
|
|
28
27
|
return result;
|
|
29
28
|
}
|
|
30
29
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Args, Command } from '@oclif/core';
|
|
2
2
|
import { createAuthenticatedClient } from '../../lib/client-from-config.js';
|
|
3
3
|
import { appFlag, isValidUuid } from '../../lib/flags.js';
|
|
4
|
+
import { printResponse } from '../../lib/output.js';
|
|
4
5
|
export default class PlacementsGet extends Command {
|
|
5
6
|
static args = {
|
|
6
7
|
placement_id: Args.string({ description: 'Placement ID (UUID)', required: true }),
|
|
@@ -18,10 +19,7 @@ export default class PlacementsGet extends Command {
|
|
|
18
19
|
}
|
|
19
20
|
const client = await createAuthenticatedClient(this.config);
|
|
20
21
|
const result = await client.get(`/apps/${flags.app}/placements/${args.placement_id}`);
|
|
21
|
-
this.log(
|
|
22
|
-
this.log(`Name: ${result.name}`);
|
|
23
|
-
this.log(`Developer ID: ${result.developer_id}`);
|
|
24
|
-
this.log(`Paywall ID: ${result.paywall_id}`);
|
|
22
|
+
printResponse(result, this.log.bind(this));
|
|
25
23
|
return result;
|
|
26
24
|
}
|
|
27
25
|
}
|
|
@@ -14,7 +14,7 @@ export default class PlacementsList extends Command {
|
|
|
14
14
|
const { flags } = await this.parse(PlacementsList);
|
|
15
15
|
const client = await createAuthenticatedClient(this.config);
|
|
16
16
|
const result = await client.get(`/apps/${flags.app}/placements`, paginationParams(flags));
|
|
17
|
-
printList(result.data
|
|
17
|
+
printList(result.data, this.log.bind(this), result.meta.pagination);
|
|
18
18
|
return result;
|
|
19
19
|
}
|
|
20
20
|
}
|
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
|
-
interface PlacementResponse {
|
|
3
|
-
developer_id: string;
|
|
4
|
-
id: string;
|
|
5
|
-
name: string;
|
|
6
|
-
}
|
|
7
2
|
export default class PlacementsUpdate extends Command {
|
|
8
3
|
static args: {
|
|
9
4
|
placement_id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
@@ -13,10 +8,9 @@ export default class PlacementsUpdate extends Command {
|
|
|
13
8
|
static examples: string[];
|
|
14
9
|
static flags: {
|
|
15
10
|
'developer-id': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
|
-
name: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
11
|
'paywall-id': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
title: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
18
13
|
app: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
19
14
|
};
|
|
20
|
-
run(): Promise<
|
|
15
|
+
run(): Promise<Record<string, unknown>>;
|
|
21
16
|
}
|
|
22
|
-
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Args, Command, Flags } from '@oclif/core';
|
|
2
2
|
import { createAuthenticatedClient } from '../../lib/client-from-config.js';
|
|
3
3
|
import { appFlag, isValidUuid } from '../../lib/flags.js';
|
|
4
|
+
import { printResponse } from '../../lib/output.js';
|
|
4
5
|
export default class PlacementsUpdate extends Command {
|
|
5
6
|
static args = {
|
|
6
7
|
placement_id: Args.string({ description: 'Placement ID (UUID)', required: true }),
|
|
@@ -8,13 +9,13 @@ export default class PlacementsUpdate extends Command {
|
|
|
8
9
|
static description = 'Update a placement';
|
|
9
10
|
static enableJsonFlag = true;
|
|
10
11
|
static examples = [
|
|
11
|
-
'<%= config.bin %> placements update --app UUID 550e8400-... --
|
|
12
|
+
'<%= config.bin %> placements update --app UUID 550e8400-... --title "Default" --developer-id default --paywall-id UUID',
|
|
12
13
|
];
|
|
13
14
|
static flags = {
|
|
14
15
|
...appFlag,
|
|
15
16
|
'developer-id': Flags.string({ description: 'Developer ID for the placement', required: true }),
|
|
16
|
-
name: Flags.string({ description: 'Placement name', required: true }),
|
|
17
17
|
'paywall-id': Flags.string({ description: 'Paywall ID (UUID)', required: true }),
|
|
18
|
+
title: Flags.string({ description: 'Placement title', required: true }),
|
|
18
19
|
};
|
|
19
20
|
async run() {
|
|
20
21
|
const { args, flags } = await this.parse(PlacementsUpdate);
|
|
@@ -24,13 +25,11 @@ export default class PlacementsUpdate extends Command {
|
|
|
24
25
|
const client = await createAuthenticatedClient(this.config);
|
|
25
26
|
const result = await client.put(`/apps/${flags.app}/placements/${args.placement_id}`, {
|
|
26
27
|
developer_id: flags['developer-id'],
|
|
27
|
-
name: flags.name,
|
|
28
28
|
paywall_id: flags['paywall-id'],
|
|
29
|
+
title: flags.title,
|
|
29
30
|
});
|
|
30
31
|
this.log('Placement updated!');
|
|
31
|
-
this.log(
|
|
32
|
-
this.log(`Developer ID: ${result.developer_id}`);
|
|
33
|
-
this.log(`Name: ${result.name}`);
|
|
32
|
+
printResponse(result, this.log.bind(this));
|
|
34
33
|
return result;
|
|
35
34
|
}
|
|
36
35
|
}
|
|
@@ -1,20 +1,4 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
|
-
interface VendorProducts {
|
|
3
|
-
android?: {
|
|
4
|
-
base_plan_id?: string;
|
|
5
|
-
id: string;
|
|
6
|
-
product_id: string;
|
|
7
|
-
};
|
|
8
|
-
ios?: {
|
|
9
|
-
id: string;
|
|
10
|
-
product_id: string;
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
interface ProductResponse {
|
|
14
|
-
id: string;
|
|
15
|
-
name: string;
|
|
16
|
-
vendor_products: VendorProducts;
|
|
17
|
-
}
|
|
18
2
|
export default class ProductsCreate extends Command {
|
|
19
3
|
static description: string;
|
|
20
4
|
static enableJsonFlag: boolean;
|
|
@@ -24,10 +8,9 @@ export default class ProductsCreate extends Command {
|
|
|
24
8
|
'android-base-plan-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
25
9
|
'android-product-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
26
10
|
'ios-product-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
27
|
-
name: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
28
11
|
period: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
title: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
29
13
|
app: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
30
14
|
};
|
|
31
|
-
run(): Promise<
|
|
15
|
+
run(): Promise<Record<string, unknown>>;
|
|
32
16
|
}
|
|
33
|
-
export {};
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { Command, Flags } from '@oclif/core';
|
|
2
2
|
import { createAuthenticatedClient } from '../../lib/client-from-config.js';
|
|
3
3
|
import { appFlag } from '../../lib/flags.js';
|
|
4
|
-
|
|
4
|
+
import { printResponse } from '../../lib/output.js';
|
|
5
|
+
const VALID_PERIODS = ['weekly', 'monthly', 'two_months', 'trimonthly', 'semiannual', 'annual', 'lifetime'];
|
|
5
6
|
export default class ProductsCreate extends Command {
|
|
6
7
|
static description = 'Create a product with vendor products per platform';
|
|
7
8
|
static enableJsonFlag = true;
|
|
8
9
|
static examples = [
|
|
9
|
-
'<%= config.bin %> products create --app UUID --
|
|
10
|
+
'<%= config.bin %> products create --app UUID --title "Monthly" --access-level-id UUID --period monthly --ios-product-id com.example.monthly',
|
|
10
11
|
];
|
|
11
12
|
static flags = {
|
|
12
13
|
...appFlag,
|
|
@@ -14,11 +15,11 @@ export default class ProductsCreate extends Command {
|
|
|
14
15
|
'android-base-plan-id': Flags.string({ description: 'Android base plan ID' }),
|
|
15
16
|
'android-product-id': Flags.string({ description: 'Android product ID' }),
|
|
16
17
|
'ios-product-id': Flags.string({ description: 'iOS product ID' }),
|
|
17
|
-
name: Flags.string({ description: 'Product name', required: true }),
|
|
18
18
|
period: Flags.string({
|
|
19
|
-
description: 'Subscription period (weekly, monthly,
|
|
19
|
+
description: 'Subscription period (weekly, monthly, two_months, trimonthly, semiannual, annual, lifetime)',
|
|
20
20
|
required: true,
|
|
21
21
|
}),
|
|
22
|
+
title: Flags.string({ description: 'Product title', required: true }),
|
|
22
23
|
};
|
|
23
24
|
async run() {
|
|
24
25
|
const { flags } = await this.parse(ProductsCreate);
|
|
@@ -34,8 +35,8 @@ export default class ProductsCreate extends Command {
|
|
|
34
35
|
const client = await createAuthenticatedClient(this.config);
|
|
35
36
|
const body = {
|
|
36
37
|
access_level_id: flags['access-level-id'],
|
|
37
|
-
name: flags.name,
|
|
38
38
|
period: flags.period,
|
|
39
|
+
title: flags.title,
|
|
39
40
|
};
|
|
40
41
|
if (flags['ios-product-id'])
|
|
41
42
|
body.ios_product_id = flags['ios-product-id'];
|
|
@@ -45,15 +46,7 @@ export default class ProductsCreate extends Command {
|
|
|
45
46
|
body.android_base_plan_id = flags['android-base-plan-id'];
|
|
46
47
|
const result = await client.post(`/apps/${flags.app}/products`, body);
|
|
47
48
|
this.log('Product created!');
|
|
48
|
-
this.log(
|
|
49
|
-
this.log(`Name: ${result.name}`);
|
|
50
|
-
if (result.vendor_products.ios) {
|
|
51
|
-
this.log(`iOS Product: ${result.vendor_products.ios.product_id}`);
|
|
52
|
-
}
|
|
53
|
-
if (result.vendor_products.android) {
|
|
54
|
-
const bp = result.vendor_products.android.base_plan_id;
|
|
55
|
-
this.log(`Android Product: ${result.vendor_products.android.product_id}${bp ? ` (base plan: ${bp})` : ''}`);
|
|
56
|
-
}
|
|
49
|
+
printResponse(result, this.log.bind(this));
|
|
57
50
|
return result;
|
|
58
51
|
}
|
|
59
52
|
}
|
|
@@ -1,21 +1,10 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
|
-
interface VendorProducts {
|
|
3
|
-
android?: {
|
|
4
|
-
base_plan_id?: string;
|
|
5
|
-
id: string;
|
|
6
|
-
product_id: string;
|
|
7
|
-
};
|
|
8
|
-
ios?: {
|
|
9
|
-
id: string;
|
|
10
|
-
product_id: string;
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
2
|
interface ProductDetailResponse {
|
|
14
3
|
access_level_id: string;
|
|
15
4
|
id: string;
|
|
16
|
-
name: string;
|
|
17
5
|
period: string;
|
|
18
|
-
|
|
6
|
+
title: string;
|
|
7
|
+
vendor_products: Record<string, unknown>;
|
|
19
8
|
}
|
|
20
9
|
export default class ProductsGet extends Command {
|
|
21
10
|
static args: {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Args, Command } from '@oclif/core';
|
|
2
2
|
import { createAuthenticatedClient } from '../../lib/client-from-config.js';
|
|
3
3
|
import { appFlag, isValidUuid } from '../../lib/flags.js';
|
|
4
|
+
import { printResponse } from '../../lib/output.js';
|
|
4
5
|
export default class ProductsGet extends Command {
|
|
5
6
|
static args = {
|
|
6
7
|
product_id: Args.string({ description: 'Product ID (UUID)', required: true }),
|
|
@@ -18,17 +19,7 @@ export default class ProductsGet extends Command {
|
|
|
18
19
|
}
|
|
19
20
|
const client = await createAuthenticatedClient(this.config);
|
|
20
21
|
const result = await client.get(`/apps/${flags.app}/products/${args.product_id}`);
|
|
21
|
-
this.log(
|
|
22
|
-
this.log(`Name: ${result.name}`);
|
|
23
|
-
this.log(`Period: ${result.period}`);
|
|
24
|
-
this.log(`Access Level ID: ${result.access_level_id}`);
|
|
25
|
-
if (result.vendor_products.ios) {
|
|
26
|
-
this.log(`iOS Product: ${result.vendor_products.ios.product_id}`);
|
|
27
|
-
}
|
|
28
|
-
if (result.vendor_products.android) {
|
|
29
|
-
const bp = result.vendor_products.android.base_plan_id;
|
|
30
|
-
this.log(`Android Product: ${result.vendor_products.android.product_id}${bp ? ` (base plan: ${bp})` : ''}`);
|
|
31
|
-
}
|
|
22
|
+
printResponse(result, this.log.bind(this));
|
|
32
23
|
return result;
|
|
33
24
|
}
|
|
34
25
|
}
|
|
@@ -1,20 +1,9 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
2
|
import { type PaginatedResponse } from '../../lib/flags.js';
|
|
3
|
-
interface VendorProducts {
|
|
4
|
-
android?: {
|
|
5
|
-
base_plan_id?: string;
|
|
6
|
-
id: string;
|
|
7
|
-
product_id: string;
|
|
8
|
-
};
|
|
9
|
-
ios?: {
|
|
10
|
-
id: string;
|
|
11
|
-
product_id: string;
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
3
|
interface ProductItem {
|
|
15
4
|
id: string;
|
|
16
|
-
|
|
17
|
-
vendor_products:
|
|
5
|
+
title: string;
|
|
6
|
+
vendor_products: Record<string, unknown>;
|
|
18
7
|
}
|
|
19
8
|
export default class ProductsList extends Command {
|
|
20
9
|
static description: string;
|
|
@@ -14,18 +14,7 @@ export default class ProductsList extends Command {
|
|
|
14
14
|
const { flags } = await this.parse(ProductsList);
|
|
15
15
|
const client = await createAuthenticatedClient(this.config);
|
|
16
16
|
const result = await client.get(`/apps/${flags.app}/products`, paginationParams(flags));
|
|
17
|
-
printList(result.data.
|
|
18
|
-
const row = { ID: p.id, Name: p.name };
|
|
19
|
-
if (p.vendor_products.ios)
|
|
20
|
-
row['iOS Product'] = p.vendor_products.ios.product_id;
|
|
21
|
-
if (p.vendor_products.android) {
|
|
22
|
-
const bp = p.vendor_products.android.base_plan_id;
|
|
23
|
-
row['Android Product'] = bp
|
|
24
|
-
? `${p.vendor_products.android.product_id} (base plan: ${bp})`
|
|
25
|
-
: p.vendor_products.android.product_id;
|
|
26
|
-
}
|
|
27
|
-
return row;
|
|
28
|
-
}), this.log.bind(this), result.meta.pagination);
|
|
17
|
+
printList(result.data, this.log.bind(this), result.meta.pagination);
|
|
29
18
|
return result;
|
|
30
19
|
}
|
|
31
20
|
}
|
|
@@ -1,20 +1,4 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
|
-
interface VendorProducts {
|
|
3
|
-
android?: {
|
|
4
|
-
base_plan_id?: string;
|
|
5
|
-
id: string;
|
|
6
|
-
product_id: string;
|
|
7
|
-
};
|
|
8
|
-
ios?: {
|
|
9
|
-
id: string;
|
|
10
|
-
product_id: string;
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
interface ProductResponse {
|
|
14
|
-
id: string;
|
|
15
|
-
name: string;
|
|
16
|
-
vendor_products: VendorProducts;
|
|
17
|
-
}
|
|
18
2
|
export default class ProductsUpdate extends Command {
|
|
19
3
|
static args: {
|
|
20
4
|
product_id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
@@ -24,13 +8,8 @@ export default class ProductsUpdate extends Command {
|
|
|
24
8
|
static examples: string[];
|
|
25
9
|
static flags: {
|
|
26
10
|
'access-level-id': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
27
|
-
|
|
28
|
-
'android-product-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
29
|
-
'ios-product-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
30
|
-
name: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
31
|
-
period: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
title: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
32
12
|
app: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
33
13
|
};
|
|
34
|
-
run(): Promise<
|
|
14
|
+
run(): Promise<Record<string, unknown>>;
|
|
35
15
|
}
|
|
36
|
-
export {};
|
|
@@ -1,65 +1,34 @@
|
|
|
1
1
|
import { Args, Command, Flags } from '@oclif/core';
|
|
2
2
|
import { createAuthenticatedClient } from '../../lib/client-from-config.js';
|
|
3
3
|
import { appFlag, isValidUuid } from '../../lib/flags.js';
|
|
4
|
-
|
|
4
|
+
import { printResponse } from '../../lib/output.js';
|
|
5
5
|
export default class ProductsUpdate extends Command {
|
|
6
6
|
static args = {
|
|
7
7
|
product_id: Args.string({ description: 'Product ID (UUID)', required: true }),
|
|
8
8
|
};
|
|
9
|
-
static description = 'Update a product';
|
|
9
|
+
static description = 'Update a product (title and access level only)';
|
|
10
10
|
static enableJsonFlag = true;
|
|
11
11
|
static examples = [
|
|
12
|
-
'<%= config.bin %> products update --app UUID 550e8400-... --
|
|
12
|
+
'<%= config.bin %> products update --app UUID 550e8400-... --title "Monthly" --access-level-id UUID',
|
|
13
13
|
];
|
|
14
14
|
static flags = {
|
|
15
15
|
...appFlag,
|
|
16
16
|
'access-level-id': Flags.string({ description: 'Access level ID (UUID)', required: true }),
|
|
17
|
-
|
|
18
|
-
'android-product-id': Flags.string({ description: 'Android product ID' }),
|
|
19
|
-
'ios-product-id': Flags.string({ description: 'iOS product ID' }),
|
|
20
|
-
name: Flags.string({ description: 'Product name', required: true }),
|
|
21
|
-
period: Flags.string({
|
|
22
|
-
description: 'Subscription period (weekly, monthly, 2_months, 3_months, 6_months, yearly, lifetime)',
|
|
23
|
-
required: true,
|
|
24
|
-
}),
|
|
17
|
+
title: Flags.string({ description: 'Product title', required: true }),
|
|
25
18
|
};
|
|
26
19
|
async run() {
|
|
27
20
|
const { args, flags } = await this.parse(ProductsUpdate);
|
|
28
21
|
if (!isValidUuid(args.product_id)) {
|
|
29
22
|
this.error('Invalid product ID format.', { exit: 2 });
|
|
30
23
|
}
|
|
31
|
-
if (!VALID_PERIODS.includes(flags.period)) {
|
|
32
|
-
this.error(`Invalid period. Must be one of: ${VALID_PERIODS.join(', ')}`, { exit: 2 });
|
|
33
|
-
}
|
|
34
|
-
if (!flags['ios-product-id'] && !flags['android-product-id']) {
|
|
35
|
-
this.error('At least one of --ios-product-id or --android-product-id is required', { exit: 2 });
|
|
36
|
-
}
|
|
37
|
-
if (flags['android-product-id'] && !flags['android-base-plan-id'] && flags.period !== 'lifetime') {
|
|
38
|
-
this.error('--android-base-plan-id is required with --android-product-id for subscriptions', { exit: 2 });
|
|
39
|
-
}
|
|
40
24
|
const client = await createAuthenticatedClient(this.config);
|
|
41
25
|
const body = {
|
|
42
26
|
access_level_id: flags['access-level-id'],
|
|
43
|
-
|
|
44
|
-
period: flags.period,
|
|
27
|
+
title: flags.title,
|
|
45
28
|
};
|
|
46
|
-
if (flags['ios-product-id'])
|
|
47
|
-
body.ios_product_id = flags['ios-product-id'];
|
|
48
|
-
if (flags['android-product-id'])
|
|
49
|
-
body.android_product_id = flags['android-product-id'];
|
|
50
|
-
if (flags['android-base-plan-id'])
|
|
51
|
-
body.android_base_plan_id = flags['android-base-plan-id'];
|
|
52
29
|
const result = await client.put(`/apps/${flags.app}/products/${args.product_id}`, body);
|
|
53
30
|
this.log('Product updated!');
|
|
54
|
-
this.log(
|
|
55
|
-
this.log(`Name: ${result.name}`);
|
|
56
|
-
if (result.vendor_products.ios) {
|
|
57
|
-
this.log(`iOS Product: ${result.vendor_products.ios.product_id}`);
|
|
58
|
-
}
|
|
59
|
-
if (result.vendor_products.android) {
|
|
60
|
-
const bp = result.vendor_products.android.base_plan_id;
|
|
61
|
-
this.log(`Android Product: ${result.vendor_products.android.product_id}${bp ? ` (base plan: ${bp})` : ''}`);
|
|
62
|
-
}
|
|
31
|
+
printResponse(result, this.log.bind(this));
|
|
63
32
|
return result;
|
|
64
33
|
}
|
|
65
34
|
}
|
package/dist/lib/output.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare function
|
|
1
|
+
export declare function printResponse(data: Record<string, unknown>, log: (msg: string) => void): void;
|
|
2
2
|
export declare function printList(items: Record<string, unknown>[], log: (msg: string) => void, pagination?: {
|
|
3
3
|
count: number;
|
|
4
4
|
page: number;
|
package/dist/lib/output.js
CHANGED
|
@@ -1,13 +1,44 @@
|
|
|
1
|
-
|
|
1
|
+
const UPPER_WORDS = new Set(['api', 'id', 'ios', 'sdk', 'uri', 'url', 'uuid']);
|
|
2
|
+
function formatLabel(snakeKey) {
|
|
3
|
+
return snakeKey
|
|
4
|
+
.split('_')
|
|
5
|
+
.map((w) => {
|
|
6
|
+
if (w === 'ids')
|
|
7
|
+
return 'IDs';
|
|
8
|
+
if (UPPER_WORDS.has(w))
|
|
9
|
+
return w.toUpperCase();
|
|
10
|
+
return w.charAt(0).toUpperCase() + w.slice(1);
|
|
11
|
+
})
|
|
12
|
+
.join(' ');
|
|
13
|
+
}
|
|
14
|
+
function formatValue(value, indent = '') {
|
|
15
|
+
if (Array.isArray(value)) {
|
|
16
|
+
return value.map((v) => (typeof v === 'object' && v !== null ? formatValue(v, indent) : String(v))).join(', ');
|
|
17
|
+
}
|
|
18
|
+
if (typeof value === 'object' && value !== null) {
|
|
19
|
+
return Object.entries(value)
|
|
20
|
+
.filter(([, v]) => v !== undefined && v !== null)
|
|
21
|
+
.map(([k, v]) => `${indent} ${formatLabel(k)}: ${formatValue(v, indent + ' ')}`)
|
|
22
|
+
.join('\n');
|
|
23
|
+
}
|
|
24
|
+
return String(value);
|
|
25
|
+
}
|
|
26
|
+
export function printResponse(data, log) {
|
|
2
27
|
for (const [key, value] of Object.entries(data)) {
|
|
3
|
-
if (value
|
|
4
|
-
|
|
28
|
+
if (value === undefined || value === null)
|
|
29
|
+
continue;
|
|
30
|
+
if (typeof value === 'object' && !Array.isArray(value)) {
|
|
31
|
+
log(`${formatLabel(key)}:`);
|
|
32
|
+
log(formatValue(value));
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
log(`${formatLabel(key)}: ${formatValue(value)}`);
|
|
5
36
|
}
|
|
6
37
|
}
|
|
7
38
|
}
|
|
8
39
|
export function printList(items, log, pagination) {
|
|
9
40
|
for (const [i, item] of items.entries()) {
|
|
10
|
-
|
|
41
|
+
printResponse(item, log);
|
|
11
42
|
if (i < items.length - 1)
|
|
12
43
|
log('---');
|
|
13
44
|
}
|