Skip to content

Commit b703968

Browse files
committed
Release 3.0.0
1 parent 4547ee1 commit b703968

40 files changed

+4037
-70
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright 2020 wallee AG
189+
Copyright 2021 wallee AG
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

index.ts

Lines changed: 78 additions & 3 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "postfinancecheckout",
33
"title": "PostFinance Checkout",
4-
"version": "2.2.2",
4+
"version": "3.0.0",
55
"description": "TypeScript/JavaScript client for PostFinance Checkout",
66
"homepage": "http://github.com/pfpayments/typescript-sdk",
77
"repository": {

src/api/BankAccountService.ts

Lines changed: 319 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,319 @@
1+
'use strict';
2+
3+
import localVarRequest = require("request");
4+
import http = require("http");
5+
import Promise = require("bluebird");
6+
7+
import { Authentication } from '../auth/Authentication';
8+
import { VoidAuth } from '../auth/VoidAuth';
9+
import { ObjectSerializer } from '../serializers/ObjectSerializer';
10+
11+
import { BankAccount } from '../models/BankAccount';
12+
import { ClientError } from '../models/ClientError';
13+
import { EntityQuery } from '../models/EntityQuery';
14+
import { EntityQueryFilter } from '../models/EntityQueryFilter';
15+
import { ServerError } from '../models/ServerError';
16+
17+
class BankAccountService {
18+
protected _basePath = 'https://checkout.postfinance.ch:443/api';
19+
protected defaultHeaders : any = {};
20+
protected _useQuerystring : boolean = false;
21+
22+
protected authentications = {
23+
'default': <Authentication>new VoidAuth({})
24+
};
25+
26+
constructor(configuration: any) {
27+
this.setDefaultAuthentication(new VoidAuth(configuration))
28+
}
29+
30+
set useQuerystring(value: boolean) {
31+
this._useQuerystring = value;
32+
}
33+
34+
set basePath(basePath: string) {
35+
this._basePath = basePath;
36+
}
37+
38+
get basePath() {
39+
return this._basePath;
40+
}
41+
42+
protected setDefaultAuthentication(auth: Authentication) {
43+
this.authentications.default = auth;
44+
}
45+
46+
/**
47+
* Counts the number of items in the database as restricted by the given filter.
48+
* @summary Count
49+
* @param spaceId
50+
* @param filter The filter which restricts the entities which are used to calculate the count.
51+
* @param {*} [options] Override http request options.
52+
*/
53+
public count (spaceId: number, filter?: EntityQueryFilter, options: any = {}) : Promise<{ response: http.IncomingMessage; body: number; }> {
54+
const localVarPath = this.basePath + '/bank-account/count';
55+
let localVarQueryParameters: any = {};
56+
let localVarHeaderParams: any = (<any>Object).assign({}, this.defaultHeaders);
57+
let localVarFormParams: any = {};
58+
59+
// verify required parameter 'spaceId' is not null or undefined
60+
if (spaceId === null || spaceId === undefined) {
61+
throw new Error('Required parameter spaceId was null or undefined when calling count.');
62+
}
63+
64+
if (spaceId !== undefined) {
65+
localVarQueryParameters['spaceId'] = ObjectSerializer.serialize(spaceId, "number");
66+
}
67+
68+
(<any>Object).assign(localVarHeaderParams, options.headers);
69+
70+
let localVarUseFormData = false;
71+
72+
let localVarRequestOptions: localVarRequest.Options = {
73+
method: 'POST',
74+
qs: localVarQueryParameters,
75+
headers: localVarHeaderParams,
76+
uri: localVarPath,
77+
useQuerystring: this._useQuerystring,
78+
json: true,
79+
body: ObjectSerializer.serialize(filter, "EntityQueryFilter"),
80+
};
81+
82+
this.authentications.default.applyToRequest(localVarRequestOptions);
83+
84+
if (Object.keys(localVarFormParams).length) {
85+
if (localVarUseFormData) {
86+
(<any>localVarRequestOptions).formData = localVarFormParams;
87+
} else {
88+
localVarRequestOptions.form = localVarFormParams;
89+
}
90+
}
91+
return new Promise<{ response: http.IncomingMessage; body: number; }>((resolve, reject) => {
92+
localVarRequest(localVarRequestOptions, (error, response, body) => {
93+
if (error) {
94+
return reject(error);
95+
} else {
96+
if (response.statusCode){
97+
if (response.statusCode >= 200 && response.statusCode <= 299) {
98+
body = ObjectSerializer.deserialize(body, "number");
99+
return resolve({ response: response, body: body });
100+
} else {
101+
let errorObject: ClientError | ServerError;
102+
if (response.statusCode >= 400 && response.statusCode <= 499) {
103+
errorObject = new ClientError();
104+
} else if (response.statusCode >= 500 && response.statusCode <= 599){
105+
errorObject = new ServerError();
106+
} else {
107+
errorObject = new Object();
108+
}
109+
return reject({
110+
errorType: errorObject.constructor.name,
111+
date: (new Date()).toDateString(),
112+
statusCode: <string> <any> response.statusCode,
113+
statusMessage: response.statusMessage,
114+
body: body,
115+
response: response
116+
});
117+
}
118+
}
119+
return reject({
120+
errorType: "Unknown",
121+
date: (new Date()).toDateString(),
122+
statusCode: "Unknown",
123+
statusMessage: "Unknown",
124+
body: body,
125+
response: response
126+
});
127+
128+
}
129+
});
130+
});
131+
}
132+
/**
133+
* Reads the entity with the given 'id' and returns it.
134+
* @summary Read
135+
* @param spaceId
136+
* @param id The ID of the bank account which should be returned.
137+
* @param {*} [options] Override http request options.
138+
*/
139+
public read (spaceId: number, id: number, options: any = {}) : Promise<{ response: http.IncomingMessage; body: BankAccount; }> {
140+
const localVarPath = this.basePath + '/bank-account/read';
141+
let localVarQueryParameters: any = {};
142+
let localVarHeaderParams: any = (<any>Object).assign({}, this.defaultHeaders);
143+
let localVarFormParams: any = {};
144+
145+
// verify required parameter 'spaceId' is not null or undefined
146+
if (spaceId === null || spaceId === undefined) {
147+
throw new Error('Required parameter spaceId was null or undefined when calling read.');
148+
}
149+
150+
// verify required parameter 'id' is not null or undefined
151+
if (id === null || id === undefined) {
152+
throw new Error('Required parameter id was null or undefined when calling read.');
153+
}
154+
155+
if (spaceId !== undefined) {
156+
localVarQueryParameters['spaceId'] = ObjectSerializer.serialize(spaceId, "number");
157+
}
158+
159+
if (id !== undefined) {
160+
localVarQueryParameters['id'] = ObjectSerializer.serialize(id, "number");
161+
}
162+
163+
(<any>Object).assign(localVarHeaderParams, options.headers);
164+
165+
let localVarUseFormData = false;
166+
167+
let localVarRequestOptions: localVarRequest.Options = {
168+
method: 'GET',
169+
qs: localVarQueryParameters,
170+
headers: localVarHeaderParams,
171+
uri: localVarPath,
172+
useQuerystring: this._useQuerystring,
173+
json: true,
174+
};
175+
176+
this.authentications.default.applyToRequest(localVarRequestOptions);
177+
178+
if (Object.keys(localVarFormParams).length) {
179+
if (localVarUseFormData) {
180+
(<any>localVarRequestOptions).formData = localVarFormParams;
181+
} else {
182+
localVarRequestOptions.form = localVarFormParams;
183+
}
184+
}
185+
return new Promise<{ response: http.IncomingMessage; body: BankAccount; }>((resolve, reject) => {
186+
localVarRequest(localVarRequestOptions, (error, response, body) => {
187+
if (error) {
188+
return reject(error);
189+
} else {
190+
if (response.statusCode){
191+
if (response.statusCode >= 200 && response.statusCode <= 299) {
192+
body = ObjectSerializer.deserialize(body, "BankAccount");
193+
return resolve({ response: response, body: body });
194+
} else {
195+
let errorObject: ClientError | ServerError;
196+
if (response.statusCode >= 400 && response.statusCode <= 499) {
197+
errorObject = new ClientError();
198+
} else if (response.statusCode >= 500 && response.statusCode <= 599){
199+
errorObject = new ServerError();
200+
} else {
201+
errorObject = new Object();
202+
}
203+
return reject({
204+
errorType: errorObject.constructor.name,
205+
date: (new Date()).toDateString(),
206+
statusCode: <string> <any> response.statusCode,
207+
statusMessage: response.statusMessage,
208+
body: body,
209+
response: response
210+
});
211+
}
212+
}
213+
return reject({
214+
errorType: "Unknown",
215+
date: (new Date()).toDateString(),
216+
statusCode: "Unknown",
217+
statusMessage: "Unknown",
218+
body: body,
219+
response: response
220+
});
221+
222+
}
223+
});
224+
});
225+
}
226+
/**
227+
* Searches for the entities as specified by the given query.
228+
* @summary Search
229+
* @param spaceId
230+
* @param query The query restricts the bank accounts which are returned by the search.
231+
* @param {*} [options] Override http request options.
232+
*/
233+
public search (spaceId: number, query: EntityQuery, options: any = {}) : Promise<{ response: http.IncomingMessage; body: Array<BankAccount>; }> {
234+
const localVarPath = this.basePath + '/bank-account/search';
235+
let localVarQueryParameters: any = {};
236+
let localVarHeaderParams: any = (<any>Object).assign({}, this.defaultHeaders);
237+
let localVarFormParams: any = {};
238+
239+
// verify required parameter 'spaceId' is not null or undefined
240+
if (spaceId === null || spaceId === undefined) {
241+
throw new Error('Required parameter spaceId was null or undefined when calling search.');
242+
}
243+
244+
// verify required parameter 'query' is not null or undefined
245+
if (query === null || query === undefined) {
246+
throw new Error('Required parameter query was null or undefined when calling search.');
247+
}
248+
249+
if (spaceId !== undefined) {
250+
localVarQueryParameters['spaceId'] = ObjectSerializer.serialize(spaceId, "number");
251+
}
252+
253+
(<any>Object).assign(localVarHeaderParams, options.headers);
254+
255+
let localVarUseFormData = false;
256+
257+
let localVarRequestOptions: localVarRequest.Options = {
258+
method: 'POST',
259+
qs: localVarQueryParameters,
260+
headers: localVarHeaderParams,
261+
uri: localVarPath,
262+
useQuerystring: this._useQuerystring,
263+
json: true,
264+
body: ObjectSerializer.serialize(query, "EntityQuery"),
265+
};
266+
267+
this.authentications.default.applyToRequest(localVarRequestOptions);
268+
269+
if (Object.keys(localVarFormParams).length) {
270+
if (localVarUseFormData) {
271+
(<any>localVarRequestOptions).formData = localVarFormParams;
272+
} else {
273+
localVarRequestOptions.form = localVarFormParams;
274+
}
275+
}
276+
return new Promise<{ response: http.IncomingMessage; body: Array<BankAccount>; }>((resolve, reject) => {
277+
localVarRequest(localVarRequestOptions, (error, response, body) => {
278+
if (error) {
279+
return reject(error);
280+
} else {
281+
if (response.statusCode){
282+
if (response.statusCode >= 200 && response.statusCode <= 299) {
283+
body = ObjectSerializer.deserialize(body, "Array<BankAccount>");
284+
return resolve({ response: response, body: body });
285+
} else {
286+
let errorObject: ClientError | ServerError;
287+
if (response.statusCode >= 400 && response.statusCode <= 499) {
288+
errorObject = new ClientError();
289+
} else if (response.statusCode >= 500 && response.statusCode <= 599){
290+
errorObject = new ServerError();
291+
} else {
292+
errorObject = new Object();
293+
}
294+
return reject({
295+
errorType: errorObject.constructor.name,
296+
date: (new Date()).toDateString(),
297+
statusCode: <string> <any> response.statusCode,
298+
statusMessage: response.statusMessage,
299+
body: body,
300+
response: response
301+
});
302+
}
303+
}
304+
return reject({
305+
errorType: "Unknown",
306+
date: (new Date()).toDateString(),
307+
statusCode: "Unknown",
308+
statusMessage: "Unknown",
309+
body: body,
310+
response: response
311+
});
312+
313+
}
314+
});
315+
});
316+
}
317+
}
318+
319+
export { BankAccountService }

0 commit comments

Comments
 (0)