How to use the @algolia/requester-common.MethodEnum.Post function in @algolia/requester-common

To help you get started, we’ve selected a few @algolia/requester-common 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 / 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)
    );
  };
};
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 / transporter / src / __tests__ / fixtures.ts View on Github external
transporterRequest() {
      return {
        method: MethodEnum.Post,
        path: 'save',
        data: {},
        cacheable: false,
      };
    },
github algolia / algoliasearch-client-javascript / packages / client-search / src / methods / index / searchSynonyms.ts View on Github external
return (
    query: string,
    requestOptions?: SearchSynonymsOptions & RequestOptions
  ): Readonly> => {
    return base.transporter.read(
      {
        method: MethodEnum.Post,
        path: encode('1/indexes/%s/synonyms/search', base.indexName),
        data: {
          query,
        },
      },
      requestOptions
    );
  };
};
github algolia / algoliasearch-client-javascript / packages / client-search / src / methods / client / addApiKey.ts View on Github external
const wait: Wait = (response, waitRequestOptions) => {
      return createRetryablePromise(retry => {
        return getApiKey(base)(response.key, waitRequestOptions).catch((apiError: ApiError) => {
          if (apiError.status === 404) {
            throw apiError;
          }

          return retry();
        });
      });
    };

    return createWaitablePromise(
      base.transporter.write(
        {
          method: MethodEnum.Post,
          path: '1/keys',
          data,
        },
        options
      ),
      wait
    );
  };
};
github algolia / algoliasearch-client-javascript / packages / client-search / src / methods / index / deleteBy.ts View on Github external
return (
    filters: DeleteByFiltersOptions,
    requestOptions?: RequestOptions
  ): Readonly> => {
    return createWaitablePromise(
      base.transporter.write(
        {
          method: MethodEnum.Post,
          path: encode('1/indexes/%s/deleteByQuery', base.indexName),
          data: filters,
        },
        requestOptions
      ),
      (response, waitRequestOptions) => waitTask(base)(response.taskID, waitRequestOptions)
    );
  };
};
github algolia / algoliasearch-client-javascript / packages / client-search / src / methods / index / browseObjects.ts View on Github external
request: (data: object): Readonly>> =>
        base.transporter.read(
          {
            method: MethodEnum.Post,
            path: encode('1/indexes/%s/browse', base.indexName),
            data,
          },
          requestOptions
        ),
    });
github algolia / algoliasearch-client-javascript / packages / client-search / src / methods / client / multipleQueries.ts View on Github external
return (
    queries: readonly MultipleQueriesQuery[],
    requestOptions?: RequestOptions & MultipleQueriesOptions
  ): Readonly>> => {
    const requests = queries.map(query => {
      return {
        ...query,
        params: serializeQueryParameters(query.params || {}),
      };
    });

    return base.transporter.read(
      {
        method: MethodEnum.Post,
        path: '1/indexes/*/queries',
        data: {
          requests,
        },
        cacheable: true,
      },
      requestOptions
    );
  };
};
github algolia / algoliasearch-client-javascript / packages / client-search / src / methods / index / getObjects.ts View on Github external
objectIDs: readonly string[],
    requestOptions?: RequestOptions & GetObjectsOptions
  ): Readonly>> => {
    const { attributesToRetrieve, ...options } = requestOptions || {};

    const requests = objectIDs.map(objectID => {
      return {
        indexName: base.indexName,
        objectID,
        ...(attributesToRetrieve ? { attributesToRetrieve } : {}),
      };
    });

    return base.transporter.read(
      {
        method: MethodEnum.Post,
        path: '1/indexes/*/objects',
        data: {
          requests,
        },
      },
      options
    );
  };
};
github algolia / algoliasearch-client-javascript / packages / client-search / src / methods / client / searchUserIDs.ts View on Github external
return (
    query: string,
    requestOptions?: SearchUserIDsOptions & RequestOptions
  ): Readonly> => {
    return base.transporter.read(
      {
        method: MethodEnum.Post,
        path: '1/clusters/mapping/search',
        data: {
          query,
        },
      },
      requestOptions
    );
  };
};

@algolia/requester-common

Common interfaces for promise-based request libraries

MIT
Latest version published 5 months ago

Package Health Score

78 / 100
Full package analysis

Similar packages