react-native-seel-widget 0.1.0 → 0.1.1

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.
Files changed (39) hide show
  1. package/package.json +1 -1
  2. package/src/assets/images/accredited.png +0 -0
  3. package/src/assets/images/background_image.jpg +0 -0
  4. package/src/assets/images/button_close.png +0 -0
  5. package/src/assets/images/button_close_background.png +0 -0
  6. package/src/assets/images/checkbox_normal.png +0 -0
  7. package/src/assets/images/checkbox_selected.png +0 -0
  8. package/src/assets/images/close_white.png +0 -0
  9. package/src/assets/images/ic_launcher.png +0 -0
  10. package/src/assets/images/icon_arrow_left.png +0 -0
  11. package/src/assets/images/icon_bg_select.png +0 -0
  12. package/src/assets/images/icon_check_selected_black.png +0 -0
  13. package/src/assets/images/icon_select.png +0 -0
  14. package/src/assets/images/info_black.png +0 -0
  15. package/src/assets/images/seel_icon.png +0 -0
  16. package/src/assets/images/seel_logo.png +0 -0
  17. package/src/assets/images/seel_word.png +0 -0
  18. package/src/assets/images/tick_small_minor.png +0 -0
  19. package/src/constants/key_value.ts +48 -0
  20. package/src/constants/network_request_statue_enum.ts +13 -0
  21. package/src/core/SeelWidgetSDK.ts +103 -0
  22. package/src/dto/EventsRequest.ts +71 -0
  23. package/src/dto/EventsResponse.ts +13 -0
  24. package/src/dto/IEvents.ts +51 -0
  25. package/src/dto/IQuotes.ts +36 -0
  26. package/src/dto/IQuotesRequest.ts +220 -0
  27. package/src/dto/IQuotesResponse.ts +111 -0
  28. package/src/network/request.ts +214 -0
  29. package/src/ui/coverage-info-footer.tsx +186 -0
  30. package/src/ui/gradient-animation-text.tsx +185 -0
  31. package/src/ui/gradient-animation-view.tsx +150 -0
  32. package/src/ui/index.ts +4 -0
  33. package/src/ui/seel-wfp-info-view.tsx +351 -0
  34. package/src/ui/seel-wfp-title-view.tsx +388 -0
  35. package/src/ui/seel-wfp-widget.tsx +270 -0
  36. package/src/utils/format_util.ts +117 -0
  37. package/src/utils/http_util.ts +30 -0
  38. package/src/utils/storage_util.ts +42 -0
  39. package/src/utils/uuid.ts +18 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-seel-widget",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "React-Native SeelWidget",
5
5
  "keywords": [
6
6
  "ReactNative"
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,48 @@
1
+ const KeyValue = {
2
+ wfp_title: `{{title}} for {{price}}`,
3
+ wfp_subtitle: `Extend your return window to 35 days`,
4
+ wfp_description: `Get a full refund if the order doesn't arrive as described, including loss & damage in transit`,
5
+ powered_by: `Powered by {{seel}}`,
6
+ ineligible_main_message: `We're unable to offer Worry-Free Purchase® for this order. This could be due to one or more of the following reasons`,
7
+ ineligible_reason_shipping: `Shipping destination not supported`,
8
+ ineligible_reason_currency: `Checkout currency not accepted`,
9
+ ineligible_reason_value: `Order value exceeds our coverage limit`,
10
+ ineligible_reason_items: `Item(s) not eligible for this service`,
11
+ ineligible_reason_system: `Our system has flagged this order as ineligible`,
12
+ ineligible_support_message: `If you have any questions, please contact our customer support team for assistance`,
13
+ ineligible_title: `Worry-Free Purchase® isn't eligible for this order`,
14
+ coverage_title: `We've Got You Covered`,
15
+ pricing_message: `Only {{price}} for Complete Peace of Mind`,
16
+ product_name: `Worry-Free Purchase®`,
17
+ whats_covered_title: `What's Covered`,
18
+ standard_coverage_intro: `In addition to your standard coverage under consumer protection laws for`,
19
+ standard_coverage_not_as_described: `Items not as described`,
20
+ standard_coverage_lost_damaged: `Items lost, stolen or damaged in transit (i.e. before they are in your physical possession (or in the possession of someone you have authorised to take delivery)`,
21
+ standard_coverage_not_matching: `Items not matching their description`,
22
+ standard_coverage_quality: `Items not of satisfactory quality or not fit for purpose`,
23
+ standard_coverage_not_delivered: `Items not delivered within 30 days of purchase, unless agreed otherwise`,
24
+ additional_coverage_intro: `Worry-Free Purchase® provides the following protection`,
25
+ additional_coverage_extended_return: `Extended return windows – Seven (7) additional days to decide`,
26
+ additional_coverage_post_delivery: `Post-delivery theft coverage – Protection for packages stolen or missing after delivery`,
27
+ additional_coverage_delay: `Delay compensation if the items are not delivered within 10 days`,
28
+ concierge_intro: `Shoppers also get white glove concierge help with post purchase issues and mishaps`,
29
+ concierge_app_access: `Access to desktop and mobile app`,
30
+ concierge_support: `Live, instant support`,
31
+ privacy_policy: `Privacy Policy`,
32
+ terms_of_service: `Terms of Service`,
33
+ cta_secure_purchase: `Secure Your Purchase Now`,
34
+ cta_continue_without: `Continue Without Protection`,
35
+ get_full_refund: `Get a Full Refund, No Questions Asked`,
36
+ lost_in_transit: `Lost in-transit`,
37
+ item_not_as_described: `Item arrived not as described`,
38
+ item_damaged: `Item damaged/non-functional on arrival`,
39
+ package_stolen: `Package stolen or missing after delivery`,
40
+ easy_resolution: `Easy Resolution`,
41
+ resolve_with_clicks: `Resolve your issues with just a few clicks`,
42
+ complete_peace_of_mind: `Complete Peace of Mind`,
43
+ zero_risk: `Zero-risk on your order with our protection`,
44
+ get_refund_promptly: `Get your refund promptly`,
45
+ worry_free_delivery: `Worry-Free Delivery®`,
46
+ };
47
+
48
+ export default KeyValue;
@@ -0,0 +1,13 @@
1
+ export enum NetworkRequestStatueEnum {
2
+ /* eslint-disable no-bitwise */
3
+ Idle = 1 << 0,
4
+ Refreshing = 1 << 1,
5
+ LoadingMore = 1 << 2,
6
+ Loading = Refreshing | LoadingMore,
7
+ RefreshSuccess = 1 << 3,
8
+ LoadMoreSuccess = 1 << 4,
9
+ Success = RefreshSuccess | LoadMoreSuccess,
10
+ RefreshFailed = 1 << 5,
11
+ LoadMoreFailed = 1 << 6,
12
+ Failed = RefreshFailed | LoadMoreFailed,
13
+ }
@@ -0,0 +1,103 @@
1
+ /**
2
+ * Environment Enum
3
+ */
4
+ export enum SeelEnvironment {
5
+ Development = 'development',
6
+ Production = 'production',
7
+ }
8
+
9
+ const defaultApiVersion: string = '2.6.0';
10
+ const defaultSeelEnvironment: SeelEnvironment = SeelEnvironment.Production;
11
+ const defaultRequestTimeout: number = 5000;
12
+
13
+ interface SeelWidgetSDKProps {
14
+ apiKey: string;
15
+ apiVersion?: string;
16
+ environment?: SeelEnvironment;
17
+ requestTimeout?: number;
18
+ }
19
+
20
+ /**
21
+ * SeelWidgetSDK
22
+ * Main SDK class for Seel Widget functionality
23
+ */
24
+ export class SeelWidgetSDK {
25
+ // MARK: - Singleton Instance
26
+ private static _shared: SeelWidgetSDK | null = null;
27
+
28
+ public static get shared(): SeelWidgetSDK {
29
+ if (!SeelWidgetSDK._shared) {
30
+ SeelWidgetSDK._shared = new SeelWidgetSDK();
31
+ }
32
+ return SeelWidgetSDK._shared;
33
+ }
34
+
35
+ // MARK: - Properties
36
+ private _apiKey: string = '';
37
+ private _apiVersion: string = defaultApiVersion;
38
+ private _environment: SeelEnvironment = defaultSeelEnvironment;
39
+ private _requestTimeout: number = defaultRequestTimeout;
40
+
41
+ // MARK: - Private Constructor
42
+ private constructor() {
43
+ // Private constructor for singleton pattern
44
+ }
45
+
46
+ // MARK: - Public Methods
47
+
48
+ /**
49
+ * Configure SeelWidgetSDK
50
+ * @param apiKey API key
51
+ * @param environment Environment (optional, defaults to production)
52
+ */
53
+ public configure(props: SeelWidgetSDKProps): void {
54
+ this._apiKey = props.apiKey;
55
+ this._apiVersion = props.apiVersion ?? defaultApiVersion;
56
+ this._environment = props.environment ?? defaultSeelEnvironment;
57
+ this._requestTimeout = props.requestTimeout ?? defaultRequestTimeout;
58
+ }
59
+
60
+ /**
61
+ * Get current API Key
62
+ */
63
+ public get apiKey(): string {
64
+ return this._apiKey;
65
+ }
66
+
67
+ /**
68
+ * Get current API Version
69
+ */
70
+ public get apiVersion(): string {
71
+ return this._apiVersion;
72
+ }
73
+
74
+ /**
75
+ * Get current environment
76
+ */
77
+ public get environment(): SeelEnvironment {
78
+ return this._environment;
79
+ }
80
+
81
+ /**
82
+ * Get current Request Timeout
83
+ */
84
+ public get requestTimeout(): number {
85
+ return this._requestTimeout;
86
+ }
87
+
88
+ /**
89
+ * Get current BaseURL
90
+ */
91
+ public get baseURL(): string {
92
+ return this._environment === SeelEnvironment.Production
93
+ ? 'https://api.seel.com'
94
+ : 'https://api-test.seel.com';
95
+ }
96
+
97
+ /**
98
+ * Check if configured
99
+ */
100
+ public get isConfigured(): boolean {
101
+ return this._apiKey !== '';
102
+ }
103
+ }
@@ -0,0 +1,71 @@
1
+ import type { IEventInfo, IEvents, EventType } from './IEvents';
2
+
3
+ /**
4
+ * Events Request/Response class
5
+ * Converts snake_case API format to camelCase for internal use
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * const iRequest: IEvents = {
10
+ * client_ip: '',
11
+ * customer_id: '',
12
+ * session_id: '',
13
+ * event_source: '',
14
+ * event_ts: '',
15
+ * event_type: EventTypeEnum.product_page_exit,
16
+ * };
17
+ *
18
+ * const request: EventsRequest = new EventsRequest(iRequest);
19
+ * ```
20
+ */
21
+ export default class EventsRequest {
22
+ /**
23
+ * Browser IP address
24
+ */
25
+ clientIP: string;
26
+ /**
27
+ * Customer Id
28
+ */
29
+ customerId: string;
30
+ /**
31
+ * Device Id
32
+ */
33
+ deviceId?: string;
34
+ /**
35
+ * Event Id
36
+ */
37
+ eventId?: string;
38
+ /**
39
+ * Event information object
40
+ * Each event_type has its own unique schema. For specific details, please refer to the custom pixel guide.
41
+ */
42
+ eventInfo?: IEventInfo;
43
+ /**
44
+ * Event source
45
+ */
46
+ eventSource: string;
47
+ /**
48
+ * Event created timestamp in milliseconds
49
+ */
50
+ eventTs: string;
51
+ /**
52
+ * Event type
53
+ */
54
+ eventType: EventType;
55
+ /**
56
+ * Session Id
57
+ */
58
+ sessionId: string;
59
+
60
+ constructor(props: IEvents) {
61
+ this.clientIP = props.client_ip;
62
+ this.customerId = props.customer_id;
63
+ this.deviceId = props.device_id;
64
+ this.eventId = props.event_id;
65
+ this.eventInfo = props.event_info;
66
+ this.eventSource = props.event_source || '';
67
+ this.eventTs = props.event_ts;
68
+ this.eventType = props.event_type;
69
+ this.sessionId = props.session_id;
70
+ }
71
+ }
@@ -0,0 +1,13 @@
1
+ import type { IEvents } from './IEvents';
2
+ import EventsRequest from './EventsRequest';
3
+
4
+ /**
5
+ * Events Response class
6
+ * Reuses EventsRequest since they have the same structure
7
+ * This avoids code duplication while maintaining semantic clarity
8
+ */
9
+ export default class EventsResponse extends EventsRequest {
10
+ constructor(props: IEvents) {
11
+ super(props);
12
+ }
13
+ }
@@ -0,0 +1,51 @@
1
+ export enum EventTypeEnum {
2
+ product_page_enter = 'product_page_enter',
3
+ product_page_exit = 'product_page_exit',
4
+ product_share = 'product_share',
5
+ favorite_add = 'favorite_add',
6
+ favorite_remove = 'favorite_remove',
7
+ cart_add = 'cart_add',
8
+ cart_remove = 'cart_remove',
9
+ ra_checked = 'ra_checked',
10
+ ra_unchecked = 'ra_unchecked',
11
+ checkout_begin = 'checkout_begin',
12
+ checkout_complete = 'checkout_complete',
13
+ }
14
+
15
+ /**
16
+ * Event type union type
17
+ * Can be simplified to: export type EventType = EventTypeEnum;
18
+ */
19
+ export type EventType = EventTypeEnum;
20
+
21
+ /**
22
+ * Shipping address information for events
23
+ */
24
+ export interface IEventShippingAddress {
25
+ shipping_address_state: string;
26
+ shipping_address_city: string;
27
+ shipping_address_zipcode: string;
28
+ shipping_address_country: string;
29
+ }
30
+
31
+ /**
32
+ * Event information object
33
+ * Each event_type has its own unique schema. For specific details, please refer to the custom pixel guide.
34
+ */
35
+ export interface IEventInfo {
36
+ user_email?: string;
37
+ shipping_address?: IEventShippingAddress;
38
+ user_phone_number?: string;
39
+ }
40
+
41
+ export interface IEvents {
42
+ client_ip: string;
43
+ customer_id: string;
44
+ device_id?: string;
45
+ event_id?: string;
46
+ event_info?: IEventInfo;
47
+ event_source: string;
48
+ event_ts: string;
49
+ event_type: EventType;
50
+ session_id: string;
51
+ }
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Shipping origin address information
3
+ */
4
+ export interface IShippingOrigin {
5
+ /**
6
+ * The first line of the shipping address
7
+ */
8
+ address_1?: string;
9
+ /**
10
+ * The second line of the shipping address
11
+ */
12
+ address_2?: string;
13
+ /**
14
+ * The city of the shipping address
15
+ */
16
+ city: string;
17
+ /**
18
+ * ISO 3166-1 alpha-2 country code of the shipping address
19
+ */
20
+ country: string;
21
+ /**
22
+ * The state or province code of the shipping address
23
+ */
24
+ state: string;
25
+ /**
26
+ * The zipcode of the shipping address
27
+ */
28
+ zipcode: string;
29
+ }
30
+
31
+ /**
32
+ * Shipping address information
33
+ * Currently has the same structure as IShippingOrigin
34
+ * Using type alias to avoid unnecessary interface extension
35
+ */
36
+ export type IShippingAddress = IShippingOrigin;
@@ -0,0 +1,220 @@
1
+ import type { IShippingOrigin, IShippingAddress } from './IQuotes';
2
+
3
+ /**
4
+ * Customer information for quotes request
5
+ */
6
+ export interface IQuotesRequestCustomer {
7
+ /**
8
+ * The unique identifier for the customer
9
+ */
10
+ customer_id: string;
11
+ /**
12
+ * The email address of the customer
13
+ */
14
+ email: string;
15
+ /**
16
+ * The first name of the customer
17
+ */
18
+ first_name?: string;
19
+ /**
20
+ * The last name of the customer
21
+ */
22
+ last_name?: string;
23
+ /**
24
+ * The phone number of the customer
25
+ */
26
+ phone?: string;
27
+ }
28
+
29
+ /**
30
+ * Extra information for quotes request
31
+ */
32
+ export interface IQuotesRequestExtraInfo {
33
+ shipping_fee?: number;
34
+ }
35
+
36
+ /**
37
+ * Product Attributes
38
+ */
39
+ export interface IProductAttributes {
40
+ /**
41
+ * The color of the product.
42
+ */
43
+ color?: string;
44
+ /**
45
+ * The size of the product.
46
+ */
47
+ size?: string;
48
+ }
49
+
50
+ /**
51
+ * Line item information for quotes request
52
+ */
53
+ export interface IQuotesRequestLineItem {
54
+ /**
55
+ * The allocated discounts of the product.
56
+ */
57
+ allocated_discounts: number;
58
+ /**
59
+ * The brand name of the product.
60
+ */
61
+ brand_name?: string;
62
+ /**
63
+ * The main category of the product.
64
+ */
65
+ category_1: string;
66
+ /**
67
+ * The sub category of the product.
68
+ */
69
+ category_2: string;
70
+ /**
71
+ * The sub category of the product.
72
+ */
73
+ category_3?: string;
74
+ /**
75
+ * The sub category of the product.
76
+ */
77
+ category_4?: string;
78
+ /**
79
+ * The physical condition of the item (e.g. new, used, refurbished)
80
+ */
81
+ condition?: 'new' | 'used' | 'refurbished';
82
+ /**
83
+ * The currency of the price.
84
+ */
85
+ currency: string;
86
+ /**
87
+ * The final price of the product.
88
+ */
89
+ final_price: number | string;
90
+ /**
91
+ * The URLs of the product images.
92
+ */
93
+ image_urls?: string[];
94
+ /**
95
+ * Whether the item is final sale or not.
96
+ * Default: true
97
+ */
98
+ is_final_sale: boolean;
99
+ /**
100
+ * The ID of the item.
101
+ */
102
+ line_item_id: string;
103
+ /**
104
+ * The price of the product.
105
+ */
106
+ price: number;
107
+
108
+ product_attributes?: IProductAttributes;
109
+ /**
110
+ * The description of the product.
111
+ */
112
+ product_description?: string;
113
+ /**
114
+ * The ID of the product.
115
+ */
116
+ product_id: string;
117
+ /**
118
+ * The title of the product.
119
+ */
120
+ product_title: string;
121
+ /**
122
+ * The URL of the product.
123
+ */
124
+ product_url?: string;
125
+ /**
126
+ * The quantity of the product.
127
+ */
128
+ quantity: number;
129
+ /**
130
+ * The retail price of the product.
131
+ */
132
+ retail_price?: number;
133
+ /**
134
+ * Whether the item requires shipping or not.
135
+ */
136
+ requires_shipping: boolean;
137
+ /**
138
+ * The sales tax of the product.
139
+ */
140
+ sales_tax: number;
141
+ /**
142
+ * The ID of the seller.
143
+ */
144
+ seller_id?: string;
145
+ /**
146
+ * The name of the seller.
147
+ */
148
+ seller_name?: string;
149
+ /**
150
+ * Shipping origin
151
+ */
152
+ shipping_origin?: IShippingOrigin | null;
153
+ /**
154
+ * The sku of the product variant.
155
+ */
156
+ sku?: string;
157
+ /**
158
+ * The ID of the product variant.
159
+ */
160
+ variant_id?: string;
161
+ /**
162
+ * The title of the product variant.
163
+ */
164
+ variant_title?: string;
165
+ }
166
+
167
+ /**
168
+ * Quotes Request interface
169
+ * Fields are ordered logically: identifiers, configuration, data, metadata
170
+ */
171
+ export interface IQuotesRequest {
172
+ /**
173
+ * The ID of a cart.
174
+ */
175
+ cart_id?: string;
176
+ /**
177
+ * The IP address of the client.
178
+ */
179
+ client_ip?: string;
180
+ /**
181
+ * The unique identifier for the merchant within Seel's system.
182
+ */
183
+ merchant_id?: string;
184
+ /**
185
+ * The ID of the shopping session.
186
+ */
187
+ session_id: string;
188
+
189
+ /**
190
+ * The type of the quote.
191
+ */
192
+ type: string;
193
+ /**
194
+ * The type of device from which user activity originated.
195
+ */
196
+ device_category: string;
197
+ /**
198
+ * The ID of the client device.
199
+ */
200
+ device_id?: string;
201
+ /**
202
+ * The method by which users accessed your website or application.
203
+ */
204
+ device_platform: string;
205
+ /**
206
+ * The default opt-in setting for the quote
207
+ */
208
+ is_default_on: boolean;
209
+
210
+ /**
211
+ * The list of items included in the quote.
212
+ */
213
+ line_items: IQuotesRequestLineItem[] | null;
214
+ customer: IQuotesRequestCustomer;
215
+ shipping_address: IShippingAddress;
216
+ /**
217
+ * Additional information for the quote
218
+ */
219
+ extra_info?: IQuotesRequestExtraInfo | null;
220
+ }