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AAkB,IAAlB,EAAuC,IAAA,GAAuC,IAA9E,EAAoF,iBAApF,EAA0H,MAA1H,EAA2J;AAC/K,WAAO,+BAAU,KAAK,YAAL,CAAkB,OAAlB,CAA0B,6CAAwB;AAAC,MAAA,QAAQ,EAAE,iBAAX;AAA8B,MAAA,IAA9B;AAAoC,MAAA,OAAO,EAAE,KAAK,cAAL,IAAuB;AAApE,KAAxB,EAAwG,IAAxG,EAA8G,MAA9G,CAA1B,EAAiJ,iBAAjJ,EAAoK,IAApK,CAAV,CAAP;AACD;;AAED,EAAA,UAAU,CAAC,OAAD,EAAgB;AACxB,WAAO,KAAK,cAAL,CAAoB,GAAG,KAAK,QAAQ,aAAa,OAAO,EAAxD,EAA4D,KAAK,IAAjE,EAAuE,IAAvE,EAA6E,KAAK,iBAAlF,CAAP;AACD;;AAED,EAAA,eAAe,CAAC,OAAD,EAAgB;AAC7B,WAAO,KAAK,cAAL,CAAiC,GAAG,KAAK,QAAQ,aAAa,OAAO,QAArE,EAA+E,KAAK,IAApF,EAA0F,IAA1F,EAAgG,KAAK,iBAArG,CAAP;AACD;;AAED,EAAA,aAAa,CAAC,OAAD,EAAgB;AAC3B,WAAO,KAAK,cAAL,CAA6B,GAAG,KAAK,QAAQ,WAA7C,EAA0D,KAAK,IAA/D,EAAqE;AAC1E,MAAA,IAAI,EAAE;AADoE,KAArE,EAEJ,KAAK,iBAFD,CAAP;AAGD;;AAED,EAAA,aAAa,CAAC,OAAD,EAAgB;AAC3B,WAAO,KAAK,cAAL,CAAoB,GAAG,KAAK,QAAQ,aAAa,OAAO,EAAxD,EAA4D,KAAK,IAAjE,EAAuE,IAAvE,EAA6E,KAAK,iBAAlF,EAAqG,QAArG,CAAP;AACD;;AAvDuB,C","sourcesContent":["import { CancellationToken } from \"./CancellationToken\"\nimport { configureRequestOptions, HttpExecutor, parseJson, RequestHeaders } from \"./httpExecutor\"\nimport { BintrayOptions } from \"./publishOptions\"\n\nexport interface Version {\n readonly name: string\n //noinspection ReservedWordAsName\n readonly package: string\n}\n\nexport interface File {\n name: string\n path: string\n\n sha1: string\n sha256: string\n}\n\nexport class BintrayClient {\n private readonly basePath: string\n readonly auth: string | null\n readonly repo: string\n\n readonly owner: string\n readonly user: string\n readonly component: string | null\n readonly distribution: string | null\n readonly packageName: string\n\n private requestHeaders: RequestHeaders | null = null\n\n setRequestHeaders(value: RequestHeaders | null) {\n this.requestHeaders = value\n }\n\n constructor(options: BintrayOptions, private readonly httpExecutor: HttpExecutor<any>, private readonly cancellationToken: CancellationToken, apiKey?: string | null) {\n if (options.owner == null) {\n throw new Error(\"owner is not specified\")\n }\n if (options.package == null) {\n throw new Error(\"package is not specified\")\n }\n\n this.repo = options.repo || \"generic\"\n this.packageName = options.package\n this.owner = options.owner\n this.user = options.user || options.owner\n this.component = options.component || null\n this.distribution = options.distribution || \"stable\"\n this.auth = apiKey == null ? null : `Basic ${Buffer.from(`${this.user}:${apiKey}`).toString(\"base64\")}`\n this.basePath = `/packages/${this.owner}/${this.repo}/${this.packageName}`\n }\n\n private bintrayRequest<T>(path: string, auth: string | null, data: {[name: string]: any; } | null = null, cancellationToken: CancellationToken, method?: \"GET\" | \"DELETE\" | \"PUT\"): Promise<T> {\n return parseJson(this.httpExecutor.request(configureRequestOptions({hostname: \"api.bintray.com\", path, headers: this.requestHeaders || undefined}, auth, method), cancellationToken, data))\n }\n\n getVersion(version: string): Promise<Version> {\n return this.bintrayRequest(`${this.basePath}/versions/${version}`, this.auth, null, this.cancellationToken)\n }\n\n getVersionFiles(version: string): Promise<Array<File>> {\n return this.bintrayRequest<Array<File>>(`${this.basePath}/versions/${version}/files`, this.auth, null, this.cancellationToken)\n }\n\n createVersion(version: string): Promise<any> {\n return this.bintrayRequest<Version>(`${this.basePath}/versions`, this.auth, {\n name: version,\n }, this.cancellationToken)\n }\n\n deleteVersion(version: string): Promise<any> {\n return this.bintrayRequest(`${this.basePath}/versions/${version}`, this.auth, null, this.cancellationToken, \"DELETE\")\n }\n}"],"sourceRoot":""}