Skip to content

Commit e8a0f75

Browse files
author
Aman Aalam
authored
Merge pull request #42 from PaymentRails/dev.suggestions
[not master] Suggestions for dev branch
2 parents be9058f + 7ee5ba8 commit e8a0f75

File tree

2 files changed

+38
-32
lines changed

2 files changed

+38
-32
lines changed

lib/Client.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ import { Exceptions } from './exceptions';
99
* @param options The request to pass to the request library
1010
* @hidden
1111
*/
12+
13+
const CURRENT_CLIENT_VERSION = "0.11.1";
14+
const DEFAULT_HEADERS = {
15+
"Content-Type": "application/json",
16+
"Trolley-Source": `javascript-sdk_${CURRENT_CLIENT_VERSION}`,
17+
};
18+
1219
function sendRequest<T>(options: request.UriOptions) {
1320
return new Promise<T>((resolve, reject) => {
1421
// tslint:disable-next-line:cyclomatic-complexity
@@ -86,10 +93,9 @@ export class Client {
8693
baseUrl: this.config.apiBase,
8794
method: "GET",
8895
headers: {
89-
"Content-Type": "application/json",
96+
...DEFAULT_HEADERS,
9097
Authorization: authorization,
9198
"X-PR-Timestamp": timestamp,
92-
"Trolley-Source": "javascript-sdk_0.11.1",
9399
},
94100
};
95101

@@ -117,10 +123,9 @@ export class Client {
117123
uri: this.config.apiBase + endPoint,
118124
method: "POST",
119125
headers: {
120-
"Content-Type": "application/json",
126+
...DEFAULT_HEADERS,
121127
Authorization: authoriation,
122128
"X-PR-Timestamp": timestamp,
123-
"Trolley-Source": "javascript-sdk_0.11.1",
124129
},
125130
body,
126131
};
@@ -174,10 +179,9 @@ export class Client {
174179
baseUrl: this.config.apiBase,
175180
method: "DELETE",
176181
headers: {
177-
"Content-Type": "application/json",
182+
...DEFAULT_HEADERS,
178183
Authorization: authoriation,
179184
"X-PR-Timestamp": timestamp,
180-
"Trolley-Source": "javascript-sdk_0.11.1",
181185
},
182186
};
183187

test/integration/helpers/fixtures/invoice-create.json

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@
1919
"response": {
2020
"ok": true,
2121
"recipient": {
22-
"id": "R-0NcqdaDtjvdq2Mw6gSEStj",
23-
"referenceId": "R-0NcqdaDtjvdq2Mw6gSEStj",
22+
"id": "R-GZjaGyw8yQ2QLfKgrb5toN",
23+
"referenceId": "R-GZjaGyw8yQ2QLfKgrb5toN",
24+
"parentRecipientId": null,
2425
"email": "[email protected]",
2526
"name": "Tom Jones",
2627
"lastName": "Jones",
@@ -33,8 +34,8 @@
3334
"dob": null,
3435
"passport": "",
3536
"placeOfBirth": null,
36-
"updatedAt": "2022-10-20T14:04:31.198Z",
37-
"createdAt": "2022-10-20T14:04:31.198Z",
37+
"updatedAt": "2023-03-10T05:44:58.748Z",
38+
"createdAt": "2023-03-10T05:44:58.748Z",
3839
"tags": [],
3940
"isPortalUser": false,
4041
"taxDeliveryType": "mail",
@@ -66,12 +67,12 @@
6667
"citizenships": [],
6768
"routeType": "sepa",
6869
"routeMinimum": "0",
69-
"estimatedFees": "4",
70+
"estimatedFees": "5",
7071
"accounts": [],
7172
"payoutMethod": null,
7273
"primaryCurrency": null,
7374
"riskScore": null,
74-
"merchantId": "M-W3mQuLjDafUGietRUqmeRz",
75+
"merchantId": "M-C7AsydAeAqW3husDNHSAND",
7576
"inactiveReasons": {
7677
"primaryAccount": "missing"
7778
},
@@ -82,11 +83,11 @@
8283
},
8384
"rawHeaders": [
8485
"Date",
85-
"Thu, 20 Oct 2022 14:04:31 GMT",
86+
"Fri, 10 Mar 2023 05:44:58 GMT",
8687
"Content-Type",
8788
"application/json; charset=utf-8",
8889
"Content-Length",
89-
"1595",
90+
"1230",
9091
"Connection",
9192
"close",
9293
"Cache-Control",
@@ -112,15 +113,15 @@
112113
"Access-Control-Allow-Origin",
113114
"*",
114115
"X-Rate-Limit-Limit",
115-
"75",
116+
"600",
116117
"X-Rate-Limit-Remaining",
117-
"74",
118+
"599",
118119
"X-Rate-Limit-Reset",
119-
"1666274731",
120+
"1678427158",
120121
"Vary",
121122
"Origin",
122123
"ETag",
123-
"W/\"63b-sNaki5z3njrO+C483O8Wqx58qvk\""
124+
"W/\"4ce-9F3Gw0f5aZr+NiTrrbMuBQCvjMY\""
124125
],
125126
"responseIsBinary": false
126127
},
@@ -129,7 +130,7 @@
129130
"method": "POST",
130131
"path": "/v1/invoices/create",
131132
"body": {
132-
"recipientId": "R-0NcqdaDtjvdq2Mw6gSEStj",
133+
"recipientId": "R-GZjaGyw8yQ2QLfKgrb5toN",
133134
"description": "Test Invoice",
134135
"externalId": "testInvoice",
135136
"invoiceDate": "2020-01-01",
@@ -139,40 +140,41 @@
139140
"response": {
140141
"ok": true,
141142
"invoice": {
142-
"id": "I-KGQU5HUTpGwU4aEgQ5e6w7",
143+
"id": "I-XS4YquHtMeVBDvQQ76PAqw",
143144
"invoiceNumber": "",
144145
"description": "Test Invoice",
145146
"status": "open",
146147
"externalId": "testInvoice",
147148
"invoiceDate": "2020-01-01T00:00:00.000Z",
148149
"dueDate": "2020-01-01T00:00:00.000Z",
149150
"releaseAfter": null,
150-
"createdAt": "2022-10-20T14:04:31.699Z",
151-
"updatedAt": "2022-10-20T14:04:31.699Z",
151+
"createdAt": "2023-03-10T05:44:59.086Z",
152+
"updatedAt": "2023-03-10T05:44:59.086Z",
152153
"totalAmount": {
153154
"value": "0.00",
154-
"currency": "USD"
155+
"currency": "CAD"
155156
},
156157
"paidAmount": {
157158
"value": "0.00",
158-
"currency": "USD"
159+
"currency": "CAD"
159160
},
160161
"dueAmount": {
161162
"value": "0.00",
162-
"currency": "USD"
163+
"currency": "CAD"
163164
},
164165
"tags": [],
165166
"lines": [],
166-
"recipientId": "R-0NcqdaDtjvdq2Mw6gSEStj"
167+
"recipientId": "R-GZjaGyw8yQ2QLfKgrb5toN",
168+
"syncDetails": null
167169
}
168170
},
169171
"rawHeaders": [
170172
"Date",
171-
"Thu, 20 Oct 2022 14:04:31 GMT",
173+
"Fri, 10 Mar 2023 05:44:59 GMT",
172174
"Content-Type",
173175
"application/json; charset=utf-8",
174176
"Content-Length",
175-
"696",
177+
"544",
176178
"Connection",
177179
"close",
178180
"Cache-Control",
@@ -198,15 +200,15 @@
198200
"Access-Control-Allow-Origin",
199201
"*",
200202
"X-Rate-Limit-Limit",
201-
"75",
203+
"600",
202204
"X-Rate-Limit-Remaining",
203-
"73",
205+
"598",
204206
"X-Rate-Limit-Reset",
205-
"1666274731",
207+
"1678427158",
206208
"Vary",
207209
"Origin",
208210
"ETag",
209-
"W/\"2b8-Z5pvrB+mWCvESPnsA/zBicOItSw\""
211+
"W/\"220-8CDMV4qcpUhPrv0WgK863ebHD0I\""
210212
],
211213
"responseIsBinary": false
212214
}

0 commit comments

Comments
 (0)