1
1
import type {
2
+ CommerceMoneyAmount ,
2
3
CommercePayerResourceType ,
3
4
CommercePlanJSON ,
4
- CommercePlanJSONSnapshot ,
5
5
CommercePlanResource ,
6
6
} from '@clerk/types' ;
7
7
8
+ import { commerceMoneyAmountFromJSON } from '@/utils/commerce' ;
9
+
8
10
import { BaseResource , CommerceFeature } from './internal' ;
9
11
10
12
export class CommercePlan extends BaseResource implements CommercePlanResource {
11
13
id ! : string ;
12
14
name ! : string ;
13
- amount ! : number ;
14
- amountFormatted ! : string ;
15
- annualAmount ! : number ;
16
- annualAmountFormatted ! : string ;
17
- annualMonthlyAmount ! : number ;
18
- annualMonthlyAmountFormatted ! : string ;
19
- currencySymbol ! : string ;
20
- currency ! : string ;
15
+ fee ! : CommerceMoneyAmount ;
16
+ annualFee ! : CommerceMoneyAmount ;
17
+ annualMonthlyFee ! : CommerceMoneyAmount ;
21
18
description ! : string ;
22
19
isDefault ! : boolean ;
23
20
isRecurring ! : boolean ;
@@ -42,14 +39,9 @@ export class CommercePlan extends BaseResource implements CommercePlanResource {
42
39
43
40
this . id = data . id ;
44
41
this . name = data . name ;
45
- this . amount = data . amount ;
46
- this . amountFormatted = data . amount_formatted ;
47
- this . annualAmount = data . annual_amount ;
48
- this . annualAmountFormatted = data . annual_amount_formatted ;
49
- this . annualMonthlyAmount = data . annual_monthly_amount ;
50
- this . annualMonthlyAmountFormatted = data . annual_monthly_amount_formatted ;
51
- this . currencySymbol = data . currency_symbol ;
52
- this . currency = data . currency ;
42
+ this . fee = commerceMoneyAmountFromJSON ( data . fee ) ;
43
+ this . annualFee = commerceMoneyAmountFromJSON ( data . annual_fee ) ;
44
+ this . annualMonthlyFee = commerceMoneyAmountFromJSON ( data . annual_monthly_fee ) ;
53
45
this . description = data . description ;
54
46
this . isDefault = data . is_default ;
55
47
this . isRecurring = data . is_recurring ;
@@ -64,29 +56,4 @@ export class CommercePlan extends BaseResource implements CommercePlanResource {
64
56
65
57
return this ;
66
58
}
67
-
68
- public __internal_toSnapshot ( ) : CommercePlanJSONSnapshot {
69
- return {
70
- object : 'commerce_plan' ,
71
- id : this . id ,
72
- name : this . name ,
73
- amount : this . amount ,
74
- amount_formatted : this . amountFormatted ,
75
- annual_amount : this . annualAmount ,
76
- annual_amount_formatted : this . annualAmountFormatted ,
77
- annual_monthly_amount : this . annualMonthlyAmount ,
78
- annual_monthly_amount_formatted : this . annualMonthlyAmountFormatted ,
79
- currency : this . currency ,
80
- currency_symbol : this . currencySymbol ,
81
- description : this . description ,
82
- is_default : this . isDefault ,
83
- is_recurring : this . isRecurring ,
84
- has_base_fee : this . hasBaseFee ,
85
- for_payer_type : this . forPayerType ,
86
- publicly_visible : this . publiclyVisible ,
87
- slug : this . slug ,
88
- avatar_url : this . avatarUrl ,
89
- features : this . features . map ( feature => feature . __internal_toSnapshot ( ) ) ,
90
- } ;
91
- }
92
59
}
0 commit comments