Method reference

Public Interfaces

IDataApiCall


IDataApiCall is a public interface used to execute requests with parameterized objects.

Java:

public interface IDataApiCall<T> {
/**
     * It is recommended to call the {@link #cancel()} method before next execution.
     *
     * @param onSuccessListener callback with response
     * @param onFailureListener callback with Throwable instance
     */
    void execute(@NonNull DataActionListener<T> onSuccessListener, @NonNull DataActionListener<ApiError> onFailureListener);
    /**
     * Cancels the API request, therefore no response will be provided nor callback fired. <br>
     * It is recommended to call this method when an activity/fragment is being stopped.
     */
    void cancel();
    /**
     * Specify a reactive Scheduler for your request. <br>
     * By default, all internal methods use the {@link Schedulers#io()} scheduler.
     * See {@link io.reactivex.schedulers.Schedulers} factory for more info.
     *
     * @param scheduler reactive scheduler.
     */
    BasicDataApiCall<T> subscribeOn(Scheduler scheduler);
    /**
     * Specify your action when the request is being subscribed. This action will be fired just before calling the API.
     *
     * @param onSubscribeListener callback
     */
    BasicDataApiCall<T> onSubscribe(ActionListener onSubscribeListener);
    /**
     * Specify your action when the request succeeds, fails, or is cancelled.
     *
     * @param doFinallyListener callback
     */
    BasicDataApiCall<T> doFinally(ActionListener doFinallyListener);
    /**
     * Get the original reactive observable to chain your requests.<br>
     * Note that some of the SDK methods not only wrap observables in IDataApiCall,
     * but also add some extra logic, which shouldn't be skipped.<br>
     *
     * @return original reactive observable.
     */
    Observable<T> getObservable();
}

IApiCall


IApiCall is a public interface used to execute requests.

Java:

public interface IApiCall<T> {
    /**
     * It is recommended to call the {@link #cancel()} method before next execution.
     *
     * @param onSuccessListener successful callback with no response
     * @param onFailureListener callback with Throwable instance
     */
    void execute(@NonNull ActionListener onSuccessListener, @NonNull DataActionListener<ApiError> onFailureListener);
    /**
     * Cancels the API request, therefore no response will be provided nor callback fired. <br>
     * It is recommended to call this method when an activity/fragment is being stopped.
     */
    void cancel();
    /**
     * Specify a reactive Scheduler for your request. <br>
     * By default, all internal methods use the {@link Schedulers#io()} scheduler.
     * See {@link io.reactivex.schedulers.Schedulers} factory for more info.
     *
     * @param scheduler reactive scheduler.
     */
    BasicApiCall<T> subscribeOn(Scheduler scheduler);
    /**
     * Specify your action when the request is being subscribed. This action will be fired just before calling API.
     *
     * @param onSubscribeListener callback.
     */
    BasicApiCall<T> onSubscribe(ActionListener onSubscribeListener);
    /**
     * Specify your action when the request succeeds, fails, or is cancelled.
     *
     * @param doFinallyListener callback.
     */
    BasicApiCall<T> doFinally(ActionListener doFinallyListener);
    /**
     * Get the original reactive observable to chain your requests.<br>
     * Note that some of SDK methods not only wrap observables in IApiCall,
     * but also add some extra logic, which shouldn't be skipped.<br>
     *
     * @return original reactive observable.
     */
    Observable<T> getObservable();
}

Client Authentication


Registering a Client account


Register a new Client with email, password, and optional data. This method requires RegisterClient Builder Pattern object with the client’s email, password, and optional data. Fields that were not provided are not modified. The method returns an IApiCall object needed to execute the request. Remember that an account becomes active only after successful email verification.

Note:

Do NOT allow signing in again (or signing up) when a user is already signed in. Sign the user out first.

Do not create multiple instances nor call this method multiple times before execution.

This method is a global operation and does not require authorization.

Method name: Client.registerAccount(registerClient)

Declaration

public static IApiCall registerAccount(@NonNull RegisterClient registerClient)

Parameters

Parameter Type Mandatory Default
registerClient RegisterClient yes -

Return Value

IApiCall object to execute the request.

Example

private IApiCall signUpCall;
private void signUp(RegisterClient registerClient) {
        if (signUpCall != null) signUpCall.cancel();
        signUpCall = Client.registerAccount(registerClient);
        signUpCall.onSubscribe(() -> toggleLoading(true))
                  .doFinally(() -> toggleLoading(false))
                  .execute(this::onSignUpSuccessful, this::onSignUpFailure);
    }

Sign in a Client


Sign in a Client in order to obtain the JWT token, which can be used in subsequent requests.
The token is valid for 1 hour (unless configured otherwise in Synerise) and the SDK will refresh the token before each call if it is close to expiring (but not yet expired).
The method requires a valid and non-null email and password. Device ID is optional.
The method returns IApiCall to execute the request.

Note:

Do NOT allow signing in again (or signing up) when a user is already signed in. Sign the user out first.

Do not create multiple instances nor call this method multiple times before execution.

This method is a global operation and does not require authorization.

Method name: Client.signIn(email, password)

Declaration

public static IApiCall signIn(@NonNull String email, @NonNull String password)

Parameters

Parameter Type Mandatory Default Description
email String yes - User’s email
password String yes - User’s password

Return Value

IApiCall object to execute the request.

Example

private IApiCall signInCall;
private void signIn(String login, String password) {
        if (signInCall != null) signInCall.cancel();
        signInCall = Client.signIn(login, password);
        signInCall.onSubscribe(() -> toggleLoading(true))
                  .execute(() -> onSignInSuccessful(login), () -> onSignInFailure());
    }

Activate a Client account


Activate a Client with email. This method requires the Client’s email. The method returns an IApiCall object needed to execute the request. This method is a global operation and does not require authorization.

Method name: Client.activateAccount(email)

Declaration

public static IApiCall activateAccount(String email)

Parameters

Parameter Type Mandatory Default Description
email String yes - Client’s email

Return Value

IApiCall object to execute the request.

Example

private IApiCall call;
if (call != null) call.cancel();

            call = Client.activateAccount(email);
            call.execute(this::onSuccess, this::onError);

Confirm a Client account


Confirm a Client’s account with token.

The Method returns the HTTP 400 status code if the account is already confirmed or 404 if the account does not exist. The method returns an IApiCall object needed to execute the request. This method is a global operation and does not require authorization.

Method name: Client.confirmAccount(token)

Declaration

public static IApiCall confirmAccount(String token)

Parameters

Parameter Type Mandatory Default Description
token String yes - Client’s token

Return Value

IApiCall object to execute the request.

Example

private IApiCall call;
if (call != null) call.cancel();
            call = Client.confirmAccount(token);
            call.execute(this::onSuccess, this::onError);

Authenticate a Client by Facebook with registration


Use this method to sign in with Facebook. HTTP 401 status code is returned if the provided Facebook token and/or API Key is invalid.

This method returns an IApiCall object needed to execute the request. This method is a global operation and does not require authorization.

Method name: Client.authenticateByFacebook(facebookToken, agreements, attributes, authId)

Declaration

public static IApiCall authenticateByFacebook(@NonNull String facebookToken, @Nullable Agreements agreements, @Nullable Attributes attributes, @Nullable String authId)

Parameters

Parameter Type Mandatory Default Description
facebookToken String yes - Token retrieved from Facebook SDK
agreements Agreements no Marketing agreements
attributes Attributes no Additional attributes
authId String no Optional authId to decrease the number of UUID refreshes

Return Value

IApiCall object to execute the request.

Example

private IApiCall signInFacebookCall;
private void signInFacebook(String facebookToken) {
        if (signInFacebookCall != null) signInFacebookCall.cancel();
        signInFacebookCall = Client.authenticateByFacebook(facebookToken, null, null, null);
        signInFacebookCall.onSubscribe(() -> toggleFacebookLoading(true))
                          .execute(this::onSignInFacebookSuccess, this::onSignInFacebookError);
    }

Authenticate a Client by Facebook without registration


Use this method to sign in with an already registered Facebook account.

HTTP 401 status code is returned if no account is associated with the provided facebook token. This method returns an IApiCall object needed to execute the request. This method is a global operation and does not require authorization.

Method name: Client.authenticateByFacebookRegistered(facebookToken, authId)

Declaration

public static IApiCall authenticateByFacebookRegistered(@NonNull String facebookToken, @Nullable String authId)

Parameters

Parameter Type Mandatory Default Description
facebookToken String yes - Token retrieved from Facebook SDK
authId String no Optional authId to decrease the number of UUID refreshes

Return Value

IApiCall object to execute the request.

Example

private IApiCall signInFacebookRegisteredCall;
private void signInFacebookRegistered(String facebookToken) {
        if (signInFacebookRegisteredCall != null) signInFacebookRegisteredCall.cancel();
        signInFacebookRegisteredCall = Client.authenticateByFacebookRegistered(facebookToken, null);
        signInFacebookRegisteredCall.onSubscribe(() -> toggleFacebookLoading(true))
                          .execute(this::onSignInFacebookSuccess, this::onSignInFacebookError);
    }

Authenticate a Client by OAuth


Use this method to sign in with an already prepared OAuth authorization token.

the HTTP 401 status code is returned if the provided access token and/or API Key is invalid. This method returns an IApiCall object needed to execute the request. This method is a global operation and does not require authorization.

Method name: Client.authenticateByOAuth(accessToken, agreements, attributes, authId)

Declaration

public static IApiCall authenticateByOAuth(@NonNull String accessToken, @Nullable Agreements agreements, @Nullable Attributes attributes, @Nullable String authId)

Parameters

Parameter Type Mandatory Default Description
accessToken String yes - Token retrieved from OAuth authorization
agreements Agreements no Optional agreements
attributes Attributes no Optional attributes
authId String no AuthenticationId to decrease the number of UUID refreshes

Return Value

IApiCall object to execute the request.

Example

private IApiCall call;
if (call != null) call.cancel();
            call = Client.authenticateByOAuth(token, null, null, null);
            call.execute(this::onSuccess, this::onFailure);

Check if a Client is signed in


Check if a Client is signed in (whether the Client’s token is authorized).

Method name: Client.isSignedIn()

Declaration

public static boolean isSignedIn()

Parameters

No parameters.

Return Value

Boolean defining whether a Client is signed in or not.

Example

boolean isSignedIn = Client.isSignedIn()

Sign out a Client


Signing a Client out clears the Client’s JWT token.

Method name: Client.signOut()

Declaration

public static void signOut()

Parameters

No parameters.

Return Value

Nothing is returned.

Example

Client.signOut();

Client Account Management


Get Client account information


Use this method to get a Client’s account information.

This method returns a IDataApiCall with a parameterized GetAccountInformation object needed to execute the request.

Method name: Client.getAccount()

Declaration

public static IDataApiCall<GetAccountInformation> getAccount()

Parameters

No parameters required.

Return Value

IDataApiCall object to execute the request.

Example

private IDataApiCall<GetAccountInformation> getAccountCall;
private void getAccount(boolean isFacebook) {
        if (getAccountCall != null) getAccountCall.cancel();
        getAccountCall = Client.getAccount();
        getAccountCall.execute(({ this.onGetAccountSuccessful() }), ({ this.onGetAccountFailure() });
    }

Update Client account information


Use this method to update a Client’s account information.

This method requires the UpdateAccountInformation Builder Pattern object with the Client’s account information. Only the provided fields are modified. The method returns an IApiCall object needed to execute the request.

Method name: Client.updateAccount(accountInformation)

Declaration

public static IApiCall updateAccount(@NonNull UpdateAccountInformation accountInformation)

Parameters

Parameter Type Mandatory Default Description
accountInformation UpdateAccountInformation yes - Builder Pattern object with the Client’s account information

Return Value

IApiCall object to execute the request.

Example

if (apiCall != null) apiCall.cancel();
            apiCall = Client.updateAccount(accountInformation);
            apiCall.execute(this::onSuccess, this::onFailure);

Change Client account password


Use this method to change a Client’s password.

This method returns HTTP 403 if the provided old password is invalid. The method returns an IApiCall needed to execute the request.

Method name: Client.changePassword(oldPassword, password)

Declaration

public static IApiCall changePassword(@NonNull String oldPassword, @NonNull String password)

Parameters

Parameter Type Mandatory Default Description
oldPassword String yes - Client’s old password
password String yes Client’s new password

Return Value

IApiCall object to execute the request.

Example

private IApiCall apiCall;
if (apiCall != null) apiCall.cancel();
            apiCall = Client.changePassword(oldPassword, password);
            apiCall.execute(this::onSuccess, this::onFailure);

Request password reset for a Client’s account


Request a Client’s password reset with email.

The Client will receive a token to the provided email address in order to use Client.confirmResetPassword(password, token).

This method requires the Client’s email. The method returns an IApiCall object needed to execute the request. This method is a global operation and does not require authorization.

Method name: Client.requestPasswordReset(resetRequest)

Declaration

public static IApiCall requestPasswordReset(@NonNull PasswordResetRequest resetRequest)

Parameters

Parameter Type Mandatory Default Description
resetRequest PasswordResetRequest yes - PasswordResetRequest object with the Client’s email.

Return Value

IApiCall object to execute the request.

Example

if (call != null) call.cancel();
        call = Client.requestPasswordReset(new PasswordResetRequest(email));
        EspressoTestingIdlingResource.increment();
        call.execute(this::onSuccess, this::onFailure);

Confirm password reset for a Client’s account


Confirm a Client’s password reset with the new password and a token provided by Client.requestPasswordReset(email).

This method requires a Client’s password and the confirmation token sent to the email address. The method returns an IApiCall object needed to execute the request. This method is a global operation and does not require authorization.

Method name: Client.confirmPasswordReset(resetConfirmation)

Declaration

public static IApiCall confirmPasswordReset(@NonNull PasswordResetConfirmation resetConfirmation)

Parameters

Parameter Type Mandatory Default Description
resetConfirmation PasswordResetConfirmation yes - PasswordResetConfirmation object with the Client’s new password and confirmation token.

Return Value

IApiCall object to execute the request.

Example

private IApiCall call;
if (call != null) call.cancel();
            call = Client.confirmPasswordReset(confirmation);
            call.execute(this::onSuccess, this::onFailure);

Request email change for a Client’s account


Use this method to request an email change.

Returns HTTP 403 if the provided UUID does not exist or the password is invalid. The method returns an IApiCall needed to execute the request.

Method name: Client.requestEmailChange(email, password, uuid)

Declaration

public static IApiCall requestEmailChange(String email, String password, @Nullable String uuid)

Parameters

Parameter Type Mandatory Default Description
email String yes - Client’s email
password String yes - Client’s password
uuid String no - Optional Client UUID, internal UUID is used if this parameter is null

Return Value

IApiCall object to execute the request.

Example

IApiCall apiCall;
apiCall = Client.requestEmailChange(email, password, uuid);
            apiCall.execute(this::onSuccess, this::onFailure);

Request email change by Facebook


Use this method to request an email change.

Returns HTTP 403 if the provided UUID does not exist. The method returns an IApiCall needed to execute the request.

Method name: Client.requestEmailChangeByFacebook(email, uuid)

Declaration

public static IApiCall requestEmailChangeByFacebook(String email, @Nullable String uuid)

Parameters

Parameter Type Mandatory Default Description
email String yes - User’s email
uuid String no - Optional Client UUID, internal UUID is used if this parameter is null

Return Value

IApiCall object to execute the request.

Example

IApiCall apiCall;
apiCall = Client.requestEmailChangeByFacebook(email, uuid);
            apiCall.execute(this::onSuccess, this::onFailure);

Confirm email change for a Client’s account


Use this method to confirm an email change.

Returns HTTP 403 if the provided token is invalid. The method returns an IApiCall needed to execute the request.

Method name: Client.confirmEmailChange(token, newsletterAgreement)

Declaration

public static IApiCall confirmEmailChange(String token, boolean newsletterAgreement)

Parameters

Parameter Type Mandatory Default Description
token String yes - Token from user’s email
newsletterAgreement boolean yes - Newsletter agreement

Return Value

IApiCall object to execute the request.

Example

IApiCall apiCall;
apiCall = Client.confirmEmailChange(token, newsletterAgreement.isChecked());
            apiCall.execute(this::onSuccess, this::onFailure);

Request phone update on a Client’s account


Use this method to request a phone number update. This action requires additional validation via PIN code. The method returns an IApiCall needed to execute the request.

Method name: Client.requestPhoneUpdate(phone)

Declaration

public static IApiCall requestPhoneUpdate(String phone)

Parameters

Parameter Type Mandatory Default Description
phone String yes - Client’s phone number.

Return Value

IApiCall object to execute the request.

Example

IApiCall apiCall;
apiCall = Client.requestPhoneUpdate(phone);
        apiCall.execute(this::onSuccess, this::onFailure);

Confirm phone update on a Client’s account


Use this method to confirm a phone number update. This action requires the phone number and confirmation code as parameters. The method returns an IApiCall needed to execute the request.

Method name: Client.confirmPhoneUpdate(phone, confirmationCode, smsAgreement)

Declaration

public static IApiCall confirmPhoneUpdate(String phone, String confirmationCode, @Nullable Boolean smsAgreement)

Parameters

Parameter Type Mandatory Default Description
phone String yes - Phone number that will be confirmed
confirmationCode String yes - Code received in SMS
smsAgreement Boolean no - Optional SMS marketing agreement

Return Value

IApiCall object to execute the request.

Example

IApiCall apiCall;
apiCall = Client.confirmPhoneUpdate(phone, code, enableAgreement.isChecked() ? null : smsAgreement.isChecked());
            apiCall.execute(this::onSuccess, this::onFailure);

Register for Push Notifications


Use this method to pass the Firebase token to Synerise for notifications.

Method name: Client.registerForPush(firebaseId)

Declaration

public static IApiCall registerForPush(@NonNull String firebaseId)

Parameters

Parameter Type Mandatory Default Description
firebaseId String yes - FirebaseInstanceId

Return Value

IApiCall object to execute the request.

Example

IApiCall call = Client.registerForPush(refreshedToken);
            call.execute(() -> Log.d(TAG, "Register for Push succeed: " + refreshedToken),
                         apiError -> Log.w(TAG, "Register for push failed: " + refreshedToken));

Delete a Client’s account


Use this method to delete a Client’s account. HTTP 403 status code is returned when the provided password is invalid. The method returns an IApiCall needed to execute the request.

Method name: Client.deleteAccount(password)

Declaration

public static IApiCall deleteAccount(String password)

Parameters

Parameter Type Mandatory Default Description
password String yes - Client’s current password.

Return Value

IApiCall object to execute the request.

Example

IApiCall deleteCall = Client.deleteAccount(password);
            deleteCall.execute(this::onSuccess, this::onFailure);

Delete a Client’s account by Facebook


Use this method to delete an account by Facebook. Returns:

  • HTTP 400 status code if the provided data is invalid.
  • HTTP 403 status code if the provided token is invalid.
  • HTTP 404 status code if the Facebook user does not exist.

The method returns an IApiCall needed to execute the request.

Method name: Client.deleteAccountByFacebook(facebookToken, uuid)

Declaration

public static IApiCall deleteAccountByFacebook(String facebookToken, @Nullable String uuid)

Parameters

Parameter Type Mandatory Default Description
facebookToken String yes - Client’s facebook token
uuid String no Optional Client UUID, internal UUID is used if this parameter is null

Return Value

IApiCall object to execute the request.

Example

IApiCall deleteCall = Client.deleteAccountByFacebook(facebookToken, uuid)
            deleteCall.execute(this::onSuccess, this::onFailure);

Client Session


Get Client token


Get a valid and refreshed JWT login token. An error is thrown when the Client is not logged in or the token has expired and cannot be refreshed.

The method returns IDataApiCall with a parameterized Token to execute request.

Method name: Client.getToken()

Declaration

public static IDataApiCall<Token> getToken()

Parameters

No parameters required.

Return Value

IDataApiCall object to execute the request.

Example

IDataApiCall getTokenCall = Client.getToken();
        getTokenCall.execute(success -> onSuccess(), this::onFailure);

Get current UUID of a Client


Retrieve current Client UUID.

Method name: Client.getUuid()

Declaration

public static String getUuid()

Parameters

No parameters required.

Return Value

Client’s UUID as a string.

Example

Client.getUuid()

Regenerate UUID for a Client


Regenerate UUID and clear authentication token, login session, custom email, and custom identifier.

This operation works only if the current Client is anonymous.

The method returns true when the current Client is anonymous and the operation was successful.

Method name: Client.regenerateUuid()

Declaration

public static boolean regenerateUuid()

Parameters

No parameters required.

Return Value

Returns true if the current Client is anonymous and the operation succeeds.

Example

boolean success = Client.regenerateUuid();

Change API Key dynamically


Change the API Key dynamically. If the currently saved API Key is different than provided, the authentication token will be cleared.

The Client’s UUID, login session, custom email, and custom identifier will always be cleared.

Method name: Client.changeApiKey(newApiKey)

Declaration

public static void changeApiKey(@NonNull String newApiKey)

Parameters

Parameter Type Mandatory Default Description
newApiKey String yes - New API Key

Return Value

Void type method.

Example

Client.changeApiKey(apiKey);

Promotions


Get promotions for a Client


Use this method to get all possible combinations of promotions defined for this Client. The method returns promotions with statuses, types, and optional metadata provided in the list. A special query is built upon your params. This method returns IDataApiCall with a parameterized List<PromotionResponse> object to execute the request.

Method name: Promotions.getPromotions(statuses, types, page) Method name: Promotions.getPromotions(statuses, types, limit, page) Method name: Promotions.getPromotions(statuses, types, page, includeMeta) Method name: Promotions.getPromotions(promotionsApiQuery)

Warning:

Methods using arguments are now deprecated.

Only Promotions.getPromotions(promotionsApiQuery) is valid.

Declaration

public static IDataApiCall<PromotionResponse> getPromotions(@Nullable List<PromotionStatus> statuses,
                                                                @Nullable List<PromotionType> types, int page)
public static IDataApiCall<PromotionResponse> getPromotions(@Nullable List<PromotionStatus> statuses,
                                                                @Nullable List<PromotionType> types, int limit, int page)
public static IDataApiCall<PromotionResponse> getPromotions(@Nullable List<PromotionStatus> statuses,
                                                                @Nullable List<PromotionType> types, int page, boolean includeMeta)
public static IDataApiCall<PromotionResponse> getPromotions(PromotionsApiQuery promotionsApiQuery)

Parameters

Parameter Type Mandatory Default Description
statuses List yes - Specify a status filter, can be any combination or an empty list.
types List yes - Specify type filter, can be any combination or an empty list.
page int yes - Query for a specific page, minimum 1.
limit int yes 100 Query for promotions limit.
includeMeta boolean yes false Decide whether to include metadata in the final response.
promotionsApiQuery PromotionsApiQuery yes Class responsible for storing all queryParameters.

Return Value

IDataApiCall object to execute the request.

Example

if (apiCall != null) 
    apiCall.cancel();
PromotionsApiQuery query = new PromotionsApiQuery();
query.limit = limit;
query.statuses = statuses;
query.page = 5;
query.includeMeta = true;

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);
apiCall = Promotions.getPromotions(query);
apiCall.execute(this::onSuccess, this::onFailure);

Get promotion information by its UUID


Use this method to get promotion by UUID. This method returns an IDataApiCall with a parameterized SinglePromotionResponse object to execute the request.

Method name: Promotions.getPromotionByUuid(uuid)

Declaration

public static IDataApiCall<SinglePromotionResponse> getPromotionByUuid(@NonNull String uuid)

Parameters

Parameter Type Mandatory Default Description
uuid String yes - UUID of the promotion that you want to get.

Return Value

IDataApiCall object to execute the request.

Example

IDataApiCall<SinglePromotionResponse> apiCall = Promotions.getPromotionByUuid(uuid);
        apiCall.execute(response -> {
            if (response != null) {
                Promotion promotion = response.getPromotion();
            }
        }, this::showAlertError);

Get promotion information by its code


Use this method to get a promotion by code. This method returns an IDataApiCall with a parameterized SinglePromotionResponse object to execute the request.

Method name: Promotions.getPromotionByCode(code)

Declaration

public static IDataApiCall<SinglePromotionResponse> getPromotionByCode(@NonNull String code)

Parameters

Parameter Type Mandatory Default Description
code String yes - Code of the promotion that you want to get.

Return Value

IDataApiCall object to execute the request.

Example

IDataApiCall<SinglePromotionResponse> apiCall = Promotions.getPromotionByCode(code);
        apiCall.execute(response -> {
            if (response != null) {
                Promotion promotion = response.getPromotion();
            }
        }, this::showAlertError);

Activate promotion by its UUID


Use this method to activate a promotion by UUID. The method returns an IApiCall needed to execute the request.

Method name: Promotions.activatePromotionByUuid(uuid)

Declaration

public static IApiCall activatePromotionByUuid(@NonNull String uuid)

Parameters

Parameter Type Mandatory Default Description
uuid String yes - UUID of the promotion that will be activated.

Return Value

IApiCall object to execute the request.

Example

IApiCall apiCall = Promotions.activatePromotionByUuid(uuid);
            apiCall.execute(this::onSuccess, this::onFailure);

Activate promotion by its code


Use this method to activate a promotion by code. The method returns an IApiCall needed to execute the request.

Method name: Promotions.activatePromotionByCode(code)

Declaration

public static IApiCall activatePromotionByCode(@NonNull String code)

Parameters

Parameter Type Mandatory Default Description
code String yes - Code of the promotion that will be activated.

Return Value

IApiCall object to execute the request.

Example

IApiCall apiCall = Promotions.activatePromotionByCode(code);

Deactivate promotion by its UUID


Use this method to deactivate a promotion by UUID. The method returns an IApiCall needed to execute the request.

Method name: Promotions.deactivatePromotionByUuid(uuid)

Declaration

public static IApiCall deactivatePromotionByUuid(@NonNull String uuid)

Parameters

Parameter Type Mandatory Default Description
uuid String yes - UUID of the promotion that will be deactivated.

Return Value

IApiCall object to execute the request.

Example

IApiCall apiCall = Promotions.deactivatePromotionByUuid(uuid);
            apiCall.execute(this::onSuccess, this::onFailure);

Deactivate promotion by its code


Use this method to deactivate a promotion by code. The method returns an IApiCall needed to execute the request.

Method name: Promotions.deactivatePromotionByCode(code)

Declaration

public static IApiCall deactivatePromotionByCode(@NonNull String code)

Parameters

Parameter Type Mandatory Default Description
code String yes - Code of the promotion that will be deactivated.

Return Value

IApiCall object to execute the request.

Example

IApiCall apiCall = Promotions.deactivatePromotionByCode(code);
            apiCall.execute(this::onSuccess, this::onFailure);

Vouchers


Assign voucher code from a pool


Use this method to assign a voucher to a Client. The pool is identified by UUID.

Every request returns different code until the pool is empty. When the pool is empty, the method returns the HTTP 416 status code. Methods returns IDataApiCall with parameterized AssignVoucherResponse object to execute the request.

Method name: Promotions.assignVoucherCode(poolUuid)

Declaration

public static IDataApiCall<AssignVoucherResponse> assignVoucherCode(@NonNull String poolUuid)

Parameters

Parameter Type Mandatory Default Description
poolUuid String yes - Pool’s universally unique identifier.

Return Value

IDataApiCall object to execute the request.

Example

IDataApiCall<AssignVoucherResponse> call = Promotions.assignVoucherCode(poolUuid);
            call.execute(this::onSuccess, this::onFailure);

Get voucher codes assigned to a Client


Use this method to get a Client’s voucher codes. The methods returns an IDataApiCall with a parameterized VoucherCodesResponse object to execute the request.

Method name: Promotions.getAssignedVoucherCodes()

Declaration

public static IDataApiCall<VoucherCodesResponse> getAssignedVoucherCodes()

Parameters

No parameters required.

Return Value

IDataApiCall object to execute the request.

Example

IDataApiCall<VoucherCodesResponse> call = Promotions.getAssignedVoucherCodes();
        call.execute(this::onSuccess, this::onFailure);

Get or assign voucher from a pool


Retrieve the code assigned to a Client. If no code was assigned earlier, the method assigns one from a pool identified by UUID. For each Client, the same code is retrieved every time. This can be used, for example, to retrieve unique codes used to identify a Client.

The methods returns an IDataApiCall with a parameterized AssignVoucherResponse object to execute the request.

Method name: Promotions.getOrAssignVoucher(poolUuid)

Declaration

public static IDataApiCall<AssignVoucherResponse> getOrAssignVoucher(@NonNull String poolUuid)

Parameters

Parameter Type Mandatory Default Description
poolUuid String yes - Pool’s universally unique identifier.

Return Value

IDataApiCall object to execute the request.

Example

IDataApiCall<AssignVoucherResponse> call = Promotions.getOrAssignVoucher(poolUuid);
            call.execute(this::onSuccess, this::onFailure);

Tracker


Send event


To send an event, use Tracker.send(Event) method, which in the most basic scenario looks like this:

Method name: Tracker.send(event)

Declaration

public static void send(Event event)

Parameters

Parameter Type Mandatory Default Description
event Event yes - Event object (e.g. CustomEvent() instance).

Return Value

Void type method.

Example

Tracker.send(new CustomEvent("my.action", "My label that will be visible on Activity Stream"));

However, you can pass additional parameters with the event, like in the example below:

TrackerParams params = new TrackerParams.Builder()
                .add("name", "John")
                .add("surname", "Rise")
                .add("company", "Synerise")
                .add("age", 25)
                .add("isGreat", true)
                .add("lastOrder", 384.28)
                .add("count", 0x7fffffffffffffffL)
                .add("someObject", new MySerializableObject())
                .build();
Tracker.send(new CustomEvent("my.action", "My label that will be visible on Activity Stream", params));

The Tracker caches and enqueues all your events locally, so they will all be sent eventually.
It also supports Android O’s Background Execution Limits.

For more information about events, check Event Tracking.

Flush events from Tracker


The flush method forces the sending of events from the queue to the server. This method is a global operation and does not require authorization.

Method name: Tracker.flush()

Declaration

public static void flush()

Parameters

No parameters required.

Return Value

Void type method.

Example

Tracker.flush();

Set customIdentifier for events


You can pass your custom identifier to match your users in our CRM. Your custom identifier will be sent in every event, in the event params.

Method name: Tracker.setCustomIdentifier(customIdentifier)

Declaration

public static void setCustomIdentifier(String customIdentifier)

Parameters

Parameter Type Mandatory Default Description
customIdentifier String yes - Client’s custom identifier

Return Value

Void type method.

Example

Tracker.setCustomIdentifier(customIdentifier)

Set customEmail for events


You can pass your custom email to match your users in our CRM. Your custom email will be sent in every event, in the event params.

Method name: Tracker.setCustomEmail(customEmail)

Declaration

public static void setCustomEmail(String customEmail)

Parameters

Parameter Type Mandatory Default Description
customEmail String yes - Client’s email

Return Value

Void type method.

Example

private void setCustomEmail(String customEmail) {
    Tracker.setCustomEmail(customEmail);
}

😕

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.