Promotions


Promotions let you fetch special offers for your customers. The offers must first be configured in app.synerise.com.

Loyalty and promotions
Loyalty and promotions

Basic implementation

The example below is the most basic implementation and retrieves all promotions, without any parameters to filter them.

IDataApiCall<PromotionResponse> apiCall = Promotions.getPromotions();
        apiCall.execute(onSuccess, showAlertError);

Additional query options

The table explains the filtering options available when fetching promotions.

Property Type Default Description
statuses List<PromotionStatus> [] List of statuses for query
types List<PromotionType> [] List of types for query
sortParameters LinkedHashMap<PromotionSortingKey, ApiQuerySortingOrder> [] Specifies sorting rules for items in the response
limit int 100 Limit of items per page in the response
page int 1 Page number
includeMeta boolean false Specifies if meta data should be included in the response

Promotion status

  • ACTIVE - promotion is activated by the customer.
  • ASSIGNED - promotion is assigned to a customer and visible to them.
  • REDEEMED - promotion is redeemed and finished for the customer.

Constants in the SDK correlated with promotion statuses:

  • ACTIVE
  • ASSIGNED
  • REDEEMED

These constants should be used when you retrieve promotions by using the PromotionsApiQuery object.

Promotion type

  • GENERAL - promotions are available to all customers.
  • MEMBERS_ONLY - promotions are available to customers who joined a loyalty program.
  • CUSTOM - custom promotions are a category that has custom configuration, tailored for chosen customers.

Constants in the SDK correlated with promotion types:

  • GENERAL
  • MEMBERS_ONLY
  • CUSTOM

These constants should be used when you retrieve promotions by using the SNRPromotionsApiQuery object.

Promotion sorting options

You can set an array of sorting options. Each sorting option is a key-value pair.
The key is the sorting key constant and the value is the sorting order.

Promotion-related sorting constants:

  • EXPIRE_AT - time when the promotion expires
  • CREATED_AT - time when the promotion was created
  • LASTING_AT - time when the promotion stops being active for the customer
  • REQUIRE_REDEEMED_POINTS - how many loyalty points are needed to redeem the promotion
  • UPDATED_AT - time when the promotion was last updated
  • TYPE - type of the promotion
  • PRIORITY - priority of the promotion

You can sort each of the above ascending or descending by using the values:

  • ASCENDING
  • DESCENDING

You can add a number of key-value pairs for sorting.

Parameterized implementation

First, configure the PromotionsApiQuery object. Then you can use it in an SDK method.

Important: Getting promotions using the PromotionsApiQuery is best way to achieve it. Parameterized methods in the SDK are deprecated.
List<PromotionStatus> statuses = new ArrayList<>();
        if (activeBox.isChecked()) statuses.add(PromotionStatus.ACTIVE);
        if (assignedBox.isChecked()) statuses.add(PromotionStatus.ASSIGNED);
        if (redeemedBox.isChecked()) statuses.add(PromotionStatus.REDEEMED);

        List<PromotionType> types = new ArrayList<>();
        if (generalBox.isChecked()) types.add(PromotionType.GENERAL);
        if (customBox.isChecked()) types.add(PromotionType.CUSTOM);
        if (membersOnlyBox.isChecked()) types.add(PromotionType.MEMBERS_ONLY);

PromotionsApiQuery query = new PromotionsApiQuery();
            query.limit = 100;
            query.statuses = statuses;
            query.types = types;
            query.page = page;
            query.includeMeta = includeButton.isChecked();
            LinkedHashMap<PromotionSortingKey, ApiQuerySortingOrder> sortParams = new LinkedHashMap<>();
            sortParams.put(PromotionSortingKey.TYPE, ApiQuerySortingOrder.ASCENDING);
            sortParams.put(PromotionSortingKey.CREATED_AT, ApiQuerySortingOrder.ASCENDING);
            sortParams.put(PromotionSortingKey.EXPIRE_AT, ApiQuerySortingOrder.DESCENDING);
            query.setSortParameters(sortParams);
            IDataApiCall<PromotionResponse> apiCall = Promotions.getPromotions(query);
            apiCall.execute(onSuccess, new DataActionListener<ApiError>() {
                @Override
                public void onDataAction(ApiError apiError) {
                   // error handling
                }
            });

Working with a single promotion

In addition to retrieve all promotions or a filtered list, you can retrieve a single promotion.

You retrieve get a single promotion by:

  • UUID of the promotion
  • Code of the promotion

These are the basic identity properties for a promotion. Thanks to them, you can activate and deactivate single promotions too.

Note: The method reference for promotions is available in this section.
😕

We are sorry to hear that

Thank you for helping improve out documentation. If you need help or have any questions, please consider contacting support.

😉

Awesome!

Thank you for helping improve out documentation. If you need help or have any questions, please consider contacting support.

Close modal icon Placeholder alt for modal to satisfy link checker