@metrifox/angular-sdk 1.0.0
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/LICENSE +21 -0
- package/README.md +487 -0
- package/fesm2022/index.mjs +5898 -0
- package/index.d.ts +5 -0
- package/lib/components/customer-portal/customer-portal.component.d.ts +193 -0
- package/lib/components/pricing-table/pricing-table.component.d.ts +157 -0
- package/lib/metrifox.module.d.ts +52 -0
- package/lib/metrifox.service.d.ts +190 -0
- package/lib/types/enum.d.ts +156 -0
- package/lib/types/index.d.ts +2 -0
- package/lib/types/interface.d.ts +739 -0
- package/package.json +51 -0
- package/public-api.d.ts +20 -0
- package/styles.css +3 -0
package/index.d.ts
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { EventEmitter, OnInit, OnDestroy } from '@angular/core';
|
|
2
|
+
import { SafeHtml } from '@angular/platform-browser';
|
|
3
|
+
import { CustomerDetails, Wallet, SectionConfig, CustomerDataLoadedEvent, ErrorEvent, BillingHistory, ProductPlans, Offering, Invoice, InvoiceLineItem } from '../../types';
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
5
|
+
declare const ICONS: {
|
|
6
|
+
money: string;
|
|
7
|
+
cardReceive: string;
|
|
8
|
+
settings: string;
|
|
9
|
+
settingsAlt: string;
|
|
10
|
+
closeCircle: string;
|
|
11
|
+
walletEmpty: string;
|
|
12
|
+
noteEmpty: string;
|
|
13
|
+
receipt: string;
|
|
14
|
+
radar: string;
|
|
15
|
+
arrowDown: string;
|
|
16
|
+
arrowDownRight: string;
|
|
17
|
+
subtitle: string;
|
|
18
|
+
subtitleLarge: string;
|
|
19
|
+
check: string;
|
|
20
|
+
};
|
|
21
|
+
export declare class CustomerPortalComponent implements OnInit, OnDestroy {
|
|
22
|
+
private destroy$;
|
|
23
|
+
private isLoadingData;
|
|
24
|
+
private lastLoadedCustomerKey;
|
|
25
|
+
private expandedLineItems;
|
|
26
|
+
private iconCache;
|
|
27
|
+
customerKey: string;
|
|
28
|
+
sectionsConfig?: SectionConfig[];
|
|
29
|
+
dataLoaded: EventEmitter<CustomerDataLoadedEvent>;
|
|
30
|
+
errorOccurred: EventEmitter<ErrorEvent>;
|
|
31
|
+
private metrifoxService;
|
|
32
|
+
private sanitizer;
|
|
33
|
+
constructor();
|
|
34
|
+
loading: import("@angular/core").WritableSignal<boolean>;
|
|
35
|
+
error: import("@angular/core").WritableSignal<string>;
|
|
36
|
+
customerDetails: import("@angular/core").WritableSignal<CustomerDetails>;
|
|
37
|
+
wallets: import("@angular/core").WritableSignal<Wallet[]>;
|
|
38
|
+
billingHistory: import("@angular/core").WritableSignal<BillingHistory[]>;
|
|
39
|
+
productPlans: import("@angular/core").WritableSignal<ProductPlans>;
|
|
40
|
+
entitlementSummary: import("@angular/core").WritableSignal<any[]>;
|
|
41
|
+
entitlementUsage: import("@angular/core").WritableSignal<any[]>;
|
|
42
|
+
creditAllocations: import("@angular/core").WritableSignal<any[]>;
|
|
43
|
+
selectedTabIndex: import("@angular/core").WritableSignal<number>;
|
|
44
|
+
explorePricesPlan: import("@angular/core").WritableSignal<Offering>;
|
|
45
|
+
selectedPlanInterval: import("@angular/core").WritableSignal<string>;
|
|
46
|
+
showInvoicePreview: import("@angular/core").WritableSignal<boolean>;
|
|
47
|
+
selectedInvoice: import("@angular/core").WritableSignal<any>;
|
|
48
|
+
invoiceDetails: import("@angular/core").WritableSignal<Invoice>;
|
|
49
|
+
invoiceDetailsLoading: import("@angular/core").WritableSignal<boolean>;
|
|
50
|
+
selectedWalletIndex: import("@angular/core").WritableSignal<number>;
|
|
51
|
+
walletTab: import("@angular/core").WritableSignal<"active" | "expired" | "overage">;
|
|
52
|
+
entitlementTab: import("@angular/core").WritableSignal<"usage" | "summary">;
|
|
53
|
+
showWalletSettings: import("@angular/core").WritableSignal<boolean>;
|
|
54
|
+
selectedWalletForSettings: string;
|
|
55
|
+
lowBalanceEnabled: boolean;
|
|
56
|
+
walletSettingThreshold: string;
|
|
57
|
+
walletSettingBehaviour: 'notify' | 'auto_top_up';
|
|
58
|
+
walletSettingTargetBalance: string;
|
|
59
|
+
walletSettingMonthlyLimit: string;
|
|
60
|
+
walletSettingsList: import("@angular/core").WritableSignal<any[]>;
|
|
61
|
+
walletSettingsLoading: import("@angular/core").WritableSignal<boolean>;
|
|
62
|
+
walletSettingsSaving: import("@angular/core").WritableSignal<boolean>;
|
|
63
|
+
walletSettingsError: import("@angular/core").WritableSignal<string>;
|
|
64
|
+
walletSettingEditId: import("@angular/core").WritableSignal<string>;
|
|
65
|
+
expandedEntitlements: Set<string>;
|
|
66
|
+
allocationsLoading: import("@angular/core").WritableSignal<boolean>;
|
|
67
|
+
showCreditTransactions: import("@angular/core").WritableSignal<boolean>;
|
|
68
|
+
selectedAllocation: import("@angular/core").WritableSignal<any>;
|
|
69
|
+
creditTransactions: import("@angular/core").WritableSignal<any[]>;
|
|
70
|
+
creditTransactionsLoading: import("@angular/core").WritableSignal<boolean>;
|
|
71
|
+
Math: Math;
|
|
72
|
+
subscriptions: import("@angular/core").Signal<import("../../types").Subscription[]>;
|
|
73
|
+
tenantCheckoutUsername: import("@angular/core").Signal<string>;
|
|
74
|
+
plans: import("@angular/core").Signal<Offering[]>;
|
|
75
|
+
planIntervals: import("@angular/core").Signal<string[]>;
|
|
76
|
+
currentPlanIndex: import("@angular/core").Signal<number>;
|
|
77
|
+
cssVars: import("@angular/core").Signal<import("../../types").CssVarMap>;
|
|
78
|
+
private sectionLabels;
|
|
79
|
+
ngOnInit(): void;
|
|
80
|
+
ngOnDestroy(): void;
|
|
81
|
+
private loadCustomerDetails;
|
|
82
|
+
private loadAdditionalData;
|
|
83
|
+
private loadCreditAllocations;
|
|
84
|
+
selectTab(index: number): void;
|
|
85
|
+
isSectionHidden(key: string): boolean;
|
|
86
|
+
getSectionLabel(key: string): string;
|
|
87
|
+
getIcon(name: keyof typeof ICONS): SafeHtml;
|
|
88
|
+
toggleLineItems(productKey: string): void;
|
|
89
|
+
isLineItemsExpanded(productKey: string): boolean;
|
|
90
|
+
openUpdateItems(subscription: {
|
|
91
|
+
subscription: {
|
|
92
|
+
id: string;
|
|
93
|
+
offering_key: string;
|
|
94
|
+
};
|
|
95
|
+
}): void;
|
|
96
|
+
formatDate(dateString: string | null | undefined): string;
|
|
97
|
+
formatCurrency(amount: number | null | undefined, currency: string | null | undefined): string;
|
|
98
|
+
formatStatus(status: string | null | undefined): string;
|
|
99
|
+
formatSourceType(sourceType: string | null | undefined): string;
|
|
100
|
+
openInvoicePreview(invoice: any): void;
|
|
101
|
+
closeInvoicePreview(): void;
|
|
102
|
+
openExplorePricesModal(plan: Offering): void;
|
|
103
|
+
closeExplorePricesModal(): void;
|
|
104
|
+
buildTenantAddress(addr: any): string;
|
|
105
|
+
buildBilledToAddress(customer: any): string;
|
|
106
|
+
formatInvoiceDate(d: string | null | undefined): string;
|
|
107
|
+
/** Build range label from usage_tiers like React SDK: "0 and above" or "X to Y". */
|
|
108
|
+
private getInvoiceLineItemRangeLabel;
|
|
109
|
+
/** Normalize a single item from API (handles snake_case and camelCase, nested data, range from tiers, unit_price from tiers). */
|
|
110
|
+
private normalizeInvoiceLineItem;
|
|
111
|
+
getInvoiceLineItems(invoice: Invoice | null | undefined): Array<InvoiceLineItem & {
|
|
112
|
+
itemType: string;
|
|
113
|
+
}>;
|
|
114
|
+
/** Build HTML string for invoice print (new window) so download/print has no Storybook URL or timestamp in header. */
|
|
115
|
+
private buildInvoicePrintHtml;
|
|
116
|
+
private escapeHtml;
|
|
117
|
+
triggerInvoicePrint(): void;
|
|
118
|
+
selectWallet(index: number): void;
|
|
119
|
+
formatWalletBalance(wallet: Wallet): string;
|
|
120
|
+
changeWalletTab(tab: 'active' | 'expired' | 'overage'): void;
|
|
121
|
+
getActiveAllocationsCount(): number;
|
|
122
|
+
formatAllocationDate(dateStr: string): string;
|
|
123
|
+
formatAllocationSource(type: string): string;
|
|
124
|
+
formatAllocationDateShort(dateStr: string): string;
|
|
125
|
+
formatValidUntilDate(dateStr: string): string;
|
|
126
|
+
formatPrice(value: number | undefined | null): string;
|
|
127
|
+
getAllocationBalance(allocation: any): number;
|
|
128
|
+
getAllocationProgressPercent(allocation: any): number;
|
|
129
|
+
openWalletSettings(): void;
|
|
130
|
+
private loadWalletSettings;
|
|
131
|
+
private applyExistingWalletSetting;
|
|
132
|
+
closeWalletSettings(): void;
|
|
133
|
+
getWalletSettingsValidationErrors(): string[];
|
|
134
|
+
saveWalletSettings(): void;
|
|
135
|
+
onWalletSelectChange(event: Event): void;
|
|
136
|
+
toggleLowBalance(): void;
|
|
137
|
+
getSelectedWalletName(): string;
|
|
138
|
+
handleTopup(walletId: string): void;
|
|
139
|
+
openCreditTransactions(allocation: any): void;
|
|
140
|
+
closeCreditTransactions(): void;
|
|
141
|
+
changeEntitlementTab(tab: 'summary' | 'usage'): void;
|
|
142
|
+
getMeteredEntitlements(): any[];
|
|
143
|
+
capitalize(str: string): string;
|
|
144
|
+
formatUsageModel(entitlement: any): string;
|
|
145
|
+
formatIncludedAllowance(entitlement: any): string;
|
|
146
|
+
formatUsageLimits(entitlement: any): string;
|
|
147
|
+
getResetIntervalLabel(interval: string): string;
|
|
148
|
+
formatNumber(num: number): string;
|
|
149
|
+
toggleEntitlementExpand(id: string): void;
|
|
150
|
+
isEntitlementExpanded(id: string): boolean;
|
|
151
|
+
getEntitlementUsageBalance(usage: any): string;
|
|
152
|
+
getEntitlementUsagePercent(usage: any): number;
|
|
153
|
+
getEntitlementUsageText(usage: any): string;
|
|
154
|
+
getProcessedPools(usage: any): any[];
|
|
155
|
+
formatResetDate(dateStr: string): string;
|
|
156
|
+
getStatusBgClass(status: string | null | undefined): string;
|
|
157
|
+
getInvoiceStatusBgClass(status: string | null | undefined): string;
|
|
158
|
+
getBillingAddress(): string;
|
|
159
|
+
selectPlanInterval(interval: string): void;
|
|
160
|
+
formatPlanInterval(interval: string): string;
|
|
161
|
+
getPlanPriceOption(plan: any): any;
|
|
162
|
+
getPlanPriceInteger(plan: Offering): string;
|
|
163
|
+
getPlanPriceDecimal(plan: Offering): string;
|
|
164
|
+
getCurrencySymbol(currency: string): string;
|
|
165
|
+
hasFixedPrice(plan: any): boolean;
|
|
166
|
+
getDynamicPrices(plan: any): any[];
|
|
167
|
+
getDynamicPriceName(priceOption: any): string;
|
|
168
|
+
formatDynamicPrice(priceOption: any): string;
|
|
169
|
+
formatDynamicPriceFull(priceOption: any): string;
|
|
170
|
+
/** Formatted amount only for a dynamic price (e.g. "$3.00") for modal display. */
|
|
171
|
+
getDynamicPriceAmountDisplay(priceOption: any): string;
|
|
172
|
+
getMainDynamicPriceInteger(plan: any): string;
|
|
173
|
+
getMainDynamicPriceDecimal(plan: any): string;
|
|
174
|
+
getMainDynamicPriceUnit(plan: any): string;
|
|
175
|
+
formatPriceAmount(amount: number): string;
|
|
176
|
+
/** Format price with exactly two decimal places for invoice (e.g. $3.00). */
|
|
177
|
+
formatInvoicePrice(amount: number): string;
|
|
178
|
+
/** Get currency symbol from invoice (handles snake_case/camelCase). */
|
|
179
|
+
getInvoiceCurrencySymbol(invoice: Invoice | null | undefined): string;
|
|
180
|
+
/** Get a summary number from invoice (tries snake_case and camelCase keys). */
|
|
181
|
+
getInvoiceSummaryNumber(invoice: Invoice | null | undefined, ...keys: string[]): number;
|
|
182
|
+
/** Safe parse to number for invoice display (handles string/number, NaN -> 0). */
|
|
183
|
+
toNumber(value: string | number | null | undefined): number;
|
|
184
|
+
getPluralizedUnit(plan: Offering): string;
|
|
185
|
+
getPlanButtonText(plan: Offering, index: number): string;
|
|
186
|
+
getVisibleEntitlements(plan: Offering): any[];
|
|
187
|
+
formatEntitlement(entitlement: any): string;
|
|
188
|
+
getListingUrl(subscription: any): string;
|
|
189
|
+
handlePlanAction(plan: Offering): void;
|
|
190
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<CustomerPortalComponent, never>;
|
|
191
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<CustomerPortalComponent, "metrifox-customer-portal", never, { "customerKey": { "alias": "customerKey"; "required": true; }; "sectionsConfig": { "alias": "sectionsConfig"; "required": false; }; }, { "dataLoaded": "dataLoaded"; "errorOccurred": "errorOccurred"; }, never, never, true, never>;
|
|
192
|
+
}
|
|
193
|
+
export {};
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { EventEmitter, OnInit, OnDestroy } from '@angular/core';
|
|
2
|
+
import { SafeHtml } from '@angular/platform-browser';
|
|
3
|
+
import { Product, ParentOffering, Offering, PlanSelectedEvent, PurchaseSelectedEvent, ErrorEvent, Entitlement } from '../../types';
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
5
|
+
declare const ICONS: {
|
|
6
|
+
check: string;
|
|
7
|
+
search: string;
|
|
8
|
+
close: string;
|
|
9
|
+
trash: string;
|
|
10
|
+
minus: string;
|
|
11
|
+
plus: string;
|
|
12
|
+
};
|
|
13
|
+
interface CartItem {
|
|
14
|
+
id: string;
|
|
15
|
+
name: string;
|
|
16
|
+
price: number;
|
|
17
|
+
currency: string;
|
|
18
|
+
quantity: number;
|
|
19
|
+
offering_key: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Pricing Table Component
|
|
23
|
+
*
|
|
24
|
+
* Displays pricing plans and single purchases for a product.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```html
|
|
28
|
+
* <metrifox-pricing-table
|
|
29
|
+
* [checkoutUsername]="'your-checkout-username'"
|
|
30
|
+
* [productKey]="'product_xxx'"
|
|
31
|
+
* (planSelected)="onPlanSelected($event)"
|
|
32
|
+
* (error)="onError($event)">
|
|
33
|
+
* </metrifox-pricing-table>
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare class PricingTableComponent implements OnInit, OnDestroy {
|
|
37
|
+
private destroy$;
|
|
38
|
+
private quantities;
|
|
39
|
+
private iconCache;
|
|
40
|
+
/** Checkout username for building checkout URLs */
|
|
41
|
+
checkoutUsername: string;
|
|
42
|
+
private metrifoxService;
|
|
43
|
+
private sanitizer;
|
|
44
|
+
constructor();
|
|
45
|
+
/** Product key to load pricing for */
|
|
46
|
+
productKey: string;
|
|
47
|
+
/** Show only plans (hide single purchases) */
|
|
48
|
+
plansOnly: boolean;
|
|
49
|
+
/** Show only single purchases (hide plans) */
|
|
50
|
+
singlePurchasesOnly: boolean;
|
|
51
|
+
/** Show tab header when both plans and purchases exist */
|
|
52
|
+
showTabHeader: boolean;
|
|
53
|
+
/** Emitted when a plan is selected */
|
|
54
|
+
planSelected: EventEmitter<PlanSelectedEvent>;
|
|
55
|
+
/** Emitted when a single purchase is selected */
|
|
56
|
+
purchaseSelected: EventEmitter<PurchaseSelectedEvent>;
|
|
57
|
+
/** Emitted when an error occurs */
|
|
58
|
+
errorOccurred: EventEmitter<ErrorEvent>;
|
|
59
|
+
loading: import("@angular/core").WritableSignal<boolean>;
|
|
60
|
+
error: import("@angular/core").WritableSignal<string>;
|
|
61
|
+
product: import("@angular/core").WritableSignal<Product>;
|
|
62
|
+
selectedTab: import("@angular/core").WritableSignal<string>;
|
|
63
|
+
selectedInterval: import("@angular/core").WritableSignal<string>;
|
|
64
|
+
searchTerm: import("@angular/core").WritableSignal<string>;
|
|
65
|
+
cartItems: import("@angular/core").WritableSignal<CartItem[]>;
|
|
66
|
+
plans: import("@angular/core").Signal<ParentOffering[]>;
|
|
67
|
+
singlePurchases: import("@angular/core").Signal<ParentOffering[]>;
|
|
68
|
+
showPlans: import("@angular/core").Signal<boolean>;
|
|
69
|
+
showSinglePurchases: import("@angular/core").Signal<boolean>;
|
|
70
|
+
hasBothTypes: import("@angular/core").Signal<boolean>;
|
|
71
|
+
tabOptions: import("@angular/core").Signal<{
|
|
72
|
+
label: string;
|
|
73
|
+
value: string;
|
|
74
|
+
}[]>;
|
|
75
|
+
intervals: import("@angular/core").Signal<string[]>;
|
|
76
|
+
filteredSinglePurchases: import("@angular/core").Signal<ParentOffering[]>;
|
|
77
|
+
cssVars: import("@angular/core").Signal<import("../../types").CssVarMap>;
|
|
78
|
+
ngOnInit(): void;
|
|
79
|
+
ngOnDestroy(): void;
|
|
80
|
+
/**
|
|
81
|
+
* Load product data
|
|
82
|
+
*/
|
|
83
|
+
private loadProduct;
|
|
84
|
+
/**
|
|
85
|
+
* Select a tab
|
|
86
|
+
*/
|
|
87
|
+
selectTab(tab: string): void;
|
|
88
|
+
/**
|
|
89
|
+
* Select billing interval
|
|
90
|
+
*/
|
|
91
|
+
selectInterval(interval: string): void;
|
|
92
|
+
/**
|
|
93
|
+
* Handle plan selection
|
|
94
|
+
*/
|
|
95
|
+
selectPlan(plan: ParentOffering): void;
|
|
96
|
+
/**
|
|
97
|
+
* Handle single purchase selection
|
|
98
|
+
*/
|
|
99
|
+
selectPurchase(purchase: ParentOffering): void;
|
|
100
|
+
/**
|
|
101
|
+
* Get price for a plan at current interval - integer part
|
|
102
|
+
*/
|
|
103
|
+
getPlanPriceInteger(offering: Offering): string;
|
|
104
|
+
/**
|
|
105
|
+
* Get price for a plan at current interval - decimal part
|
|
106
|
+
*/
|
|
107
|
+
getPlanPriceDecimal(offering: Offering): string;
|
|
108
|
+
/**
|
|
109
|
+
* Get single purchase price - integer part
|
|
110
|
+
*/
|
|
111
|
+
getSinglePurchasePriceInteger(purchase: ParentOffering): string;
|
|
112
|
+
/**
|
|
113
|
+
* Get single purchase price - decimal part
|
|
114
|
+
*/
|
|
115
|
+
getSinglePurchasePriceDecimal(purchase: ParentOffering): string;
|
|
116
|
+
/**
|
|
117
|
+
* Get currency symbol
|
|
118
|
+
*/
|
|
119
|
+
getCurrencySymbol(currency: string): string;
|
|
120
|
+
/**
|
|
121
|
+
* Get visible entitlements
|
|
122
|
+
*/
|
|
123
|
+
getVisibleEntitlements(offering: Offering): Entitlement[];
|
|
124
|
+
/**
|
|
125
|
+
* Format entitlement for display
|
|
126
|
+
*/
|
|
127
|
+
formatEntitlement(entitlement: Entitlement): string;
|
|
128
|
+
/**
|
|
129
|
+
* Format billing interval
|
|
130
|
+
*/
|
|
131
|
+
formatInterval(interval: string): string;
|
|
132
|
+
/**
|
|
133
|
+
* Get pluralized unit for trial
|
|
134
|
+
*/
|
|
135
|
+
getPluralizedUnit(offering: Offering): string;
|
|
136
|
+
/**
|
|
137
|
+
* Get button text for plan
|
|
138
|
+
*/
|
|
139
|
+
getButtonText(offering: Offering): string;
|
|
140
|
+
/**
|
|
141
|
+
* Get icon HTML (sanitized for safe rendering)
|
|
142
|
+
*/
|
|
143
|
+
getIcon(name: keyof typeof ICONS): SafeHtml;
|
|
144
|
+
onSearchInput(event: Event): void;
|
|
145
|
+
clearSearch(): void;
|
|
146
|
+
getItemQuantity(purchase: ParentOffering): number;
|
|
147
|
+
incrementQuantity(purchase: ParentOffering): void;
|
|
148
|
+
decrementQuantity(purchase: ParentOffering): void;
|
|
149
|
+
isInCart(purchase: ParentOffering): boolean;
|
|
150
|
+
addToCart(purchase: ParentOffering): void;
|
|
151
|
+
removeFromCart(purchase: ParentOffering): void;
|
|
152
|
+
private updateCartItem;
|
|
153
|
+
proceedToCheckout(): void;
|
|
154
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<PricingTableComponent, never>;
|
|
155
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<PricingTableComponent, "metrifox-pricing-table", never, { "checkoutUsername": { "alias": "checkoutUsername"; "required": true; }; "productKey": { "alias": "productKey"; "required": true; }; "plansOnly": { "alias": "plansOnly"; "required": false; }; "singlePurchasesOnly": { "alias": "singlePurchasesOnly"; "required": false; }; "showTabHeader": { "alias": "showTabHeader"; "required": false; }; }, { "planSelected": "planSelected"; "purchaseSelected": "purchaseSelected"; "errorOccurred": "errorOccurred"; }, never, never, true, never>;
|
|
156
|
+
}
|
|
157
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { ModuleWithProviders } from '@angular/core';
|
|
2
|
+
import { MetrifoxService } from './metrifox.service';
|
|
3
|
+
import { MetrifoxConfig } from './types';
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
5
|
+
import * as i1 from "@angular/common";
|
|
6
|
+
import * as i2 from "./components/customer-portal/customer-portal.component";
|
|
7
|
+
import * as i3 from "./components/pricing-table/pricing-table.component";
|
|
8
|
+
/**
|
|
9
|
+
* Metrifox Angular Module
|
|
10
|
+
*
|
|
11
|
+
* Use `MetrifoxModule.forRoot(config)` in your root module to configure the SDK.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* @NgModule({
|
|
16
|
+
* imports: [
|
|
17
|
+
* MetrifoxModule.forRoot({
|
|
18
|
+
* clientKey: 'your-client-key'
|
|
19
|
+
* })
|
|
20
|
+
* ]
|
|
21
|
+
* })
|
|
22
|
+
* export class AppModule { }
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare class MetrifoxModule {
|
|
26
|
+
/**
|
|
27
|
+
* Configure the Metrifox SDK for root module
|
|
28
|
+
*/
|
|
29
|
+
static forRoot(config?: MetrifoxConfig): ModuleWithProviders<MetrifoxModule>;
|
|
30
|
+
/**
|
|
31
|
+
* Import MetrifoxModule in feature modules
|
|
32
|
+
*/
|
|
33
|
+
static forChild(): ModuleWithProviders<MetrifoxModule>;
|
|
34
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<MetrifoxModule, never>;
|
|
35
|
+
static ɵmod: i0.ɵɵNgModuleDeclaration<MetrifoxModule, never, [typeof i1.CommonModule, typeof i2.CustomerPortalComponent, typeof i3.PricingTableComponent], [typeof i2.CustomerPortalComponent, typeof i3.PricingTableComponent]>;
|
|
36
|
+
static ɵinj: i0.ɵɵInjectorDeclaration<MetrifoxModule>;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Provide Metrifox for standalone applications
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* bootstrapApplication(AppComponent, {
|
|
44
|
+
* providers: [
|
|
45
|
+
* provideMetrifox({
|
|
46
|
+
* clientKey: 'your-client-key'
|
|
47
|
+
* })
|
|
48
|
+
* ]
|
|
49
|
+
* });
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export declare function provideMetrifox(config?: MetrifoxConfig): (typeof MetrifoxService | import("@angular/core").EnvironmentProviders)[];
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { HttpClient } from '@angular/common/http';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { MetrifoxConfig, Theme, CustomerDetails, Product, ProductPlans, BillingHistory, EntitlementUsage, EntitlementSummary, Wallet, CreditAllocation, Invoice, CustomerPortalTheme, PricingTableTheme, CssVarMap, Localization, LocalizationSettings, WalletSetting, CreateWalletSettings } from './types';
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
5
|
+
/**
|
|
6
|
+
* Error thrown when SDK is not initialized
|
|
7
|
+
*/
|
|
8
|
+
export declare class MetrifoxNotInitializedError extends Error {
|
|
9
|
+
constructor();
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Metrifox SDK Service
|
|
13
|
+
*
|
|
14
|
+
* Core service for the Metrifox Angular SDK. Handles initialization,
|
|
15
|
+
* configuration management, and API interactions.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* // Initialize in your app
|
|
20
|
+
* MetrifoxService.initialize({
|
|
21
|
+
* clientKey: 'your-client-key',
|
|
22
|
+
* theme: { ... }
|
|
23
|
+
* });
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare class MetrifoxService {
|
|
27
|
+
private http;
|
|
28
|
+
private static _config;
|
|
29
|
+
private static _initialized;
|
|
30
|
+
private static configSubject;
|
|
31
|
+
constructor(http: HttpClient);
|
|
32
|
+
/**
|
|
33
|
+
* Initialize the Metrifox SDK with configuration
|
|
34
|
+
* This is equivalent to React SDK's metrifoxInit()
|
|
35
|
+
*/
|
|
36
|
+
static initialize(config: MetrifoxConfig): void;
|
|
37
|
+
/**
|
|
38
|
+
* Get the current configuration
|
|
39
|
+
*/
|
|
40
|
+
static getConfig(): MetrifoxConfig | null;
|
|
41
|
+
/**
|
|
42
|
+
* Check if SDK is initialized
|
|
43
|
+
*/
|
|
44
|
+
static isInitialized(): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Get the client key
|
|
47
|
+
*/
|
|
48
|
+
static getClientKey(): string;
|
|
49
|
+
/**
|
|
50
|
+
* Get the base URL
|
|
51
|
+
*/
|
|
52
|
+
static getBaseUrl(): string;
|
|
53
|
+
/**
|
|
54
|
+
* Get the web app URL
|
|
55
|
+
*/
|
|
56
|
+
static getWebAppUrl(): string;
|
|
57
|
+
/**
|
|
58
|
+
* Get the current theme
|
|
59
|
+
*/
|
|
60
|
+
static getTheme(): Theme | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* Update the theme configuration
|
|
63
|
+
*/
|
|
64
|
+
static updateTheme(theme: Theme): void;
|
|
65
|
+
/**
|
|
66
|
+
* Observable for config changes
|
|
67
|
+
*/
|
|
68
|
+
static get config$(): Observable<MetrifoxConfig | null>;
|
|
69
|
+
/**
|
|
70
|
+
* Get HTTP headers for API requests
|
|
71
|
+
*/
|
|
72
|
+
private getHeaders;
|
|
73
|
+
/**
|
|
74
|
+
* Handle HTTP errors
|
|
75
|
+
*/
|
|
76
|
+
private handleError;
|
|
77
|
+
/**
|
|
78
|
+
* Get customer details
|
|
79
|
+
*/
|
|
80
|
+
getCustomerDetails(customerKey: string): Observable<CustomerDetails>;
|
|
81
|
+
/**
|
|
82
|
+
* Get customer wallets
|
|
83
|
+
*/
|
|
84
|
+
getCustomerWallets(customerKey: string): Observable<Wallet[]>;
|
|
85
|
+
/**
|
|
86
|
+
* Get billing history for a subscription
|
|
87
|
+
*/
|
|
88
|
+
getBillingHistory(subscriptionId: string, params?: {
|
|
89
|
+
page?: number;
|
|
90
|
+
limit?: number;
|
|
91
|
+
}): Observable<BillingHistory[]>;
|
|
92
|
+
/**
|
|
93
|
+
* Get invoice details
|
|
94
|
+
*/
|
|
95
|
+
getInvoiceDetails(invoiceId: string): Observable<Invoice>;
|
|
96
|
+
/**
|
|
97
|
+
* Get entitlement usage
|
|
98
|
+
*/
|
|
99
|
+
getEntitlementUsage(subscriptionId: string): Observable<EntitlementUsage[]>;
|
|
100
|
+
/**
|
|
101
|
+
* Get entitlement summary for a subscription
|
|
102
|
+
*/
|
|
103
|
+
getEntitlementSummary(subscriptionId: string): Observable<EntitlementSummary[]>;
|
|
104
|
+
/**
|
|
105
|
+
* Get credit allocations for a wallet
|
|
106
|
+
*/
|
|
107
|
+
getCreditAllocations(walletId: string, status?: string): Observable<CreditAllocation[]>;
|
|
108
|
+
/**
|
|
109
|
+
* Get credit transactions for an allocation
|
|
110
|
+
*/
|
|
111
|
+
getCreditTransactions(allocationId: string): Observable<any>;
|
|
112
|
+
/**
|
|
113
|
+
* Read wallet settings for customer
|
|
114
|
+
*/
|
|
115
|
+
readWalletSettings(customerKey: string): Observable<WalletSetting[]>;
|
|
116
|
+
/**
|
|
117
|
+
* Create wallet settings
|
|
118
|
+
*/
|
|
119
|
+
createWalletSettings(payload: CreateWalletSettings): Observable<any>;
|
|
120
|
+
/**
|
|
121
|
+
* Edit wallet settings
|
|
122
|
+
*/
|
|
123
|
+
editWalletSettings(id: string, payload: CreateWalletSettings): Observable<any>;
|
|
124
|
+
/**
|
|
125
|
+
* Delete wallet settings
|
|
126
|
+
*/
|
|
127
|
+
deleteWalletSettings(id: string): Observable<any>;
|
|
128
|
+
/**
|
|
129
|
+
* Cancel subscription (schedule cancellation)
|
|
130
|
+
*/
|
|
131
|
+
cancelSubscription(subscriptionId: string, options?: {
|
|
132
|
+
cancel_at_period_end?: boolean;
|
|
133
|
+
reason?: string;
|
|
134
|
+
}): Observable<{
|
|
135
|
+
success: boolean;
|
|
136
|
+
}>;
|
|
137
|
+
/**
|
|
138
|
+
* Revert subscription cancellation
|
|
139
|
+
*/
|
|
140
|
+
revertCancelSubscription(subscriptionId: string): Observable<{
|
|
141
|
+
success: boolean;
|
|
142
|
+
}>;
|
|
143
|
+
/**
|
|
144
|
+
* Get public product details (for pricing table)
|
|
145
|
+
*/
|
|
146
|
+
getPublicProduct(productKey: string, checkoutUsername: string, countryCode?: string): Observable<Product>;
|
|
147
|
+
/**
|
|
148
|
+
* Get localization settings for pricing table
|
|
149
|
+
*/
|
|
150
|
+
getLocalizationSettings(checkoutUsername: string): Observable<LocalizationSettings>;
|
|
151
|
+
/**
|
|
152
|
+
* Get product localizations for pricing table
|
|
153
|
+
*/
|
|
154
|
+
getProductLocalizations(productKey: string, checkoutUsername: string): Observable<Localization[]>;
|
|
155
|
+
/**
|
|
156
|
+
* Get product plans (published plans for a product)
|
|
157
|
+
* Note: Returns Offering[] directly, not ParentOffering[]
|
|
158
|
+
*/
|
|
159
|
+
getProductPlans(productKey?: string, customerKey?: string): Observable<ProductPlans>;
|
|
160
|
+
/**
|
|
161
|
+
* Get checkout URL for an offering
|
|
162
|
+
*/
|
|
163
|
+
getCheckoutUrl(params: {
|
|
164
|
+
offeringKey: string;
|
|
165
|
+
billingInterval?: string;
|
|
166
|
+
customerKey?: string;
|
|
167
|
+
}): Observable<string>;
|
|
168
|
+
/**
|
|
169
|
+
* Build checkout URL manually
|
|
170
|
+
*/
|
|
171
|
+
buildCheckoutUrl(checkoutUsername: string, offeringKey: string, options?: {
|
|
172
|
+
billingPeriod?: string;
|
|
173
|
+
localization?: string;
|
|
174
|
+
}): string;
|
|
175
|
+
/**
|
|
176
|
+
* Convert CustomerPortal theme to CSS variables
|
|
177
|
+
*/
|
|
178
|
+
static customerPortalThemeToCssVars(theme: CustomerPortalTheme): CssVarMap;
|
|
179
|
+
/**
|
|
180
|
+
* Convert PricingTable theme to CSS variables
|
|
181
|
+
*/
|
|
182
|
+
static pricingTableThemeToCssVars(theme: PricingTableTheme): CssVarMap;
|
|
183
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<MetrifoxService, never>;
|
|
184
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<MetrifoxService>;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Function to initialize Metrifox SDK
|
|
188
|
+
* This is the equivalent of React SDK's metrifoxInit()
|
|
189
|
+
*/
|
|
190
|
+
export declare function metrifoxInit(config: MetrifoxConfig): void;
|