@quintype/components 3.8.7 → 3.8.8-only-react-v19.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.
- package/dist/cjs/index.js +1090 -2039
- package/dist/es/components/access-type.js +574 -822
- package/dist/es/components/adbutler-ad.js +10 -14
- package/dist/es/components/api-client.js +4 -6
- package/dist/es/components/breaking-news-item.js +2 -3
- package/dist/es/components/breaking-news.js +7 -23
- package/dist/es/components/client-side-only.js +6 -19
- package/dist/es/components/collection.js +5 -5
- package/dist/es/components/dfp-ad.js +23 -30
- package/dist/es/components/eager-load-images.js +7 -17
- package/dist/es/components/hamburger-button.js +2 -5
- package/dist/es/components/image-gallery.js +10 -13
- package/dist/es/components/impl/collection-impl.js +2 -8
- package/dist/es/components/impl/gumlet-image.js +10 -19
- package/dist/es/components/impl/image-utils.js +3 -4
- package/dist/es/components/impl/load-more-stories-manager.js +6 -19
- package/dist/es/components/impl/thumbor-image.js +10 -32
- package/dist/es/components/infinite-scroll.js +29 -85
- package/dist/es/components/infinite-story-base.js +7 -24
- package/dist/es/components/lazy-collection.js +8 -8
- package/dist/es/components/lazy-load-images.js +10 -43
- package/dist/es/components/link-base.js +11 -19
- package/dist/es/components/link.js +1 -4
- package/dist/es/components/load-more-collection-stories.js +7 -18
- package/dist/es/components/load-more-stories-base.js +6 -20
- package/dist/es/components/loading-indicator.js +1 -5
- package/dist/es/components/menu-item.js +6 -10
- package/dist/es/components/menu.js +6 -9
- package/dist/es/components/responsive-hero-image.js +1 -3
- package/dist/es/components/responsive-image.js +0 -5
- package/dist/es/components/responsive-source.js +1 -1
- package/dist/es/components/review-rating/review-rating.js +21 -27
- package/dist/es/components/review-rating/star-icon.js +3 -5
- package/dist/es/components/search-box.js +7 -23
- package/dist/es/components/search-page-base.js +7 -18
- package/dist/es/components/social-logins/with-facebook-login.js +10 -20
- package/dist/es/components/social-logins/with-google-login.js +8 -18
- package/dist/es/components/social-logins/with-linkedin-login.js +7 -12
- package/dist/es/components/social-logins/with-social-login.js +7 -21
- package/dist/es/components/social-logins/with-twitter-login.js +7 -7
- package/dist/es/components/social-share.js +8 -24
- package/dist/es/components/story-element.js +43 -88
- package/dist/es/components/story-elements/brightcove.js +54 -94
- package/dist/es/components/story-elements/dailymotion-embed-script.js +13 -39
- package/dist/es/components/story-elements/dailymotion.js +19 -61
- package/dist/es/components/story-elements/jsembed.js +10 -30
- package/dist/es/components/story-elements/jwPlayer.js +9 -24
- package/dist/es/components/story-elements/polltype.js +6 -20
- package/dist/es/components/story-elements/table.js +16 -34
- package/dist/es/components/story-elements/youtube.js +24 -73
- package/dist/es/components/update-on-interval.js +31 -52
- package/dist/es/components/with-client-side-only.js +3 -4
- package/dist/es/components/with-error.js +7 -20
- package/dist/es/components/with-host-url.js +4 -9
- package/dist/es/components/with-lazy.js +7 -21
- package/dist/es/components/with-member.js +14 -33
- package/dist/es/components/with-preview.js +7 -20
- package/dist/es/components/wrap-collection-layout.js +4 -16
- package/dist/es/store/reducers.js +1 -45
- package/dist/es/utils.js +7 -12
- package/package.json +9 -6
|
@@ -2,22 +2,15 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
|
2
2
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
3
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
4
4
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
5
|
-
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
6
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
7
5
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
8
6
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
9
8
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
10
|
-
|
|
11
|
-
function
|
|
12
|
-
|
|
13
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
14
|
-
|
|
9
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
10
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
15
11
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
16
|
-
|
|
17
|
-
function
|
|
18
|
-
|
|
19
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
20
|
-
|
|
12
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
13
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
21
14
|
import get from 'lodash/get';
|
|
22
15
|
import { bool, func, number, string } from 'prop-types';
|
|
23
16
|
import React from 'react';
|
|
@@ -25,41 +18,28 @@ import ReactDOM from 'react-dom';
|
|
|
25
18
|
import { batch, connect } from 'react-redux';
|
|
26
19
|
import { ACCESS_BEING_LOADED, ACCESS_UPDATED, ASSET_PLANS, CAMPAIGN_SUBSCRIPTION_GROUP_UPDATED, METER_UPDATED, PAYMENT_OPTIONS_UPDATED, SUBSCRIPTION_GROUP_UPDATED } from '../store/actions';
|
|
27
20
|
import { awaitHelper } from '../utils';
|
|
28
|
-
|
|
29
21
|
var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
30
|
-
_inherits(AccessTypeBase, _React$Component);
|
|
31
|
-
|
|
32
|
-
var _super = /*#__PURE__*/_createSuper(AccessTypeBase);
|
|
33
|
-
|
|
34
22
|
function AccessTypeBase(props) {
|
|
35
23
|
var _this;
|
|
36
|
-
|
|
37
24
|
_classCallCheck(this, AccessTypeBase);
|
|
38
|
-
|
|
39
|
-
_this
|
|
40
|
-
|
|
41
|
-
_defineProperty(_assertThisInitialized(_this), "loadScript", function (callback) {
|
|
25
|
+
_this = _callSuper(this, AccessTypeBase, [props]);
|
|
26
|
+
_defineProperty(_this, "loadScript", function (callback) {
|
|
42
27
|
var accessTypeKey = get(_this.props, ['accessTypeKey']);
|
|
43
28
|
var isStaging = get(_this.props, ['isStaging']);
|
|
44
29
|
var enableAccesstype = get(_this.props, ['enableAccesstype']);
|
|
45
|
-
|
|
46
30
|
if (!enableAccesstype) {
|
|
47
31
|
return false;
|
|
48
32
|
}
|
|
49
|
-
|
|
50
33
|
var HOST = isStaging ? _this.stagingHost : _this.prodHost;
|
|
51
34
|
var environment = isStaging ? '&env=sandbox' : '';
|
|
52
35
|
var accessTypeHost = "".concat(HOST, "/frontend/v2/accesstype.js?key=").concat(accessTypeKey).concat(environment);
|
|
53
36
|
var isATScriptAlreadyPresent = document.querySelector("script[src=\"".concat(accessTypeHost, "\"]"));
|
|
54
|
-
|
|
55
37
|
if (accessTypeKey && !isATScriptAlreadyPresent && !global.AccessType && global.document) {
|
|
56
38
|
var accessTypeScript = document.createElement('script');
|
|
57
|
-
|
|
58
39
|
accessTypeScript.onload = function () {
|
|
59
40
|
_this.props.onATGlobalSet && _this.props.onATGlobalSet();
|
|
60
41
|
callback();
|
|
61
42
|
};
|
|
62
|
-
|
|
63
43
|
accessTypeScript.setAttribute('src', accessTypeHost);
|
|
64
44
|
accessTypeScript.setAttribute('id', 'AccessTypeScript');
|
|
65
45
|
accessTypeScript.setAttribute('data-accessType-script', '1');
|
|
@@ -67,541 +47,416 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
67
47
|
document.body.appendChild(accessTypeScript);
|
|
68
48
|
return true;
|
|
69
49
|
}
|
|
70
|
-
|
|
71
50
|
if (global.AccessType) {
|
|
72
51
|
_this.props.onATGlobalSet && _this.props.onATGlobalSet();
|
|
73
52
|
callback();
|
|
74
53
|
}
|
|
75
|
-
|
|
76
54
|
return true;
|
|
77
55
|
});
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(emailAddress, mobileNumber, accesstypeJwt) {
|
|
56
|
+
_defineProperty(_this, "setUser", /*#__PURE__*/function () {
|
|
57
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(emailAddress, mobileNumber, accesstypeJwt) {
|
|
81
58
|
var isLoggedIn,
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
console.warn("User context setting failed --> ", error);
|
|
123
|
-
return _context.abrupt("return", error);
|
|
124
|
-
|
|
125
|
-
case 12:
|
|
126
|
-
_this.props.onUserSet && _this.props.onUserSet();
|
|
127
|
-
return _context.abrupt("return", user);
|
|
128
|
-
|
|
129
|
-
case 14:
|
|
130
|
-
case "end":
|
|
131
|
-
return _context.stop();
|
|
132
|
-
}
|
|
59
|
+
userObj,
|
|
60
|
+
_yield$awaitHelper,
|
|
61
|
+
error,
|
|
62
|
+
user,
|
|
63
|
+
_args = arguments;
|
|
64
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
65
|
+
while (1) switch (_context.prev = _context.next) {
|
|
66
|
+
case 0:
|
|
67
|
+
isLoggedIn = _args.length > 3 && _args[3] !== undefined ? _args[3] : true;
|
|
68
|
+
if (global.AccessType) {
|
|
69
|
+
_context.next = 1;
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
return _context.abrupt("return", null);
|
|
73
|
+
case 1:
|
|
74
|
+
userObj = isLoggedIn ? {
|
|
75
|
+
emailAddress: emailAddress,
|
|
76
|
+
mobileNumber: mobileNumber,
|
|
77
|
+
accesstypeJwt: accesstypeJwt
|
|
78
|
+
} : {
|
|
79
|
+
isLoggedIn: false
|
|
80
|
+
};
|
|
81
|
+
_context.next = 2;
|
|
82
|
+
return awaitHelper(global.AccessType.setUser(userObj));
|
|
83
|
+
case 2:
|
|
84
|
+
_yield$awaitHelper = _context.sent;
|
|
85
|
+
error = _yield$awaitHelper.error;
|
|
86
|
+
user = _yield$awaitHelper.data;
|
|
87
|
+
if (!error) {
|
|
88
|
+
_context.next = 3;
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
console.warn("User context setting failed --> ", error);
|
|
92
|
+
return _context.abrupt("return", error);
|
|
93
|
+
case 3:
|
|
94
|
+
_this.props.onUserSet && _this.props.onUserSet();
|
|
95
|
+
return _context.abrupt("return", user);
|
|
96
|
+
case 4:
|
|
97
|
+
case "end":
|
|
98
|
+
return _context.stop();
|
|
133
99
|
}
|
|
134
100
|
}, _callee);
|
|
135
101
|
}));
|
|
136
|
-
|
|
137
102
|
return function (_x, _x2, _x3) {
|
|
138
103
|
return _ref.apply(this, arguments);
|
|
139
104
|
};
|
|
140
105
|
}());
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(selectedPlanId, couponCode) {
|
|
106
|
+
_defineProperty(_this, "validateCoupon", /*#__PURE__*/function () {
|
|
107
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(selectedPlanId, couponCode) {
|
|
144
108
|
var _yield$awaitHelper2, error, data;
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
console.warn("Error --> ", error);
|
|
175
|
-
return _context2.abrupt("return", error);
|
|
176
|
-
|
|
177
|
-
case 10:
|
|
178
|
-
return _context2.abrupt("return", data);
|
|
179
|
-
|
|
180
|
-
case 11:
|
|
181
|
-
case "end":
|
|
182
|
-
return _context2.stop();
|
|
183
|
-
}
|
|
109
|
+
return _regeneratorRuntime.wrap(function (_context2) {
|
|
110
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
111
|
+
case 0:
|
|
112
|
+
if (global.AccessType) {
|
|
113
|
+
_context2.next = 1;
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
return _context2.abrupt("return", {});
|
|
117
|
+
case 1:
|
|
118
|
+
_context2.next = 2;
|
|
119
|
+
return awaitHelper(global.AccessType.validateCoupon({
|
|
120
|
+
subscriptionPlanId: selectedPlanId,
|
|
121
|
+
couponCode: couponCode
|
|
122
|
+
}));
|
|
123
|
+
case 2:
|
|
124
|
+
_yield$awaitHelper2 = _context2.sent;
|
|
125
|
+
error = _yield$awaitHelper2.error;
|
|
126
|
+
data = _yield$awaitHelper2.data;
|
|
127
|
+
if (!error) {
|
|
128
|
+
_context2.next = 3;
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
console.warn("Error --> ", error);
|
|
132
|
+
return _context2.abrupt("return", error);
|
|
133
|
+
case 3:
|
|
134
|
+
return _context2.abrupt("return", data);
|
|
135
|
+
case 4:
|
|
136
|
+
case "end":
|
|
137
|
+
return _context2.stop();
|
|
184
138
|
}
|
|
185
139
|
}, _callee2);
|
|
186
140
|
}));
|
|
187
|
-
|
|
188
141
|
return function (_x4, _x5) {
|
|
189
142
|
return _ref2.apply(this, arguments);
|
|
190
143
|
};
|
|
191
144
|
}());
|
|
192
|
-
|
|
193
|
-
_defineProperty(_assertThisInitialized(_this), "cancelSubscription", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
145
|
+
_defineProperty(_this, "cancelSubscription", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
194
146
|
var subscriptionId,
|
|
195
|
-
|
|
196
|
-
return _regeneratorRuntime.wrap(function
|
|
197
|
-
while (1) {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
return _context3.abrupt("return", global.AccessType.cancelSubscription(subscriptionId));
|
|
211
|
-
|
|
212
|
-
case 4:
|
|
213
|
-
case "end":
|
|
214
|
-
return _context3.stop();
|
|
215
|
-
}
|
|
147
|
+
_args3 = arguments;
|
|
148
|
+
return _regeneratorRuntime.wrap(function (_context3) {
|
|
149
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
150
|
+
case 0:
|
|
151
|
+
subscriptionId = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : null;
|
|
152
|
+
if (subscriptionId) {
|
|
153
|
+
_context3.next = 1;
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
return _context3.abrupt("return", Promise.reject('Subscription id is not defined'));
|
|
157
|
+
case 1:
|
|
158
|
+
return _context3.abrupt("return", global.AccessType.cancelSubscription(subscriptionId));
|
|
159
|
+
case 2:
|
|
160
|
+
case "end":
|
|
161
|
+
return _context3.stop();
|
|
216
162
|
}
|
|
217
163
|
}, _callee3);
|
|
218
164
|
})));
|
|
219
|
-
|
|
220
|
-
_defineProperty(_assertThisInitialized(_this), "getPath", function (sketchesHost, relativePath) {
|
|
165
|
+
_defineProperty(_this, "getPath", function (sketchesHost, relativePath) {
|
|
221
166
|
try {
|
|
222
167
|
var _URL = new URL(sketchesHost),
|
|
223
|
-
|
|
224
|
-
|
|
168
|
+
pathname = _URL.pathname;
|
|
225
169
|
if (pathname && pathname !== '/') {
|
|
226
170
|
return "".concat(sketchesHost).concat(relativePath);
|
|
227
171
|
}
|
|
228
|
-
|
|
229
172
|
return relativePath;
|
|
230
173
|
} catch (err) {
|
|
231
174
|
console.log('Sketches host path error ---> ', err);
|
|
232
175
|
return relativePath;
|
|
233
176
|
}
|
|
234
177
|
});
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
error
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
return _context4.abrupt("return", {
|
|
268
|
-
error: 'subscriptions fetch failed'
|
|
269
|
-
});
|
|
270
|
-
|
|
271
|
-
case 15:
|
|
272
|
-
return _context4.abrupt("return", subscriptions['subscription_groups'] || []);
|
|
273
|
-
|
|
274
|
-
case 16:
|
|
275
|
-
case "end":
|
|
276
|
-
return _context4.stop();
|
|
277
|
-
}
|
|
178
|
+
_defineProperty(_this, "getSubscription", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
179
|
+
var accessTypeKey, isStaging, HOST, accessTypeHost, _yield$awaitHelper3, error, subscriptions, _t;
|
|
180
|
+
return _regeneratorRuntime.wrap(function (_context4) {
|
|
181
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
182
|
+
case 0:
|
|
183
|
+
accessTypeKey = get(_this.props, ['accessTypeKey']);
|
|
184
|
+
isStaging = get(_this.props, ['isStaging']);
|
|
185
|
+
HOST = isStaging ? _this.stagingHost : _this.prodHost; // TODO: use AccesstypeJS method insead of direct api call
|
|
186
|
+
accessTypeHost = "".concat(HOST, "/api/v1/subscription_groups.json?key=").concat(accessTypeKey);
|
|
187
|
+
_t = awaitHelper;
|
|
188
|
+
_context4.next = 1;
|
|
189
|
+
return global.fetch(accessTypeHost);
|
|
190
|
+
case 1:
|
|
191
|
+
_context4.next = 2;
|
|
192
|
+
return _t(_context4.sent.json());
|
|
193
|
+
case 2:
|
|
194
|
+
_yield$awaitHelper3 = _context4.sent;
|
|
195
|
+
error = _yield$awaitHelper3.error;
|
|
196
|
+
subscriptions = _yield$awaitHelper3.data;
|
|
197
|
+
if (!error) {
|
|
198
|
+
_context4.next = 3;
|
|
199
|
+
break;
|
|
200
|
+
}
|
|
201
|
+
return _context4.abrupt("return", {
|
|
202
|
+
error: 'subscriptions fetch failed'
|
|
203
|
+
});
|
|
204
|
+
case 3:
|
|
205
|
+
return _context4.abrupt("return", subscriptions['subscription_groups'] || []);
|
|
206
|
+
case 4:
|
|
207
|
+
case "end":
|
|
208
|
+
return _context4.stop();
|
|
278
209
|
}
|
|
279
210
|
}, _callee4);
|
|
280
211
|
})));
|
|
281
|
-
|
|
282
|
-
_defineProperty(_assertThisInitialized(_this), "getPaymentOptions", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
|
|
212
|
+
_defineProperty(_this, "getPaymentOptions", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
|
|
283
213
|
var _yield$awaitHelper4, error, paymentOptions;
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
error: 'payment options fetch failed'
|
|
312
|
-
});
|
|
313
|
-
|
|
314
|
-
case 9:
|
|
315
|
-
return _context5.abrupt("return", paymentOptions);
|
|
316
|
-
|
|
317
|
-
case 10:
|
|
318
|
-
case "end":
|
|
319
|
-
return _context5.stop();
|
|
320
|
-
}
|
|
214
|
+
return _regeneratorRuntime.wrap(function (_context5) {
|
|
215
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
216
|
+
case 0:
|
|
217
|
+
if (global.AccessType) {
|
|
218
|
+
_context5.next = 1;
|
|
219
|
+
break;
|
|
220
|
+
}
|
|
221
|
+
return _context5.abrupt("return", []);
|
|
222
|
+
case 1:
|
|
223
|
+
_context5.next = 2;
|
|
224
|
+
return awaitHelper(global.AccessType.getPaymentOptions());
|
|
225
|
+
case 2:
|
|
226
|
+
_yield$awaitHelper4 = _context5.sent;
|
|
227
|
+
error = _yield$awaitHelper4.error;
|
|
228
|
+
paymentOptions = _yield$awaitHelper4.data;
|
|
229
|
+
if (!error) {
|
|
230
|
+
_context5.next = 3;
|
|
231
|
+
break;
|
|
232
|
+
}
|
|
233
|
+
return _context5.abrupt("return", {
|
|
234
|
+
error: 'payment options fetch failed'
|
|
235
|
+
});
|
|
236
|
+
case 3:
|
|
237
|
+
return _context5.abrupt("return", paymentOptions);
|
|
238
|
+
case 4:
|
|
239
|
+
case "end":
|
|
240
|
+
return _context5.stop();
|
|
321
241
|
}
|
|
322
242
|
}, _callee5);
|
|
323
243
|
})));
|
|
324
|
-
|
|
325
|
-
_defineProperty(_assertThisInitialized(_this), "getAssetPlans", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
|
|
244
|
+
_defineProperty(_this, "getAssetPlans", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
|
|
326
245
|
var storyId,
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
return _context6.abrupt("return", {
|
|
365
|
-
error: 'asset plan fetch failed'
|
|
366
|
-
});
|
|
367
|
-
|
|
368
|
-
case 11:
|
|
369
|
-
return _context6.abrupt("return", assetPlans);
|
|
370
|
-
|
|
371
|
-
case 12:
|
|
372
|
-
case "end":
|
|
373
|
-
return _context6.stop();
|
|
374
|
-
}
|
|
246
|
+
_yield$awaitHelper5,
|
|
247
|
+
error,
|
|
248
|
+
_yield$awaitHelper5$d,
|
|
249
|
+
assetPlans,
|
|
250
|
+
_args6 = arguments;
|
|
251
|
+
return _regeneratorRuntime.wrap(function (_context6) {
|
|
252
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
253
|
+
case 0:
|
|
254
|
+
storyId = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : '';
|
|
255
|
+
if (global.AccessType) {
|
|
256
|
+
_context6.next = 1;
|
|
257
|
+
break;
|
|
258
|
+
}
|
|
259
|
+
return _context6.abrupt("return", []);
|
|
260
|
+
case 1:
|
|
261
|
+
_context6.next = 2;
|
|
262
|
+
return awaitHelper(global.AccessType.getAssetPlans({
|
|
263
|
+
id: storyId,
|
|
264
|
+
type: 'story'
|
|
265
|
+
}));
|
|
266
|
+
case 2:
|
|
267
|
+
_yield$awaitHelper5 = _context6.sent;
|
|
268
|
+
error = _yield$awaitHelper5.error;
|
|
269
|
+
_yield$awaitHelper5$d = _yield$awaitHelper5.data;
|
|
270
|
+
assetPlans = _yield$awaitHelper5$d === void 0 ? {} : _yield$awaitHelper5$d;
|
|
271
|
+
if (!error) {
|
|
272
|
+
_context6.next = 3;
|
|
273
|
+
break;
|
|
274
|
+
}
|
|
275
|
+
return _context6.abrupt("return", {
|
|
276
|
+
error: 'asset plan fetch failed'
|
|
277
|
+
});
|
|
278
|
+
case 3:
|
|
279
|
+
return _context6.abrupt("return", assetPlans);
|
|
280
|
+
case 4:
|
|
281
|
+
case "end":
|
|
282
|
+
return _context6.stop();
|
|
375
283
|
}
|
|
376
284
|
}, _callee6);
|
|
377
285
|
})));
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
_context7.next =
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
return _context7.abrupt("return", {
|
|
417
|
-
error: 'subscriptions fetch failed'
|
|
418
|
-
});
|
|
419
|
-
|
|
420
|
-
case 17:
|
|
421
|
-
return _context7.abrupt("return", campaignSubscriptions['subscription_groups'] || []);
|
|
422
|
-
|
|
423
|
-
case 18:
|
|
424
|
-
return _context7.abrupt("return", []);
|
|
425
|
-
|
|
426
|
-
case 19:
|
|
427
|
-
case "end":
|
|
428
|
-
return _context7.stop();
|
|
429
|
-
}
|
|
286
|
+
_defineProperty(_this, "getCampaignSubscription", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7() {
|
|
287
|
+
var isAccessTypeCampaignEnabled, accessTypeKey, isStaging, HOST, accessTypeHost, _yield$awaitHelper6, error, campaignSubscriptions, _t2;
|
|
288
|
+
return _regeneratorRuntime.wrap(function (_context7) {
|
|
289
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
290
|
+
case 0:
|
|
291
|
+
isAccessTypeCampaignEnabled = get(_this.props, ['isAccessTypeCampaignEnabled'], false);
|
|
292
|
+
if (!isAccessTypeCampaignEnabled) {
|
|
293
|
+
_context7.next = 4;
|
|
294
|
+
break;
|
|
295
|
+
}
|
|
296
|
+
accessTypeKey = get(_this.props, ['accessTypeKey']);
|
|
297
|
+
isStaging = get(_this.props, ['isStaging']);
|
|
298
|
+
HOST = isStaging ? _this.stagingHost : _this.prodHost;
|
|
299
|
+
accessTypeHost = "".concat(HOST, "/api/v1/campaigns.json?key=").concat(accessTypeKey);
|
|
300
|
+
_t2 = awaitHelper;
|
|
301
|
+
_context7.next = 1;
|
|
302
|
+
return global.fetch(accessTypeHost);
|
|
303
|
+
case 1:
|
|
304
|
+
_context7.next = 2;
|
|
305
|
+
return _t2(_context7.sent.json());
|
|
306
|
+
case 2:
|
|
307
|
+
_yield$awaitHelper6 = _context7.sent;
|
|
308
|
+
error = _yield$awaitHelper6.error;
|
|
309
|
+
campaignSubscriptions = _yield$awaitHelper6.data;
|
|
310
|
+
if (!error) {
|
|
311
|
+
_context7.next = 3;
|
|
312
|
+
break;
|
|
313
|
+
}
|
|
314
|
+
return _context7.abrupt("return", {
|
|
315
|
+
error: 'subscriptions fetch failed'
|
|
316
|
+
});
|
|
317
|
+
case 3:
|
|
318
|
+
return _context7.abrupt("return", campaignSubscriptions['subscription_groups'] || []);
|
|
319
|
+
case 4:
|
|
320
|
+
return _context7.abrupt("return", []);
|
|
321
|
+
case 5:
|
|
322
|
+
case "end":
|
|
323
|
+
return _context7.stop();
|
|
430
324
|
}
|
|
431
325
|
}, _callee7);
|
|
432
326
|
})));
|
|
433
|
-
|
|
434
|
-
_defineProperty(_assertThisInitialized(_this), "runSequentialCalls", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {
|
|
327
|
+
_defineProperty(_this, "runSequentialCalls", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {
|
|
435
328
|
var callback,
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
batch(function () {
|
|
478
|
-
_this.props.subscriptionGroupLoaded(subscriptionGroups);
|
|
479
|
-
|
|
480
|
-
_this.props.paymentOptionsLoaded(paymentOptions);
|
|
481
|
-
|
|
482
|
-
_this.props.assetPlanLoaded(assetPlans);
|
|
483
|
-
|
|
484
|
-
_this.props.campaignSubscriptionGroupLoaded(campaignSubscriptionGroups);
|
|
485
|
-
});
|
|
486
|
-
callback();
|
|
329
|
+
_ref9,
|
|
330
|
+
email,
|
|
331
|
+
phone,
|
|
332
|
+
accessTypeBkIntegrationId,
|
|
333
|
+
_ref9$executeSequenti,
|
|
334
|
+
executeSequentialCalls,
|
|
335
|
+
jwtResponse,
|
|
336
|
+
_yield$awaitHelper7,
|
|
337
|
+
error,
|
|
338
|
+
_args8 = arguments;
|
|
339
|
+
return _regeneratorRuntime.wrap(function (_context8) {
|
|
340
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
341
|
+
case 0:
|
|
342
|
+
callback = _args8.length > 0 && _args8[0] !== undefined ? _args8[0] : function () {
|
|
343
|
+
return null;
|
|
344
|
+
};
|
|
345
|
+
_ref9 = _this.props || {}, email = _ref9.email, phone = _ref9.phone, accessTypeBkIntegrationId = _ref9.accessTypeBkIntegrationId, _ref9$executeSequenti = _ref9.executeSequentialCalls, executeSequentialCalls = _ref9$executeSequenti === void 0 ? true : _ref9$executeSequenti;
|
|
346
|
+
_context8.next = 1;
|
|
347
|
+
return fetch("/api/auth/v1/access-token/integrations/".concat(accessTypeBkIntegrationId));
|
|
348
|
+
case 1:
|
|
349
|
+
jwtResponse = _context8.sent;
|
|
350
|
+
_context8.next = 2;
|
|
351
|
+
return awaitHelper(_this.setUser(email, phone, jwtResponse.headers.get('x-integration-token'), !!jwtResponse.headers.get('x-integration-token')));
|
|
352
|
+
case 2:
|
|
353
|
+
_yield$awaitHelper7 = _context8.sent;
|
|
354
|
+
error = _yield$awaitHelper7.error;
|
|
355
|
+
if (!error) {
|
|
356
|
+
try {
|
|
357
|
+
if (executeSequentialCalls) {
|
|
358
|
+
Promise.all([_this.getSubscription(), _this.getPaymentOptions(), _this.getAssetPlans(), _this.getCampaignSubscription()]).then(function (_ref0) {
|
|
359
|
+
var _ref1 = _slicedToArray(_ref0, 4),
|
|
360
|
+
subscriptionGroups = _ref1[0],
|
|
361
|
+
paymentOptions = _ref1[1],
|
|
362
|
+
assetPlans = _ref1[2],
|
|
363
|
+
campaignSubscriptionGroups = _ref1[3];
|
|
364
|
+
batch(function () {
|
|
365
|
+
_this.props.subscriptionGroupLoaded(subscriptionGroups);
|
|
366
|
+
_this.props.paymentOptionsLoaded(paymentOptions);
|
|
367
|
+
_this.props.assetPlanLoaded(assetPlans);
|
|
368
|
+
_this.props.campaignSubscriptionGroupLoaded(campaignSubscriptionGroups);
|
|
487
369
|
});
|
|
488
|
-
} else {
|
|
489
370
|
callback();
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
|
|
371
|
+
});
|
|
372
|
+
} else {
|
|
373
|
+
callback();
|
|
493
374
|
}
|
|
375
|
+
} catch (e) {
|
|
376
|
+
console.log("Subscription / payments failed", e);
|
|
494
377
|
}
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
}
|
|
378
|
+
}
|
|
379
|
+
case 3:
|
|
380
|
+
case "end":
|
|
381
|
+
return _context8.stop();
|
|
500
382
|
}
|
|
501
383
|
}, _callee8);
|
|
502
384
|
})));
|
|
503
|
-
|
|
504
|
-
_defineProperty(_assertThisInitialized(_this), "getSubscriptionForUser", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9() {
|
|
385
|
+
_defineProperty(_this, "getSubscriptionForUser", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee9() {
|
|
505
386
|
var _yield$awaitHelper8, error, _yield$awaitHelper8$d, subscriptions;
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
387
|
+
return _regeneratorRuntime.wrap(function (_context9) {
|
|
388
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
389
|
+
case 0:
|
|
390
|
+
if (global.AccessType) {
|
|
391
|
+
_context9.next = 1;
|
|
392
|
+
break;
|
|
393
|
+
}
|
|
394
|
+
return _context9.abrupt("return", {});
|
|
395
|
+
case 1:
|
|
396
|
+
_context9.next = 2;
|
|
397
|
+
return awaitHelper(global.AccessType.getSubscriptions());
|
|
398
|
+
case 2:
|
|
399
|
+
_yield$awaitHelper8 = _context9.sent;
|
|
400
|
+
error = _yield$awaitHelper8.error;
|
|
401
|
+
_yield$awaitHelper8$d = _yield$awaitHelper8.data;
|
|
402
|
+
subscriptions = _yield$awaitHelper8$d === void 0 ? [] : _yield$awaitHelper8$d;
|
|
403
|
+
if (!error) {
|
|
404
|
+
_context9.next = 3;
|
|
405
|
+
break;
|
|
406
|
+
}
|
|
407
|
+
return _context9.abrupt("return", error);
|
|
408
|
+
case 3:
|
|
409
|
+
return _context9.abrupt("return", subscriptions);
|
|
410
|
+
case 4:
|
|
411
|
+
case "end":
|
|
412
|
+
return _context9.stop();
|
|
413
|
+
}
|
|
414
|
+
}, _callee9);
|
|
415
|
+
})));
|
|
416
|
+
_defineProperty(_this, "getSubscriptionsWithSwitchablePlans", /*#__PURE__*/function () {
|
|
417
|
+
var _ref11 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee0(planId) {
|
|
418
|
+
var _yield$awaitHelper9, error, _yield$awaitHelper9$d, subscription;
|
|
419
|
+
return _regeneratorRuntime.wrap(function (_context0) {
|
|
420
|
+
while (1) switch (_context0.prev = _context0.next) {
|
|
510
421
|
case 0:
|
|
511
422
|
if (global.AccessType) {
|
|
512
|
-
|
|
423
|
+
_context0.next = 1;
|
|
513
424
|
break;
|
|
514
425
|
}
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
426
|
+
return _context0.abrupt("return", {});
|
|
427
|
+
case 1:
|
|
428
|
+
if (planId) {
|
|
429
|
+
_context0.next = 2;
|
|
430
|
+
break;
|
|
431
|
+
}
|
|
432
|
+
throw new Error('planId is mandatory');
|
|
518
433
|
case 2:
|
|
519
|
-
|
|
520
|
-
return awaitHelper(global.AccessType.
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
_yield$
|
|
526
|
-
subscriptions = _yield$awaitHelper8$d === void 0 ? [] : _yield$awaitHelper8$d;
|
|
527
|
-
|
|
434
|
+
_context0.next = 3;
|
|
435
|
+
return awaitHelper(global.AccessType.getSubscriptionWithSwitchablePlans(planId, 'switch'));
|
|
436
|
+
case 3:
|
|
437
|
+
_yield$awaitHelper9 = _context0.sent;
|
|
438
|
+
error = _yield$awaitHelper9.error;
|
|
439
|
+
_yield$awaitHelper9$d = _yield$awaitHelper9.data;
|
|
440
|
+
subscription = _yield$awaitHelper9$d === void 0 ? {} : _yield$awaitHelper9$d;
|
|
528
441
|
if (!error) {
|
|
529
|
-
|
|
442
|
+
_context0.next = 4;
|
|
530
443
|
break;
|
|
531
444
|
}
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
case
|
|
536
|
-
return _context9.abrupt("return", subscriptions);
|
|
537
|
-
|
|
538
|
-
case 11:
|
|
445
|
+
return _context0.abrupt("return", error);
|
|
446
|
+
case 4:
|
|
447
|
+
return _context0.abrupt("return", subscription);
|
|
448
|
+
case 5:
|
|
539
449
|
case "end":
|
|
540
|
-
return
|
|
450
|
+
return _context0.stop();
|
|
541
451
|
}
|
|
542
|
-
}
|
|
543
|
-
}, _callee9);
|
|
544
|
-
})));
|
|
545
|
-
|
|
546
|
-
_defineProperty(_assertThisInitialized(_this), "getSubscriptionsWithSwitchablePlans", /*#__PURE__*/function () {
|
|
547
|
-
var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(planId) {
|
|
548
|
-
var _yield$awaitHelper9, error, _yield$awaitHelper9$d, subscription;
|
|
549
|
-
|
|
550
|
-
return _regeneratorRuntime.wrap(function _callee10$(_context10) {
|
|
551
|
-
while (1) {
|
|
552
|
-
switch (_context10.prev = _context10.next) {
|
|
553
|
-
case 0:
|
|
554
|
-
if (global.AccessType) {
|
|
555
|
-
_context10.next = 2;
|
|
556
|
-
break;
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
return _context10.abrupt("return", {});
|
|
560
|
-
|
|
561
|
-
case 2:
|
|
562
|
-
if (planId) {
|
|
563
|
-
_context10.next = 4;
|
|
564
|
-
break;
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
throw new Error('planId is mandatory');
|
|
568
|
-
|
|
569
|
-
case 4:
|
|
570
|
-
_context10.next = 6;
|
|
571
|
-
return awaitHelper(global.AccessType.getSubscriptionWithSwitchablePlans(planId, 'switch'));
|
|
572
|
-
|
|
573
|
-
case 6:
|
|
574
|
-
_yield$awaitHelper9 = _context10.sent;
|
|
575
|
-
error = _yield$awaitHelper9.error;
|
|
576
|
-
_yield$awaitHelper9$d = _yield$awaitHelper9.data;
|
|
577
|
-
subscription = _yield$awaitHelper9$d === void 0 ? {} : _yield$awaitHelper9$d;
|
|
578
|
-
|
|
579
|
-
if (!error) {
|
|
580
|
-
_context10.next = 12;
|
|
581
|
-
break;
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
return _context10.abrupt("return", error);
|
|
585
|
-
|
|
586
|
-
case 12:
|
|
587
|
-
return _context10.abrupt("return", subscription);
|
|
588
|
-
|
|
589
|
-
case 13:
|
|
590
|
-
case "end":
|
|
591
|
-
return _context10.stop();
|
|
592
|
-
}
|
|
593
|
-
}
|
|
594
|
-
}, _callee10);
|
|
452
|
+
}, _callee0);
|
|
595
453
|
}));
|
|
596
|
-
|
|
597
454
|
return function (_x6) {
|
|
598
|
-
return
|
|
455
|
+
return _ref11.apply(this, arguments);
|
|
599
456
|
};
|
|
600
457
|
}());
|
|
601
|
-
|
|
602
|
-
_defineProperty(_assertThisInitialized(_this), "initAccessType", function (callback) {
|
|
458
|
+
_defineProperty(_this, "initAccessType", function (callback) {
|
|
603
459
|
var accessTypeBkIntegrationId = _this.props.accessTypeBkIntegrationId;
|
|
604
|
-
|
|
605
460
|
try {
|
|
606
461
|
_this.loadScript(function () {
|
|
607
462
|
// dont try to initialize accessType if integration id is not available
|
|
@@ -609,224 +464,178 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
609
464
|
console.warn('AccessType: Integration Id is undefined');
|
|
610
465
|
return false;
|
|
611
466
|
}
|
|
612
|
-
|
|
613
467
|
_this.runSequentialCalls(callback);
|
|
614
468
|
});
|
|
615
469
|
} catch (e) {
|
|
616
470
|
console.warn("Accesstype load fail", e);
|
|
617
471
|
}
|
|
618
472
|
});
|
|
619
|
-
|
|
620
|
-
_defineProperty(_assertThisInitialized(_this), "initRazorPayPayment", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11() {
|
|
473
|
+
_defineProperty(_this, "initRazorPayPayment", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee1() {
|
|
621
474
|
var selectedPlanObj,
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
_context11.next = 33;
|
|
714
|
-
break;
|
|
715
|
-
}
|
|
716
|
-
|
|
717
|
-
throw new Error('payment options fetch failed');
|
|
718
|
-
|
|
719
|
-
case 33:
|
|
720
|
-
return _context11.abrupt("return", switchPaymentOptions.razorpay.proceed(_objectSpread(_objectSpread({}, paymentObject), {}, {
|
|
721
|
-
switch_type: switchType,
|
|
722
|
-
subscription_plan_id: selectedPlanObj.id,
|
|
723
|
-
subscriptionId: selectedPlanObj.subscriptionId
|
|
724
|
-
})));
|
|
725
|
-
|
|
726
|
-
case 34:
|
|
727
|
-
return _context11.abrupt("return", paymentOptions.razorpay.proceed(paymentObject));
|
|
728
|
-
|
|
729
|
-
case 35:
|
|
730
|
-
case "end":
|
|
731
|
-
return _context11.stop();
|
|
732
|
-
}
|
|
475
|
+
planType,
|
|
476
|
+
storyId,
|
|
477
|
+
storyHeadline,
|
|
478
|
+
storySlug,
|
|
479
|
+
paymentType,
|
|
480
|
+
opts,
|
|
481
|
+
intent,
|
|
482
|
+
switchType,
|
|
483
|
+
planObject,
|
|
484
|
+
paymentOptions,
|
|
485
|
+
_planObject$selectedP,
|
|
486
|
+
discounted_price_cents,
|
|
487
|
+
price_cents,
|
|
488
|
+
paymentObject,
|
|
489
|
+
_yield$awaitHelper0,
|
|
490
|
+
data,
|
|
491
|
+
_yield$awaitHelper1,
|
|
492
|
+
error,
|
|
493
|
+
switchPaymentOptions,
|
|
494
|
+
_args1 = arguments;
|
|
495
|
+
return _regeneratorRuntime.wrap(function (_context1) {
|
|
496
|
+
while (1) switch (_context1.prev = _context1.next) {
|
|
497
|
+
case 0:
|
|
498
|
+
selectedPlanObj = _args1.length > 0 && _args1[0] !== undefined ? _args1[0] : {};
|
|
499
|
+
planType = _args1.length > 1 && _args1[1] !== undefined ? _args1[1] : '';
|
|
500
|
+
storyId = _args1.length > 2 && _args1[2] !== undefined ? _args1[2] : '';
|
|
501
|
+
storyHeadline = _args1.length > 3 && _args1[3] !== undefined ? _args1[3] : '';
|
|
502
|
+
storySlug = _args1.length > 4 && _args1[4] !== undefined ? _args1[4] : '';
|
|
503
|
+
paymentType = _args1.length > 5 && _args1[5] !== undefined ? _args1[5] : '';
|
|
504
|
+
opts = _args1.length > 6 ? _args1[6] : undefined;
|
|
505
|
+
if (selectedPlanObj) {
|
|
506
|
+
_context1.next = 1;
|
|
507
|
+
break;
|
|
508
|
+
}
|
|
509
|
+
console.warn('Razor pay needs a plan');
|
|
510
|
+
return _context1.abrupt("return", false);
|
|
511
|
+
case 1:
|
|
512
|
+
intent = get(opts, ['intent'], 'default');
|
|
513
|
+
switchType = get(opts, ['switchType']);
|
|
514
|
+
planObject = _this.makePlanObject(selectedPlanObj, planType, storyId, storyHeadline, storySlug); //we are doing this to sake of backward compatibility and will be refactored later.
|
|
515
|
+
planObject['paymentType'] = paymentType || (get(planObject, ['selectedPlan', 'recurring']) ? 'razorpay_recurring' : 'razorpay');
|
|
516
|
+
paymentOptions = _this.props.paymentOptions;
|
|
517
|
+
_planObject$selectedP = planObject.selectedPlan, discounted_price_cents = _planObject$selectedP.discounted_price_cents, price_cents = _planObject$selectedP.price_cents;
|
|
518
|
+
paymentObject = _this.makePaymentObject(_objectSpread(_objectSpread({}, planObject), {}, {
|
|
519
|
+
couponCode: selectedPlanObj.coupon_code
|
|
520
|
+
}));
|
|
521
|
+
if (!(discounted_price_cents === 0 || price_cents === 0)) {
|
|
522
|
+
_context1.next = 3;
|
|
523
|
+
break;
|
|
524
|
+
}
|
|
525
|
+
_context1.next = 2;
|
|
526
|
+
return awaitHelper(global.AccessType.getPaymentOptions(0));
|
|
527
|
+
case 2:
|
|
528
|
+
_yield$awaitHelper0 = _context1.sent;
|
|
529
|
+
data = _yield$awaitHelper0.data;
|
|
530
|
+
paymentOptions = data;
|
|
531
|
+
case 3:
|
|
532
|
+
if (!(paymentObject.payment.amount_cents === 0)) {
|
|
533
|
+
_context1.next = 4;
|
|
534
|
+
break;
|
|
535
|
+
}
|
|
536
|
+
return _context1.abrupt("return", global.AccessType.getPaymentOptions(0).then(function (provider) {
|
|
537
|
+
return provider.razorpay.proceed(paymentObject);
|
|
538
|
+
}));
|
|
539
|
+
case 4:
|
|
540
|
+
if (!(intent === 'switch')) {
|
|
541
|
+
_context1.next = 7;
|
|
542
|
+
break;
|
|
543
|
+
}
|
|
544
|
+
_context1.next = 5;
|
|
545
|
+
return awaitHelper(global.AccessType.getPaymentOptions(null, null, 'switch'));
|
|
546
|
+
case 5:
|
|
547
|
+
_yield$awaitHelper1 = _context1.sent;
|
|
548
|
+
error = _yield$awaitHelper1.error;
|
|
549
|
+
switchPaymentOptions = _yield$awaitHelper1.data;
|
|
550
|
+
if (!error) {
|
|
551
|
+
_context1.next = 6;
|
|
552
|
+
break;
|
|
553
|
+
}
|
|
554
|
+
throw new Error('payment options fetch failed');
|
|
555
|
+
case 6:
|
|
556
|
+
return _context1.abrupt("return", switchPaymentOptions.razorpay.proceed(_objectSpread(_objectSpread({}, paymentObject), {}, {
|
|
557
|
+
switch_type: switchType,
|
|
558
|
+
subscription_plan_id: selectedPlanObj.id,
|
|
559
|
+
subscriptionId: selectedPlanObj.subscriptionId
|
|
560
|
+
})));
|
|
561
|
+
case 7:
|
|
562
|
+
return _context1.abrupt("return", paymentOptions.razorpay.proceed(paymentObject));
|
|
563
|
+
case 8:
|
|
564
|
+
case "end":
|
|
565
|
+
return _context1.stop();
|
|
733
566
|
}
|
|
734
|
-
},
|
|
567
|
+
}, _callee1);
|
|
735
568
|
})));
|
|
736
|
-
|
|
737
|
-
_defineProperty(_assertThisInitialized(_this), "initStripePayment", function () {
|
|
569
|
+
_defineProperty(_this, "initStripePayment", function () {
|
|
738
570
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
739
|
-
|
|
740
571
|
if (!options.selectedPlan) {
|
|
741
572
|
console.warn('Stripe pay needs a plan');
|
|
742
573
|
return false;
|
|
743
574
|
}
|
|
744
|
-
|
|
745
575
|
var paymentOptions = _this.props.paymentOptions;
|
|
746
576
|
var paymentType = get(options.selectedPlan, ['recurring']) ? 'stripe_recurring' : 'stripe';
|
|
747
|
-
|
|
748
577
|
var paymentObject = _this.makePaymentObject(_objectSpread({
|
|
749
578
|
paymentType: paymentType
|
|
750
579
|
}, options));
|
|
751
|
-
|
|
752
580
|
return paymentOptions.stripe ? paymentOptions.stripe.proceed(paymentObject) : Promise.reject({
|
|
753
581
|
message: 'Payment option is loading...'
|
|
754
582
|
});
|
|
755
583
|
});
|
|
756
|
-
|
|
757
|
-
_defineProperty(_assertThisInitialized(_this), "initPaypalPayment", function () {
|
|
584
|
+
_defineProperty(_this, "initPaypalPayment", function () {
|
|
758
585
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
759
|
-
|
|
760
586
|
if (!options.selectedPlan) {
|
|
761
587
|
console.warn('Paypal pay needs a plan');
|
|
762
588
|
return false;
|
|
763
589
|
}
|
|
764
|
-
|
|
765
590
|
var paymentOptions = _this.props.paymentOptions;
|
|
766
591
|
var paymentType = get(options.selectedPlan, ['recurring']) ? 'paypal_recurring' : 'paypal';
|
|
767
|
-
|
|
768
592
|
var paymentObject = _this.makePaymentObject(_objectSpread({
|
|
769
593
|
paymentType: paymentType
|
|
770
594
|
}, options));
|
|
771
|
-
|
|
772
595
|
return paymentOptions.paypal ? paymentOptions.paypal.proceed(paymentObject).then(function (response) {
|
|
773
596
|
return response.proceed(paymentObject);
|
|
774
597
|
}) : Promise.reject({
|
|
775
598
|
message: 'Payment option is loading...'
|
|
776
599
|
});
|
|
777
600
|
});
|
|
778
|
-
|
|
779
|
-
_defineProperty(_assertThisInitialized(_this), "initOmisePayment", function () {
|
|
601
|
+
_defineProperty(_this, "initOmisePayment", function () {
|
|
780
602
|
var selectedPlanObj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
781
603
|
var planType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
782
|
-
|
|
783
604
|
if (!selectedPlanObj) {
|
|
784
605
|
console.warn('Omise pay needs a plan');
|
|
785
606
|
return false;
|
|
786
607
|
}
|
|
787
|
-
|
|
788
608
|
var planObject = _this.makePlanObject(selectedPlanObj, planType);
|
|
789
|
-
|
|
790
609
|
planObject['paymentType'] = get(planObject, ['selectedPlan', 'recurring']) ? 'omise_recurring' : 'omise';
|
|
791
|
-
|
|
792
610
|
var paymentObject = _this.makePaymentObject(planObject);
|
|
793
|
-
|
|
794
611
|
var omise = get(_this.props, ['paymentOptions', 'omise']);
|
|
795
|
-
|
|
796
612
|
if (!omise) {
|
|
797
613
|
return Promise.reject({
|
|
798
614
|
message: 'Payment option is loading...'
|
|
799
615
|
});
|
|
800
616
|
}
|
|
801
|
-
|
|
802
617
|
return omise.proceed(paymentObject).then(function (response) {
|
|
803
618
|
return response;
|
|
804
619
|
});
|
|
805
620
|
});
|
|
806
|
-
|
|
807
|
-
_defineProperty(_assertThisInitialized(_this), "initAdyenPayment", function () {
|
|
621
|
+
_defineProperty(_this, "initAdyenPayment", function () {
|
|
808
622
|
var selectedPlanObj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
809
623
|
var planType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
810
624
|
var AdyenModal = arguments.length > 2 ? arguments[2] : undefined;
|
|
811
625
|
var locale = arguments.length > 3 ? arguments[3] : undefined;
|
|
812
|
-
|
|
813
626
|
var adyenExecutor = function adyenExecutor(resolve, reject) {
|
|
814
627
|
if (!document.getElementById('adyen-modal')) {
|
|
815
628
|
var modalElement = document.createElement('div');
|
|
816
629
|
modalElement.setAttribute('id', 'adyen-modal');
|
|
817
630
|
document.body.appendChild(modalElement);
|
|
818
631
|
}
|
|
819
|
-
|
|
820
632
|
var afterOpen = function afterOpen() {
|
|
821
633
|
var planObject = _this.makePlanObject(selectedPlanObj, planType);
|
|
822
|
-
|
|
823
634
|
var isRecurring = get(planObject, ['selectedPlan', 'recurring']);
|
|
824
635
|
var paymentType = isRecurring ? 'adyen_recurring' : 'adyen';
|
|
825
|
-
|
|
826
636
|
var paymentObject = _this.makePaymentObject(_objectSpread(_objectSpread({}, planObject), {}, {
|
|
827
637
|
paymentType: paymentType
|
|
828
638
|
}));
|
|
829
|
-
|
|
830
639
|
var adyen = get(_this.props, ['paymentOptions', 'adyen']);
|
|
831
640
|
paymentObject = _objectSpread(_objectSpread({}, paymentObject), {}, {
|
|
832
641
|
options: _objectSpread(_objectSpread({}, paymentObject['options']), {}, {
|
|
@@ -841,241 +650,193 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
841
650
|
return response.proceed(paymentObject);
|
|
842
651
|
}));
|
|
843
652
|
};
|
|
844
|
-
|
|
845
|
-
ReactDOM.render( /*#__PURE__*/React.createElement(AdyenModal, {
|
|
653
|
+
ReactDOM.render(/*#__PURE__*/React.createElement(AdyenModal, {
|
|
846
654
|
afterOpen: afterOpen,
|
|
847
655
|
afterClose: reject
|
|
848
656
|
}), document.getElementById('adyen-modal'));
|
|
849
657
|
};
|
|
850
|
-
|
|
851
658
|
return new Promise(adyenExecutor);
|
|
852
659
|
});
|
|
853
|
-
|
|
854
|
-
_defineProperty(_assertThisInitialized(_this), "initPaytrailPayment", function () {
|
|
660
|
+
_defineProperty(_this, "initPaytrailPayment", function () {
|
|
855
661
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
856
|
-
|
|
857
662
|
if (!options.selectedPlan) {
|
|
858
663
|
console.warn('Paytrail needs a plan');
|
|
859
664
|
return false;
|
|
860
665
|
}
|
|
861
|
-
|
|
862
666
|
var paymentOptions = _this.props.paymentOptions;
|
|
863
667
|
var paymentType = get(options.selectedPlan, ['recurring']) ? 'paytrail_recurring' : 'paytrail';
|
|
864
|
-
|
|
865
668
|
var paymentObject = _this.makePaymentObject(_objectSpread({
|
|
866
669
|
paymentType: paymentType
|
|
867
670
|
}, options));
|
|
868
|
-
|
|
869
671
|
return paymentOptions.paytrail ? paymentOptions.paytrail.proceed(paymentObject).then(function (response) {
|
|
870
672
|
return response.proceed(paymentObject);
|
|
871
673
|
}) : Promise.reject({
|
|
872
674
|
message: 'Payment option is loading...'
|
|
873
675
|
});
|
|
874
676
|
});
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
case 2:
|
|
891
|
-
case "end":
|
|
892
|
-
return _context12.stop();
|
|
893
|
-
}
|
|
677
|
+
_defineProperty(_this, "pingBackMeteredStory", /*#__PURE__*/function () {
|
|
678
|
+
var _ref13 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee10(asset, accessData) {
|
|
679
|
+
return _regeneratorRuntime.wrap(function (_context10) {
|
|
680
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
681
|
+
case 0:
|
|
682
|
+
try {
|
|
683
|
+
global.AccessType.pingbackAssetAccess(asset, accessData);
|
|
684
|
+
} catch (e) {
|
|
685
|
+
console.log('error in pingbackAssetAccess', e);
|
|
686
|
+
}
|
|
687
|
+
return _context10.abrupt("return", true);
|
|
688
|
+
case 1:
|
|
689
|
+
case "end":
|
|
690
|
+
return _context10.stop();
|
|
894
691
|
}
|
|
895
|
-
},
|
|
692
|
+
}, _callee10);
|
|
896
693
|
}));
|
|
897
|
-
|
|
898
694
|
return function (_x7, _x8) {
|
|
899
|
-
return
|
|
695
|
+
return _ref13.apply(this, arguments);
|
|
900
696
|
};
|
|
901
697
|
}());
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
_this.props.accessUpdated(accessById);
|
|
945
|
-
|
|
946
|
-
_this.props.accessIsLoading(false);
|
|
947
|
-
|
|
948
|
-
_ref17 = accessData || {}, granted = _ref17.granted, grantReason = _ref17.grantReason, _ref17$data = _ref17.data, data = _ref17$data === void 0 ? {} : _ref17$data;
|
|
949
|
-
|
|
950
|
-
if (!_this.props.disableMetering && granted && grantReason === 'METERING') {
|
|
951
|
-
_this.pingBackMeteredStory(asset, accessData);
|
|
952
|
-
|
|
953
|
-
_this.props.meterUpdated(data.numberRemaining || -1);
|
|
954
|
-
}
|
|
955
|
-
|
|
956
|
-
return _context13.abrupt("return", accessById);
|
|
957
|
-
|
|
958
|
-
case 18:
|
|
959
|
-
case "end":
|
|
960
|
-
return _context13.stop();
|
|
961
|
-
}
|
|
698
|
+
_defineProperty(_this, "checkAccess", /*#__PURE__*/function () {
|
|
699
|
+
var _ref14 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee11(assetId) {
|
|
700
|
+
var asset, _yield$awaitHelper10, error, accessData, accessById, _ref15, granted, grantReason, _ref15$data, data;
|
|
701
|
+
return _regeneratorRuntime.wrap(function (_context11) {
|
|
702
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
703
|
+
case 0:
|
|
704
|
+
if (assetId) {
|
|
705
|
+
_context11.next = 1;
|
|
706
|
+
break;
|
|
707
|
+
}
|
|
708
|
+
console.warn('AssetId is required');
|
|
709
|
+
return _context11.abrupt("return", false);
|
|
710
|
+
case 1:
|
|
711
|
+
_this.props.accessIsLoading(true);
|
|
712
|
+
asset = {
|
|
713
|
+
id: assetId,
|
|
714
|
+
type: 'story'
|
|
715
|
+
};
|
|
716
|
+
_context11.next = 2;
|
|
717
|
+
return awaitHelper(global.AccessType.isAssetAccessible(asset, _this.props.disableMetering));
|
|
718
|
+
case 2:
|
|
719
|
+
_yield$awaitHelper10 = _context11.sent;
|
|
720
|
+
error = _yield$awaitHelper10.error;
|
|
721
|
+
accessData = _yield$awaitHelper10.data;
|
|
722
|
+
if (!error) {
|
|
723
|
+
_context11.next = 3;
|
|
724
|
+
break;
|
|
725
|
+
}
|
|
726
|
+
return _context11.abrupt("return", error);
|
|
727
|
+
case 3:
|
|
728
|
+
accessById = _defineProperty({}, assetId, accessData);
|
|
729
|
+
_this.props.accessUpdated(accessById);
|
|
730
|
+
_this.props.accessIsLoading(false);
|
|
731
|
+
_ref15 = accessData || {}, granted = _ref15.granted, grantReason = _ref15.grantReason, _ref15$data = _ref15.data, data = _ref15$data === void 0 ? {} : _ref15$data;
|
|
732
|
+
if (!_this.props.disableMetering && granted && grantReason === 'METERING') {
|
|
733
|
+
_this.pingBackMeteredStory(asset, accessData);
|
|
734
|
+
_this.props.meterUpdated(data.numberRemaining || -1);
|
|
735
|
+
}
|
|
736
|
+
return _context11.abrupt("return", accessById);
|
|
737
|
+
case 4:
|
|
738
|
+
case "end":
|
|
739
|
+
return _context11.stop();
|
|
962
740
|
}
|
|
963
|
-
},
|
|
741
|
+
}, _callee11);
|
|
964
742
|
}));
|
|
965
|
-
|
|
966
743
|
return function (_x9) {
|
|
967
|
-
return
|
|
744
|
+
return _ref14.apply(this, arguments);
|
|
968
745
|
};
|
|
969
746
|
}());
|
|
970
|
-
|
|
971
|
-
_defineProperty(_assertThisInitialized(_this), "getSubscriberMetadata", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14() {
|
|
747
|
+
_defineProperty(_this, "getSubscriberMetadata", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee12() {
|
|
972
748
|
var metadata;
|
|
973
|
-
return _regeneratorRuntime.wrap(function
|
|
974
|
-
while (1) {
|
|
975
|
-
|
|
749
|
+
return _regeneratorRuntime.wrap(function (_context12) {
|
|
750
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
751
|
+
case 0:
|
|
752
|
+
if (global.AccessType) {
|
|
753
|
+
_context12.next = 1;
|
|
754
|
+
break;
|
|
755
|
+
}
|
|
756
|
+
return _context12.abrupt("return", {});
|
|
757
|
+
case 1:
|
|
758
|
+
_context12.next = 2;
|
|
759
|
+
return awaitHelper(global.AccessType.getSubscriberMetadata());
|
|
760
|
+
case 2:
|
|
761
|
+
metadata = _context12.sent;
|
|
762
|
+
return _context12.abrupt("return", metadata);
|
|
763
|
+
case 3:
|
|
764
|
+
case "end":
|
|
765
|
+
return _context12.stop();
|
|
766
|
+
}
|
|
767
|
+
}, _callee12);
|
|
768
|
+
})));
|
|
769
|
+
_defineProperty(_this, "setSubscriberMetadata", /*#__PURE__*/function () {
|
|
770
|
+
var _ref17 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee13(subscriberMetadata) {
|
|
771
|
+
var response;
|
|
772
|
+
return _regeneratorRuntime.wrap(function (_context13) {
|
|
773
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
976
774
|
case 0:
|
|
977
|
-
if (global.AccessType) {
|
|
978
|
-
|
|
775
|
+
if (!(!global.AccessType || !subscriberMetadata)) {
|
|
776
|
+
_context13.next = 1;
|
|
979
777
|
break;
|
|
980
778
|
}
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
779
|
+
return _context13.abrupt("return", {});
|
|
780
|
+
case 1:
|
|
781
|
+
_context13.next = 2;
|
|
782
|
+
return awaitHelper(global.AccessType.setSubscriberMetadata(subscriberMetadata));
|
|
984
783
|
case 2:
|
|
985
|
-
|
|
986
|
-
return
|
|
987
|
-
|
|
988
|
-
case 4:
|
|
989
|
-
metadata = _context14.sent;
|
|
990
|
-
return _context14.abrupt("return", metadata);
|
|
991
|
-
|
|
992
|
-
case 6:
|
|
784
|
+
response = _context13.sent;
|
|
785
|
+
return _context13.abrupt("return", response);
|
|
786
|
+
case 3:
|
|
993
787
|
case "end":
|
|
994
|
-
return
|
|
995
|
-
}
|
|
996
|
-
}
|
|
997
|
-
}, _callee14);
|
|
998
|
-
})));
|
|
999
|
-
|
|
1000
|
-
_defineProperty(_assertThisInitialized(_this), "setSubscriberMetadata", /*#__PURE__*/function () {
|
|
1001
|
-
var _ref19 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(subscriberMetadata) {
|
|
1002
|
-
var response;
|
|
1003
|
-
return _regeneratorRuntime.wrap(function _callee15$(_context15) {
|
|
1004
|
-
while (1) {
|
|
1005
|
-
switch (_context15.prev = _context15.next) {
|
|
1006
|
-
case 0:
|
|
1007
|
-
if (!(!global.AccessType || !subscriberMetadata)) {
|
|
1008
|
-
_context15.next = 2;
|
|
1009
|
-
break;
|
|
1010
|
-
}
|
|
1011
|
-
|
|
1012
|
-
return _context15.abrupt("return", {});
|
|
1013
|
-
|
|
1014
|
-
case 2:
|
|
1015
|
-
_context15.next = 4;
|
|
1016
|
-
return awaitHelper(global.AccessType.setSubscriberMetadata(subscriberMetadata));
|
|
1017
|
-
|
|
1018
|
-
case 4:
|
|
1019
|
-
response = _context15.sent;
|
|
1020
|
-
return _context15.abrupt("return", response);
|
|
1021
|
-
|
|
1022
|
-
case 6:
|
|
1023
|
-
case "end":
|
|
1024
|
-
return _context15.stop();
|
|
1025
|
-
}
|
|
788
|
+
return _context13.stop();
|
|
1026
789
|
}
|
|
1027
|
-
},
|
|
790
|
+
}, _callee13);
|
|
1028
791
|
}));
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
return _ref19.apply(this, arguments);
|
|
792
|
+
return function (_x0) {
|
|
793
|
+
return _ref17.apply(this, arguments);
|
|
1032
794
|
};
|
|
1033
795
|
}());
|
|
1034
|
-
|
|
1035
796
|
_this.prodHost = props.prodHost || 'https://www.accesstype.com';
|
|
1036
797
|
_this.stagingHost = props.stagingHost || 'https://staging.accesstype.com';
|
|
1037
798
|
return _this;
|
|
1038
799
|
}
|
|
1039
|
-
|
|
1040
|
-
_createClass(AccessTypeBase, [{
|
|
800
|
+
_inherits(AccessTypeBase, _React$Component);
|
|
801
|
+
return _createClass(AccessTypeBase, [{
|
|
1041
802
|
key: "componentDidMount",
|
|
1042
803
|
value: function componentDidMount() {
|
|
1043
804
|
this.initAccessType();
|
|
1044
805
|
}
|
|
1045
806
|
}, {
|
|
1046
807
|
key: "makePaymentObject",
|
|
1047
|
-
value: function makePaymentObject(
|
|
1048
|
-
var
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
808
|
+
value: function makePaymentObject(_ref18) {
|
|
809
|
+
var _ref18$selectedPlan = _ref18.selectedPlan,
|
|
810
|
+
selectedPlan = _ref18$selectedPlan === void 0 ? {} : _ref18$selectedPlan,
|
|
811
|
+
_ref18$couponCode = _ref18.couponCode,
|
|
812
|
+
couponCode = _ref18$couponCode === void 0 ? '' : _ref18$couponCode,
|
|
813
|
+
_ref18$recipientSubsc = _ref18.recipientSubscriber,
|
|
814
|
+
recipientSubscriber = _ref18$recipientSubsc === void 0 ? {} : _ref18$recipientSubsc,
|
|
815
|
+
_ref18$planType = _ref18.planType,
|
|
816
|
+
planType = _ref18$planType === void 0 ? '' : _ref18$planType,
|
|
817
|
+
_ref18$storyId = _ref18.storyId,
|
|
818
|
+
storyId = _ref18$storyId === void 0 ? '' : _ref18$storyId,
|
|
819
|
+
_ref18$storyHeadline = _ref18.storyHeadline,
|
|
820
|
+
storyHeadline = _ref18$storyHeadline === void 0 ? '' : _ref18$storyHeadline,
|
|
821
|
+
_ref18$storySlug = _ref18.storySlug,
|
|
822
|
+
storySlug = _ref18$storySlug === void 0 ? '' : _ref18$storySlug,
|
|
823
|
+
_ref18$paymentType = _ref18.paymentType,
|
|
824
|
+
paymentType = _ref18$paymentType === void 0 ? '' : _ref18$paymentType,
|
|
825
|
+
_ref18$successUrl = _ref18.successUrl,
|
|
826
|
+
successUrl = _ref18$successUrl === void 0 ? '' : _ref18$successUrl,
|
|
827
|
+
_ref18$returnUrl = _ref18.returnUrl,
|
|
828
|
+
returnUrl = _ref18$returnUrl === void 0 ? '' : _ref18$returnUrl,
|
|
829
|
+
_ref18$cancelUrl = _ref18.cancelUrl,
|
|
830
|
+
cancelUrl = _ref18$cancelUrl === void 0 ? '' : _ref18$cancelUrl;
|
|
1070
831
|
var id = selectedPlan.id,
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
832
|
+
title = selectedPlan.title,
|
|
833
|
+
description = selectedPlan.description,
|
|
834
|
+
price_cents = selectedPlan.price_cents,
|
|
835
|
+
price_currency = selectedPlan.price_currency,
|
|
836
|
+
duration_length = selectedPlan.duration_length,
|
|
837
|
+
duration_unit = selectedPlan.duration_unit,
|
|
838
|
+
discounted_price_cents = selectedPlan.discounted_price_cents,
|
|
839
|
+
metadata = selectedPlan.metadata;
|
|
1079
840
|
var paymentObject = {
|
|
1080
841
|
type: planType,
|
|
1081
842
|
plan: {
|
|
@@ -1101,22 +862,18 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
1101
862
|
slug: storySlug
|
|
1102
863
|
}],
|
|
1103
864
|
recipient_subscriber: recipientSubscriber //for gift subscription
|
|
1104
|
-
|
|
1105
865
|
};
|
|
1106
|
-
|
|
1107
866
|
if ((successUrl || returnUrl) && cancelUrl) {
|
|
1108
867
|
paymentObject.options = {};
|
|
1109
868
|
paymentObject.options.urls = {
|
|
1110
869
|
cancel_url: cancelUrl
|
|
1111
870
|
};
|
|
1112
|
-
|
|
1113
871
|
if (returnUrl) {
|
|
1114
872
|
paymentObject.options.urls['return_url'] = returnUrl;
|
|
1115
873
|
} else {
|
|
1116
874
|
paymentObject.options.urls['success_url'] = successUrl;
|
|
1117
875
|
}
|
|
1118
876
|
}
|
|
1119
|
-
|
|
1120
877
|
return paymentObject;
|
|
1121
878
|
}
|
|
1122
879
|
}, {
|
|
@@ -1169,10 +926,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
1169
926
|
});
|
|
1170
927
|
}
|
|
1171
928
|
}]);
|
|
1172
|
-
|
|
1173
|
-
return AccessTypeBase;
|
|
1174
929
|
}(React.Component);
|
|
1175
|
-
|
|
1176
930
|
var mapStateToProps = function mapStateToProps(state) {
|
|
1177
931
|
return {
|
|
1178
932
|
subscriptions: state.subscriptions || null,
|
|
@@ -1180,7 +934,6 @@ var mapStateToProps = function mapStateToProps(state) {
|
|
|
1180
934
|
assetPlans: state.assetPlans || null
|
|
1181
935
|
};
|
|
1182
936
|
};
|
|
1183
|
-
|
|
1184
937
|
var mapDispatchToProps = function mapDispatchToProps(dispatch) {
|
|
1185
938
|
return {
|
|
1186
939
|
subscriptionGroupLoaded: function subscriptionGroupLoaded(subscriptions) {
|
|
@@ -1227,6 +980,7 @@ var mapDispatchToProps = function mapDispatchToProps(dispatch) {
|
|
|
1227
980
|
}
|
|
1228
981
|
};
|
|
1229
982
|
};
|
|
983
|
+
|
|
1230
984
|
/**
|
|
1231
985
|
* `AccessType` is a generic connected render prop which exposes methods to handle access to stories / assets and initialize AccessTypeJS.
|
|
1232
986
|
|
|
@@ -1393,6 +1147,4 @@ var mapDispatchToProps = function mapDispatchToProps(dispatch) {
|
|
|
1393
1147
|
* @component
|
|
1394
1148
|
* @category Subscription
|
|
1395
1149
|
*/
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
1150
|
export var AccessType = /*#__PURE__*/connect(mapStateToProps, mapDispatchToProps)(AccessTypeBase);
|