0.2.1 • Published 3 months ago

@subhubapps/store-sdk v0.2.1

Weekly downloads
-
License
UNLICENSED
Repository
github
Last release
3 months ago

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

  1. 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)
  1. 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"
}
  1. 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>
  1. 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>
0.2.1

3 months ago

0.1.14

3 months ago

0.1.15

3 months ago

0.2.0

3 months ago

0.1.16

3 months ago

0.1.17

3 months ago

0.1.10

7 months ago

0.1.11

7 months ago

0.1.12

7 months ago

0.1.13

7 months ago

0.1.2

11 months ago

0.1.1

11 months ago

0.1.8

9 months ago

0.1.7

10 months ago

0.1.9

9 months ago

0.1.4

10 months ago

0.1.3

10 months ago

0.1.6

10 months ago

0.1.5

10 months ago

0.1.0

11 months ago

0.0.40

1 year ago

0.0.41

1 year ago

0.0.42

1 year ago

0.0.43

12 months ago

0.0.44

12 months ago

0.0.45

12 months ago

0.0.46

12 months ago

0.0.47

12 months ago

0.0.51

12 months ago

0.0.50

12 months ago

0.0.48

12 months ago

0.0.49

12 months ago

0.0.30

1 year ago

0.0.31

1 year ago

0.0.20

1 year ago

0.0.32

1 year ago

0.0.21

1 year ago

0.0.33

1 year ago

0.0.22

1 year ago

0.0.34

1 year ago

0.0.23

1 year ago

0.0.35

1 year ago

0.0.24

1 year ago

0.0.36

1 year ago

0.0.25

1 year ago

0.0.37

1 year ago

0.0.26

1 year ago

0.0.27

1 year ago

0.0.28

1 year ago

0.0.29

1 year ago

0.0.18

1 year ago

0.0.19

1 year ago

0.0.17

1 year ago

0.0.16

1 year ago