btrz-api-client 8.72.0 → 8.73.0
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.
|
@@ -43,6 +43,33 @@ function agenciesFactory(_ref) {
|
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
/**
|
|
47
|
+
* PUT /agencies/:agencyId - update an agency.
|
|
48
|
+
* @param {Object} opts
|
|
49
|
+
* @param {string} opts.token - API key
|
|
50
|
+
* @param {string} opts.jwtToken - JWT
|
|
51
|
+
* @param {string} opts.agencyId - Agency (seller) ID, 24-char hex ObjectId. Must not be the provider's own accountId.
|
|
52
|
+
* @param {Object} opts.agency - Agency payload
|
|
53
|
+
* @param {Object} [opts.headers] - Optional headers
|
|
54
|
+
* @returns {Promise<import("axios").AxiosResponse>}
|
|
55
|
+
*/
|
|
56
|
+
function update(_ref3) {
|
|
57
|
+
var token = _ref3.token,
|
|
58
|
+
jwtToken = _ref3.jwtToken,
|
|
59
|
+
agencyId = _ref3.agencyId,
|
|
60
|
+
agency = _ref3.agency,
|
|
61
|
+
headers = _ref3.headers;
|
|
62
|
+
|
|
63
|
+
return client({
|
|
64
|
+
url: "/agencies/" + agencyId,
|
|
65
|
+
method: "put",
|
|
66
|
+
headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers }),
|
|
67
|
+
data: {
|
|
68
|
+
agency: agency
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
46
73
|
/**
|
|
47
74
|
* PUT /agencies/:agencyId/credit-limit - update credit limit for an agency (seller) in the provider's network.
|
|
48
75
|
* Requires BETTEREZ_APP audience. Request body can be { limitAmount, unlimited } or { creditLimit: { limitAmount, unlimited } }.
|
|
@@ -55,12 +82,12 @@ function agenciesFactory(_ref) {
|
|
|
55
82
|
* @param {Object} [opts.headers] - Optional headers
|
|
56
83
|
* @returns {Promise<import("axios").AxiosResponse<{ creditLimit: { _id: string, sellerId: string, providerId: string, unlimited: boolean, overrideLimit: number, currentLimit: number } }>>}
|
|
57
84
|
*/
|
|
58
|
-
function putCreditLimit(
|
|
59
|
-
var token =
|
|
60
|
-
jwtToken =
|
|
61
|
-
agencyId =
|
|
62
|
-
data =
|
|
63
|
-
headers =
|
|
85
|
+
function putCreditLimit(_ref4) {
|
|
86
|
+
var token = _ref4.token,
|
|
87
|
+
jwtToken = _ref4.jwtToken,
|
|
88
|
+
agencyId = _ref4.agencyId,
|
|
89
|
+
data = _ref4.data,
|
|
90
|
+
headers = _ref4.headers;
|
|
64
91
|
|
|
65
92
|
return client({
|
|
66
93
|
url: "/agencies/" + agencyId + "/credit-limit",
|
|
@@ -72,6 +99,7 @@ function agenciesFactory(_ref) {
|
|
|
72
99
|
|
|
73
100
|
return {
|
|
74
101
|
create: create,
|
|
102
|
+
update: update,
|
|
75
103
|
putCreditLimit: putCreditLimit
|
|
76
104
|
};
|
|
77
105
|
}
|
package/package.json
CHANGED
|
@@ -32,6 +32,27 @@ function agenciesFactory({client, internalAuthTokenProvider}) {
|
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
/**
|
|
36
|
+
* PUT /agencies/:agencyId - update an agency.
|
|
37
|
+
* @param {Object} opts
|
|
38
|
+
* @param {string} opts.token - API key
|
|
39
|
+
* @param {string} opts.jwtToken - JWT
|
|
40
|
+
* @param {string} opts.agencyId - Agency (seller) ID, 24-char hex ObjectId. Must not be the provider's own accountId.
|
|
41
|
+
* @param {Object} opts.agency - Agency payload
|
|
42
|
+
* @param {Object} [opts.headers] - Optional headers
|
|
43
|
+
* @returns {Promise<import("axios").AxiosResponse>}
|
|
44
|
+
*/
|
|
45
|
+
function update({token, jwtToken, agencyId, agency, headers}) {
|
|
46
|
+
return client({
|
|
47
|
+
url: `/agencies/${agencyId}`,
|
|
48
|
+
method: "put",
|
|
49
|
+
headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers}),
|
|
50
|
+
data: {
|
|
51
|
+
agency
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
35
56
|
/**
|
|
36
57
|
* PUT /agencies/:agencyId/credit-limit - update credit limit for an agency (seller) in the provider's network.
|
|
37
58
|
* Requires BETTEREZ_APP audience. Request body can be { limitAmount, unlimited } or { creditLimit: { limitAmount, unlimited } }.
|
|
@@ -55,6 +76,7 @@ function agenciesFactory({client, internalAuthTokenProvider}) {
|
|
|
55
76
|
|
|
56
77
|
return {
|
|
57
78
|
create,
|
|
79
|
+
update,
|
|
58
80
|
putCreditLimit
|
|
59
81
|
};
|
|
60
82
|
}
|
|
@@ -42,6 +42,41 @@ describe("accounts/agencies", () => {
|
|
|
42
42
|
});
|
|
43
43
|
});
|
|
44
44
|
|
|
45
|
+
it("should PUT an agency", () => {
|
|
46
|
+
const agencyId = "507f1f77bcf86cd799439011";
|
|
47
|
+
const agency = {
|
|
48
|
+
seller: {
|
|
49
|
+
preferences: {
|
|
50
|
+
sales: {
|
|
51
|
+
creditLimit: {
|
|
52
|
+
limitAmount: 1000,
|
|
53
|
+
unlimited: false
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
network: {
|
|
59
|
+
productIds: ["productId"],
|
|
60
|
+
globalSearch: false,
|
|
61
|
+
active: true
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
axiosMock.onPut(`/agencies/${agencyId}`).reply(expectRequest({
|
|
66
|
+
statusCode: 200,
|
|
67
|
+
token,
|
|
68
|
+
jwtToken,
|
|
69
|
+
body: {agency}
|
|
70
|
+
}));
|
|
71
|
+
|
|
72
|
+
return api.accounts.agencies.update({
|
|
73
|
+
token,
|
|
74
|
+
jwtToken,
|
|
75
|
+
agencyId,
|
|
76
|
+
agency
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
|
|
45
80
|
it("should PUT credit limit for an agency", () => {
|
|
46
81
|
const agencyId = "507f1f77bcf86cd799439011";
|
|
47
82
|
const data = {
|