lhisp-oauth-client 1.0.23 → 1.0.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lhisp-oauth-client",
3
- "version": "1.0.23",
3
+ "version": "1.0.24",
4
4
  "main": "src/index",
5
5
  "types": "src/index.d.ts",
6
6
  "repository": "git@bitbucket.org:leandro_costa/lhisp-oauth-client.git",
@@ -33,10 +33,10 @@ export declare class LhispOauthClient<iAccessToken extends AccessToken = AccessT
33
33
  getAccessToken(): Promise<iAccessToken>;
34
34
  buildAccessToken(data: any): iAccessToken;
35
35
  getAuthToken(): string;
36
- executarRequest<ResponseType>({ method, path, data, params, contentType, }: ExecutarRequestParams): Promise<ResponseType>;
37
- get<ResponseType>({ path, contentType, params }: ExecutarRequestParams): Promise<ResponseType>;
38
- put<ResponseType>({ path, data, contentType }: ExecutarRequestParams): Promise<ResponseType>;
39
- patch<ResponseType>({ path, data, contentType }: ExecutarRequestParams): Promise<ResponseType>;
40
- post<ResponseType>({ path, data, contentType }: ExecutarRequestParams): Promise<ResponseType>;
41
- delete<ResponseType>({ path, contentType }: ExecutarRequestParams): Promise<ResponseType>;
36
+ executarRequest<ResponseType>({ method, path, data, params, contentType, ...opt }: ExecutarRequestParams): Promise<ResponseType>;
37
+ get<ResponseType>(opt: ExecutarRequestParams): Promise<ResponseType>;
38
+ put<ResponseType>(opt: ExecutarRequestParams): Promise<ResponseType>;
39
+ patch<ResponseType>(opt: ExecutarRequestParams): Promise<ResponseType>;
40
+ post<ResponseType>(opt: ExecutarRequestParams): Promise<ResponseType>;
41
+ delete<ResponseType>(opt: ExecutarRequestParams): Promise<ResponseType>;
42
42
  }
@@ -8,6 +8,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
+ var __rest = (this && this.__rest) || function (s, e) {
12
+ var t = {};
13
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
14
+ t[p] = s[p];
15
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
16
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
17
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
18
+ t[p[i]] = s[p[i]];
19
+ }
20
+ return t;
21
+ };
11
22
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
23
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
24
  };
@@ -125,19 +136,15 @@ class LhispOauthClient {
125
136
  }
126
137
  return `${(_a = this.accessToken) === null || _a === void 0 ? void 0 : _a.token_type} ${(_b = this.accessToken) === null || _b === void 0 ? void 0 : _b.access_token}`;
127
138
  }
128
- executarRequest({ method, path, data, params, contentType = lhisp_oauth_client_t_1.ContentType.APPLICATION_JSON, }) {
139
+ executarRequest(_a) {
140
+ var { method, path, data, params, contentType = lhisp_oauth_client_t_1.ContentType.APPLICATION_JSON } = _a, opt = __rest(_a, ["method", "path", "data", "params", "contentType"]);
129
141
  return __awaiter(this, void 0, void 0, function* () {
130
142
  try {
131
143
  yield this.getAccessToken();
132
144
  const headers = Object.assign({ "Content-Type": contentType, [this.tokenHeaderName]: this.getAuthToken() }, (this.headers || {}));
133
- const response = yield axios_1.default.request({
134
- method,
135
- url: `${this.apiUrl}${path}`,
136
- httpsAgent: this.agent,
137
- headers,
145
+ const response = yield axios_1.default.request(Object.assign({ method, url: `${this.apiUrl}${path}`, httpsAgent: this.agent, headers,
138
146
  data,
139
- params,
140
- });
147
+ params }, opt));
141
148
  return response.data;
142
149
  }
143
150
  catch (error) {
@@ -154,53 +161,29 @@ class LhispOauthClient {
154
161
  }
155
162
  });
156
163
  }
157
- get({ path, contentType = lhisp_oauth_client_t_1.ContentType.APPLICATION_JSON, params }) {
164
+ get(opt) {
158
165
  return __awaiter(this, void 0, void 0, function* () {
159
- return this.executarRequest({
160
- method: "GET",
161
- path,
162
- contentType,
163
- params,
164
- });
166
+ return this.executarRequest(Object.assign({ method: "GET" }, opt));
165
167
  });
166
168
  }
167
- put({ path, data, contentType = lhisp_oauth_client_t_1.ContentType.APPLICATION_JSON }) {
169
+ put(opt) {
168
170
  return __awaiter(this, void 0, void 0, function* () {
169
- return this.executarRequest({
170
- method: "PUT",
171
- path,
172
- data,
173
- contentType,
174
- });
171
+ return this.executarRequest(Object.assign({ method: "PUT" }, opt));
175
172
  });
176
173
  }
177
- patch({ path, data, contentType = lhisp_oauth_client_t_1.ContentType.APPLICATION_JSON }) {
174
+ patch(opt) {
178
175
  return __awaiter(this, void 0, void 0, function* () {
179
- return this.executarRequest({
180
- method: "PATCH",
181
- path,
182
- data,
183
- contentType,
184
- });
176
+ return this.executarRequest(Object.assign({ method: "PATCH" }, opt));
185
177
  });
186
178
  }
187
- post({ path, data, contentType = lhisp_oauth_client_t_1.ContentType.APPLICATION_JSON }) {
179
+ post(opt) {
188
180
  return __awaiter(this, void 0, void 0, function* () {
189
- return this.executarRequest({
190
- method: "POST",
191
- path,
192
- data,
193
- contentType,
194
- });
181
+ return this.executarRequest(Object.assign({ method: "POST" }, opt));
195
182
  });
196
183
  }
197
- delete({ path, contentType = lhisp_oauth_client_t_1.ContentType.APPLICATION_JSON }) {
184
+ delete(opt) {
198
185
  return __awaiter(this, void 0, void 0, function* () {
199
- return this.executarRequest({
200
- method: "DELETE",
201
- path,
202
- contentType,
203
- });
186
+ return this.executarRequest(Object.assign({ method: "DELETE" }, opt));
204
187
  });
205
188
  }
206
189
  }