Saasquatch

Superclass:
NSObject
Declared In:

Introduction

`Saasquatch` is the Referral Saasquatch iOS SDK which provides a set of methods for interfacing with Referral SaaSquatch. It can register user with Referral SaaSquatch, retrieve information about users and referral codes, validate referral codes, and apply referral codes to a user's account.



Methods

+applyReferralCode:forTenant:toUserID:toAccountID:withToken:completionHandler:
+listReferralsForTenant:withToken:forReferringAccountID:forReferringUserID:beforeDateReferralPaid:beforeDateReferralEnded:withReferredModerationStatus:withReferrerModerationStatus:withLimit:withOffset:completionHandler:
+lookupReferralCode:forTenant:withToken:completionHandler:
+registerUserForTenant:withUserID:withAccountID:withToken:withUserInfo:completionHandler:
+userByReferralCode:forTenant:withToken:completionHandler:
+userForTenant:withUserID:withAccountID:withToken:completionHandler:

applyReferralCode:forTenant:toUserID:toAccountID:withToken:completionHandler:


+ (void)applyReferralCode:(NSString *)referralCode forTenant:(NSString *)tenant 
        toUserID:(NSString *)userID toAccountID:(NSString *)accountID 
        withToken:(NSString *)token completionHandler:(void (^)(id userInfo, NSError *error))completionHandler; 
Parameters
referralCode

The referral code to be applied.

tenant

Identifies which tenant to connect to. For your app, you will get two tenant aliases -- one for test mode and one for live mode. Test mode alias are prefixed with test_ , for example `test_abhoihnqwet`.

userID

A user ID from your system (must be unique for every user). We use this to uniquely track users, and lets us handle accounts that are shared between users.

accountID

We use this ID to link a group of users together. [See Shared vs Solo Accounts]("http://docs.referralsaasquatch.com/shared-vs-solo-accounts/" See Shared vs Solo Accounts) to see what you should use here.

token

The JWT to sign the request.

completionHandler

A block object to be executed when the task finishes. This block has no return value and takes two arguments: **userInfo** the Foundation object containing the returned referral code information constructed from the JSON response, and **error** containing an NSError descibing the error if the request failed.

See: Referral SaaSquatch REST API reference for a list of available fields.

Discussion

Applies a referral code to a user's account.


listReferralsForTenant:withToken:forReferringAccountID:forReferringUserID:beforeDateReferralPaid:beforeDateReferralEnded:withReferredModerationStatus:withReferrerModerationStatus:withLimit:withOffset:completionHandler:


+ (void)listReferralsForTenant:(NSString *)tenant withToken:(NSString *)token 
        forReferringAccountID:(NSString *)accountID 
        forReferringUserID:(NSString *)userID beforeDateReferralPaid:(NSString *)datePaid 
        beforeDateReferralEnded:(NSString *)dateEnded 
        withReferredModerationStatus:(NSString *)referredStatus 
        withReferrerModerationStatus:(NSString *)referrerStatus 
        withLimit:(NSString *)limit withOffset:(NSString *)offset 
        completionHandler:(void (^)(id userInfo, NSError *error))completionHandler; 
Parameters
tenant

Identifies which tenant to connect to. For your app, you will get two tenant aliases -- one for test mode and one for live mode. Test mode alias are prefixed with test_ , for example `test_abhoihnqwet`.

token

The JWT to sign the request.

accountID

When included, filters the results to only referrals that were referred by users with this account id.

userID

When included, filters the results to only referrals that were referred by users with this user id.

datePaid

When included, filters the results either to the exact timestamp if only one value is given, or a range if devided by a comma. I.E. 0,123412451 gives all referrals that converted between 0 and 123412451.

dateEnded

When included, filters the results either to the exact timestamp if only one value is given, or a range if devided by a comma. I.E. 0,123412451 gives all referrals that ended between 0 and 123412451.

referredStatus

When included, filters the result to only include referred users with that status. Statuses that are accepted: PENDING, APPROVED or DENIED.

referrerStatus

When included, filters the result to only include referrers with that status. Statuses that are accepted: PENDING, APPROVED or DENIED.

limit

A limit on the number of results returned. Defaults to 10.

offset

When included offsets the first result returns in the list. Use this to paginate through a long list of results. Defaults to 0.

completionHandler

A block object to be executed when the task finishes. This block has no return value and takes two arguments: **userInfo** the Foundation object containing the returned referrals information constructed from the JSON response, and **error** containing an NSError descibing the error if the request failed.

See: Referral SaaSquatch REST API reference for a list of available fields.

Discussion

Returns the list of referrals for the tenant with options for filtering.


lookupReferralCode:forTenant:withToken:completionHandler:


+ (void)lookupReferralCode:(NSString *)referralCode forTenant:(NSString *)tenant 
        withToken:(NSString *)token completionHandler:(void (^)(id userInfo, NSError *error))completionHandler; 
Parameters
referralCode

The referral code being validated.

tenant

Identifies which tenant to connect to. For your app, you will get two tenant aliases -- one for test mode and one for live mode. Test mode alias are prefixed with test_ , for example `test_abhoihnqwet`.

token

The JWT to sign the request.

completionHandler

A block object to be executed when the task finishes. This block has no return value and takes two arguments: **userInfo** the Foundation object containing the returned referral code context constructed from the JSON response, and **error** containing an NSError descibing the error if the request failed.

See: Referral SaaSquatch REST API reference for a list of available fields.

Discussion

Checks if a referral code exists and retrieves information about the code and it's reward.


registerUserForTenant:withUserID:withAccountID:withToken:withUserInfo:completionHandler:


+ (void)registerUserForTenant:(NSString *)tenant withUserID:(NSString *)userID 
        withAccountID:(NSString *)accountID withToken:(NSString *)token 
        withUserInfo:(id)userInfo completionHandler:(void (^)(id userInfo, NSError *error))completionHandler; 
Parameters
tenant

Identifies which tenant to connect to. For your app, you will get two tenant aliases -- one for test mode and one for live mode. Test mode alias are prefixed with test_ , for example `test_abhoihnqwet`.

userID

A user ID from your system (must be unique for every user). We use this to uniquely track users, and lets us handle accounts that are shared between users.

accountID

We use this ID to link a group of users together. See Shared vs Solo Accounts to see what you should use here.

token

The JWT to sign the request.

userInfo

A Foundation object from which to generate JSON for the request.

completionHandler

A block object to be executed when the task finishes. This block has no return value and takes two arguments: **userInfo** the Foundation object containing the returned user information constructed from the JSON response, and **error** containing an NSError descibing the error if the request failed.

The top level object in **userInfo** will be an NSDictionary containing the JSON data to be passed to the Referral SaaSquatch server. This requires the `id` and `accountId` values and can include several others. For a complete description see the Referral SaaSquatch REST API docs. Here is an example::

  NSDictionary *userInfo = @{
      @"id" : @"10001110101",
      @"accountId" : @"10001110101",
      @"email" : @"claire@lallybroch.com",
      @"firstName" : @"Claire",
      @"lastName" : @"Fraser",
      @"locale" : @"en_US",
      @"referralCode" : @"CLAIREFRASER"
  };
  
See: Referral SaaSquatch REST API reference for a list of available fields.
Discussion

Registers a user with Referral SaaSquatch.


userByReferralCode:forTenant:withToken:completionHandler:


+ (void)userByReferralCode:(NSString *)referralCode forTenant:(NSString *)tenant 
        withToken:(NSString *)token completionHandler:(void (^)(id userInfo, NSError *error))completionHandler; 
Parameters
referralCode

The referral code of the user being looked up.

tenant

Identifies which tenant to connect to. For your app, you will get two tenant aliases -- one for test mode and one for live mode. Test mode alias are prefixed with test_ , for example `test_abhoihnqwet`.

token

The JWT to sign the request.

completionHandler

A block object to be executed when the task finishes. This block has no return value and takes two arguments: **userInfo** the Foundation object containing the returned user information constructed from the JSON response, and **error** containing an NSError descibing the error if the request failed.

See: Referral SaaSquatch REST API reference for a list of available fields.

Discussion

Gets a user's information by their referral code.


userForTenant:withUserID:withAccountID:withToken:completionHandler:


+ (void)userForTenant:(NSString *)tenant withUserID:(NSString *)userId 
        withAccountID:(NSString *)accountID withToken:(NSString *)token 
        completionHandler:(void (^)(id userInfo, NSError *error))completionHandler; 
Parameters
tenant

Identifies which tenant to connect to. For your app, you will get two tenant aliases -- one for test mode and one for live mode. Test mode alias are prefixed with test_ , for example `test_abhoihnqwet`.

userId

A user ID from your system (must be unique for every user). We use this to uniquely track users, and lets us handle accounts that are shared between users.

accountID

We use this ID to link a group of users together. [See Shared vs Solo Accounts]("http://docs.referralsaasquatch.com/shared-vs-solo-accounts/" See Shared vs Solo Accounts) to see what you should use here.

token

The JWT to sign the request.

completionHandler

A block object to be executed when the task finishes. This block has no return value and takes two arguments: **userInfo** the Foundation object containing the returned user information constructed from the JSON response, and **error** containing an NSError descibing the error if the request failed.

See: Referral SaaSquatch REST API reference for a list of available fields.

Discussion

Gets a user's information from Referral Saasquatch.