Source: managers/referral.js

import Manager from "./manager";

/**
 * @class Referral
 * @hideconstructor
 */
export default class Referral extends Manager {
    constructor(client) {
        super(client)
    }

    /**
     * @memberOf Referral
     * @typedef {Object} ReferredUser
     * @property {string} id - User ID
     * @property {string} display_name - Username
     * @property {string} avatar_url - URL to user's picture
     * @property {Object.<string, string>} auth_identities - Custom identity key/value pairs, e.g "email":"hello@example.com"
     * @property {string} install_date - The date the user installed the app, in RFC3339 format. Only applies to users who install the app from a GetSocial link.
     * @property {string} install_channel - The channel the user installed the app from, e.g <code>whatsapp</code>.
     */

    /**
     * @memberOf Referral
     * @typedef {Object} ReferralUser
     * @property {User} user - User
     * @property {string} event_date - The date the event was triggered, in RFC3339 format..
     * @property {string} event - The related event
     * @property {Object.<string, string>} custom_data - The custom data from the event. 
     *     For the `app_install` event additional data is included: 
     *     * `$channel`
     *     * `$suspicious`
     *     * `$platform`
     *     * any other custom data included in the Smart Invite
     */

    /**
     * @memberOf Referral
     * @typedef {Object} PaginatedReferredUsers
     * @property {ReferralUser[]} referred - List of referred users
     * @property {string} next_cursor - String cursor to use to get the next batch of referred users
     */

    /**
     * List of users referred by the current user.
     *
     * @memberOf Referral
     * @deprecated Use getReferred instead
     * @returns {Promise<ReferredUser[]>} - A Promise of an array of referred users.
     */
    getReferredUsers() {
        return this.client.authenticatedRequest("/referral/referred-users", {
            method: "GET",
        });
    }

    /**
     * List of users referred by the current user.
     *
     * @memberOf Referral
     * @param {Object} params - getReferred parameters.
     * @param {string} params.event - If set, result will include only referred users for this specific event.
     * @param {string} params.next_cursor - String cursor returned from the previous request.
     * @param {number} params.limit - Number of referred users to return.
     * @returns {Promise<PaginatedReferredUsers>} - A Promise of page of referred users.
     */
    getReferred(params) {
        params = params || {};

        return this.client.authenticatedRequest("/referral/referred", {
            method: "GET",
            queryParams: params
        });
    }

    /**
     * List of referrers of the current user.
     *
     * @memberOf Referral
     * @param {Object} params - getReferrers parameters.
     * @param {string} params.event - If set, result will include only referrers for this specific event.
     * @returns {Promise<ReferralUser[]>} - A Promise of an array of referrers.
     */
    getReferrers(params) {
        params = params || {};

        return this.client.authenticatedRequest("/referral/referrers", {
            method: "GET",
            queryParams: params
        });
    }


}