@tennac-booking/sdk 1.0.5 → 1.0.8

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.
Files changed (130) hide show
  1. package/.openapi-generator/FILES +1 -1
  2. package/README.md +1 -2
  3. package/api.ts +8 -273
  4. package/dist/api.d.ts +4 -156
  5. package/dist/api.js +9 -174
  6. package/dist/esm/api.d.ts +4 -156
  7. package/dist/esm/api.js +9 -170
  8. package/docs/UsersApi.md +4 -4
  9. package/package.json +4 -4
  10. package/apis/AuthApi.ts +0 -157
  11. package/apis/UsersApi.ts +0 -56
  12. package/apis/index.ts +0 -4
  13. package/dist/apis/AuthApi.d.ts +0 -39
  14. package/dist/apis/AuthApi.js +0 -117
  15. package/dist/apis/UsersApi.d.ts +0 -26
  16. package/dist/apis/UsersApi.js +0 -58
  17. package/dist/apis/index.d.ts +0 -2
  18. package/dist/apis/index.js +0 -20
  19. package/dist/esm/apis/AuthApi.d.ts +0 -39
  20. package/dist/esm/apis/AuthApi.js +0 -113
  21. package/dist/esm/apis/UsersApi.d.ts +0 -26
  22. package/dist/esm/apis/UsersApi.js +0 -54
  23. package/dist/esm/apis/index.d.ts +0 -2
  24. package/dist/esm/apis/index.js +0 -4
  25. package/dist/esm/models/Booking.d.ts +0 -87
  26. package/dist/esm/models/Booking.js +0 -82
  27. package/dist/esm/models/Court.d.ts +0 -76
  28. package/dist/esm/models/Court.js +0 -72
  29. package/dist/esm/models/Slot.d.ts +0 -44
  30. package/dist/esm/models/Slot.js +0 -51
  31. package/dist/esm/models/SlotException.d.ts +0 -50
  32. package/dist/esm/models/SlotException.js +0 -55
  33. package/dist/esm/models/User.d.ts +0 -92
  34. package/dist/esm/models/User.js +0 -69
  35. package/dist/esm/models/index.d.ts +0 -5
  36. package/dist/esm/models/index.js +0 -7
  37. package/dist/esm/runtime.d.ts +0 -184
  38. package/dist/esm/runtime.js +0 -334
  39. package/dist/esm/src/apis/AuthApi.d.ts +0 -39
  40. package/dist/esm/src/apis/AuthApi.js +0 -113
  41. package/dist/esm/src/apis/UsersApi.d.ts +0 -26
  42. package/dist/esm/src/apis/UsersApi.js +0 -54
  43. package/dist/esm/src/apis/index.d.ts +0 -2
  44. package/dist/esm/src/apis/index.js +0 -4
  45. package/dist/esm/src/index.d.ts +0 -3
  46. package/dist/esm/src/index.js +0 -5
  47. package/dist/esm/src/models/Booking.d.ts +0 -87
  48. package/dist/esm/src/models/Booking.js +0 -82
  49. package/dist/esm/src/models/BookingStatus.d.ts +0 -25
  50. package/dist/esm/src/models/BookingStatus.js +0 -43
  51. package/dist/esm/src/models/Court.d.ts +0 -76
  52. package/dist/esm/src/models/Court.js +0 -72
  53. package/dist/esm/src/models/CourtStatus.d.ts +0 -25
  54. package/dist/esm/src/models/CourtStatus.js +0 -43
  55. package/dist/esm/src/models/Slot.d.ts +0 -44
  56. package/dist/esm/src/models/Slot.js +0 -51
  57. package/dist/esm/src/models/SlotException.d.ts +0 -50
  58. package/dist/esm/src/models/SlotException.js +0 -55
  59. package/dist/esm/src/models/StripeStatus.d.ts +0 -28
  60. package/dist/esm/src/models/StripeStatus.js +0 -46
  61. package/dist/esm/src/models/User.d.ts +0 -92
  62. package/dist/esm/src/models/User.js +0 -69
  63. package/dist/esm/src/models/index.d.ts +0 -5
  64. package/dist/esm/src/models/index.js +0 -7
  65. package/dist/esm/src/runtime.d.ts +0 -184
  66. package/dist/esm/src/runtime.js +0 -334
  67. package/dist/models/Booking.d.ts +0 -87
  68. package/dist/models/Booking.js +0 -90
  69. package/dist/models/Court.d.ts +0 -76
  70. package/dist/models/Court.js +0 -80
  71. package/dist/models/Slot.d.ts +0 -44
  72. package/dist/models/Slot.js +0 -58
  73. package/dist/models/SlotException.d.ts +0 -50
  74. package/dist/models/SlotException.js +0 -62
  75. package/dist/models/User.d.ts +0 -92
  76. package/dist/models/User.js +0 -76
  77. package/dist/models/index.d.ts +0 -5
  78. package/dist/models/index.js +0 -23
  79. package/dist/runtime.d.ts +0 -184
  80. package/dist/runtime.js +0 -350
  81. package/dist/src/apis/AuthApi.d.ts +0 -39
  82. package/dist/src/apis/AuthApi.js +0 -117
  83. package/dist/src/apis/UsersApi.d.ts +0 -26
  84. package/dist/src/apis/UsersApi.js +0 -58
  85. package/dist/src/apis/index.d.ts +0 -2
  86. package/dist/src/apis/index.js +0 -20
  87. package/dist/src/index.d.ts +0 -3
  88. package/dist/src/index.js +0 -21
  89. package/dist/src/models/Booking.d.ts +0 -87
  90. package/dist/src/models/Booking.js +0 -90
  91. package/dist/src/models/BookingStatus.d.ts +0 -25
  92. package/dist/src/models/BookingStatus.js +0 -51
  93. package/dist/src/models/Court.d.ts +0 -76
  94. package/dist/src/models/Court.js +0 -80
  95. package/dist/src/models/CourtStatus.d.ts +0 -25
  96. package/dist/src/models/CourtStatus.js +0 -51
  97. package/dist/src/models/Slot.d.ts +0 -44
  98. package/dist/src/models/Slot.js +0 -58
  99. package/dist/src/models/SlotException.d.ts +0 -50
  100. package/dist/src/models/SlotException.js +0 -62
  101. package/dist/src/models/StripeStatus.d.ts +0 -28
  102. package/dist/src/models/StripeStatus.js +0 -54
  103. package/dist/src/models/User.d.ts +0 -92
  104. package/dist/src/models/User.js +0 -76
  105. package/dist/src/models/index.d.ts +0 -5
  106. package/dist/src/models/index.js +0 -23
  107. package/dist/src/runtime.d.ts +0 -184
  108. package/dist/src/runtime.js +0 -350
  109. package/docs/AuthApi.md +0 -88
  110. package/models/Booking.ts +0 -142
  111. package/models/Court.ts +0 -130
  112. package/models/Slot.ts +0 -84
  113. package/models/SlotException.ts +0 -93
  114. package/models/User.ts +0 -149
  115. package/models/index.ts +0 -7
  116. package/runtime.ts +0 -432
  117. package/src/apis/AuthApi.ts +0 -157
  118. package/src/apis/UsersApi.ts +0 -56
  119. package/src/apis/index.ts +0 -4
  120. package/src/index.ts +0 -5
  121. package/src/models/Booking.ts +0 -142
  122. package/src/models/BookingStatus.ts +0 -53
  123. package/src/models/Court.ts +0 -130
  124. package/src/models/CourtStatus.ts +0 -53
  125. package/src/models/Slot.ts +0 -84
  126. package/src/models/SlotException.ts +0 -93
  127. package/src/models/StripeStatus.ts +0 -56
  128. package/src/models/User.ts +0 -149
  129. package/src/models/index.ts +0 -7
  130. package/src/runtime.ts +0 -432
@@ -1,92 +0,0 @@
1
- /**
2
- * Pickle Ball API
3
- * API for managing pickle ball games and players
4
- *
5
- * The version of the OpenAPI document: 1.0.0
6
- *
7
- *
8
- * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9
- * https://openapi-generator.tech
10
- * Do not edit the class manually.
11
- */
12
- /**
13
- *
14
- * @export
15
- * @interface User
16
- */
17
- export interface User {
18
- /**
19
- *
20
- * @type {string}
21
- * @memberof User
22
- */
23
- username?: string;
24
- /**
25
- *
26
- * @type {string}
27
- * @memberof User
28
- */
29
- firstName: string;
30
- /**
31
- *
32
- * @type {string}
33
- * @memberof User
34
- */
35
- lastName: string;
36
- /**
37
- *
38
- * @type {string}
39
- * @memberof User
40
- */
41
- email: string;
42
- /**
43
- *
44
- * @type {boolean}
45
- * @memberof User
46
- */
47
- isAccountVerified?: boolean;
48
- /**
49
- *
50
- * @type {string}
51
- * @memberof User
52
- */
53
- level?: string;
54
- /**
55
- *
56
- * @type {string}
57
- * @memberof User
58
- */
59
- stripeCustomerId?: string;
60
- /**
61
- *
62
- * @type {string}
63
- * @memberof User
64
- */
65
- phone?: string;
66
- /**
67
- *
68
- * @type {string}
69
- * @memberof User
70
- */
71
- password: string;
72
- /**
73
- *
74
- * @type {string}
75
- * @memberof User
76
- */
77
- profilePicture?: string;
78
- /**
79
- *
80
- * @type {boolean}
81
- * @memberof User
82
- */
83
- isAdmin?: boolean;
84
- }
85
- /**
86
- * Check if a given object implements the User interface.
87
- */
88
- export declare function instanceOfUser(value: object): value is User;
89
- export declare function UserFromJSON(json: any): User;
90
- export declare function UserFromJSONTyped(json: any, ignoreDiscriminator: boolean): User;
91
- export declare function UserToJSON(json: any): User;
92
- export declare function UserToJSONTyped(value?: User | null, ignoreDiscriminator?: boolean): any;
@@ -1,69 +0,0 @@
1
- /* tslint:disable */
2
- /* eslint-disable */
3
- /**
4
- * Pickle Ball API
5
- * API for managing pickle ball games and players
6
- *
7
- * The version of the OpenAPI document: 1.0.0
8
- *
9
- *
10
- * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
11
- * https://openapi-generator.tech
12
- * Do not edit the class manually.
13
- */
14
- /**
15
- * Check if a given object implements the User interface.
16
- */
17
- export function instanceOfUser(value) {
18
- if (!('firstName' in value) || value['firstName'] === undefined)
19
- return false;
20
- if (!('lastName' in value) || value['lastName'] === undefined)
21
- return false;
22
- if (!('email' in value) || value['email'] === undefined)
23
- return false;
24
- if (!('password' in value) || value['password'] === undefined)
25
- return false;
26
- return true;
27
- }
28
- export function UserFromJSON(json) {
29
- return UserFromJSONTyped(json, false);
30
- }
31
- export function UserFromJSONTyped(json, ignoreDiscriminator) {
32
- if (json == null) {
33
- return json;
34
- }
35
- return {
36
- 'username': json['username'] == null ? undefined : json['username'],
37
- 'firstName': json['firstName'],
38
- 'lastName': json['lastName'],
39
- 'email': json['email'],
40
- 'isAccountVerified': json['isAccountVerified'] == null ? undefined : json['isAccountVerified'],
41
- 'level': json['level'] == null ? undefined : json['level'],
42
- 'stripeCustomerId': json['stripeCustomerId'] == null ? undefined : json['stripeCustomerId'],
43
- 'phone': json['phone'] == null ? undefined : json['phone'],
44
- 'password': json['password'],
45
- 'profilePicture': json['profilePicture'] == null ? undefined : json['profilePicture'],
46
- 'isAdmin': json['isAdmin'] == null ? undefined : json['isAdmin'],
47
- };
48
- }
49
- export function UserToJSON(json) {
50
- return UserToJSONTyped(json, false);
51
- }
52
- export function UserToJSONTyped(value, ignoreDiscriminator = false) {
53
- if (value == null) {
54
- return value;
55
- }
56
- return {
57
- 'username': value['username'],
58
- 'firstName': value['firstName'],
59
- 'lastName': value['lastName'],
60
- 'email': value['email'],
61
- 'isAccountVerified': value['isAccountVerified'],
62
- 'level': value['level'],
63
- 'stripeCustomerId': value['stripeCustomerId'],
64
- 'phone': value['phone'],
65
- 'password': value['password'],
66
- 'profilePicture': value['profilePicture'],
67
- 'isAdmin': value['isAdmin'],
68
- };
69
- }
@@ -1,5 +0,0 @@
1
- export * from './Booking';
2
- export * from './Court';
3
- export * from './Slot';
4
- export * from './SlotException';
5
- export * from './User';
@@ -1,7 +0,0 @@
1
- /* tslint:disable */
2
- /* eslint-disable */
3
- export * from './Booking';
4
- export * from './Court';
5
- export * from './Slot';
6
- export * from './SlotException';
7
- export * from './User';
@@ -1,184 +0,0 @@
1
- /**
2
- * Pickle Ball API
3
- * API for managing pickle ball games and players
4
- *
5
- * The version of the OpenAPI document: 1.0.0
6
- *
7
- *
8
- * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9
- * https://openapi-generator.tech
10
- * Do not edit the class manually.
11
- */
12
- export declare const BASE_PATH: string;
13
- export interface ConfigurationParameters {
14
- basePath?: string;
15
- fetchApi?: FetchAPI;
16
- middleware?: Middleware[];
17
- queryParamsStringify?: (params: HTTPQuery) => string;
18
- username?: string;
19
- password?: string;
20
- apiKey?: string | Promise<string> | ((name: string) => string | Promise<string>);
21
- accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string | Promise<string>);
22
- headers?: HTTPHeaders;
23
- credentials?: RequestCredentials;
24
- }
25
- export declare class Configuration {
26
- private configuration;
27
- constructor(configuration?: ConfigurationParameters);
28
- set config(configuration: Configuration);
29
- get basePath(): string;
30
- get fetchApi(): FetchAPI | undefined;
31
- get middleware(): Middleware[];
32
- get queryParamsStringify(): (params: HTTPQuery) => string;
33
- get username(): string | undefined;
34
- get password(): string | undefined;
35
- get apiKey(): ((name: string) => string | Promise<string>) | undefined;
36
- get accessToken(): ((name?: string, scopes?: string[]) => string | Promise<string>) | undefined;
37
- get headers(): HTTPHeaders | undefined;
38
- get credentials(): RequestCredentials | undefined;
39
- }
40
- export declare const DefaultConfig: Configuration;
41
- /**
42
- * This is the base class for all generated API classes.
43
- */
44
- export declare class BaseAPI {
45
- protected configuration: Configuration;
46
- private static readonly jsonRegex;
47
- private middleware;
48
- constructor(configuration?: Configuration);
49
- withMiddleware<T extends BaseAPI>(this: T, ...middlewares: Middleware[]): T;
50
- withPreMiddleware<T extends BaseAPI>(this: T, ...preMiddlewares: Array<Middleware['pre']>): T;
51
- withPostMiddleware<T extends BaseAPI>(this: T, ...postMiddlewares: Array<Middleware['post']>): T;
52
- /**
53
- * Check if the given MIME is a JSON MIME.
54
- * JSON MIME examples:
55
- * application/json
56
- * application/json; charset=UTF8
57
- * APPLICATION/JSON
58
- * application/vnd.company+json
59
- * @param mime - MIME (Multipurpose Internet Mail Extensions)
60
- * @return True if the given MIME is JSON, false otherwise.
61
- */
62
- protected isJsonMime(mime: string | null | undefined): boolean;
63
- protected request(context: RequestOpts, initOverrides?: RequestInit | InitOverrideFunction): Promise<Response>;
64
- private createFetchParams;
65
- private fetchApi;
66
- /**
67
- * Create a shallow clone of `this` by constructing a new instance
68
- * and then shallow cloning data members.
69
- */
70
- private clone;
71
- }
72
- export declare class ResponseError extends Error {
73
- response: Response;
74
- name: "ResponseError";
75
- constructor(response: Response, msg?: string);
76
- }
77
- export declare class FetchError extends Error {
78
- cause: Error;
79
- name: "FetchError";
80
- constructor(cause: Error, msg?: string);
81
- }
82
- export declare class RequiredError extends Error {
83
- field: string;
84
- name: "RequiredError";
85
- constructor(field: string, msg?: string);
86
- }
87
- export declare const COLLECTION_FORMATS: {
88
- csv: string;
89
- ssv: string;
90
- tsv: string;
91
- pipes: string;
92
- };
93
- export type FetchAPI = WindowOrWorkerGlobalScope['fetch'];
94
- export type Json = any;
95
- export type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | 'HEAD';
96
- export type HTTPHeaders = {
97
- [key: string]: string;
98
- };
99
- export type HTTPQuery = {
100
- [key: string]: string | number | null | boolean | Array<string | number | null | boolean> | Set<string | number | null | boolean> | HTTPQuery;
101
- };
102
- export type HTTPBody = Json | FormData | URLSearchParams;
103
- export type HTTPRequestInit = {
104
- headers?: HTTPHeaders;
105
- method: HTTPMethod;
106
- credentials?: RequestCredentials;
107
- body?: HTTPBody;
108
- };
109
- export type ModelPropertyNaming = 'camelCase' | 'snake_case' | 'PascalCase' | 'original';
110
- export type InitOverrideFunction = (requestContext: {
111
- init: HTTPRequestInit;
112
- context: RequestOpts;
113
- }) => Promise<RequestInit>;
114
- export interface FetchParams {
115
- url: string;
116
- init: RequestInit;
117
- }
118
- export interface RequestOpts {
119
- path: string;
120
- method: HTTPMethod;
121
- headers: HTTPHeaders;
122
- query?: HTTPQuery;
123
- body?: HTTPBody;
124
- }
125
- export declare function querystring(params: HTTPQuery, prefix?: string): string;
126
- export declare function exists(json: any, key: string): boolean;
127
- export declare function mapValues(data: any, fn: (item: any) => any): {
128
- [key: string]: any;
129
- };
130
- export declare function canConsumeForm(consumes: Consume[]): boolean;
131
- export interface Consume {
132
- contentType: string;
133
- }
134
- export interface RequestContext {
135
- fetch: FetchAPI;
136
- url: string;
137
- init: RequestInit;
138
- }
139
- export interface ResponseContext {
140
- fetch: FetchAPI;
141
- url: string;
142
- init: RequestInit;
143
- response: Response;
144
- }
145
- export interface ErrorContext {
146
- fetch: FetchAPI;
147
- url: string;
148
- init: RequestInit;
149
- error: unknown;
150
- response?: Response;
151
- }
152
- export interface Middleware {
153
- pre?(context: RequestContext): Promise<FetchParams | void>;
154
- post?(context: ResponseContext): Promise<Response | void>;
155
- onError?(context: ErrorContext): Promise<Response | void>;
156
- }
157
- export interface ApiResponse<T> {
158
- raw: Response;
159
- value(): Promise<T>;
160
- }
161
- export interface ResponseTransformer<T> {
162
- (json: any): T;
163
- }
164
- export declare class JSONApiResponse<T> {
165
- raw: Response;
166
- private transformer;
167
- constructor(raw: Response, transformer?: ResponseTransformer<T>);
168
- value(): Promise<T>;
169
- }
170
- export declare class VoidApiResponse {
171
- raw: Response;
172
- constructor(raw: Response);
173
- value(): Promise<void>;
174
- }
175
- export declare class BlobApiResponse {
176
- raw: Response;
177
- constructor(raw: Response);
178
- value(): Promise<Blob>;
179
- }
180
- export declare class TextApiResponse {
181
- raw: Response;
182
- constructor(raw: Response);
183
- value(): Promise<string>;
184
- }
@@ -1,334 +0,0 @@
1
- /* tslint:disable */
2
- /* eslint-disable */
3
- /**
4
- * Pickle Ball API
5
- * API for managing pickle ball games and players
6
- *
7
- * The version of the OpenAPI document: 1.0.0
8
- *
9
- *
10
- * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
11
- * https://openapi-generator.tech
12
- * Do not edit the class manually.
13
- */
14
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
15
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
16
- return new (P || (P = Promise))(function (resolve, reject) {
17
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
18
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
19
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
20
- step((generator = generator.apply(thisArg, _arguments || [])).next());
21
- });
22
- };
23
- export const BASE_PATH = "https://api.mon-domaine.com".replace(/\/+$/, "");
24
- export class Configuration {
25
- constructor(configuration = {}) {
26
- this.configuration = configuration;
27
- }
28
- set config(configuration) {
29
- this.configuration = configuration;
30
- }
31
- get basePath() {
32
- return this.configuration.basePath != null ? this.configuration.basePath : BASE_PATH;
33
- }
34
- get fetchApi() {
35
- return this.configuration.fetchApi;
36
- }
37
- get middleware() {
38
- return this.configuration.middleware || [];
39
- }
40
- get queryParamsStringify() {
41
- return this.configuration.queryParamsStringify || querystring;
42
- }
43
- get username() {
44
- return this.configuration.username;
45
- }
46
- get password() {
47
- return this.configuration.password;
48
- }
49
- get apiKey() {
50
- const apiKey = this.configuration.apiKey;
51
- if (apiKey) {
52
- return typeof apiKey === 'function' ? apiKey : () => apiKey;
53
- }
54
- return undefined;
55
- }
56
- get accessToken() {
57
- const accessToken = this.configuration.accessToken;
58
- if (accessToken) {
59
- return typeof accessToken === 'function' ? accessToken : () => __awaiter(this, void 0, void 0, function* () { return accessToken; });
60
- }
61
- return undefined;
62
- }
63
- get headers() {
64
- return this.configuration.headers;
65
- }
66
- get credentials() {
67
- return this.configuration.credentials;
68
- }
69
- }
70
- export const DefaultConfig = new Configuration();
71
- /**
72
- * This is the base class for all generated API classes.
73
- */
74
- export class BaseAPI {
75
- constructor(configuration = DefaultConfig) {
76
- this.configuration = configuration;
77
- this.fetchApi = (url, init) => __awaiter(this, void 0, void 0, function* () {
78
- let fetchParams = { url, init };
79
- for (const middleware of this.middleware) {
80
- if (middleware.pre) {
81
- fetchParams = (yield middleware.pre(Object.assign({ fetch: this.fetchApi }, fetchParams))) || fetchParams;
82
- }
83
- }
84
- let response = undefined;
85
- try {
86
- response = yield (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init);
87
- }
88
- catch (e) {
89
- for (const middleware of this.middleware) {
90
- if (middleware.onError) {
91
- response = (yield middleware.onError({
92
- fetch: this.fetchApi,
93
- url: fetchParams.url,
94
- init: fetchParams.init,
95
- error: e,
96
- response: response ? response.clone() : undefined,
97
- })) || response;
98
- }
99
- }
100
- if (response === undefined) {
101
- if (e instanceof Error) {
102
- throw new FetchError(e, 'The request failed and the interceptors did not return an alternative response');
103
- }
104
- else {
105
- throw e;
106
- }
107
- }
108
- }
109
- for (const middleware of this.middleware) {
110
- if (middleware.post) {
111
- response = (yield middleware.post({
112
- fetch: this.fetchApi,
113
- url: fetchParams.url,
114
- init: fetchParams.init,
115
- response: response.clone(),
116
- })) || response;
117
- }
118
- }
119
- return response;
120
- });
121
- this.middleware = configuration.middleware;
122
- }
123
- withMiddleware(...middlewares) {
124
- const next = this.clone();
125
- next.middleware = next.middleware.concat(...middlewares);
126
- return next;
127
- }
128
- withPreMiddleware(...preMiddlewares) {
129
- const middlewares = preMiddlewares.map((pre) => ({ pre }));
130
- return this.withMiddleware(...middlewares);
131
- }
132
- withPostMiddleware(...postMiddlewares) {
133
- const middlewares = postMiddlewares.map((post) => ({ post }));
134
- return this.withMiddleware(...middlewares);
135
- }
136
- /**
137
- * Check if the given MIME is a JSON MIME.
138
- * JSON MIME examples:
139
- * application/json
140
- * application/json; charset=UTF8
141
- * APPLICATION/JSON
142
- * application/vnd.company+json
143
- * @param mime - MIME (Multipurpose Internet Mail Extensions)
144
- * @return True if the given MIME is JSON, false otherwise.
145
- */
146
- isJsonMime(mime) {
147
- if (!mime) {
148
- return false;
149
- }
150
- return BaseAPI.jsonRegex.test(mime);
151
- }
152
- request(context, initOverrides) {
153
- return __awaiter(this, void 0, void 0, function* () {
154
- const { url, init } = yield this.createFetchParams(context, initOverrides);
155
- const response = yield this.fetchApi(url, init);
156
- if (response && (response.status >= 200 && response.status < 300)) {
157
- return response;
158
- }
159
- throw new ResponseError(response, 'Response returned an error code');
160
- });
161
- }
162
- createFetchParams(context, initOverrides) {
163
- return __awaiter(this, void 0, void 0, function* () {
164
- let url = this.configuration.basePath + context.path;
165
- if (context.query !== undefined && Object.keys(context.query).length !== 0) {
166
- // only add the querystring to the URL if there are query parameters.
167
- // this is done to avoid urls ending with a "?" character which buggy webservers
168
- // do not handle correctly sometimes.
169
- url += '?' + this.configuration.queryParamsStringify(context.query);
170
- }
171
- const headers = Object.assign({}, this.configuration.headers, context.headers);
172
- Object.keys(headers).forEach(key => headers[key] === undefined ? delete headers[key] : {});
173
- const initOverrideFn = typeof initOverrides === "function"
174
- ? initOverrides
175
- : () => __awaiter(this, void 0, void 0, function* () { return initOverrides; });
176
- const initParams = {
177
- method: context.method,
178
- headers,
179
- body: context.body,
180
- credentials: this.configuration.credentials,
181
- };
182
- const overriddenInit = Object.assign(Object.assign({}, initParams), (yield initOverrideFn({
183
- init: initParams,
184
- context,
185
- })));
186
- let body;
187
- if (isFormData(overriddenInit.body)
188
- || (overriddenInit.body instanceof URLSearchParams)
189
- || isBlob(overriddenInit.body)) {
190
- body = overriddenInit.body;
191
- }
192
- else if (this.isJsonMime(headers['Content-Type'])) {
193
- body = JSON.stringify(overriddenInit.body);
194
- }
195
- else {
196
- body = overriddenInit.body;
197
- }
198
- const init = Object.assign(Object.assign({}, overriddenInit), { body });
199
- return { url, init };
200
- });
201
- }
202
- /**
203
- * Create a shallow clone of `this` by constructing a new instance
204
- * and then shallow cloning data members.
205
- */
206
- clone() {
207
- const constructor = this.constructor;
208
- const next = new constructor(this.configuration);
209
- next.middleware = this.middleware.slice();
210
- return next;
211
- }
212
- }
213
- BaseAPI.jsonRegex = new RegExp('^(:?application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i');
214
- ;
215
- function isBlob(value) {
216
- return typeof Blob !== 'undefined' && value instanceof Blob;
217
- }
218
- function isFormData(value) {
219
- return typeof FormData !== "undefined" && value instanceof FormData;
220
- }
221
- export class ResponseError extends Error {
222
- constructor(response, msg) {
223
- super(msg);
224
- this.response = response;
225
- this.name = "ResponseError";
226
- }
227
- }
228
- export class FetchError extends Error {
229
- constructor(cause, msg) {
230
- super(msg);
231
- this.cause = cause;
232
- this.name = "FetchError";
233
- }
234
- }
235
- export class RequiredError extends Error {
236
- constructor(field, msg) {
237
- super(msg);
238
- this.field = field;
239
- this.name = "RequiredError";
240
- }
241
- }
242
- export const COLLECTION_FORMATS = {
243
- csv: ",",
244
- ssv: " ",
245
- tsv: "\t",
246
- pipes: "|",
247
- };
248
- export function querystring(params, prefix = '') {
249
- return Object.keys(params)
250
- .map(key => querystringSingleKey(key, params[key], prefix))
251
- .filter(part => part.length > 0)
252
- .join('&');
253
- }
254
- function querystringSingleKey(key, value, keyPrefix = '') {
255
- const fullKey = keyPrefix + (keyPrefix.length ? `[${key}]` : key);
256
- if (value instanceof Array) {
257
- const multiValue = value.map(singleValue => encodeURIComponent(String(singleValue)))
258
- .join(`&${encodeURIComponent(fullKey)}=`);
259
- return `${encodeURIComponent(fullKey)}=${multiValue}`;
260
- }
261
- if (value instanceof Set) {
262
- const valueAsArray = Array.from(value);
263
- return querystringSingleKey(key, valueAsArray, keyPrefix);
264
- }
265
- if (value instanceof Date) {
266
- return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value.toISOString())}`;
267
- }
268
- if (value instanceof Object) {
269
- return querystring(value, fullKey);
270
- }
271
- return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`;
272
- }
273
- export function exists(json, key) {
274
- const value = json[key];
275
- return value !== null && value !== undefined;
276
- }
277
- export function mapValues(data, fn) {
278
- const result = {};
279
- for (const key of Object.keys(data)) {
280
- result[key] = fn(data[key]);
281
- }
282
- return result;
283
- }
284
- export function canConsumeForm(consumes) {
285
- for (const consume of consumes) {
286
- if ('multipart/form-data' === consume.contentType) {
287
- return true;
288
- }
289
- }
290
- return false;
291
- }
292
- export class JSONApiResponse {
293
- constructor(raw, transformer = (jsonValue) => jsonValue) {
294
- this.raw = raw;
295
- this.transformer = transformer;
296
- }
297
- value() {
298
- return __awaiter(this, void 0, void 0, function* () {
299
- return this.transformer(yield this.raw.json());
300
- });
301
- }
302
- }
303
- export class VoidApiResponse {
304
- constructor(raw) {
305
- this.raw = raw;
306
- }
307
- value() {
308
- return __awaiter(this, void 0, void 0, function* () {
309
- return undefined;
310
- });
311
- }
312
- }
313
- export class BlobApiResponse {
314
- constructor(raw) {
315
- this.raw = raw;
316
- }
317
- value() {
318
- return __awaiter(this, void 0, void 0, function* () {
319
- return yield this.raw.blob();
320
- });
321
- }
322
- ;
323
- }
324
- export class TextApiResponse {
325
- constructor(raw) {
326
- this.raw = raw;
327
- }
328
- value() {
329
- return __awaiter(this, void 0, void 0, function* () {
330
- return yield this.raw.text();
331
- });
332
- }
333
- ;
334
- }