How to use the @algolia/transporter.createMappedRequestOptions function in @algolia/transporter

To help you get started, we’ve selected a few @algolia/transporter examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github algolia / algoliasearch-client-javascript / packages / client-search / src / methods / client / assignUserID.ts View on Github external
return (
    userID: string,
    clusterName: string,
    requestOptions?: RequestOptions
  ): Readonly> => {
    const mappedRequestOptions = createMappedRequestOptions(requestOptions);

    // eslint-disable-next-line functional/immutable-data
    mappedRequestOptions.headers['X-Algolia-User-ID'] = userID;

    return base.transporter.write(
      {
        method: MethodEnum.Post,
        path: '1/clusters/mapping',
        data: {
          cluster: clusterName,
        },
      },
      mappedRequestOptions
    );
  };
};
github algolia / algoliasearch-client-javascript / packages / client-search / src / methods / index / deleteRule.ts View on Github external
return (
    objectID: string,
    requestOptions?: RequestOptions
  ): Readonly> => {
    const { forwardToReplicas, ...options } = requestOptions || {};

    const mappedRequestOptions = createMappedRequestOptions(options);
    if (forwardToReplicas) {
      mappedRequestOptions.queryParameters.forwardToReplicas = 1; // eslint-disable-line functional/immutable-data
    }

    return createWaitablePromise(
      base.transporter.write(
        {
          method: MethodEnum.Delete,
          path: encode('1/indexes/%s/rules/%s', base.indexName, objectID),
        },
        mappedRequestOptions
      ),
      (response, waitRequestOptions) => waitTask(base)(response.taskID, waitRequestOptions)
    );
  };
};
github algolia / algoliasearch-client-javascript / packages / client-search / src / methods / index / clearRules.ts View on Github external
return (
    requestOptions?: RequestOptions & ClearRulesOptions
  ): Readonly> => {
    const { forwardToReplicas, ...options } = requestOptions || {};
    const mappedRequestOptions = createMappedRequestOptions(options);
    if (forwardToReplicas) {
      mappedRequestOptions.queryParameters.forwardToReplicas = 1; // eslint-disable-line functional/immutable-data
    }

    return createWaitablePromise(
      base.transporter.write(
        {
          method: MethodEnum.Post,
          path: encode('1/indexes/%s/rules/clear', base.indexName),
        },
        mappedRequestOptions
      ),
      (response, waitRequestOptions) => waitTask(base)(response.taskID, waitRequestOptions)
    );
  };
};
github algolia / algoliasearch-client-javascript / packages / client-search / src / methods / index / deleteSynonym.ts View on Github external
return (
    objectID: string,
    requestOptions?: RequestOptions & DeleteSynonymOptions
  ): Readonly> => {
    const { forwardToReplicas, ...options } = requestOptions || {};

    const mappedRequestOptions = createMappedRequestOptions(options);
    if (forwardToReplicas) {
      mappedRequestOptions.queryParameters.forwardToReplicas = 1; // eslint-disable-line functional/immutable-data
    }

    return createWaitablePromise(
      base.transporter.write(
        {
          method: MethodEnum.Delete,
          path: encode('1/indexes/%s/synonyms/%s', base.indexName, objectID),
        },
        mappedRequestOptions
      ),
      (response, waitRequestOptions) => waitTask(base)(response.taskID, waitRequestOptions)
    );
  };
};
github algolia / algoliasearch-client-javascript / packages / client-search / src / methods / index / setSettings.ts View on Github external
return (
    settings: Settings,
    requestOptions?: RequestOptions & SetSettingsOptions
  ): Readonly> => {
    const { forwardToReplicas, ...options } = requestOptions || {};
    const mappedRequestOptions = createMappedRequestOptions(options);

    if (forwardToReplicas) {
      mappedRequestOptions.queryParameters.forwardToReplicas = 1; // eslint-disable-line functional/immutable-data
    }

    return createWaitablePromise(
      base.transporter.write(
        {
          method: MethodEnum.Put,
          path: encode('1/indexes/%s/settings', base.indexName),
          data: settings,
        },
        mappedRequestOptions
      ),
      (response, waitRequestOptions) => waitTask(base)(response.taskID, waitRequestOptions)
    );
github algolia / algoliasearch-client-javascript / packages / client-search / src / methods / client / removeUserID.ts View on Github external
return (
    userID: string,
    requestOptions?: RequestOptions
  ): Readonly> => {
    const mappedRequestOptions = createMappedRequestOptions(requestOptions);

    // eslint-disable-next-line functional/immutable-data
    mappedRequestOptions.headers['X-Algolia-User-ID'] = userID;

    return base.transporter.write(
      {
        method: MethodEnum.Delete,
        path: '1/clusters/mapping',
      },
      mappedRequestOptions
    );
  };
};
github algolia / algoliasearch-client-javascript / packages / client-search / src / methods / client / listUserIDs.ts View on Github external
return (
    requestOptions?: ListUserIDsOptions & RequestOptions
  ): Readonly> => {
    const { page, hitsPerPage, ...options } = requestOptions || {};
    const mappedRequestOptions = createMappedRequestOptions(options);

    if (page) {
      mappedRequestOptions.queryParameters.page = page; // eslint-disable-line functional/immutable-data
    }

    if (hitsPerPage) {
      mappedRequestOptions.queryParameters.hitsPerPage = hitsPerPage; // eslint-disable-line functional/immutable-data
    }

    return base.transporter.read(
      {
        method: MethodEnum.Get,
        path: '1/clusters/mapping',
      },
      mappedRequestOptions
    );
github algolia / algoliasearch-client-javascript / packages / client-search / src / methods / index / getSettings.ts View on Github external
return (requestOptions?: RequestOptions): Readonly> => {
    const mappedRequestOptions = createMappedRequestOptions(requestOptions);

    // eslint-disable-next-line functional/immutable-data
    mappedRequestOptions.queryParameters.getVersion = '2';

    return base.transporter.read(
      {
        method: MethodEnum.Get,
        path: encode('1/indexes/%s/settings', base.indexName),
      },
      mappedRequestOptions
    );
  };
};
github algolia / algoliasearch-client-javascript / packages / client-search / src / methods / index / saveRules.ts View on Github external
return (
    rules: readonly Rule[],
    requestOptions?: RequestOptions & SaveRulesOptions
  ): Readonly> => {
    const { forwardToReplicas, clearExistingRules, ...options } = requestOptions || {};
    const mappedRequestOptions = createMappedRequestOptions(options);

    if (forwardToReplicas) {
      mappedRequestOptions.queryParameters.forwardToReplicas = 1; // eslint-disable-line functional/immutable-data
    }

    if (clearExistingRules) {
      mappedRequestOptions.queryParameters.clearExistingRules = 1; // eslint-disable-line functional/immutable-data
    }

    return createWaitablePromise(
      base.transporter.write(
        {
          method: MethodEnum.Post,
          path: encode('1/indexes/%s/rules/batch', base.indexName),
          data: rules,
        },
github algolia / algoliasearch-client-javascript / packages / client-search / src / methods / index / clearSynonyms.ts View on Github external
return (
    requestOptions?: ClearSynonymsOptions & RequestOptions
  ): Readonly> => {
    const { forwardToReplicas, ...options } = requestOptions || {};

    const mappedRequestOptions = createMappedRequestOptions(options);
    if (forwardToReplicas) {
      mappedRequestOptions.queryParameters.forwardToReplicas = 1; // eslint-disable-line functional/immutable-data
    }

    return createWaitablePromise(
      base.transporter.write(
        {
          method: MethodEnum.Post,
          path: encode('1/indexes/%s/synonyms/clear', base.indexName),
        },
        mappedRequestOptions
      ),
      (response, waitRequestOptions) => waitTask(base)(response.taskID, waitRequestOptions)
    );
  };
};