@subhubapps/store-sdk v0.2.1
store-sdk
SubHub's Typescript/Javascript SDK for Merchant Stores
Installation
Install the package
npm install @subhubapps/store-sdk
# OR
yarn add @subhubapps/store-sdk
Usage
- Instantiate the SubHub Referral Client
import { Referrals } from '@subhubapps/store-sdk'
// accountUuid can be obtained from your SubHub Dashboard -> Settings -> Store
// or it is available in Shopify Liquid through `shop.metafields.subhub.account_uuid`
// ambassadorPortalUrl is the your SubHub Ambassador Portal URL like `mybrand.subhubapps.com`
const subHubReferrals = new Referrals(accountUuid, ambassadorPortalUrl)
- Get Ambassador's Info
// customerSubHubUuid - can be obtained in Shopify Liquid as `customer.metafields.subhub.sh_uuid
subHubReferrals.getCustomerReferralInfo(customerSubHubUuid) // Returns a promise that fetches ambassador's data if ambassador has joined the program, otherwise returns undefined
Example Response:
{
"name": "John Smith",
"paymentAmountLifetime": 234.5,
"paymentAmount30Days": 130.4,
"orderCount": 19,
"unpaidBalance": 45.4,
"tierName": "Gold",
"defaultDiscountCode": "JSMITH20",
"qrCodeUrl": "https://imgs.com/qr_code.png",
"discountCodeApplicationUrl": "https://myrefl.ink/v/JSMITH20",
"discountAmountType": "percentage",
"discountAmount": 20,
"commissionAmount": 10,
"commissionAmountType": "percentage",
"createdAt": "2023-01-12T17:53:19-08:00"
}
- Get Ambassador Sign up URL
If the customer has not yet joined the Ambassador program:
// Initiate customer signup
<button onClick={() => subHubReferrals.initiateCustomerSignup(shopifyCustomerId)}>Join Now</button>
// OR generate the Sign Up URL
<a href={subHubReferrals.getCustomerSignupUrl(shopifyCustomerId)}>Join Now</a>
- Get Ambassador Login URL
If the customer has already signed up with the Ambassador Program
// Initiate customer login
// customerSubHubUuid - can be obtained in Shopify Liquid as `customer.metafields.subhub.sh_uuid
<button onClick={() => subHubReferrals.initiateCustomerLogin(shopifyCustomerId, customerSubHubUuid)}>View Dashboard</button>
// OR generate the Login URL
<a href={subHubReferrals.getCustomerLoginUrl(shopifyCustomerId, customerSubHubUuid)}>View Dashboard</a>
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
7 months ago
7 months ago
7 months ago
7 months ago
11 months ago
11 months ago
9 months ago
10 months ago
9 months ago
10 months ago
10 months ago
10 months ago
10 months ago
11 months ago
1 year ago
1 year ago
1 year ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago