@saasquatch/vanilla-components 1.2.4-4 → 1.2.4-7

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