Saasquatch
public class Saasquatch
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.
Information on our iOS SDK can be found on our iOS SDK Overview.
Information about authentication for our mobile SDK can be found on our Open Endpoints page.
-
Registers a user with Referral SaaSquatch.
Note
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
secret,id, andaccountIdvalues and can include several others. For a complete description see the Referral SaaSquatch REST API docs. Here is an example:let userInfo: [String: AnyObject] = [ "secret": "978-0440212560", "id": "10001110101", "accountId": "10001110101", "email": "claire@lallybroch.com", "firstName": "Claire", "lastName": "Fraser", "locale": "en_US", "referralCode": "CLAIREFRASER" ]Warning
The secret is your password for authenticating the user. It should not contain sensitive user data such as their password. Make sure to save it somewhere, or else you won’t be able to authenticate future requests for the user.Declaration
Swift
public class func registerUserForTenant( tenant: String, withUserID userID: String, withAccountID accountID: String, withUserInfo userInfo: AnyObject, completionHandler: (userInfo: AnyObject?, error: NSError?) -> Void)Parameters
tenantIdentifies 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.userIDA 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.
accountIDWe use this ID to link a group of users together. See Shared vs Solo Accounts to see what you should use here.
userInfoA Foundation object from which to generate JSON for the request.
completionHandlerA block object to be executed when the task finishes. This block has no return value and takes two arguments: the Foundation object containing the returned user information constructed from the JSON response, and containing an NSError descibing the error if the request failed.
-
Gets a user’s information from Referral Saasquatch.
Declaration
Swift
public class func userForTenant( tenant: String, withUserID userID: String, withAccountID accountID: String, withSecret secret: String, completionHandler: (userInfo: AnyObject?, error: NSError?) -> Void)Parameters
tenantIdentifies 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.userIDA 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.
accountIDWe use this ID to link a group of users together. See Shared vs Solo Accounts to see what you should use here.
secretThe secret for the user.
completionHandlerA block object to be executed when the task finishes. This block has no return value and takes two arguments: the Foundation object containing the returned user information constructed from the JSON response, and containing an NSError descibing the error if the request failed.
-
Gets a user’s information by their referral code.
Declaration
Swift
public class func userByReferralCode( referralCode: String, forTenant tenant: String, withSecret secret: String?, completionHandler: (userInfo: AnyObject?, error: NSError?) -> Void)Parameters
referralCodeThe referral code of the user being looked up.
tenantIdentifies 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.secretThe secret for the user.
completionHandlerA block object to be executed when the task finishes. This block has no return value and takes two arguments: the Foundation object containing the returned user information constructed from the JSON response, and containing an NSError descibing the error if the request failed.
-
Checks if a referral code exists and retrieves information about the code and it’s reward.
Declaration
Swift
public class func lookupReferralCode( referralCode: String, forTenant tenant: String, withSecret secret: String?, completionHandler: (userInfo: AnyObject?, error: NSError?) -> Void)Parameters
referralCodeThe referral code being validated.
tenantIdentifies 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.secretThe secret for the user.
completionHandlerA block object to be executed when the task finishes. This block has no return value and takes two arguments: the Foundation object containing the returned referral code context constructed from the JSON response, and containing an NSError descibing the error if the request failed.
-
Applies a referral code to a user’s account.
Declaration
Swift
public class func applyReferralCode( referralCode: String, forTenant tenant: String, toUserID userID: String, toAccountID accountID: String, withSecret secret: String, completionHandler: (userInfo: AnyObject?, error: NSError?) -> Void)Parameters
referralCodeThe referral code to be applied.
tenantIdentifies 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.userIDA 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.
accountIDWe use this ID to link a group of users together. See Shared vs Solo Accounts to see what you should use here.
secretThe secret for the user.
completionHandlerA block object to be executed when the task finishes. This block has no return value and takes two arguments: the Foundation object containing the returned referral code information constructed from the JSON response, and containing an NSError descibing the error if the request failed.
-
listReferralsForTenant(_:withSecret:forReferringAccountID:forReferringUserID:beforeDateReferralPaid:beforeDateReferralEnded:withReferredModerationStatus:withReferrerModerationStatus:withLimit:withOffset:completionHandler:)Returns the list of referrals for the tenant with options for filtering.
Declaration
Swift
public class func listReferralsForTenant( tenant: String, withSecret secret: String, forReferringAccountID accountID: String?, forReferringUserID userID: String?, beforeDateReferralPaid datePaid: String?, beforeDateReferralEnded dateEnded: String?, withReferredModerationStatus referredStatus: String?, withReferrerModerationStatus referrerStatus: String?, withLimit limit: NSString?, withOffset offset: NSString?, completionHandler: (userInfo: AnyObject?, error: NSError?) -> Void)Parameters
tenantIdentifies 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.secretThe secret for the user.
accountIDWhen included, filters the results to only referrals that were referred by users with this account id.
userIDWhen included, filters the results to only referrals that were referred by users with this user id.
datePaidWhen 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.
dateEndedWhen 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.
referredStatusWhen included, filters the result to only include referred users with that status. Statuses that are accepted: PENDING, APPROVED or DENIED.
referrerStatusWhen included, filters the result to only include referrers with that status. Statuses that are accepted: PENDING, APPROVED or DENIED.
limitA limit on the number of results returned. Defaults to 10.
offsetWhen included offsets the first result returns in the list. Use this to paginate through a long list of results. Defaults to 0.
completionHandlerA block object to be executed when the task finishes. This block has no return value and takes two arguments: the Foundation object containing the returned referrals information constructed from the JSON response, and containing an NSError descibing the error if the request failed.
Saasquatch Class Reference