Source: managers/smart-invites.js

import Manager from "./manager";

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

    /**
     * @memberOf SmartInvites
     * @typedef {Object} SmartInvite
     * @property {string} url - URL of the Smart Invite.
     * @property {string} channel - The channel the link will be shared on, e.g <code>whatsapp</code>.
     * @property {Object.<string, string>} custom_data - Custom data attached to this link.
     */

    /**
     * Create a new Smart Invite.
     *
     * @memberOf SmartInvites
     * @param {Object} params - Invite parameters.
     * @param {string} params.channel - The invite channel the link will be used on, e.g <code>whatsapp</code>. Defaults to <code>web</code> if unspecified.
     * @param {Object.<string, string>} params.custom_data - Custom data in key/value pairs attached to this invite. These values will be present in the referral data. See [Referral Data Reference]{@link https://docs.getsocial.im/knowledge-base/referral-data-reference/} for reserved keys.
     *
     * @returns {Promise<SmartInvite>} - A Promise of a SmartInvite object.
     */
    create(params) {
        params = params || {};
        params.channel = params.channel || "web";
        return this.client.authenticatedRequest("/smart-invites", {
            method: "POST",
            body: params
        });
    }

    /**
     * Deprecated. Use {@link create}.
     *
     * @memberOf SmartInvites
     * @deprecated
     */
    createInvite(params) {
        return this.create(params);
    }
}