@saasquatch/vanilla-components 1.3.0-2 → 1.4.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.
Files changed (92) hide show
  1. package/LICENSE +21 -21
  2. package/dist/cjs/{WidgetHost-d7b870ce.js → WidgetHost-71b013eb.js} +615 -615
  3. package/dist/cjs/loader.cjs.js +1 -1
  4. package/dist/cjs/sqh-close-button.cjs.entry.js +25 -25
  5. package/dist/cjs/sqh-copy-button_12.cjs.entry.js +1015 -1148
  6. package/dist/cjs/sqh-referral-code.cjs.entry.js +22 -22
  7. package/dist/cjs/sqh-rewards-actions.cjs.entry.js +26 -26
  8. package/dist/cjs/widget-components.cjs.js +1 -1
  9. package/dist/collection/components/close-button/close-button.js +68 -67
  10. package/dist/collection/components/copy-button/copy-button.js +380 -332
  11. package/dist/collection/components/copy-link-button/copy-link-button.js +230 -203
  12. package/dist/collection/components/global-container/global-container.js +158 -144
  13. package/dist/collection/components/image-component/image-component.js +175 -153
  14. package/dist/collection/components/partner-stat-component/partner-stat-component.js +196 -173
  15. package/dist/collection/components/referral-code/referral-code.js +36 -33
  16. package/dist/collection/components/referral-component/referral-component.js +255 -254
  17. package/dist/collection/components/referral-list/referral-list.js +911 -818
  18. package/dist/collection/components/rewards-actions/rewards-actions.js +105 -104
  19. package/dist/collection/components/share-button/share-button.js +301 -291
  20. package/dist/collection/components/share-button-container/share-button-container.js +2384 -2194
  21. package/dist/collection/components/stat-component/stat-component.js +196 -173
  22. package/dist/collection/components/stats-container/stats-container.js +210 -197
  23. package/dist/collection/components/text-component/text-component.js +304 -264
  24. package/dist/collection/entrypoint.js +34 -32
  25. package/dist/collection/global/global.js +4 -4
  26. package/dist/collection/services/FormatJs.js +15 -15
  27. package/dist/collection/services/WidgetHost.js +621 -621
  28. package/dist/collection/utilities.js +81 -81
  29. package/dist/esm/{WidgetHost-a27e693d.js → WidgetHost-9c337319.js} +615 -615
  30. package/dist/esm/loader.mjs +1 -1
  31. package/dist/esm/polyfills/core-js.js +0 -0
  32. package/dist/esm/polyfills/dom.js +0 -0
  33. package/dist/esm/polyfills/es5-html-element.js +0 -0
  34. package/dist/esm/polyfills/index.js +0 -0
  35. package/dist/esm/polyfills/system.js +0 -0
  36. package/dist/esm/sqh-close-button.entry.js +25 -25
  37. package/dist/esm/sqh-copy-button_12.entry.js +1015 -1148
  38. package/dist/esm/sqh-referral-code.entry.js +22 -22
  39. package/dist/esm/sqh-rewards-actions.entry.js +26 -26
  40. package/dist/esm/widget-components.mjs +1 -1
  41. package/dist/esm-es5/{WidgetHost-a27e693d.js → WidgetHost-9c337319.js} +9432 -9432
  42. package/dist/esm-es5/_commonjsHelpers-1d681858.js +17 -17
  43. package/dist/esm-es5/css-shim-a659079f.js +122 -122
  44. package/dist/esm-es5/dom-4061ceba.js +468 -468
  45. package/dist/esm-es5/en-be593af0.js +1471 -1471
  46. package/dist/esm-es5/index-8ea8b6d8.js +1758 -1758
  47. package/dist/esm-es5/loader.mjs +11 -11
  48. package/dist/esm-es5/sqh-close-button.entry.js +35 -35
  49. package/dist/esm-es5/sqh-copy-button_12.entry.js +9535 -9657
  50. package/dist/esm-es5/sqh-referral-code.entry.js +29 -29
  51. package/dist/esm-es5/sqh-rewards-actions.entry.js +31 -31
  52. package/dist/esm-es5/widget-components.mjs +6 -6
  53. package/dist/types/components/close-button/close-button.d.ts +16 -15
  54. package/dist/types/components/copy-button/copy-button.d.ts +90 -86
  55. package/dist/types/components/copy-link-button/copy-link-button.d.ts +53 -50
  56. package/dist/types/components/global-container/global-container.d.ts +39 -37
  57. package/dist/types/components/image-component/image-component.d.ts +45 -42
  58. package/dist/types/components/partner-stat-component/partner-stat-component.d.ts +51 -44
  59. package/dist/types/components/referral-code/referral-code.d.ts +12 -9
  60. package/dist/types/components/referral-component/referral-component.d.ts +46 -45
  61. package/dist/types/components/referral-list/referral-list.d.ts +234 -211
  62. package/dist/types/components/rewards-actions/rewards-actions.d.ts +25 -24
  63. package/dist/types/components/share-button/share-button.d.ts +77 -75
  64. package/dist/types/components/share-button-container/share-button-container.d.ts +593 -591
  65. package/dist/types/components/stat-component/stat-component.d.ts +48 -44
  66. package/dist/types/components/stats-container/stats-container.d.ts +47 -41
  67. package/dist/types/components/text-component/text-component.d.ts +74 -73
  68. package/dist/types/components.d.ts +722 -536
  69. package/dist/types/global/global.d.ts +4 -4
  70. package/dist/types/saasquatch.d.ts +105 -103
  71. package/dist/types/services/FormatJs.d.ts +7 -7
  72. package/dist/types/services/WidgetHost.d.ts +45 -45
  73. package/dist/types/utilities.d.ts +7 -7
  74. package/dist/widget-components/entrypoint.js +34 -32
  75. package/dist/widget-components/p-24fc4ba9.js +1 -1
  76. package/dist/widget-components/{p-d4b27c72.entry.js → p-366f1663.entry.js} +1 -1
  77. package/dist/widget-components/p-46109683.js +3 -3
  78. package/dist/widget-components/{p-650d012d.entry.js → p-54ea7a00.entry.js} +1 -1
  79. package/dist/widget-components/p-58be1132.system.js +1 -1
  80. package/dist/widget-components/{p-d7059393.entry.js → p-95fe9766.entry.js} +17 -16
  81. package/dist/widget-components/{p-c0cdba77.system.entry.js → p-b17efca4.system.entry.js} +1 -1
  82. package/dist/widget-components/p-c8bc8c77.system.entry.js +1 -0
  83. package/dist/widget-components/p-d1f56be8.system.entry.js +8 -0
  84. package/dist/widget-components/widget-components.esm.js +1 -1
  85. package/docs/raisins.json +1 -1
  86. package/package.json +97 -94
  87. package/readme.md +52 -52
  88. package/CHANGELOG.md +0 -143
  89. package/dist/widget-components/p-908068c2.system.entry.js +0 -1
  90. package/dist/widget-components/p-fba5ea7f.system.entry.js +0 -8
  91. /package/dist/widget-components/{p-9adc7c50.system.js → p-8e232564.system.js} +0 -0
  92. /package/dist/widget-components/{p-9525bf4a.js → p-edd43dbc.js} +0 -0
@@ -9910,621 +9910,621 @@ gql.disableExperimentalFragmentVariables = disableExperimentalFragmentVariables;
9910
9910
 
9911
9911
  var src = gql;
9912
9912
 
9913
- if (!window["widgetIdent"]) {
9914
- window["widgetIdent"] = {
9915
- env: "demo",
9916
- };
9917
- }
9918
- function widgetIdent() {
9919
- //@ts-ignore
9920
- return window.widgetIdent;
9921
- }
9922
- const today = new Date();
9923
- const demoUser = {
9924
- shareLink: "http://ssqt.co",
9925
- fueltankCode: "12AS3F",
9926
- referralcode: "RIDDIKULUS",
9927
- locale: "en_US",
9928
- messageLink: {
9929
- EMAIL: "http://short.staging.referralsaasquatch.com/mJjFXu",
9930
- FACEBOOK: "http://short.staging.referralsaasquatch.com/mwjFXu",
9931
- TWITTER: "http://short.staging.referralsaasquatch.com/mwjFXu",
9932
- SMS: "http://short.staging.referralsaasquatch.com/mwjFXu",
9933
- WHATSAPP: "http://short.staging.referralsaasquatch.com/mwjFXu",
9934
- LINKEDIN: "http://short.staging.referralsaasquatch.com/mwjFXu",
9935
- PINTEREST: "http://short.staging.referralsaasquatch.com/mwjFXu",
9936
- FBMESSENGER: "http://short.staging.referralsaasquatch.com/mwjFXu",
9937
- },
9938
- referrals: {
9939
- totalCount: 9,
9940
- data: [
9941
- {
9942
- dateReferralStarted: today.setDate(today.getDate() - 2),
9943
- referredUser: { firstName: "Remus", lastName: "Lupin" },
9944
- rewards: [
9945
- {
9946
- prettyValue: "$20.00",
9947
- dateExpires: today.setDate(today.getDate() + 4),
9948
- statuses: ["EXPIRED"],
9949
- meta: { message: "Applied to Invoice #1234" },
9950
- },
9951
- { prettyValue: "$10.00", statuses: ["AVAILABLE"] },
9952
- { prettyValue: "$5.00", statuses: ["AVAILABLE"] },
9953
- ],
9954
- },
9955
- {
9956
- dateReferralStarted: today.setDate(today.getDate() - 1),
9957
- referredUser: { firstName: "Gellert", lastName: "Grindelwald" },
9958
- rewards: [],
9959
- },
9960
- // Blank string becomes an unknown user, which is editable
9961
- {
9962
- dateReferralStarted: today.setDate(today.getDate() - 1),
9963
- referredUser: { firstName: "", lastName: "" },
9964
- rewards: [
9965
- {
9966
- prettyValue: "$20.00",
9967
- dateExpires: today.setDate(today.getDate() - 2),
9968
- statuses: ["EXPIRED"],
9969
- },
9970
- ],
9971
- },
9972
- {
9973
- dateReferralStarted: today.setDate(today.getDate() - 5),
9974
- referredUser: { firstName: "Lavender", lastName: "Brown" },
9975
- rewards: [{ prettyValue: "$20.00", statuses: ["CANCELLED"] }],
9976
- },
9977
- {
9978
- dateReferralStarted: today.setDate(today.getDate() - 4),
9979
- referredUser: { firstName: "Blaise", lastName: "Zabini" },
9980
- rewards: [
9981
- { prettyValue: "$20.00", statuses: ["AVAILABLE"] },
9982
- { prettyValue: "$10.00", statuses: ["AVAILABLE"] },
9983
- ],
9984
- },
9985
- {
9986
- dateReferralStarted: today.setDate(today.getDate() - 10),
9987
- referredUser: { firstName: "Argus", lastName: "Filch" },
9988
- rewards: [],
9989
- },
9990
- {
9991
- dateReferralStarted: today.setDate(today.getDate() - 15),
9992
- referredUser: { firstName: "Ron", lastName: "Weasley" },
9993
- rewards: [{ prettyValue: "$20.00", statuses: ["AVAILABLE"] }],
9994
- },
9995
- {
9996
- dateReferralStarted: today.setDate(today.getDate() - 2),
9997
- referredUser: { firstName: "Hermione", lastName: "Granger" },
9998
- rewards: [
9999
- { prettyValue: "$20.00", statuses: ["AVAILABLE"] },
10000
- { prettyValue: "$10.00", statuses: ["AVAILABLE"] },
10001
- { prettyValue: "$5.00", statuses: ["AVAILABLE"] },
10002
- { prettyValue: "5%", statuses: ["AVAILABLE"] },
10003
- { prettyValue: "5%", statuses: ["AVAILABLE"] },
10004
- { prettyValue: "5%", statuses: ["AVAILABLE"] },
10005
- ],
10006
- },
10007
- {
10008
- dateConverted: 1606943971468,
10009
- dateReferralStarted: 1606943971468,
10010
- referredUser: {
10011
- imageUrl: "",
10012
- firstName: "Seamus",
10013
- lastName: "Finnigan",
10014
- },
10015
- rewards: [],
10016
- },
10017
- ],
10018
- },
10019
- referredByReferral: {
10020
- dateReferralStarted: today.setDate(today.getDate() - 2),
10021
- referrerUser: {
10022
- firstName: "Rubeus",
10023
- lastName: "Hagrid",
10024
- referralCode: "RUBEUSHAGRID12",
10025
- },
10026
- rewards: [
10027
- {
10028
- fuelTankCode: "CODE1234",
10029
- prettyValue: "$10.00",
10030
- statuses: ["AVAILABLE"],
10031
- },
10032
- ],
10033
- },
10034
- referralsMonth: { totalCount: 6 },
10035
- referralsWeek: { totalCount: 3 },
10036
- rewardsCount: { totalCount: 14 },
10037
- rewardsMonth: { totalCount: 7 },
10038
- rewardsWeek: { totalCount: 4 },
10039
- rewardBalancesGlobal: [
10040
- {
10041
- type: "CREDIT",
10042
- unit: "CENTS",
10043
- value: 17000,
10044
- prettyValue: "$170.00",
10045
- totalAssignedCredit: "17000",
10046
- totalRedeemedCredit: "1500",
10047
- prettyAssignedCredit: "$1000.00",
10048
- prettyRedeemedCredit: "$15.00",
10049
- },
10050
- { type: "PCT_DISCOUNT", unit: "%", value: 15, prettyValue: "15%" },
10051
- {
10052
- type: "CREDIT",
10053
- unit: "CASH/CAD",
10054
- count: 3,
10055
- totalPendingCredit: 20000,
10056
- totalAssignedCredit: 30000,
10057
- totalRedeemedCredit: 10000,
10058
- totalExpiredCredit: 0,
10059
- totalCancelledCredit: 0,
10060
- prettyPendingCredit: "$200.00",
10061
- prettyAssignedCredit: "$300.00",
10062
- prettyRedeemedCredit: "$100.00",
10063
- value: 30000,
10064
- prettyValue: "$300.00",
10065
- },
10066
- {
10067
- type: "CREDIT",
10068
- unit: "CASH/USD",
10069
- count: 6,
10070
- totalPendingCredit: 25000,
10071
- totalAssignedCredit: 40000,
10072
- totalRedeemedCredit: 10000,
10073
- totalExpiredCredit: 15000,
10074
- totalCancelledCredit: 10000,
10075
- prettyPendingCredit: "USD250.00",
10076
- prettyAssignedCredit: "USD400.00",
10077
- prettyRedeemedCredit: "USD150.00",
10078
- value: 40000,
10079
- prettyValue: "USD400.00",
10080
- },
10081
- ],
10082
- rewardBalances: [
10083
- {
10084
- type: "CREDIT",
10085
- unit: "CENTS",
10086
- value: 17000,
10087
- prettyValue: "$170.00",
10088
- totalAssignedCredit: "17000",
10089
- totalRedeemedCredit: "1500",
10090
- prettyAssignedCredit: "$170.00",
10091
- prettyRedeemedCredit: "$15.00",
10092
- },
10093
- { type: "PCT_DISCOUNT", unit: "%", value: 15, prettyValue: "15%" },
10094
- {
10095
- type: "CREDIT",
10096
- unit: "CASH/CAD",
10097
- count: 3,
10098
- totalPendingCredit: 20000,
10099
- totalAssignedCredit: 30000,
10100
- totalRedeemedCredit: 10000,
10101
- totalExpiredCredit: 0,
10102
- totalCancelledCredit: 0,
10103
- prettyPendingCredit: "$200.00",
10104
- prettyAssignedCredit: "$300.00",
10105
- prettyRedeemedCredit: "$100.00",
10106
- value: 30000,
10107
- prettyValue: "$300.00",
10108
- },
10109
- {
10110
- type: "CREDIT",
10111
- unit: "CASH/USD",
10112
- count: 6,
10113
- totalPendingCredit: 25000,
10114
- totalAssignedCredit: 40000,
10115
- totalRedeemedCredit: 10000,
10116
- totalExpiredCredit: 15000,
10117
- totalCancelledCredit: 10000,
10118
- prettyPendingCredit: "USD250.00",
10119
- prettyAssignedCredit: "USD400.00",
10120
- prettyRedeemedCredit: "USD150.00",
10121
- value: 40000,
10122
- prettyValue: "USD400.00",
10123
- },
10124
- ],
10125
- rewardBalanceDetails: [
10126
- {
10127
- prettyAvailableValue: "$5.00",
10128
- },
10129
- {
10130
- prettyAvailableValue: "18%",
10131
- },
10132
- ],
10133
- };
10134
- //@ts-ignore
10135
- const squatchJsApi = window.frameElement
10136
- ? window.frameElement.squatchJsApi
10137
- : {};
10138
- const apolloClient = () => {
10139
- const { tenantAlias, appDomain, token } = widgetIdent();
10140
- const uri = appDomain + "/api/v1/" + tenantAlias + "/graphql";
10141
- const headers = {
10142
- Authorization: `Bearer ${token}`,
10143
- };
10144
- const client = new ApolloClient({
10145
- link: new HttpLink({ uri, headers }),
10146
- cache: new InMemoryCache(),
10147
- });
10148
- return client;
10149
- };
10150
- const API = {
10151
- version: "Welcome to widget-host",
10152
- analytics: {
10153
- shareEvent(shareMedium) {
10154
- const widgetId = widgetIdent();
10155
- if (widgetId["env"] === "demo" || !widgetId)
10156
- return Promise.resolve({});
10157
- const { userId, accountId, programId = "classic", engagementMedium, } = widgetId;
10158
- const variables = {
10159
- eventMeta: {
10160
- id: userId,
10161
- accountId,
10162
- programId,
10163
- type: "USER_REFERRAL_PROGRAM_ENGAGEMENT_EVENT",
10164
- meta: {
10165
- engagementMedium,
10166
- shareMedium,
10167
- },
10168
- },
10169
- };
10170
- return apolloClient()
10171
- .mutate({
10172
- mutation: src `
10173
- mutation ($eventMeta: UserAnalyticsEvent!) {
10174
- createUserAnalyticsEvent(eventMeta: $eventMeta)
10175
- }
10176
- `,
10177
- variables,
10178
- })
10179
- .then((result) => {
10180
- return result.data.createUserAnalyticsEvent;
10181
- });
10182
- },
10183
- loadEvent() {
10184
- return Promise.resolve({ event: "loadEvent" });
10185
- },
10186
- },
10187
- graphql: {
10188
- getClient() {
10189
- return apolloClient();
10190
- },
10191
- getUserFragment(userFragment, fragmentVariables) {
10192
- const fragment = src `
10193
- fragment UserFragment on User {
10194
- ${userFragment}
10195
- }`;
10196
- const { userId, accountId } = widgetIdent();
10197
- const variables = Object.assign(Object.assign({}, fragmentVariables), { userId,
10198
- accountId });
10199
- return this.getClient().query({
10200
- query: src `
10201
- query ($userId: String!, $accountId: String!, $offset: Int) {
10202
- user(id: $userId, accountId: $accountId) {
10203
- ...UserFragment
10204
- }
10205
- }
10206
- ${fragment}
10207
- `,
10208
- variables,
10209
- });
10210
- },
10211
- getShareLink() {
10212
- const widgetId = widgetIdent();
10213
- if (widgetId["env"] === "demo" || !widgetId)
10214
- return Promise.resolve(demoUser.shareLink);
10215
- const { userId, accountId, programId = null, engagementMedium, } = widgetId;
10216
- const variables = {
10217
- userId,
10218
- accountId,
10219
- programId,
10220
- engagementMedium,
10221
- };
10222
- return this.getClient()
10223
- .query({
10224
- query: src `
10225
- query (
10226
- $userId: String!
10227
- $accountId: String!
10228
- $programId: ID
10229
- $engagementMedium: UserEngagementMedium!
10230
- ) {
10231
- user(id: $userId, accountId: $accountId) {
10232
- shareLink(
10233
- programId: $programId
10234
- engagementMedium: $engagementMedium
10235
- shareMedium: DIRECT
10236
- useCleanLink: true
10237
- )
10238
- }
10239
- }
10240
- `,
10241
- variables,
10242
- })
10243
- .then((res) => res.data.user.shareLink);
10244
- },
10245
- getReferrals(showReferrer, offset = 0, limit = 3) {
10246
- const widgetId = widgetIdent();
10247
- if (widgetId["env"] === "demo" || !widgetId) {
10248
- const { referrals: refs, referredByReferral, locale } = demoUser;
10249
- const referrals = {
10250
- totalCount: refs.totalCount,
10251
- data: refs.data.slice(offset, offset + limit),
10252
- };
10253
- const user = { referrals, referredByReferral, locale };
10254
- return Promise.resolve(user);
10255
- }
10256
- const { userId, accountId, programId = null } = widgetId;
10257
- const variables = {
10258
- limit,
10259
- offset,
10260
- userId,
10261
- accountId,
10262
- programId,
10263
- programId_exists: programId ? true : false,
10264
- };
10265
- return this.getClient()
10266
- .query({
10267
- query: src `
10268
- query (
10269
- $userId: String!
10270
- $accountId: String!
10271
- $offset: Int!
10272
- $limit: Int!
10273
- $programId: ID
10274
- $programId_exists: Boolean!
10275
- ) {
10276
- user(id: $userId, accountId: $accountId) {
10277
- locale
10278
- referrals(
10279
- limit: $limit
10280
- offset: $offset
10281
- filter: {
10282
- programId_eq: $programId
10283
- programId_exists: $programId_exists
10284
- }
10285
- ) {
10286
- totalCount
10287
- data {
10288
- dateConverted
10289
- dateReferralStarted
10290
- referredUser {
10291
- firstName
10292
- lastName
10293
- }
10294
- rewards(
10295
- filter: { userId_eq: $userId, accountId_eq: $accountId }
10296
- ) {
10297
- prettyValue
10298
- dateExpires
10299
- statuses
10300
- meta {
10301
- message
10302
- }
10303
- }
10304
- }
10305
- }
10306
- ${showReferrer
10307
- ? `referredByReferral(programId: $programId) {
10308
- referrerUser {
10309
- firstName
10310
- lastName
10311
- }
10312
- dateReferralStarted
10313
- rewards(
10314
- filter: { userId_eq: $userId, accountId_eq: $accountId }
10315
- ) {
10316
- prettyValue
10317
- statuses
10318
- }
10319
- }`
10320
- : ""}
10321
- }
10322
- }
10323
- `,
10324
- variables,
10325
- })
10326
- .then((res) => res.data.user);
10327
- },
10328
- getStats() {
10329
- const widgetId = widgetIdent();
10330
- if (widgetId["env"] === "demo" || !widgetId) {
10331
- const { referrals: referralsCount, referralsMonth, referralsWeek, rewardsCount, rewardsMonth, rewardsWeek, rewardBalances, rewardBalancesGlobal, } = demoUser;
10332
- const user = {
10333
- referralsCount,
10334
- referralsMonth,
10335
- referralsWeek,
10336
- rewardsCount,
10337
- rewardsMonth,
10338
- rewardsWeek,
10339
- rewardBalances,
10340
- rewardBalancesGlobal,
10341
- };
10342
- return Promise.resolve(user);
10343
- }
10344
- const { userId, accountId, programId = null } = widgetId;
10345
- const variables = {
10346
- userId,
10347
- accountId,
10348
- programId,
10349
- programId_exists: programId ? true : false,
10350
- };
10351
- return this.getClient()
10352
- .query({
10353
- query: src `
10354
- query (
10355
- $userId: String!
10356
- $accountId: String!
10357
- $programId: ID
10358
- $programId_exists: Boolean!
10359
- ) {
10360
- user(id: $userId, accountId: $accountId) {
10361
- referralsCount: referrals(
10362
- filter: {
10363
- programId_eq: $programId
10364
- programId_exists: $programId_exists
10365
- }
10366
- ) {
10367
- totalCount
10368
- }
10369
- referralsMonth: referrals(
10370
- filter: {
10371
- programId_eq: $programId
10372
- programId_exists: $programId_exists
10373
- dateReferralStarted_timeframe: "this_month"
10374
- }
10375
- ) {
10376
- totalCount
10377
- }
10378
- referralsWeek: referrals(
10379
- filter: {
10380
- programId_eq: $programId
10381
- programId_exists: $programId_exists
10382
- dateReferralStarted_timeframe: "this_week"
10383
- }
10384
- ) {
10385
- totalCount
10386
- }
10387
- rewardsCount: rewards(
10388
- filter: {
10389
- programId_eq: $programId
10390
- programId_exists: $programId_exists
10391
- }
10392
- ) {
10393
- totalCount
10394
- }
10395
- rewardsMonth: rewards(
10396
- filter: {
10397
- programId_eq: $programId
10398
- programId_exists: $programId_exists
10399
- dateGiven_timeframe: "this_month"
10400
- }
10401
- ) {
10402
- totalCount
10403
- }
10404
- rewardsWeek: rewards(
10405
- filter: {
10406
- programId_eq: $programId
10407
- programId_exists: $programId_exists
10408
- dateGiven_timeframe: "this_week"
10409
- }
10410
- ) {
10411
- totalCount
10412
- }
10413
- rewardBalances(programId: $programId)
10414
- rewardBalancesGlobal: rewardBalances
10415
- }
10416
- }
10417
- `,
10418
- variables,
10419
- })
10420
- .then((res) => res.data.user);
10421
- },
10422
- async getReferralCode() {
10423
- const widgetId = widgetIdent();
10424
- if (widgetId["env"] === "demo" || !widgetId)
10425
- return demoUser.referralcode;
10426
- const { userId, accountId, programId } = widgetId;
10427
- const variables = {
10428
- userId,
10429
- accountId,
10430
- programId,
10431
- };
10432
- return this.getClient()
10433
- .query({
10434
- query: src `
10435
- query ($userId: String!, $accountId: String!, $programId: ID!) {
10436
- user(id: $userId, accountId: $accountId) {
10437
- referralCode(programId: $programId)
10438
- }
10439
- }
10440
- `,
10441
- variables,
10442
- })
10443
- .then((res) => res.data.user.referralCode);
10444
- },
10445
- async getFueltankCode(rewardKey) {
10446
- const widgetId = widgetIdent();
10447
- if (widgetId["env"] === "demo" || !widgetId) {
10448
- return {
10449
- referredByReferral: demoUser.referredByReferral,
10450
- rewards: { data: demoUser.referredByReferral.rewards },
10451
- };
10452
- }
10453
- const { userId, accountId, programId } = widgetId;
10454
- const variables = {
10455
- userId,
10456
- accountId,
10457
- programId,
10458
- rewardKey,
10459
- };
10460
- return this.getClient()
10461
- .query({
10462
- query: src `
10463
- query (
10464
- $userId: String!
10465
- $accountId: String!
10466
- $programId: ID!
10467
- $rewardKey: String!
10468
- ) {
10469
- user(id: $userId, accountId: $accountId) {
10470
- referredByReferral(programId: $programId) {
10471
- referrerUser {
10472
- referralCode(programId: $programId)
10473
- }
10474
- }
10475
- rewards(
10476
- filter: {
10477
- programId_eq: $programId
10478
- programRewardKey_eq: $rewardKey
10479
- }
10480
- ) {
10481
- count
10482
- totalCount
10483
- data {
10484
- fuelTankCode
10485
- }
10486
- }
10487
- }
10488
- }
10489
- `,
10490
- variables,
10491
- })
10492
- .then((res) => res.data.user);
10493
- },
10494
- getMessageLinks(mediums) {
10495
- const widgetId = widgetIdent();
10496
- if (widgetId["env"] === "demo" || !widgetId)
10497
- return Promise.resolve(demoUser.messageLink);
10498
- const { userId, accountId, programId = null, engagementMedium, } = widgetId;
10499
- const variables = {
10500
- userId,
10501
- accountId,
10502
- programId,
10503
- engagementMedium,
10504
- };
10505
- return this.getClient()
10506
- .query({
10507
- query: src `
10508
- query($userId: String!, $accountId: String!, $programId: ID, $engagementMedium: UserEngagementMedium!) {
10509
- user(id: $userId, accountId: $accountId) {
10510
- ${mediums[0]}:messageLink(programId: $programId, engagementMedium: $engagementMedium, shareMedium: ${mediums[0]})
10511
- ${mediums[1]}:messageLink(programId: $programId, engagementMedium: $engagementMedium, shareMedium: ${mediums[1]})
10512
- ${mediums[2]}:messageLink(programId: $programId, engagementMedium: $engagementMedium, shareMedium: ${mediums[2]})
10513
- ${mediums[3]}:messageLink(programId: $programId, engagementMedium: $engagementMedium, shareMedium: ${mediums[3]})
10514
- ${mediums[4]}:messageLink(programId: $programId, engagementMedium: $engagementMedium, shareMedium: ${mediums[4]})
10515
- ${mediums[5]}:messageLink(programId: $programId, engagementMedium: $engagementMedium, shareMedium: ${mediums[5]})
10516
- ${mediums[6]}:messageLink(programId: $programId, engagementMedium: $engagementMedium, shareMedium: ${mediums[6]})
10517
- ${mediums[7]}:messageLink(programId: $programId, engagementMedium: $engagementMedium, shareMedium: ${mediums[7]})
10518
- ${mediums[8]}:messageLink(programId: $programId, engagementMedium: $engagementMedium, shareMedium: ${mediums[8]})
10519
- }
10520
- }
10521
- `,
10522
- variables,
10523
- })
10524
- .then((res) => res.data.user);
10525
- },
10526
- },
10527
- ui: squatchJsApi,
9913
+ if (!window["widgetIdent"]) {
9914
+ window["widgetIdent"] = {
9915
+ env: "demo",
9916
+ };
9917
+ }
9918
+ function widgetIdent() {
9919
+ //@ts-ignore
9920
+ return window.widgetIdent;
9921
+ }
9922
+ const today = new Date();
9923
+ const demoUser = {
9924
+ shareLink: "http://ssqt.co",
9925
+ fueltankCode: "12AS3F",
9926
+ referralcode: "RIDDIKULUS",
9927
+ locale: "en_US",
9928
+ messageLink: {
9929
+ EMAIL: "http://short.staging.referralsaasquatch.com/mJjFXu",
9930
+ FACEBOOK: "http://short.staging.referralsaasquatch.com/mwjFXu",
9931
+ TWITTER: "http://short.staging.referralsaasquatch.com/mwjFXu",
9932
+ SMS: "http://short.staging.referralsaasquatch.com/mwjFXu",
9933
+ WHATSAPP: "http://short.staging.referralsaasquatch.com/mwjFXu",
9934
+ LINKEDIN: "http://short.staging.referralsaasquatch.com/mwjFXu",
9935
+ PINTEREST: "http://short.staging.referralsaasquatch.com/mwjFXu",
9936
+ FBMESSENGER: "http://short.staging.referralsaasquatch.com/mwjFXu",
9937
+ },
9938
+ referrals: {
9939
+ totalCount: 9,
9940
+ data: [
9941
+ {
9942
+ dateReferralStarted: today.setDate(today.getDate() - 2),
9943
+ referredUser: { firstName: "Remus", lastName: "Lupin" },
9944
+ rewards: [
9945
+ {
9946
+ prettyValue: "$20.00",
9947
+ dateExpires: today.setDate(today.getDate() + 4),
9948
+ statuses: ["EXPIRED"],
9949
+ meta: { message: "Applied to Invoice #1234" },
9950
+ },
9951
+ { prettyValue: "$10.00", statuses: ["AVAILABLE"] },
9952
+ { prettyValue: "$5.00", statuses: ["AVAILABLE"] },
9953
+ ],
9954
+ },
9955
+ {
9956
+ dateReferralStarted: today.setDate(today.getDate() - 1),
9957
+ referredUser: { firstName: "Gellert", lastName: "Grindelwald" },
9958
+ rewards: [],
9959
+ },
9960
+ // Blank string becomes an unknown user, which is editable
9961
+ {
9962
+ dateReferralStarted: today.setDate(today.getDate() - 1),
9963
+ referredUser: { firstName: "", lastName: "" },
9964
+ rewards: [
9965
+ {
9966
+ prettyValue: "$20.00",
9967
+ dateExpires: today.setDate(today.getDate() - 2),
9968
+ statuses: ["EXPIRED"],
9969
+ },
9970
+ ],
9971
+ },
9972
+ {
9973
+ dateReferralStarted: today.setDate(today.getDate() - 5),
9974
+ referredUser: { firstName: "Lavender", lastName: "Brown" },
9975
+ rewards: [{ prettyValue: "$20.00", statuses: ["CANCELLED"] }],
9976
+ },
9977
+ {
9978
+ dateReferralStarted: today.setDate(today.getDate() - 4),
9979
+ referredUser: { firstName: "Blaise", lastName: "Zabini" },
9980
+ rewards: [
9981
+ { prettyValue: "$20.00", statuses: ["AVAILABLE"] },
9982
+ { prettyValue: "$10.00", statuses: ["AVAILABLE"] },
9983
+ ],
9984
+ },
9985
+ {
9986
+ dateReferralStarted: today.setDate(today.getDate() - 10),
9987
+ referredUser: { firstName: "Argus", lastName: "Filch" },
9988
+ rewards: [],
9989
+ },
9990
+ {
9991
+ dateReferralStarted: today.setDate(today.getDate() - 15),
9992
+ referredUser: { firstName: "Ron", lastName: "Weasley" },
9993
+ rewards: [{ prettyValue: "$20.00", statuses: ["AVAILABLE"] }],
9994
+ },
9995
+ {
9996
+ dateReferralStarted: today.setDate(today.getDate() - 2),
9997
+ referredUser: { firstName: "Hermione", lastName: "Granger" },
9998
+ rewards: [
9999
+ { prettyValue: "$20.00", statuses: ["AVAILABLE"] },
10000
+ { prettyValue: "$10.00", statuses: ["AVAILABLE"] },
10001
+ { prettyValue: "$5.00", statuses: ["AVAILABLE"] },
10002
+ { prettyValue: "5%", statuses: ["AVAILABLE"] },
10003
+ { prettyValue: "5%", statuses: ["AVAILABLE"] },
10004
+ { prettyValue: "5%", statuses: ["AVAILABLE"] },
10005
+ ],
10006
+ },
10007
+ {
10008
+ dateConverted: 1606943971468,
10009
+ dateReferralStarted: 1606943971468,
10010
+ referredUser: {
10011
+ imageUrl: "",
10012
+ firstName: "Seamus",
10013
+ lastName: "Finnigan",
10014
+ },
10015
+ rewards: [],
10016
+ },
10017
+ ],
10018
+ },
10019
+ referredByReferral: {
10020
+ dateReferralStarted: today.setDate(today.getDate() - 2),
10021
+ referrerUser: {
10022
+ firstName: "Rubeus",
10023
+ lastName: "Hagrid",
10024
+ referralCode: "RUBEUSHAGRID12",
10025
+ },
10026
+ rewards: [
10027
+ {
10028
+ fuelTankCode: "CODE1234",
10029
+ prettyValue: "$10.00",
10030
+ statuses: ["AVAILABLE"],
10031
+ },
10032
+ ],
10033
+ },
10034
+ referralsMonth: { totalCount: 6 },
10035
+ referralsWeek: { totalCount: 3 },
10036
+ rewardsCount: { totalCount: 14 },
10037
+ rewardsMonth: { totalCount: 7 },
10038
+ rewardsWeek: { totalCount: 4 },
10039
+ rewardBalancesGlobal: [
10040
+ {
10041
+ type: "CREDIT",
10042
+ unit: "CENTS",
10043
+ value: 17000,
10044
+ prettyValue: "$170.00",
10045
+ totalAssignedCredit: "17000",
10046
+ totalRedeemedCredit: "1500",
10047
+ prettyAssignedCredit: "$1000.00",
10048
+ prettyRedeemedCredit: "$15.00",
10049
+ },
10050
+ { type: "PCT_DISCOUNT", unit: "%", value: 15, prettyValue: "15%" },
10051
+ {
10052
+ type: "CREDIT",
10053
+ unit: "CASH/CAD",
10054
+ count: 3,
10055
+ totalPendingCredit: 20000,
10056
+ totalAssignedCredit: 30000,
10057
+ totalRedeemedCredit: 10000,
10058
+ totalExpiredCredit: 0,
10059
+ totalCancelledCredit: 0,
10060
+ prettyPendingCredit: "$200.00",
10061
+ prettyAssignedCredit: "$300.00",
10062
+ prettyRedeemedCredit: "$100.00",
10063
+ value: 30000,
10064
+ prettyValue: "$300.00",
10065
+ },
10066
+ {
10067
+ type: "CREDIT",
10068
+ unit: "CASH/USD",
10069
+ count: 6,
10070
+ totalPendingCredit: 25000,
10071
+ totalAssignedCredit: 40000,
10072
+ totalRedeemedCredit: 10000,
10073
+ totalExpiredCredit: 15000,
10074
+ totalCancelledCredit: 10000,
10075
+ prettyPendingCredit: "USD250.00",
10076
+ prettyAssignedCredit: "USD400.00",
10077
+ prettyRedeemedCredit: "USD150.00",
10078
+ value: 40000,
10079
+ prettyValue: "USD400.00",
10080
+ },
10081
+ ],
10082
+ rewardBalances: [
10083
+ {
10084
+ type: "CREDIT",
10085
+ unit: "CENTS",
10086
+ value: 17000,
10087
+ prettyValue: "$170.00",
10088
+ totalAssignedCredit: "17000",
10089
+ totalRedeemedCredit: "1500",
10090
+ prettyAssignedCredit: "$170.00",
10091
+ prettyRedeemedCredit: "$15.00",
10092
+ },
10093
+ { type: "PCT_DISCOUNT", unit: "%", value: 15, prettyValue: "15%" },
10094
+ {
10095
+ type: "CREDIT",
10096
+ unit: "CASH/CAD",
10097
+ count: 3,
10098
+ totalPendingCredit: 20000,
10099
+ totalAssignedCredit: 30000,
10100
+ totalRedeemedCredit: 10000,
10101
+ totalExpiredCredit: 0,
10102
+ totalCancelledCredit: 0,
10103
+ prettyPendingCredit: "$200.00",
10104
+ prettyAssignedCredit: "$300.00",
10105
+ prettyRedeemedCredit: "$100.00",
10106
+ value: 30000,
10107
+ prettyValue: "$300.00",
10108
+ },
10109
+ {
10110
+ type: "CREDIT",
10111
+ unit: "CASH/USD",
10112
+ count: 6,
10113
+ totalPendingCredit: 25000,
10114
+ totalAssignedCredit: 40000,
10115
+ totalRedeemedCredit: 10000,
10116
+ totalExpiredCredit: 15000,
10117
+ totalCancelledCredit: 10000,
10118
+ prettyPendingCredit: "USD250.00",
10119
+ prettyAssignedCredit: "USD400.00",
10120
+ prettyRedeemedCredit: "USD150.00",
10121
+ value: 40000,
10122
+ prettyValue: "USD400.00",
10123
+ },
10124
+ ],
10125
+ rewardBalanceDetails: [
10126
+ {
10127
+ prettyAvailableValue: "$5.00",
10128
+ },
10129
+ {
10130
+ prettyAvailableValue: "18%",
10131
+ },
10132
+ ],
10133
+ };
10134
+ //@ts-ignore
10135
+ const squatchJsApi = window.frameElement
10136
+ ? window.frameElement.squatchJsApi
10137
+ : {};
10138
+ const apolloClient = () => {
10139
+ const { tenantAlias, appDomain, token } = widgetIdent();
10140
+ const uri = appDomain + "/api/v1/" + tenantAlias + "/graphql";
10141
+ const headers = {
10142
+ Authorization: `Bearer ${token}`,
10143
+ };
10144
+ const client = new ApolloClient({
10145
+ link: new HttpLink({ uri, headers }),
10146
+ cache: new InMemoryCache(),
10147
+ });
10148
+ return client;
10149
+ };
10150
+ const API = {
10151
+ version: "Welcome to widget-host",
10152
+ analytics: {
10153
+ shareEvent(shareMedium) {
10154
+ const widgetId = widgetIdent();
10155
+ if (widgetId["env"] === "demo" || !widgetId)
10156
+ return Promise.resolve({});
10157
+ const { userId, accountId, programId = "classic", engagementMedium, } = widgetId;
10158
+ const variables = {
10159
+ eventMeta: {
10160
+ id: userId,
10161
+ accountId,
10162
+ programId,
10163
+ type: "USER_REFERRAL_PROGRAM_ENGAGEMENT_EVENT",
10164
+ meta: {
10165
+ engagementMedium,
10166
+ shareMedium,
10167
+ },
10168
+ },
10169
+ };
10170
+ return apolloClient()
10171
+ .mutate({
10172
+ mutation: src `
10173
+ mutation ($eventMeta: UserAnalyticsEvent!) {
10174
+ createUserAnalyticsEvent(eventMeta: $eventMeta)
10175
+ }
10176
+ `,
10177
+ variables,
10178
+ })
10179
+ .then((result) => {
10180
+ return result.data.createUserAnalyticsEvent;
10181
+ });
10182
+ },
10183
+ loadEvent() {
10184
+ return Promise.resolve({ event: "loadEvent" });
10185
+ },
10186
+ },
10187
+ graphql: {
10188
+ getClient() {
10189
+ return apolloClient();
10190
+ },
10191
+ getUserFragment(userFragment, fragmentVariables) {
10192
+ const fragment = src `
10193
+ fragment UserFragment on User {
10194
+ ${userFragment}
10195
+ }`;
10196
+ const { userId, accountId } = widgetIdent();
10197
+ const variables = Object.assign(Object.assign({}, fragmentVariables), { userId,
10198
+ accountId });
10199
+ return this.getClient().query({
10200
+ query: src `
10201
+ query ($userId: String!, $accountId: String!, $offset: Int) {
10202
+ user(id: $userId, accountId: $accountId) {
10203
+ ...UserFragment
10204
+ }
10205
+ }
10206
+ ${fragment}
10207
+ `,
10208
+ variables,
10209
+ });
10210
+ },
10211
+ getShareLink() {
10212
+ const widgetId = widgetIdent();
10213
+ if (widgetId["env"] === "demo" || !widgetId)
10214
+ return Promise.resolve(demoUser.shareLink);
10215
+ const { userId, accountId, programId = null, engagementMedium, } = widgetId;
10216
+ const variables = {
10217
+ userId,
10218
+ accountId,
10219
+ programId,
10220
+ engagementMedium,
10221
+ };
10222
+ return this.getClient()
10223
+ .query({
10224
+ query: src `
10225
+ query (
10226
+ $userId: String!
10227
+ $accountId: String!
10228
+ $programId: ID
10229
+ $engagementMedium: UserEngagementMedium!
10230
+ ) {
10231
+ user(id: $userId, accountId: $accountId) {
10232
+ shareLink(
10233
+ programId: $programId
10234
+ engagementMedium: $engagementMedium
10235
+ shareMedium: DIRECT
10236
+ useCleanLink: true
10237
+ )
10238
+ }
10239
+ }
10240
+ `,
10241
+ variables,
10242
+ })
10243
+ .then((res) => res.data.user.shareLink);
10244
+ },
10245
+ getReferrals(showReferrer, offset = 0, limit = 3) {
10246
+ const widgetId = widgetIdent();
10247
+ if (widgetId["env"] === "demo" || !widgetId) {
10248
+ const { referrals: refs, referredByReferral, locale } = demoUser;
10249
+ const referrals = {
10250
+ totalCount: refs.totalCount,
10251
+ data: refs.data.slice(offset, offset + limit),
10252
+ };
10253
+ const user = { referrals, referredByReferral, locale };
10254
+ return Promise.resolve(user);
10255
+ }
10256
+ const { userId, accountId, programId = null } = widgetId;
10257
+ const variables = {
10258
+ limit,
10259
+ offset,
10260
+ userId,
10261
+ accountId,
10262
+ programId,
10263
+ programId_exists: programId ? true : false,
10264
+ };
10265
+ return this.getClient()
10266
+ .query({
10267
+ query: src `
10268
+ query (
10269
+ $userId: String!
10270
+ $accountId: String!
10271
+ $offset: Int!
10272
+ $limit: Int!
10273
+ $programId: ID
10274
+ $programId_exists: Boolean!
10275
+ ) {
10276
+ user(id: $userId, accountId: $accountId) {
10277
+ locale
10278
+ referrals(
10279
+ limit: $limit
10280
+ offset: $offset
10281
+ filter: {
10282
+ programId_eq: $programId
10283
+ programId_exists: $programId_exists
10284
+ }
10285
+ ) {
10286
+ totalCount
10287
+ data {
10288
+ dateConverted
10289
+ dateReferralStarted
10290
+ referredUser {
10291
+ firstName
10292
+ lastName
10293
+ }
10294
+ rewards(
10295
+ filter: { userId_eq: $userId, accountId_eq: $accountId }
10296
+ ) {
10297
+ prettyValue
10298
+ dateExpires
10299
+ statuses
10300
+ meta {
10301
+ message
10302
+ }
10303
+ }
10304
+ }
10305
+ }
10306
+ ${showReferrer
10307
+ ? `referredByReferral(programId: $programId) {
10308
+ referrerUser {
10309
+ firstName
10310
+ lastName
10311
+ }
10312
+ dateReferralStarted
10313
+ rewards(
10314
+ filter: { userId_eq: $userId, accountId_eq: $accountId }
10315
+ ) {
10316
+ prettyValue
10317
+ statuses
10318
+ }
10319
+ }`
10320
+ : ""}
10321
+ }
10322
+ }
10323
+ `,
10324
+ variables,
10325
+ })
10326
+ .then((res) => res.data.user);
10327
+ },
10328
+ getStats() {
10329
+ const widgetId = widgetIdent();
10330
+ if (widgetId["env"] === "demo" || !widgetId) {
10331
+ const { referrals: referralsCount, referralsMonth, referralsWeek, rewardsCount, rewardsMonth, rewardsWeek, rewardBalances, rewardBalancesGlobal, } = demoUser;
10332
+ const user = {
10333
+ referralsCount,
10334
+ referralsMonth,
10335
+ referralsWeek,
10336
+ rewardsCount,
10337
+ rewardsMonth,
10338
+ rewardsWeek,
10339
+ rewardBalances,
10340
+ rewardBalancesGlobal,
10341
+ };
10342
+ return Promise.resolve(user);
10343
+ }
10344
+ const { userId, accountId, programId = null } = widgetId;
10345
+ const variables = {
10346
+ userId,
10347
+ accountId,
10348
+ programId,
10349
+ programId_exists: programId ? true : false,
10350
+ };
10351
+ return this.getClient()
10352
+ .query({
10353
+ query: src `
10354
+ query (
10355
+ $userId: String!
10356
+ $accountId: String!
10357
+ $programId: ID
10358
+ $programId_exists: Boolean!
10359
+ ) {
10360
+ user(id: $userId, accountId: $accountId) {
10361
+ referralsCount: referrals(
10362
+ filter: {
10363
+ programId_eq: $programId
10364
+ programId_exists: $programId_exists
10365
+ }
10366
+ ) {
10367
+ totalCount
10368
+ }
10369
+ referralsMonth: referrals(
10370
+ filter: {
10371
+ programId_eq: $programId
10372
+ programId_exists: $programId_exists
10373
+ dateReferralStarted_timeframe: "this_month"
10374
+ }
10375
+ ) {
10376
+ totalCount
10377
+ }
10378
+ referralsWeek: referrals(
10379
+ filter: {
10380
+ programId_eq: $programId
10381
+ programId_exists: $programId_exists
10382
+ dateReferralStarted_timeframe: "this_week"
10383
+ }
10384
+ ) {
10385
+ totalCount
10386
+ }
10387
+ rewardsCount: rewards(
10388
+ filter: {
10389
+ programId_eq: $programId
10390
+ programId_exists: $programId_exists
10391
+ }
10392
+ ) {
10393
+ totalCount
10394
+ }
10395
+ rewardsMonth: rewards(
10396
+ filter: {
10397
+ programId_eq: $programId
10398
+ programId_exists: $programId_exists
10399
+ dateGiven_timeframe: "this_month"
10400
+ }
10401
+ ) {
10402
+ totalCount
10403
+ }
10404
+ rewardsWeek: rewards(
10405
+ filter: {
10406
+ programId_eq: $programId
10407
+ programId_exists: $programId_exists
10408
+ dateGiven_timeframe: "this_week"
10409
+ }
10410
+ ) {
10411
+ totalCount
10412
+ }
10413
+ rewardBalances(programId: $programId)
10414
+ rewardBalancesGlobal: rewardBalances
10415
+ }
10416
+ }
10417
+ `,
10418
+ variables,
10419
+ })
10420
+ .then((res) => res.data.user);
10421
+ },
10422
+ async getReferralCode() {
10423
+ const widgetId = widgetIdent();
10424
+ if (widgetId["env"] === "demo" || !widgetId)
10425
+ return demoUser.referralcode;
10426
+ const { userId, accountId, programId } = widgetId;
10427
+ const variables = {
10428
+ userId,
10429
+ accountId,
10430
+ programId,
10431
+ };
10432
+ return this.getClient()
10433
+ .query({
10434
+ query: src `
10435
+ query ($userId: String!, $accountId: String!, $programId: ID!) {
10436
+ user(id: $userId, accountId: $accountId) {
10437
+ referralCode(programId: $programId)
10438
+ }
10439
+ }
10440
+ `,
10441
+ variables,
10442
+ })
10443
+ .then((res) => res.data.user.referralCode);
10444
+ },
10445
+ async getFueltankCode(rewardKey) {
10446
+ const widgetId = widgetIdent();
10447
+ if (widgetId["env"] === "demo" || !widgetId) {
10448
+ return {
10449
+ referredByReferral: demoUser.referredByReferral,
10450
+ rewards: { data: demoUser.referredByReferral.rewards },
10451
+ };
10452
+ }
10453
+ const { userId, accountId, programId } = widgetId;
10454
+ const variables = {
10455
+ userId,
10456
+ accountId,
10457
+ programId,
10458
+ rewardKey,
10459
+ };
10460
+ return this.getClient()
10461
+ .query({
10462
+ query: src `
10463
+ query (
10464
+ $userId: String!
10465
+ $accountId: String!
10466
+ $programId: ID!
10467
+ $rewardKey: String!
10468
+ ) {
10469
+ user(id: $userId, accountId: $accountId) {
10470
+ referredByReferral(programId: $programId) {
10471
+ referrerUser {
10472
+ referralCode(programId: $programId)
10473
+ }
10474
+ }
10475
+ rewards(
10476
+ filter: {
10477
+ programId_eq: $programId
10478
+ programRewardKey_eq: $rewardKey
10479
+ }
10480
+ ) {
10481
+ count
10482
+ totalCount
10483
+ data {
10484
+ fuelTankCode
10485
+ }
10486
+ }
10487
+ }
10488
+ }
10489
+ `,
10490
+ variables,
10491
+ })
10492
+ .then((res) => res.data.user);
10493
+ },
10494
+ getMessageLinks(mediums) {
10495
+ const widgetId = widgetIdent();
10496
+ if (widgetId["env"] === "demo" || !widgetId)
10497
+ return Promise.resolve(demoUser.messageLink);
10498
+ const { userId, accountId, programId = null, engagementMedium, } = widgetId;
10499
+ const variables = {
10500
+ userId,
10501
+ accountId,
10502
+ programId,
10503
+ engagementMedium,
10504
+ };
10505
+ return this.getClient()
10506
+ .query({
10507
+ query: src `
10508
+ query($userId: String!, $accountId: String!, $programId: ID, $engagementMedium: UserEngagementMedium!) {
10509
+ user(id: $userId, accountId: $accountId) {
10510
+ ${mediums[0]}:messageLink(programId: $programId, engagementMedium: $engagementMedium, shareMedium: ${mediums[0]})
10511
+ ${mediums[1]}:messageLink(programId: $programId, engagementMedium: $engagementMedium, shareMedium: ${mediums[1]})
10512
+ ${mediums[2]}:messageLink(programId: $programId, engagementMedium: $engagementMedium, shareMedium: ${mediums[2]})
10513
+ ${mediums[3]}:messageLink(programId: $programId, engagementMedium: $engagementMedium, shareMedium: ${mediums[3]})
10514
+ ${mediums[4]}:messageLink(programId: $programId, engagementMedium: $engagementMedium, shareMedium: ${mediums[4]})
10515
+ ${mediums[5]}:messageLink(programId: $programId, engagementMedium: $engagementMedium, shareMedium: ${mediums[5]})
10516
+ ${mediums[6]}:messageLink(programId: $programId, engagementMedium: $engagementMedium, shareMedium: ${mediums[6]})
10517
+ ${mediums[7]}:messageLink(programId: $programId, engagementMedium: $engagementMedium, shareMedium: ${mediums[7]})
10518
+ ${mediums[8]}:messageLink(programId: $programId, engagementMedium: $engagementMedium, shareMedium: ${mediums[8]})
10519
+ }
10520
+ }
10521
+ `,
10522
+ variables,
10523
+ })
10524
+ .then((res) => res.data.user);
10525
+ },
10526
+ },
10527
+ ui: squatchJsApi,
10528
10528
  };
10529
10529
 
10530
10530
  exports.API = API;