UNPKG

react-native-gigya-sdk

Version:
69 lines (64 loc) 3.48 kB
import getState from './getState' import sendApiCall from './sendApiCall' type OptionsType = { /** * This method call can only be made as a secured server request. * In other words, you may use this method using one of our [Server Side SDKs](https://help.sap.com/docs/SAP_CUSTOMER_DATA_CLOUD/8b8d6fffe113457094a17701f63e3d6a/4170357870b21014bbc5a10ce4041860.html?locale=en-US) * or [direct REST API](https://help.sap.com/docs/SAP_CUSTOMER_DATA_CLOUD/8b8d6fffe113457094a17701f63e3d6a/417ef79870b21014bbc5a10ce4041860.html?locale=en-US) calls, and you must pass your [Secret Key](https://help.sap.com/docs/SAP_CUSTOMER_DATA_CLOUD/8b8d6fffe113457094a17701f63e3d6a/416ffb2e70b21014bbc5a10ce4041860.html?locale=en-US). */ secret: string /** * The unique ID of the user, for whom to delete the account. */ UID?: string /** * A string of maximum 100 characters length. The CID sets categories for transactions that can be used later for * filtering [reports generated by Gigya](https://help.sap.com/docs/link-disclaimer?site=http%3A%2F%2Fconsole.gigya.com%2FSite%2Fpartners%2FSocializeReports.aspx) in the "Context ID" combo box. The CID * allows you to associate the report information with your own internal data. For example, to identify a specific * widget or page on your site/application. You should not define more than 100 different context IDs. */ cid?: string /** * Determines the format of the response. The options are: * - `json` (default) * - `jsonp` - if the format is jsonp then you are required to define a callback method (see parameter below). */ format?: string /** * This parameter is required only when the format parameter is set to jsonp (see above). In such cases this parameter should define the name of the callback method to be called in the response, along with the jsonp response data. */ callback?: string /** * This parameter may be used to pass data through the current method and return it, unchanged, within the response. */ context?: string /** * This may be used in some cases to suppress logic applied by the Web SDK, such as automatic opening of screens (e.g., in a registration completion scenario). This parameter may not be used with REST APIs. */ ignoreInterruptions?: boolean /** * The default value of this parameter is false, which means that the HTTP status code in Gigya's response is always 200 (OK), even if an error occurs. The error code and message is given within the response data (see below). If this parameter is set to true, the HTTP status code in Gigya's response would reflect an error, if one occurred. */ httpStatusCodes?: boolean } /** * This method deletes the specified user's account from SAP Customer Data Cloud's database. * This method call can only be made as a secured server request. * @see https://help.sap.com/docs/SAP_CUSTOMER_DATA_CLOUD/8b8d6fffe113457094a17701f63e3d6a/4133a29470b21014bbc5a10ce4041860.html?locale=en-US. */ export default function <OutputType, ParamsType extends OptionsType>( { UID, ...params }: ParamsType = {} as ParamsType ): Promise<OutputType> { return new Promise(async (resolve, reject) => { try { const state = await getState() const response = await sendApiCall<OutputType, OptionsType>('accounts.deleteAccount', { UID: UID || state.UID, ...(params && params), }) resolve(response) } catch (e) { reject(e) } }) }