All files / src/clients/http_client types.ts

100% Statements 6/6
100% Branches 2/2
100% Functions 1/1
100% Lines 6/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47  15x 15x   15x 15x 15x 15x                                                                              
import {Method} from '@shopify/network';
import {Headers} from 'node-fetch';
 
export interface HeaderParams {
  [key: string]: string | number;
}
 
export enum DataType {
  JSON = 'application/json', // eslint-disable-line @shopify/typescript/prefer-pascal-case-enums
  GraphQL = 'application/graphql', // eslint-disable-line @shopify/typescript/prefer-pascal-case-enums
  URLEncoded = 'application/x-www-form-urlencoded', // eslint-disable-line @shopify/typescript/prefer-pascal-case-enums
}
 
export type QueryParams =
  | string
  | number
  | string[]
  | number[]
  | {[key: string]: QueryParams};
 
export interface GetRequestParams {
  path: string;
  type?: DataType;
  data?: {[key: string]: unknown} | string;
  query?: {[key: string]: QueryParams};
  extraHeaders?: HeaderParams;
  tries?: number;
}
 
export type PostRequestParams = GetRequestParams & {
  type: DataType;
  data: {[key: string]: unknown} | string;
};
 
export type PutRequestParams = PostRequestParams;
 
export type DeleteRequestParams = GetRequestParams;
 
export type RequestParams = (GetRequestParams | PostRequestParams) & {
  method: Method;
};
 
export interface RequestReturn<T = unknown> {
  body: T;
  headers: Headers;
}