import * as url from 'url'; declare namespace bombas.storeback.api.v0.models { interface Product { readonly 'id'?: number; readonly 'title'?: string; readonly 'handle'?: string; readonly 'description'?: string; readonly 'description_html'?: string; readonly 'item_count'?: number; readonly 'product_type'?: string; readonly 'gender'?: string; readonly 'colors'?: bombas.storeback.api.v0.models.Color[]; readonly 'sizes'?: bombas.storeback.api.v0.models.Size[]; readonly 'images'?: any/*object*/[]; readonly 'variants'?: bombas.storeback.api.v0.models.Variant[]; readonly 'breadcrumbs'?: bombas.storeback.api.v0.models.Breadcrumb[]; readonly 'details'?: bombas.storeback.api.v0.models.Detail[]; readonly 'created_at'?: string; readonly 'updated_at'?: string; } interface Size { readonly 'name'?: string; readonly 'values'?: bombas.storeback.api.v0.models.SizeValues[]; } interface SizeValues { readonly 'id'?: string; readonly 'name'?: string; readonly 'guidance'?: string; } interface Color { readonly 'id'?: string; readonly 'position'?: number; readonly 'name'?: string; readonly 'fill'?: string; } interface Variant { readonly 'id'?: number; readonly 'product_id'?: number; readonly 'sku'?: string; readonly 'title'?: string; readonly 'is_available'?: boolean; readonly 'price'?: bombas.storeback.api.v0.models.Price; readonly 'shipping'?: bombas.storeback.api.v0.models.Shipping; readonly 'created_at'?: string; readonly 'updated_at'?: string; readonly 'sizes'?: bombas.storeback.api.v0.models.Size[]; } interface Shipping { readonly 'requires_shipping'?: boolean; readonly 'grams'?: number; readonly 'weight'?: number; readonly 'weight_unit'?: string; } interface Breadcrumb { readonly 'name'?: string; readonly 'link'?: string; readonly 'position'?: number; } interface Image { readonly 'id'?: number; readonly 'position'?: number; readonly 'alt'?: string; readonly 'src'?: string; } interface Price { readonly 'msrp'?: string; readonly 'price'?: string; readonly 'isDiscounted'?: boolean; readonly 'percentOff'?: string; } interface Detail { readonly 'icon_handle'?: string; readonly 'title'?: string; readonly 'tech'?: bombas.storeback.api.v0.models.Tech[]; } interface Tech { readonly 'title'?: string; readonly 'handle'?: string; readonly 'content'?: string; } } export type Breadcrumb = bombas.storeback.api.v0.models.Breadcrumb; export type Color = bombas.storeback.api.v0.models.Color; export type Detail = bombas.storeback.api.v0.models.Detail; export type Image = bombas.storeback.api.v0.models.Image; export type Price = bombas.storeback.api.v0.models.Price; export type Product = bombas.storeback.api.v0.models.Product; export type Shipping = bombas.storeback.api.v0.models.Shipping; export type Size = bombas.storeback.api.v0.models.Size; export type SizeValues = bombas.storeback.api.v0.models.SizeValues; export type Tech = bombas.storeback.api.v0.models.Tech; export type Variant = bombas.storeback.api.v0.models.Variant; export interface $FetchOptions { body?: string; headers?: $HttpHeaders; method?: $HttpMethod; } export type $FetchFunction = (url: string, options?: $FetchOptions) => Promise; export interface $HttpHeaders { [key: string]: string; } export type $HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'CONNECT' | 'OPTIONS' | 'TRACE'; export interface $HttpQuery { [key: string]: string | number | boolean | string[] | number[] | boolean[] | undefined | null; } export interface $HttpRequest { body?: any; url: string; headers: $HttpHeaders; method: $HttpMethod; } export interface $HttpRequestOptions { body?: any; endpoint: string; headers?: $HttpHeaders; method: $HttpMethod; query?: $HttpQuery; } export interface $HttpResponse { body: B; headers: $HttpHeaders; ok: O; request: $HttpRequest; status: S; statusText: string; } export type $HttpContinue = $HttpResponse; export type $HttpSwitchingProtocol = $HttpResponse; export type $HttpProcessing = $HttpResponse; export type $HttpOk = $HttpResponse; export type $HttpCreated = $HttpResponse; export type $HttpAccepted = $HttpResponse; export type $HttpNonAuthoritativeInformation = $HttpResponse; export type $HttpNoContent = $HttpResponse; export type $HttpResetContent = $HttpResponse; export type $HttpPartialContent = $HttpResponse; export type $HttpMultiStatus = $HttpResponse; export type $HttpAlreadyReported = $HttpResponse; export type $HttpImUsed = $HttpResponse; export type $HttpMultipleChoices = $HttpResponse; export type $HttpMovedPermanently = $HttpResponse; export type $HttpFound = $HttpResponse; export type $HttpSeeOther = $HttpResponse; export type $HttpNotModified = $HttpResponse; export type $HttpUseProxy = $HttpResponse; export type $HttpTemporaryRedirect = $HttpResponse; export type $HttpPermanentRedirect = $HttpResponse; export type $HttpBadRequest = $HttpResponse; export type $HttpUnauthorized = $HttpResponse; export type $HttpPaymentRequired = $HttpResponse; export type $HttpForbidden = $HttpResponse; export type $HttpNotFound = $HttpResponse; export type $HttpMethodNotAllowed = $HttpResponse; export type $HttpNotAcceptable = $HttpResponse; export type $HttpProxyAuthenticationRequired = $HttpResponse; export type $HttpRequestTimeout = $HttpResponse; export type $HttpConflict = $HttpResponse; export type $HttpGone = $HttpResponse; export type $HttpLengthRequired = $HttpResponse; export type $HttpPreconditionFailed = $HttpResponse; export type $HttpRequestEntityTooLarge = $HttpResponse; export type $HttpRequestUriTooLong = $HttpResponse; export type $HttpUnsupportedMediaType = $HttpResponse; export type $HttpRequestedRangeNotSatisfiable = $HttpResponse; export type $HttpExpectationFailed = $HttpResponse; export type $HttpMisdirectedRequest = $HttpResponse; export type $HttpUnprocessableEntity = $HttpResponse; export type $HttpLocked = $HttpResponse; export type $HttpFailedDependency = $HttpResponse; export type $HttpUpgradeRequired = $HttpResponse; export type $HttpPreconditionRequired = $HttpResponse; export type $HttpTooManyRequests = $HttpResponse; export type $HttpRequestHeaderFieldsTooLarge = $HttpResponse; export type $HttpNoResponse = $HttpResponse; export type $HttpRetryWith = $HttpResponse; export type $HttpBlockedByWindowsParentalControls = $HttpResponse; export type $HttpUnavailableForLegalReasons = $HttpResponse; export type $HttpClientClosedRequest = $HttpResponse; export type $HttpInternalServerError = $HttpResponse; export type $HttpNotImplemented = $HttpResponse; export type $HttpBadGateway = $HttpResponse; export type $HttpServiceUnavailable = $HttpResponse; export type $HttpGatewayTimeout = $HttpResponse; export type $HttpHttpVersionNotSupported = $HttpResponse; export type $HttpInsufficientStorage = $HttpResponse; export type $HttpLoopDetected = $HttpResponse; export type $HttpBandwidthLimitExceeded = $HttpResponse; export type $HttpNotExtended = $HttpResponse; export type $HttpNetworkAuthenticationRequired = $HttpResponse; export type $HttpNetworkReadTimeoutError = $HttpResponse; export type $HttpNetworkConnectTimeoutError = $HttpResponse; export interface $HttpClientOptions { fetch: $FetchFunction; } export function isResponseEmpty(response: Response): boolean { const contentLength = response.headers.get('Content-Length'); return response.status === 204 || contentLength != null && Number.parseInt(contentLength, 10) === 0; } export function isResponseJson(response: Response): boolean { const contentType = response.headers.get('Content-Type'); return contentType != null && contentType.indexOf('json') >= 0; } export function parseJson(response: Response): Promise { return !isResponseEmpty(response) && isResponseJson(response) ? response.json() : Promise.resolve(); } export function parseHeaders(response: Response): Record { const headers: Record = {}; response.headers.forEach((value, key) => { headers[key.toLowerCase()] = value; }); return headers; } export function stripQuery(query: $HttpQuery = {}): $HttpQuery { const initialValue: $HttpQuery = {}; return Object.keys(query).reduce((previousValue, key) => { const value = query[key]; if (value != null) previousValue[key] = value; return previousValue; }, initialValue); } export class $HttpClient { private options: $HttpClientOptions; constructor(options: $HttpClientOptions) { this.options = options; } public request(options: $HttpRequestOptions): Promise<$HttpResponse> { const finalUrl: string = url.format({ hostname: 'bombas-storeback-api.global.ssl.fastly.net', pathname: '/v1' + options.endpoint, protocol: 'https:', query: stripQuery(options.query), }); const finalHeaders: $HttpHeaders = { accept: 'application/json', 'content-type': 'application/json', ...options.headers, }; const request: $HttpRequest = { body: options.body, headers: finalHeaders, method: options.method, url: finalUrl, }; return this.options.fetch(request.url, { body: JSON.stringify(request.body), headers: request.headers, method: request.method, }).then((response) => { return parseJson(response).then((json) => { return { body: json, headers: parseHeaders(response), ok: response.ok, request, status: response.status, statusText: response.statusText, }; }); }); } } export class $Resource { protected client: $HttpClient; constructor(options: $HttpClientOptions) { this.client = new $HttpClient(options); } } export interface ProductsGetV1AndProductsByProductIdParameters { headers?: $HttpHeaders; /*The ID or handle of the product to return.*/ productId: string; } export type ProductsGetV1AndProductsByProductIdResponse = $HttpOk | $HttpBadRequest | $HttpNotFound | $Httpundefined; export class ProductsResource extends $Resource { /*Returns a product by ID or by handle. The following API will return a product object sanitized of private information from shopify. It should be thought of as a serializer or alturnative interface to the public shopify information per a product.*/ public getV1AndProductsByProductId(params: ProductsGetV1AndProductsByProductIdParameters): Promise { return this.client.request({ endpoint: `/v1/products/${encodeURIComponent(params.productId)}`, headers: params.headers, method: 'GET', }); } } export interface ClientInstance { products: ProductsResource; } export function createClient(options: $HttpClientOptions): ClientInstance { return { products: new ProductsResource(options), }; }