1 | "use strict";
|
2 |
|
3 |
|
4 | Object.defineProperty(exports, "__esModule", { value: true });
|
5 | exports.ClientApiBase = void 0;
|
6 | const vsom = require("./VsoClient");
|
7 | const serm = require("./Serialization");
|
8 | const rm = require("typed-rest-client/RestClient");
|
9 | const hm = require("typed-rest-client/HttpClient");
|
10 | class ClientApiBase {
|
11 | constructor(baseUrl, handlers, userAgent, options) {
|
12 | this.baseUrl = baseUrl;
|
13 | this.http = new hm.HttpClient(userAgent, handlers, options);
|
14 | this.rest = new rm.RestClient(userAgent, null, handlers, options);
|
15 | this.vsoClient = new vsom.VsoClient(baseUrl, this.rest);
|
16 | this.userAgent = userAgent;
|
17 | }
|
18 | createAcceptHeader(type, apiVersion) {
|
19 | return type + (apiVersion ? (';api-version=' + apiVersion) : '');
|
20 | }
|
21 | createRequestOptions(type, apiVersion) {
|
22 | let options = {};
|
23 | options.acceptHeader = this.createAcceptHeader(type, apiVersion);
|
24 | return options;
|
25 | }
|
26 | formatResponse(data, responseTypeMetadata, isCollection) {
|
27 | let serializationData = {
|
28 | responseTypeMetadata: responseTypeMetadata,
|
29 | responseIsCollection: isCollection
|
30 | };
|
31 | let deserializedResult = serm.ContractSerializer.deserialize(data, serializationData.responseTypeMetadata, false, serializationData.responseIsCollection);
|
32 | return deserializedResult;
|
33 | }
|
34 | }
|
35 | exports.ClientApiBase = ClientApiBase;
|