btrz-api-client 9.18.0 → 9.19.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.
@@ -7,7 +7,7 @@ const {
7
7
  * @param {Object} deps
8
8
  * @param {import("axios").AxiosInstance} deps.client
9
9
  * @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
10
- * @returns {{ get: function, defaultUsers: { create: function } }}
10
+ * @returns {{ get: function, defaultUsers: { create: function }, configurationReplication: { create: function } }}
11
11
  */
12
12
  function accountsFactory({
13
13
  client,
@@ -66,9 +66,50 @@ function accountsFactory({
66
66
  });
67
67
  }
68
68
  };
69
+
70
+ /**
71
+ * Query params for POST /accounts/:accountId/configuration-replication (btrz-api-accounts).
72
+ * @typedef {Object} ConfigurationReplicationCreateQuery
73
+ * @property {string} superUserId - Super user id (ObjectId)
74
+ * @property {string} superUserHash - Super user hash
75
+ */
76
+
77
+ const configurationReplication = {
78
+ /**
79
+ * POST /accounts/:accountId/configuration-replication — enqueue a configuration pack export.
80
+ * No request body. Requires SuperUser query credentials.
81
+ * @param {Object} opts
82
+ * @param {string} [opts.token] - API key
83
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
84
+ * @param {string} opts.accountId - Source Account _id to export (ObjectId)
85
+ * @param {ConfigurationReplicationCreateQuery} [opts.query] - superUserId, superUserHash
86
+ * @param {Object} [opts.headers] - Optional headers
87
+ * @returns {Promise<import("axios").AxiosResponse>} 202 { accepted, accountId, requestId }
88
+ */
89
+ create({
90
+ token,
91
+ jwtToken,
92
+ accountId,
93
+ query,
94
+ headers
95
+ }) {
96
+ return client({
97
+ url: `/accounts/${accountId}/configuration-replication`,
98
+ method: "post",
99
+ headers: authorizationHeaders({
100
+ token,
101
+ jwtToken,
102
+ internalAuthTokenProvider,
103
+ headers
104
+ }),
105
+ params: query
106
+ });
107
+ }
108
+ };
69
109
  return {
70
110
  get,
71
- defaultUsers
111
+ defaultUsers,
112
+ configurationReplication
72
113
  };
73
114
  }
74
115
  module.exports = accountsFactory;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "btrz-api-client",
3
- "version": "9.18.0",
3
+ "version": "9.19.0",
4
4
  "description": "Api client for Betterez endpoints",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -7,7 +7,7 @@ const {
7
7
  * @param {Object} deps
8
8
  * @param {import("axios").AxiosInstance} deps.client
9
9
  * @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
10
- * @returns {{ get: function, defaultUsers: { create: function } }}
10
+ * @returns {{ get: function, defaultUsers: { create: function }, configurationReplication: { create: function } }}
11
11
  */
12
12
  function accountsFactory({client, internalAuthTokenProvider}) {
13
13
  /**
@@ -46,9 +46,39 @@ function accountsFactory({client, internalAuthTokenProvider}) {
46
46
  }
47
47
  };
48
48
 
49
+ /**
50
+ * Query params for POST /accounts/:accountId/configuration-replication (btrz-api-accounts).
51
+ * @typedef {Object} ConfigurationReplicationCreateQuery
52
+ * @property {string} superUserId - Super user id (ObjectId)
53
+ * @property {string} superUserHash - Super user hash
54
+ */
55
+
56
+ const configurationReplication = {
57
+ /**
58
+ * POST /accounts/:accountId/configuration-replication — enqueue a configuration pack export.
59
+ * No request body. Requires SuperUser query credentials.
60
+ * @param {Object} opts
61
+ * @param {string} [opts.token] - API key
62
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
63
+ * @param {string} opts.accountId - Source Account _id to export (ObjectId)
64
+ * @param {ConfigurationReplicationCreateQuery} [opts.query] - superUserId, superUserHash
65
+ * @param {Object} [opts.headers] - Optional headers
66
+ * @returns {Promise<import("axios").AxiosResponse>} 202 { accepted, accountId, requestId }
67
+ */
68
+ create({token, jwtToken, accountId, query, headers}) {
69
+ return client({
70
+ url: `/accounts/${accountId}/configuration-replication`,
71
+ method: "post",
72
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers}),
73
+ params: query
74
+ });
75
+ }
76
+ };
77
+
49
78
  return {
50
79
  get,
51
- defaultUsers
80
+ defaultUsers,
81
+ configurationReplication
52
82
  };
53
83
  }
54
84
 
@@ -47,4 +47,25 @@ describe("accounts/accounts", () => {
47
47
  data
48
48
  });
49
49
  });
50
+
51
+ it("should POST configuration replication for an account", () => {
52
+ const accountId = "5976090487a7f1e158000041";
53
+ const query = {
54
+ superUserId: "superUserId",
55
+ superUserHash: "superUserHash"
56
+ };
57
+ axiosMock.onPost(`/accounts/${accountId}/configuration-replication`)
58
+ .reply(expectRequest({
59
+ statusCode: 202,
60
+ token,
61
+ jwtToken,
62
+ query
63
+ }));
64
+ return api.accounts.accounts.configurationReplication.create({
65
+ token,
66
+ jwtToken,
67
+ accountId,
68
+ query
69
+ });
70
+ });
50
71
  });
@@ -4,7 +4,7 @@ export = accountsFactory;
4
4
  * @param {Object} deps
5
5
  * @param {import("axios").AxiosInstance} deps.client
6
6
  * @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
7
- * @returns {{ get: function, defaultUsers: { create: function } }}
7
+ * @returns {{ get: function, defaultUsers: { create: function }, configurationReplication: { create: function } }}
8
8
  */
9
9
  declare function accountsFactory({ client, internalAuthTokenProvider }: {
10
10
  client: import("axios").AxiosInstance;
@@ -16,4 +16,7 @@ declare function accountsFactory({ client, internalAuthTokenProvider }: {
16
16
  defaultUsers: {
17
17
  create: Function;
18
18
  };
19
+ configurationReplication: {
20
+ create: Function;
21
+ };
19
22
  };