import * as url from 'url'; declare namespace io.apibuilder.postman.collection.v21.v0.enums { type AuthEnum = 'awsv4' | 'basic' | 'bearer' | 'digest' | 'hawk' | 'noauth' | 'oauth1' | 'oauth2' | 'ntlm'; type BodyMode = 'raw' | 'urlencoded' | 'formdata' | 'file'; type EventType = 'test' | 'prerequest'; type Method = 'GET' | 'PUT' | 'POST' | 'PATCH' | 'DELETE' | 'COPY' | 'HEAD' | 'OPTIONS' | 'LINK' | 'UNLINK' | 'PURGE' | 'LOCK' | 'UNLOCK' | 'PROPFIND' | 'VIEW'; } declare namespace io.apibuilder.postman.collection.v21.v0.models { interface Auth { readonly 'type': io.apibuilder.postman.collection.v21.v0.enums.AuthEnum; readonly 'basic'?: io.apibuilder.postman.collection.v21.v0.models.BasicAuth[]; } interface BasicAuth { readonly 'key': string; readonly 'value': string; readonly 'type'?: string; } interface Body { readonly 'raw'?: string; readonly 'mode'?: io.apibuilder.postman.collection.v21.v0.enums.BodyMode; readonly 'urlencoded'?: io.apibuilder.postman.collection.v21.v0.models.UrlEncoded[]; readonly 'file'?: io.apibuilder.postman.collection.v21.v0.models.File; readonly 'formdata'?: io.apibuilder.postman.collection.v21.v0.models.FormParameter[]; } interface Collection { readonly 'info': io.apibuilder.postman.collection.v21.v0.models.Info; readonly 'item': io.apibuilder.postman.collection.v21.v0.unions.Items[]; readonly 'event': io.apibuilder.postman.collection.v21.v0.models.Event[]; readonly 'variable': io.apibuilder.postman.collection.v21.v0.models.Variable[]; readonly 'auth'?: io.apibuilder.postman.collection.v21.v0.models.Auth; } interface Description { readonly 'content'?: string; readonly 'type'?: string; } interface Event { readonly 'listen': io.apibuilder.postman.collection.v21.v0.enums.EventType; readonly 'script'?: io.apibuilder.postman.collection.v21.v0.models.Script; readonly 'id'?: string; readonly 'disabled'?: boolean; } interface File { readonly 'src'?: string; readonly 'content'?: string; } interface Folder { readonly 'type': 'folder'; readonly 'name': string; readonly 'description'?: io.apibuilder.postman.collection.v21.v0.models.Description; readonly 'variable'?: io.apibuilder.postman.collection.v21.v0.models.Variable[]; readonly 'item': io.apibuilder.postman.collection.v21.v0.models.Item[]; readonly 'event'?: io.apibuilder.postman.collection.v21.v0.models.Event[]; readonly 'auth'?: io.apibuilder.postman.collection.v21.v0.models.Auth; } interface FormParameter { readonly 'key': string; readonly 'value'?: string; readonly 'disabled'?: boolean; readonly 'description'?: io.apibuilder.postman.collection.v21.v0.models.Description; readonly 'contentType'?: string; readonly 'type'?: string; } interface Header { readonly 'key': string; readonly 'value': string; readonly 'disabled'?: boolean; readonly 'description'?: io.apibuilder.postman.collection.v21.v0.models.Description; } interface Info { readonly 'name': string; readonly 'postman_id'?: string; readonly 'description'?: io.apibuilder.postman.collection.v21.v0.models.Description; readonly 'version'?: string; readonly 'schema': string; } interface Item { readonly 'type': 'item'; readonly 'id'?: string; readonly 'name'?: string; readonly 'description'?: io.apibuilder.postman.collection.v21.v0.models.Description; readonly 'variable'?: io.apibuilder.postman.collection.v21.v0.models.Variable[]; readonly 'event'?: io.apibuilder.postman.collection.v21.v0.models.Event[]; readonly 'request': io.apibuilder.postman.collection.v21.v0.models.Request; readonly 'response'?: io.apibuilder.postman.collection.v21.v0.models.Response[]; } interface QueryParam { readonly 'key'?: string; readonly 'value'?: string; readonly 'disabled'?: boolean; readonly 'description'?: io.apibuilder.postman.collection.v21.v0.models.Description; } interface Request { readonly 'url'?: io.apibuilder.postman.collection.v21.v0.models.Url; readonly 'auth'?: io.apibuilder.postman.collection.v21.v0.models.Auth; readonly 'method'?: io.apibuilder.postman.collection.v21.v0.enums.Method; readonly 'description'?: io.apibuilder.postman.collection.v21.v0.models.Description; readonly 'header'?: io.apibuilder.postman.collection.v21.v0.models.Header[]; readonly 'body'?: io.apibuilder.postman.collection.v21.v0.models.Body; } interface Response { readonly 'id'?: string; readonly 'name'?: string; readonly 'originalRequest'?: io.apibuilder.postman.collection.v21.v0.models.Request; readonly 'responseTime'?: string; readonly 'header'?: io.apibuilder.postman.collection.v21.v0.models.Header[]; readonly 'body'?: string; readonly 'status'?: string; readonly 'code'?: number; } interface Script { readonly 'exec': string[]; readonly 'type': string; readonly 'id'?: string; readonly 'src'?: string; readonly 'name'?: string; } interface Url { readonly 'raw'?: string; readonly 'protocol'?: string; readonly 'host'?: string[]; readonly 'path'?: string[]; readonly 'port'?: string; readonly 'query'?: io.apibuilder.postman.collection.v21.v0.models.QueryParam[]; readonly 'hash'?: string; readonly 'variable'?: io.apibuilder.postman.collection.v21.v0.models.Variable[]; } interface UrlEncoded { readonly 'key': string; readonly 'value'?: string; readonly 'disabled'?: boolean; readonly 'description'?: io.apibuilder.postman.collection.v21.v0.models.Description; } interface Variable { readonly 'id'?: string; readonly 'key'?: string; readonly 'value'?: string; readonly 'type'?: string; readonly 'name'?: string; readonly 'description'?: io.apibuilder.postman.collection.v21.v0.models.Description; readonly 'system'?: boolean; readonly 'disabled'?: boolean; } } declare namespace io.apibuilder.postman.collection.v21.v0.unions { type Items = (io.apibuilder.postman.collection.v21.v0.models.Item | io.apibuilder.postman.collection.v21.v0.models.Folder); } export type Auth = io.apibuilder.postman.collection.v21.v0.models.Auth; export type AuthEnum = io.apibuilder.postman.collection.v21.v0.enums.AuthEnum; export type BasicAuth = io.apibuilder.postman.collection.v21.v0.models.BasicAuth; export type Body = io.apibuilder.postman.collection.v21.v0.models.Body; export type BodyMode = io.apibuilder.postman.collection.v21.v0.enums.BodyMode; export type Collection = io.apibuilder.postman.collection.v21.v0.models.Collection; export type Description = io.apibuilder.postman.collection.v21.v0.models.Description; export type Event = io.apibuilder.postman.collection.v21.v0.models.Event; export type EventType = io.apibuilder.postman.collection.v21.v0.enums.EventType; export type File = io.apibuilder.postman.collection.v21.v0.models.File; export type Folder = io.apibuilder.postman.collection.v21.v0.models.Folder; export type FormParameter = io.apibuilder.postman.collection.v21.v0.models.FormParameter; export type Header = io.apibuilder.postman.collection.v21.v0.models.Header; export type Info = io.apibuilder.postman.collection.v21.v0.models.Info; export type Item = io.apibuilder.postman.collection.v21.v0.models.Item; export type Items = io.apibuilder.postman.collection.v21.v0.unions.Items; export type Method = io.apibuilder.postman.collection.v21.v0.enums.Method; export type QueryParam = io.apibuilder.postman.collection.v21.v0.models.QueryParam; export type Request = io.apibuilder.postman.collection.v21.v0.models.Request; export type Response = io.apibuilder.postman.collection.v21.v0.models.Response; export type Script = io.apibuilder.postman.collection.v21.v0.models.Script; export type Url = io.apibuilder.postman.collection.v21.v0.models.Url; export type UrlEncoded = io.apibuilder.postman.collection.v21.v0.models.UrlEncoded; export type Variable = io.apibuilder.postman.collection.v21.v0.models.Variable; 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: 'www.getpostman.com', pathname: 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 ClientInstance {} export function createClient(options: $HttpClientOptions): ClientInstance { return {}; }