### Install SaaSquatch CLI Source: https://github.com/saasquatch/saasquatch-docs/blob/production/content/articles/themes-publish.md Install the saasquatch-cli globally using npm. This makes the `squatch` executable available in your system's PATH. ```bash npm install -g saasquatch-cli ``` -------------------------------- ### Example user.created Event Payload Source: https://github.com/saasquatch/saasquatch-docs/blob/production/content/api/webhooks.md An example of the JSON payload received when a user is created. ```APIDOC ## Example user.created Event Payload This is an example of the payload structure for a `user.created` event: ```json { "id": "577303ece4b066c5cb171835", "type": "user.created", "tenantAlias": "aohgcctyskc0p", "live": true, "created": 1467155436449, "data": { "id": "sat09jsaet09setset", "accountId": "90w4etjsa4et", "email": "mike.keenerson@example.com", "firstName": "Mike", "lastName": "Keenerson", "referralCodes": { "referral-program": "MIKEKEENERSON", "partner-program": "FREE" }, "imageUrl": "", "firstSeenIP": "10.230.163.157", "lastSeenIP": null, "dateCreated": 1467155436418, "locale": "fr_CA", "countryCode": "CA", "programShareLinks": { "partner-program": { "cleanShareLink": "http://example.com/free", "MOBILE": { "DIRECT": "http://example.com/free?me" }, "EMAIL": { "DIRECT": "http://example.com/free?mP" }, "UNKNOWN": { "DIRECT": "http://example.com/free?mv" } } }, "customFields": { "birthday": "--02-29" }, "segments": ["segment1"], "referredByCodes": ["CODE1"] } } ``` ``` -------------------------------- ### Install CocoaPods Source: https://github.com/saasquatch/saasquatch-docs/blob/production/content/articles/mobile-ios-quickstart.md Install CocoaPods using this Terminal command if it is not already on your system. ```bash sudo gem install cocoapods ``` -------------------------------- ### Example Mobile Widget URL Source: https://github.com/saasquatch/saasquatch-docs/blob/production/content/articles/guides-mobile-installation.md An example of a fully constructed URL for the mobile widget, demonstrating the inclusion of all necessary parameters. ```url https://app.referralsaasquatch.com/a/{{tenantalias}}/widgets/mobilewidget?jwt={{calculated_JWT}}&systemId=abc_123&userId=abc_123&email=john%40example.com&firstName=John&lastName=Doe&referralCode=JANEDOE&accountStatus=TRIAL&mode=EMPTY ``` -------------------------------- ### Example: Publish Change URL Event Source: https://github.com/saasquatch/saasquatch-docs/blob/production/content/theming/widgetjs.md This example demonstrates how to use `widget.rpc.ready` to ensure the event bus is initialized before publishing a `changeUrl` event with a new URL in the payload when a specific button is clicked. ```javascript widget.rpc.ready(function() { $(\'#changeURL\').click(function() { widget.rpc.publish(\"changeUrl\", { url : \"http://www.referralsaasquatch.com/done\" }); }); }); ``` -------------------------------- ### Example Short Tags Source: https://github.com/saasquatch/saasquatch-docs/blob/production/content/theming/short-tags.md Examples of commonly used short tags for referral links and codes. ```html {{referralcode}} ``` ```html {{twittersharelink}} ``` -------------------------------- ### Example Landing Page URL with Discount Code Source: https://github.com/saasquatch/saasquatch-docs/blob/production/content/articles/adding-custom-landing-page-parameters.md Demonstrates how a landing page URL with a custom parameter is handled by SaaSquatch. ```text www.example.com/landingpage?discountCode=REFERRED20 ``` -------------------------------- ### User Info Dictionary Example Objective-C Source: https://github.com/saasquatch/saasquatch-docs/blob/production/public/mobile/ios/docs-objectivec/Classes/Saasquatch/index.html An example of the NSDictionary structure required for the userInfo parameter when registering a user. It includes essential fields like 'id' and 'accountId', along with optional details. ```objectivec NSDictionary *userInfo = @{ @"id" : @"10001110101", @"accountId" : @"10001110101", @"email" : @"claire@lallybroch.com", @"firstName" : @"Claire", @"lastName" : @"Fraser", @"locale" : @"en_US", @"referralCode" : @"CLAIREFRASER" }; ``` -------------------------------- ### Start Import Job (GraphQL) Source: https://github.com/saasquatch/saasquatch-docs/blob/production/content/articles/developer-bulk-import.md Initiates a bulk import job using the `createJob` GraphQL mutation. Requires the `fileRef` and job `type`. ```APIDOC ## POST /api/v1/{tenant_alias}/graphql ### Description Starts a bulk import job using the `createJob` GraphQL mutation. Returns the job `id` upon successful creation. ### Method POST ### Endpoint `https://app.referralsaasquatch.com/api/v1/{tenant_alias}/graphql` ### Parameters #### Request Body - **variables** (object) - Required - Contains job input details. - **jobInput** (object) - Required. - **type** (string) - Required - The type of job (e.g., `MUTATION/USER`, `MUTATION/DELETE_USER`, `MUTATION/USER_EVENT`, `MUTATION/REDEEMABLE_REWARD_BALANCE`). - **outputFormat** (string) - Optional - The desired output format (e.g., `CSV`). - **fileRef** (string) - Required - The reference obtained from the file upload step. - **query** (string) - Required - The GraphQL query string: `mutation ($jobInput: JobInput!) { createJob(jobInput: $jobInput) {id type requester dateCreated}}` ### Request Example ```curl curl -X POST https://app.referralsaasquatch.com/api/v1/{tenant_alias}/graphql -u :{tenant_api_key} -H "Content-Type: application/json" -d '{ "variables":{ "jobInput": { "type":"{job_type}", "outputFormat":"CSV", "fileRef":"{file_ref}" } }, "query":"mutation ($jobInput: JobInput!) { createJob(jobInput: $jobInput) {id type requester dateCreated}}" }' ``` ### Response #### Success Response (200) - **data.createJob.id** (string) - The unique identifier for the created import job. - **data.createJob.type** (string) - The type of the import job. - **data.createJob.requester** (string) - Indicates who initiated the job (e.g., `API`). - **data.createJob.dateCreated** (integer) - Timestamp when the job was created. ``` -------------------------------- ### Example Folder Structure for Packaged Translations Source: https://github.com/saasquatch/saasquatch-docs/blob/production/content/articles/features-program-i18n.md This example shows how to structure your translated files within the zip archive. Translated files for specific locales (e.g., `fr_FR.json`, `en_US.json`) are placed in the corresponding subfolders for emails, widgets, and rewards. ```json Your_Program_Name.zip ├── /Emails | ├── /programEmailID <-- Place your translated email files here | | ├── fr_FR.json | | └── en_US.json | └── programEmailID.json ├── /Rewards | ├── /referredReward <-- Place your translated referred reward files here | | ├── fr_FR.json | | └── en_US.json | ├── /referrerReward <-- Place your translated referrer reward files here | | ├── fr_FR.json | | └── en_US.json | └── referredReward.json | └── referrerReward.json └── /Widgets ├── /programWidgetID <-- Place your translated widget files here | ├── fr_FR.json | └── en_US.json └── programWidgetID.json ``` -------------------------------- ### Asset Pipeline Output Example Source: https://github.com/saasquatch/saasquatch-docs/blob/production/content/theming/assets.html This shows the expected HTML output after the `{{assets}}` helper processes the references, including CDN paths and versioning. ```html ``` -------------------------------- ### Mobile Widget URL Parameters Source: https://github.com/saasquatch/saasquatch-docs/blob/production/content/articles/mobile-widget-reference.md Example parameters to construct the Mobile Widget URL. Ensure all parameters are URL encoded. ```nohighlight https://app.referralsaasquatch.com/a/test_345gh4545g23kj3/widgets/mobilewidget ?userId=123 &firstName=Bob &lastName=Testserson &accountId=abc &paymentProviderId=NULL &email=misterd%2Bmuser001%40example.com &jwt={{calculated_JWT}} ``` -------------------------------- ### test Webhook Example Source: https://github.com/saasquatch/saasquatch-docs/blob/production/content/api/webhooks.md This webhook is used to test a subscription. It sends a sample payload to the configured endpoint. ```json { "id": "1337049u0194u2105", "type": "test", "tenantAlias": "AAA111BBB222DDD333", "live": false, "created": 1337001337, "data": { "endpointUrl": "http://example.com/hook", "name": "Example" } } ``` -------------------------------- ### theme.publish.finished Webhook Example Source: https://github.com/saasquatch/saasquatch-docs/blob/production/content/api/webhooks.md This webhook is sent after a theme has been successfully published to a tenant. It contains information about the new assets version. ```json { "id": "577407a6e4b0cc57c1e2e6a6", "type": "theme.publish.finished", "tenantAlias": "aohgcctyskc0p", "live": true, "created": 1467221926388, "data": { "newAssetsVersion": "CQOkemZF" } } ``` -------------------------------- ### titleMarginStart Source: https://github.com/saasquatch/saasquatch-docs/blob/production/public/mobile/android/docs/com/referralsaasquatch/sampleapp/R.attr.html Sets the start margin for the title. Must be a dimension value (e.g., '14.5sp'). ```APIDOC ## titleMarginStart ### Description Sets the start margin for the title. ### Type Dimension value (e.g., '14.5sp'). ``` -------------------------------- ### Get Account Reward API Response Source: https://github.com/saasquatch/saasquatch-docs/blob/production/content/guides/pctDiscountGuide.md Example response when looking up account reward details. This includes the discount percentage applicable to the customer. ```json { "accountId":"SV0TYE5OWI11120144", "discountPercentage":20, "referrerDiscountPercent":10, "referredDiscountPercent":10 } ``` -------------------------------- ### Initialize Podfile Source: https://github.com/saasquatch/saasquatch-docs/blob/production/content/articles/mobile-ios-quickstart.md Create a Podfile in your Xcode project directory if one does not already exist. ```bash pod init ``` -------------------------------- ### init Source: https://github.com/saasquatch/saasquatch-docs/blob/production/content/articles/developer-squatchjs-v2-reference.md Initializes the static `squatch` global, setting up static instances for `squatch.api()` and `squatch.widgets()`. ```APIDOC ## init Initializes the static `squatch` global. This sets up: - `squatch.api()` a static instance of the [WidgetApi](#widgetapi) - `squatch.widgets()` a static instance of [Widgets](#widgets) ### Properties - `tenantAlias` (string) - The Tenant that you're using. - `domain` (string) - The domain for API. Defaults to `https://app.referralsaasquatch.com` ### Request Example ```javascript squatch.init({tenantAlias:'test_basbtabstq51v'}); ``` ### Returns - `void` ``` -------------------------------- ### View SaaSquatch CLI Help Source: https://github.com/saasquatch/saasquatch-docs/blob/production/content/articles/themes-publish.md Access the help documentation for the `squatch` CLI to see available commands and options. ```bash squatch --help ``` -------------------------------- ### referral.started Webhook Example (Classic) Source: https://github.com/saasquatch/saasquatch-docs/blob/production/content/api/webhooks.md This webhook is sent when a new referral is successfully established in the classic system. It includes detailed referral and moderation status information. ```json { "id": "5773073fe4b066c5cb171900", "type": "referral.started", "tenantAlias": "aohgcctyskc0p", "live": true, "created": 1467156287085, "data": { "id": "5773073ee4b066c5cb1718fc", "referredUser": "5773073ee4b08b14ab979fb8", "referrerUser": "577306eae4b08b14ab979f70", "referred": { "id": "5773073ee4b08b14ab979fb8", "accountId": "5773073ee4b08b14ab979fb8" }, "referrer": { "id": "577306eae4b08b14ab979f70", "accountId": "577306eae4b08b14ab979f70" }, "referralCodeUsed": "LORETTABURKE10", "shareLinkUsed": "http://ssqt.co/mPbcF5", "moderationStatus": "PENDING", "dateReferralStarted": 1467156286882, "dateReferralPaid": null, "dateConverted": null, "dateReferralEnded": null, "dateModerated": 1467156286882, "referredModerationStatus": "PENDING", "referrerModerationStatus": "PENDING", "fraudSignals": null } } ``` -------------------------------- ### Tab Padding Start Source: https://github.com/saasquatch/saasquatch-docs/blob/production/public/mobile/android/docs/com/wholepunk/saasquatch/R.attr.html Defines the start padding for the tabs. Accepts dimension values with various units. ```APIDOC ## tabPaddingStart ### Description Defines the start padding for the tabs. This attribute accepts a dimension value, which is a floating-point number appended with a unit such as "14.5sp". Available units include px, dp, sp, in, and mm. It can also be a reference to a resource or theme attribute. ### Type Dimension value or resource reference ``` -------------------------------- ### Initialize WidgetApi in Browser Source: https://github.com/saasquatch/saasquatch-docs/blob/production/content/articles/developer-squatchjs-v2-reference.md Instantiates the WidgetApi for browser environments, requiring only the tenant alias. ```javascript var squatchApi = new squatch.WidgetApi({tenantAlias:'test_12b5bo1b25125'}); ``` -------------------------------- ### Create a Referred Account Source: https://github.com/saasquatch/saasquatch-docs/blob/production/content/guides/pctDiscountGuide-nojs.md Use the Account Sync API to create a new account and include the referral code to link it to the referrer. Set the subscription status, for example, to 'TRIAL' for new signups. ```bash $ curl -X POST https://app.referralsaasquatch.com/api/v1/{tenant_alias}/accountsync \ -u API_KEY: \ -H "Content-Type: application/json" \ -d '{ "id": "def456", "subscription": { "status": "TRIAL" }, "referral": { "code": "SUPERBOB" } }' ``` -------------------------------- ### Example Message Link URL Source: https://github.com/saasquatch/saasquatch-docs/blob/production/content/articles/features-message-links.md An example of a fully constructed message link for a user sharing via email on mobile for the 'klip-referral-program'. ```curl https://app.referralsaasquatch.com/a/test_aut32av0b11uc/message/redirect/EMAIL?engagementMedium=MOBILE&accountId=messageLink&userId=messageLink&programId=klip-referral-program ``` -------------------------------- ### Legacy Deep Linking Data Example Source: https://github.com/saasquatch/saasquatch-docs/blob/production/content/articles/mobile-appsflyer.md Example JSON payload for Legacy Deep Linking, including referral code and share link. ```json { "pid": "saasquatch_int", "c": "saasquatch", "af_web_dp": "http://myReferralLandingPage.com", "utm_source": "invite", "utm_medium": "link", "utm_campaign": "saasquatch", "rsCode": "REFERRALCODE", "rsShareMedium": "UNKNOWN", "rsEngagementMedium": "UNKNOWN", "_saasquatch": "eyJhcHAucmVmZXJyYWxzYWFzcXVhdGNoLmNvbSI6eyJ0ZXN0XzEyMzQ1NjdfQ09ERSI6eyJjb2RlcyI6eyJyZWZlcnJhbCI6IlJFRkVSUkFMQ09ERSJ9LCJjb2Rlc0V4cCI6eyJSRUZFUlJBTENPREUiOjE2Mjk1ODIxOTl9LCJsaW5rcyI6eyJyZWZlcnJhbCI6Imh0dHBzOi8vc3NxdC5jby9temFBMjIifSwibGlua3NFeHAiOnsiaHR0cHM6Ly9zc3F0LmNvL216YUEyMiI6MTYyOTU4MjE5OX19fX0=" } ``` -------------------------------- ### Initialize Squatch.js with Account Status Source: https://github.com/saasquatch/saasquatch-docs/blob/production/content/guides/conversion.md Use this to initialize Squatch.js and trigger a conversion by setting the account_status to 'PAID'. Omit account_status if using payment system connectors. ```javascript _sqh.push(['init', { tenant_alias: 'test_bpinhag9yagag', account_id: 'abc', payment_provider_id: null, user_id: '5678', email: 'bob@example.com', first_name: 'John', // account_status: 'PAID' // Include the value "PAID" to trigger a conversion. Omit it if you're using a payment system connectors like Stripe and Recurly. }]); ``` -------------------------------- ### referral.started Webhook Example (GA) Source: https://github.com/saasquatch/saasquatch-docs/blob/production/content/api/webhooks.md This webhook is sent when a new referral is successfully established in the GA (non-classic) system. It includes basic referral details. ```json { "id": "5773073fe4b066c5cb171900", "type": "referral.started", "tenantAlias": "aohgcctyskc0p", "live": true, "created": 1467156287085, "data": { "id": "5773073ee4b066c5cb1718fc", "referred": { "id": "5773073ee4b08b14ab979fb8", "accountId": "5773073ee4b08b14ab979fb8" }, "referrer": { "id": "577306eae4b08b14ab979f70", "accountId": "577306eae4b08b14ab979f70" }, "referralCodeUsed": "LORETTABURKE10", "shareLinkUsed": "http://ssqt.co/mPbcF5", "moderationStatus": "PENDING", "dateReferralStarted": 1467156286882, "dateConverted": null } } ``` -------------------------------- ### Unified Deep Linking Data Example Source: https://github.com/saasquatch/saasquatch-docs/blob/production/content/articles/mobile-appsflyer.md Example JSON payload for Unified Deep Linking, including referral code and share link. ```json { "pid": "saasquatch_int", "c": "saasquatch", "af_web_dp": "http://myReferralLandingPage.com", "deep_link_sub1": "eyJhcHAucmVmZXJyYWxzYWFzcXVhdGNoLmNvbSI6eyJ0ZXN0XzEyMzQ1NjdfQ09ERSI6eyJjb2RlcyI6eyJyZWZlcnJhbCI6IlJFRkVSUkFMQ09ERSJ9LCJjb2Rlc0V4cCI6eyJSRUZFUlJBTENPREUiOjE2Mjk1ODIxOTl9LCJsaW5rcyI6eyJyZWZlcnJhbCI6Imh0dHBzOi8vc3NxdC5jby9temFBMjIifSwibGlua3NFeHAiOnsiaHR0cHM6Ly9zc3F0LmNvL216YUEyMiI6MTYyOTU4MjE5OX19fX0=", "deep_link_sub2": "invite", "deep_link_sub3": "link", "deep_link_sub4": "saasquatch", "deep_link_sub5": "REFERRALCODE", "deep_link_sub6": "UNKNOWN", "deep_link_sub7": "UNKNOWN" } ``` -------------------------------- ### Initialize Widgets Instance (Browser) Source: https://github.com/saasquatch/saasquatch-docs/blob/production/content/articles/developer-squatchjs-v2-reference.md Instantiate the `Widgets` class in a browser environment by providing your `tenantAlias`. This is the standard way to begin using SaaSquatch widgets. ```javascript var widgets = new squatch.Widgets({tenantAlias:'test_12b5bo1b25125'}); ``` -------------------------------- ### Example Personalized Mobile Widget URL Source: https://github.com/saasquatch/saasquatch-docs/blob/production/content/articles/mobile-widget-reference.md A complete example of a personalized URL for the Mobile Widget, combining base URL and encoded parameters. ```nohighlight https://app.referralsaasquatch.com/a/test_345gh4545g23kj3/widgets/mobilewidget?userId=123&firstName=Bob&lastName=Testserson&accountId=abc&paymentProviderId=NULL&email=misterd%2Bmuser001%40example.com&checksum={{calculated_JWT}} ``` -------------------------------- ### Render Widget for Classic Referral Programs Source: https://github.com/saasquatch/saasquatch-docs/blob/production/content/articles/developer-squatchjs-v2-reference.md An example of rendering a widget for classic referral programs using the `squatch.widgets().render` method. This includes user details, engagement medium, widget type, and an optional JWT for validation. The promise resolves with widget and user details or rejects with an error. ```javascript var initObj = { user: { id: 'abc_123', accountId: 'abc_123' }, engagementMedium: 'EMBED', widgetType: 'REFERRER_WIDGET', jwt: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7ImlkIjoiYWJjXzEyMyIsImFjY291bnRJZCI6ImFiY18xMjMifX0.Sor56NRtkKqZKLLOy8177bFee5ukiS2-__R1s34KNOE' }; squatch.widgets().render(initObj).then(function(response) { user = response.user; }).catch(function(error){ console.log(error); }); ``` -------------------------------- ### Segment Identify Event Body Example Source: https://github.com/saasquatch/saasquatch-docs/blob/production/content/articles/integrations-segment-v2-subscription.md Example of an Identify event body received from Segment, used for user upserts and segment transformations in SaaSquatch. ```json { "messageId": "test-message-rxya2", "timestamp": "2021-01-12T22:28:04.947Z", "type": "identify", "email": "test@example.org", "projectId": "nczL0it7lw", "traits": { "trait1": 1, "trait2": "test", "trait3": true }, "userId": "test-user-524utb" } ``` -------------------------------- ### Example SaaSquatch Web Component Source: https://github.com/saasquatch/saasquatch-docs/blob/production/content/articles/developer-widgets-writing-a-web-component-for-saasquatch.md This is an example of a SaaSquatch web component for a share link with a copy button. It demonstrates how custom components are represented in HTML. ```html ``` -------------------------------- ### Email Referral Started Webhook Source: https://github.com/saasquatch/saasquatch-docs/blob/production/content/api/webhooks.md Sent when a new referral connection is established. It provides details about the recipient and the email content for the referral start notification. ```json { "id": "1337049u0194u2105", "type": "email.referral.started", "tenantAlias": "AAA111BBB222DDD333", "live": false, "created": 1337001337, "data": { "recipientUserId": "u1234", "recipientAccountId": "a1234", "subject": "Congratulations! Susy Example signed up for a trial account.", "message": "<p>This is rendered HTML content.</p>", "mergeVars": null } } ``` -------------------------------- ### Initialize SaaSquatch with Tenant Alias Source: https://github.com/saasquatch/saasquatch-docs/blob/production/content/articles/guides-instapage-form.md Configure SaaSquatch.js for your referral program's tenant. Use a test tenant alias during development. ```javascript squatch.init({ tenantAlias: 'test_ae7bygqkh9gag' }); ``` -------------------------------- ### Example Webhook Request Headers and Body Source: https://github.com/saasquatch/saasquatch-docs/blob/production/content/articles/api-webhooks-security.md This example shows the typical headers and JSON body of a webhook request sent by SaaSquatch, including the JWS signature. ```http Accept-Encoding: gzip,deflate,br Content-Type: application/json; charset=UTF-8 Content-Length: 543 Connection: keep-alive X-Hook-JWS-RFC-7797: eyJraWQiOiIzZDMxM2JjOC1hYjNiLTRmM2MtYWJiNy0zN2I4NGE0MmQwZGEiLCJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9..DQfCOrdudxqz4r7uiCAhyKIi4bGZignWmr1ct_7Bf6DXmgwUciQJaQTvYffc5lni9K6DqclQG0cfI6X5pqceeFays1_atEP-bsN6w_0krjKg72rcVHKecgEOlFNhsF0xfYdjoY-5z-tpzpjOU1QBKOl7eE8K9AkCL5FDg6Huu26Ov1TcmEGhNMSN7UW0zBNXvNsjeRfO57dKgtA-6wyl3TUcsxYsz81Q3Og0dprMfNBr-bcqvs4aHUUxLmU013RYXAdQmK395NvN54YJniZcsy8svF1THExp4WkmOw9WmX_kHUhsvadTegAI4PbGYx9h1xIcdV_IrfuzUV1Ta9WfKg X-Hook-Signature: h2JX9dV4o1r2sJypeVBIWOqW0as= { "id": "5dfaadc9d132f00f8b742288", "type": "reward.created", "tenantAlias": "a5kz4dlxt403z", "live": true, "created": 1576709577227, "data": { "type": "CREDIT", "id": "577405e3e4b0cc57c1e2e684", "dateCreated": 1467221475151, "dateScheduledFor": null, "dateGiven": 1467221475151, "dateExpires": 1475170275151, "dateCancelled": null, "accountId": "6UTR8OQZX0HE3QBP", "userId": "56f2e6a9e4b08a1cbef6c561", "cancellable": true, "rewardSource": "FRIEND_SIGNUP", "programId": null, "unit": "%", "assignedCredit": null, "redeemedCredit": null, "name": null, "currency": null, "redemptions": null } } ``` -------------------------------- ### Reference Manually Installed SDK in Module Source: https://github.com/saasquatch/saasquatch-docs/blob/production/content/articles/mobile-android-quickstart.md Reference the manually imported SaaSquatch SDK module in your module's build.gradle file after completing the manual installation steps. ```gradle // ... dependencies { // ... compile project(':saasquatch-sdk-android-1.1.0') } ``` -------------------------------- ### Notify SaaSquatch of Account Change (Cancellation Example) Source: https://github.com/saasquatch/saasquatch-docs/blob/production/content/guides/pctDiscountGuide.md This example demonstrates how to use the SaaSquatch API to notify the system about an account cancellation, which helps in automatically adjusting referral discounts. ```APIDOC ## POST /api/v1/TENANT_ALIAS/accountsync ### Description Notifies SaaSquatch of an account change, such as a cancellation, upgrade, or downgrade. This is crucial for updating referral discount information. ### Method POST ### Endpoint /api/v1/TENANT_ALIAS/accountsync ### Request Body - **id** (string) - Required - The unique identifier for the account. - **currency** (string) - Required - The currency used for the account. - **subscription** (object) - Required - Details about the account's subscription. - **status** (string) - Required - The current status of the subscription (e.g., "CANCELLED"). - **value** (number) - Required - The monetary value of the subscription. - **billingIntervalType** (string) - Required - The type of billing interval (e.g., "DAY"). - **billingIntervalValue** (number) - Required - The value of the billing interval. - **referral** (object) - Optional - Referral information. - **code** (string) - Required - The referral code associated with the account. ### Request Example ```json { "id": "SV0TYE5OWI11120144", "currency": "USD", "subscription": { "status": "CANCELLED", "value": 99.99, "billingIntervalType": "DAY", "billingIntervalValue": 30 }, "referral": { "code": "3j033r" } } ``` ### Response #### Success Response (200) - **id** (string) - The unique identifier for the account. - **currency** (string) - The currency used for the account. - **subscription** (object) - Details about the account's subscription. - **status** (string) - The current status of the subscription. - **value** (number) - The monetary value of the subscription. - **billingIntervalType** (string) - The type of billing interval. - **billingIntervalValue** (number) - The value of the billing interval. - **referral** (object) - Referral information. - **code** (string) - The referral code associated with the account. #### Response Example ```json { "id": "SV0TYE5OWI11120144", "currency": "USD", "subscription": { "status": "CANCELLED", "value": 99.99, "billingIntervalType": "DAY", "billingIntervalValue": 30 }, "referral": { "code": "3j033r" } } ``` ``` -------------------------------- ### Initialize Squatch.js Source: https://github.com/saasquatch/saasquatch-docs/blob/production/content/articles/developer-squatchjs-v2-reference.md Initializes the static squatch global with your tenant alias and optionally a custom domain. This must be called before using other squatch functions. ```javascript squatch.init({tenantAlias:'test_basbtabstq51v'}); ``` -------------------------------- ### Segment analytics.js Identify Method Example Source: https://github.com/saasquatch/saasquatch-docs/blob/production/content/articles/developer-segment.md This example demonstrates the basic structure of the Segment analytics.js identify method when integrating with SaaSquatch. Ensure your tenantAlias is configured in the Segment portal. ```javascript analytics.identify( "userId", { /* PARAMETERS GO HERE */ }, { integrations: { SaaSquatch: { checksum: null, }, }, }, ); ``` -------------------------------- ### Initialize squatch.js with JWT Source: https://github.com/saasquatch/saasquatch-docs/blob/production/content/articles/topics-json-web-tokens.md Configure squatch.js and upsert a user with the provided JWT. Ensure the JWT is correctly formatted and included in the init object. ```javascript window.squatch.ready(function(){ //configure squatch.js for the tenant you are using squatch.init({ tenantAlias: 'test_abzxg88g30tn2' }); //object containing the init parameters for squatch.js var initObj = { //the object for the user you want to upsert user: { id: 'abc_123', accountId: 'abc_123', email: 'john@example.com', firstName: 'John', lastName: 'Doe', referable: false }, engagementMedium: 'EMBED', widgetType: 'REFERRER_WIDGET', jwt: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7ImlkIjoiYWJjXzEyMyIsImFjY291bnRJZCI6ImFiY18xMjMiLCJlbWFpbCI6ImpvaG5AZXhhbXBsZS5jb20iLCJmaXJzdE5hbWUiOiJKb2huIiwibGFzdE5hbWUiOiJEb2UiLCJyZWZlcmFibGUiOmZhbHNlfX0.ZomcuXZxyI1vhf94q2ipByj6WVMsik1OgLxaDBke0Pg' }; squatch.widgets().upsertUser(initObj).then(function(response) { user = response.user; }).catch(function(error){ console.log(error); }); }); ``` -------------------------------- ### Publish a Theme using SaaSquatch CLI Source: https://github.com/saasquatch/saasquatch-docs/blob/production/content/articles/themes-publish.md Publish a custom theme to a specific tenant using the `squatch publish` command. Ensure you have the correct tenant alias and API key. ```bash squatch publish -t test_alu125hh1si9w -k TEST_BHASKh5125Las5hL125oh3VbLmPxUSs ``` -------------------------------- ### Get Account Reward Source: https://github.com/saasquatch/saasquatch-docs/blob/production/content/guides/pctDiscountGuide.md Use the Get Account Reward method to look up the discount percentage for a new paying user. This call does not change the state of an account and can be used to update prices on the payment page. ```APIDOC ## Get Account Reward ### Description Retrieves the discount percentage associated with an account, including referrer and referred discounts. This can be used during signup or billing runs to apply referral credits. ### Method GET ### Endpoint /api/v1/{TENANT_ALIAS}/account/{ACCOUNTID}/reward ### Parameters #### Query Parameters - **couponCode** (string) - Optional - The coupon code to validate. ### Request Example ```bash $ curl https://app.referralsaasquatch.com/api/v1/{TENANT_ALIAS}/account/{ACCOUNTID}/reward \ -u {API_KEY}: \ -H "Content-Type: application/json" ``` ### Response #### Success Response (200) - **accountId** (string) - The ID of the account. - **discountPercentage** (integer) - The total discount percentage. - **referrerDiscountPercent** (integer) - The discount percentage for the referrer. - **referredDiscountPercent** (integer) - The discount percentage for the referred user. #### Response Example ```json { "accountId":"SV0TYE5OWI11120144", "discountPercentage":20, "referrerDiscountPercent":10, "referredDiscountPercent":10 } ``` ``` -------------------------------- ### Initialize Widget.js Event Bus Source: https://github.com/saasquatch/saasquatch-docs/blob/production/content/theming/widgetjs.md Use the `ready` method to execute code once the event bus has loaded and is ready to accept publish requests. It takes an anonymous JavaScript function as an argument. ```javascript widget.rpc.ready(function() { /* code to execute now the event bus has initialized */ }); ``` -------------------------------- ### CollapsingToolbarLayout_expandedTitleMarginStart Source: https://github.com/saasquatch/saasquatch-docs/blob/production/public/mobile/android/docs/com/wholepunk/saasquatch/R.styleable.html Sets the start margin for the expanded title. ```APIDOC ## CollapsingToolbarLayout_expandedTitleMarginStart ### Description This symbol is the offset where the `R.attr.expandedTitleMarginStart` attribute's value can be found in the `CollapsingToolbarLayout` array. ``` -------------------------------- ### useCompatPadding Source: https://github.com/saasquatch/saasquatch-docs/blob/production/public/mobile/android/docs/com/wholepunk/saasquatch/R.attr.html Enables compatibility padding. Must be a boolean value. ```APIDOC ## useCompatPadding ### Description Must be a boolean value, either "true" or "false". ### Type Boolean ``` -------------------------------- ### getInstance() Source: https://github.com/saasquatch/saasquatch-docs/blob/production/public/mobile/android/docs/com/referralsaasquatch/sampleapp/User.html Static method to get an instance of the User class. ```APIDOC ## getInstance() ### Description Static method to retrieve an instance of the User class. ### Method `public static User getInstance()` ``` -------------------------------- ### squatch.ready() Source: https://github.com/saasquatch/saasquatch-docs/blob/production/content/articles/developer-squatchjs-v2-reference.md Ensures that Squatch.js is ready to make operations. It accepts a callback function that will be executed once the SDK is initialized and ready. ```APIDOC ## ready() ### Description Checks if Squatch.js is ready to perform operations and executes a callback function once it is. ### Parameters #### Path Parameters - `fn` (function) - Required - A callback function to be executed once Squatch.js is ready. ### Request Example ```javascript squatch.ready(function() { console.log("ready!"); squatch.api().upsertUser(); }); ``` ### Response #### Success Response (void) This method does not return a value. ``` -------------------------------- ### Initialize Segment Analytics.js Source: https://github.com/saasquatch/saasquatch-docs/blob/production/content/articles/developer-segment-quickstart.md Basic setup for Segment's Analytics.js library. Replace YOUR_WRITE_KEY with your actual Segment write key. This script initializes the library and tracks the initial page view. ```javascript