# Tiers

# Fetching a single Point Balance's Tier

# Route

Use the following GET route to get all point allotments for a specific customer.

GET https://loyalty.slrs.io/api/shopify/point_balances/:shopify_customer_id/tier

The :shopify_customer_id references the customer's id on Shopify.

For example, in https://admin.shopify.com/store/{store_domain}/customers/1234567890, 1234567890 is the Shopify customer's id.

# Arguments

# Required Parameters

None

# Optional Parameters

None

# Returns

This route returns the following data:

Key Type Definition
amount Integer The amount of points required for the given tier
currency String The currency code for the shop
deadline Timestamp An ISO8601 timestamp, the deadline for the tier system
raw_amount Integer The amount of un-normalized points needed for the given tier
tier_name String The name of the tier
tier_uid String The internal easyPoints id for the tier

# Example

Example request and result:

curl -X GET \
 'https://loyalty.slrs.io/api/shopify/point_balances/1234567890/tier' \
-H 'content-type: application/json' \
-H 'authorization: Basic ${API_CREDENTIALS}'
{
  "data": {
    "advancement_data": {
      "amount": "2000",
      "currency": "JPY",
      "deadline": "2023-01-01T00:00:00Z",
      "raw_amount": 2000,
      "spent_requirement": {
        "amount": "2000",
        "currency": "JPY",
        "raw_amount": 2000
      },
      "tier_name": "Silver ",
      "tier_uid": "08eeb334-df4d-11ed-ba1e-787b8aae8c7a",
      "tiers": [
        {
          "amount": "2000",
          "currency": "JPY",
          "name": "Silver ",
          "ratio": 0.03,
          "raw_amount": 2000,
          "spent_requirement": {
            "amount": "2000",
            "currency": "JPY",
            "raw_amount": 2000
          },
          "uid": "08eeb334-df4d-11ed-ba1e-787b8aae8c7a"
        }
      ]
    },
    "id": "6757085806881",
    "maintenance_data": {
      "amount": "1000",
      "currency": "JPY",
      "deadline": "2023-01-01T00:00:00Z",
      "raw_amount": 1000,
      "spent_requirement": {
        "amount": "1000",
        "currency": "JPY",
        "raw_amount": 1000
      }
    },
    "minimum_tier": "Bronze",
    "skip_next_check": false,
    "tier": "Bronze",
    "tier_uid": "dd5cc1f2-df4c-11ed-8376-787b8aae8c7a"
  }
}

# Updating a single Point Balance's Tier

# Route

Use the following POST route to update the tier for a single customer.

POST https://loyalty.slrs.io/api/shopify/point_balances/:customer_shopify_id/tiers

# Arguments

# Required Arguments

* Not all three are required. At least one of tier, minimum_tier, or skip_next_check must be specified

Key Type Definition
tier String The tier the customer will be placed in
minimum_tier String The customer will never be demoted below this rank automatically
skip_next_check Boolean Skip next automatic tier designation
# Skip Next Check

If skip_next_check is set to true, the next automatic tier update will be skipped for the given customer. The can be useful if, for example, you manually set the tier near the end of a rank up period and want the setting to carry over into the following rank up period.

The value is false by default which means this customer's tier will be designated alongside all other customers during the next automatic designation. This is likely to be useful if, for example, you set the tier near the start of a rank up period.

# Optional Arguments

None

# Returns

This route returns the following data:

Key Type Definition
id String The Shopify ID of the customer
tier String The tier the customer will be placed in
minimum_tier String The customer will never be demoted below this rank automatically
skip_next_check Boolean Skip next automatic tier designation [default false]

# Examples

# Example 1

Example request to set customer 123 as a Silver tier customer and the response:

# Request
curl -X POST \
 'https://loyalty.slrs.io/api/shopify/point_balances/123/tiers' \
-H 'content-type: application/json' \
-H 'authorization: Basic ${API_CREDENTIALS}' \
-d '{
  "tier": "silver"
}'
# Response
{
  "data": {
    "id": "123",
    "tier": "silver",
    "minimum_tier": null,
    "skip_next_check": false
  }
}

# Example 2

Example request to set customer 123 as a Gold tier customer with a minimum tier of silver, skipping the next check, and the response:

# Request
curl -X POST \
 'https://loyalty.slrs.io/api/shopify/point_balances/123' \
-H 'content-type: application/json' \
-H 'authorization: Basic ${API_CREDENTIALS}' \
-d '{
  "tier": "gold",
  "minimum_tier": "silver",
  "skip_next_check": true
}'
# Response
{
  "data": {
    "id": "123",
    "tier": "gold",
    "minimum_tier": "silver",
    "skip_next_check": true
  }
}