@openfort/openfort-node 0.2.6 → 0.2.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 (93) hide show
  1. package/README.md +55 -3
  2. package/dist/api/accountsApi.d.ts +113 -0
  3. package/dist/api/accountsApi.js +489 -0
  4. package/dist/api/accountsApi.js.map +1 -0
  5. package/dist/api/apis.d.ts +3 -3
  6. package/dist/api/apis.js +3 -3
  7. package/dist/api/apis.js.map +1 -1
  8. package/dist/api/contractsApi.d.ts +18 -4
  9. package/dist/api/contractsApi.js +77 -3
  10. package/dist/api/contractsApi.js.map +1 -1
  11. package/dist/api/defaultApi.d.ts +13 -69
  12. package/dist/api/defaultApi.js +36 -332
  13. package/dist/api/defaultApi.js.map +1 -1
  14. package/dist/api/playersApi.d.ts +33 -13
  15. package/dist/api/playersApi.js +132 -34
  16. package/dist/api/playersApi.js.map +1 -1
  17. package/dist/api/policiesApi.d.ts +40 -23
  18. package/dist/api/policiesApi.js +142 -44
  19. package/dist/api/policiesApi.js.map +1 -1
  20. package/dist/api/sessionsApi.d.ts +2 -2
  21. package/dist/api/sessionsApi.js +12 -6
  22. package/dist/api/sessionsApi.js.map +1 -1
  23. package/dist/api/transactionIntentsApi.d.ts +10 -8
  24. package/dist/api/transactionIntentsApi.js +23 -15
  25. package/dist/api/transactionIntentsApi.js.map +1 -1
  26. package/dist/index.d.ts +3 -0
  27. package/dist/index.js +8 -0
  28. package/dist/index.js.map +1 -1
  29. package/dist/model/accountResponse.d.ts +3 -3
  30. package/dist/model/accountResponse.js +6 -6
  31. package/dist/model/accountResponse.js.map +1 -1
  32. package/dist/model/contractDeleteResponse.d.ts +27 -0
  33. package/dist/model/contractDeleteResponse.js +39 -0
  34. package/dist/model/contractDeleteResponse.js.map +1 -0
  35. package/dist/model/contractResponse.d.ts +3 -3
  36. package/dist/model/contractResponse.js +6 -6
  37. package/dist/model/contractResponse.js.map +1 -1
  38. package/dist/model/models.d.ts +12 -9
  39. package/dist/model/models.js +36 -27
  40. package/dist/model/models.js.map +1 -1
  41. package/dist/model/playerResponse.d.ts +5 -5
  42. package/dist/model/playerResponse.js +7 -7
  43. package/dist/model/playerResponse.js.map +1 -1
  44. package/dist/model/playerResponseAccounts.d.ts +24 -0
  45. package/dist/model/playerResponseAccounts.js +23 -0
  46. package/dist/model/playerResponseAccounts.js.map +1 -0
  47. package/dist/model/policyDeleteResponse.d.ts +27 -0
  48. package/dist/model/policyDeleteResponse.js +39 -0
  49. package/dist/model/policyDeleteResponse.js.map +1 -0
  50. package/dist/model/policyResponse.d.ts +6 -6
  51. package/dist/model/policyResponse.js +10 -10
  52. package/dist/model/policyResponse.js.map +1 -1
  53. package/dist/model/policyResponsePolicyRules.d.ts +24 -0
  54. package/dist/model/policyResponsePolicyRules.js +23 -0
  55. package/dist/model/policyResponsePolicyRules.js.map +1 -0
  56. package/dist/model/policyResponseTransactionIntents.d.ts +24 -0
  57. package/dist/model/policyResponseTransactionIntents.js +23 -0
  58. package/dist/model/policyResponseTransactionIntents.js.map +1 -0
  59. package/dist/model/policyRuleResponse.d.ts +33 -0
  60. package/dist/model/policyRuleResponse.js +54 -0
  61. package/dist/model/policyRuleResponse.js.map +1 -0
  62. package/dist/model/policyRulesResponse.d.ts +28 -0
  63. package/dist/model/policyRulesResponse.js +39 -0
  64. package/dist/model/policyRulesResponse.js.map +1 -0
  65. package/dist/model/policySchema.d.ts +15 -0
  66. package/dist/model/policySchema.js +20 -0
  67. package/dist/model/policySchema.js.map +1 -0
  68. package/dist/model/prismaJsonValue.d.ts +27 -0
  69. package/dist/model/prismaJsonValue.js +26 -0
  70. package/dist/model/prismaJsonValue.js.map +1 -0
  71. package/dist/model/projectResponse.d.ts +1 -1
  72. package/dist/model/projectResponse.js +5 -5
  73. package/dist/model/projectResponse.js.map +1 -1
  74. package/dist/model/responseResponse.d.ts +6 -5
  75. package/dist/model/responseResponse.js +2 -2
  76. package/dist/model/responseResponse.js.map +1 -1
  77. package/dist/model/sessionResponse.d.ts +1 -1
  78. package/dist/model/sessionResponse.js +5 -5
  79. package/dist/model/sessionResponse.js.map +1 -1
  80. package/dist/model/transactionIntentResponse.d.ts +11 -8
  81. package/dist/model/transactionIntentResponse.js +11 -11
  82. package/dist/model/transactionIntentResponse.js.map +1 -1
  83. package/dist/model/transactionIntentResponseAccount.d.ts +33 -0
  84. package/dist/model/transactionIntentResponseAccount.js +64 -0
  85. package/dist/model/transactionIntentResponseAccount.js.map +1 -0
  86. package/dist/model/transactionIntentResponsePlayer.d.ts +36 -0
  87. package/dist/model/transactionIntentResponsePlayer.js +74 -0
  88. package/dist/model/transactionIntentResponsePlayer.js.map +1 -0
  89. package/dist/model/transactionIntentResponsePolicy.d.ts +34 -0
  90. package/dist/model/transactionIntentResponsePolicy.js +64 -0
  91. package/dist/model/transactionIntentResponsePolicy.js.map +1 -0
  92. package/package.json +1 -1
  93. package/tsconfig.tsbuildinfo +1 -1
package/README.md CHANGED
@@ -1,6 +1,18 @@
1
- ## @openfort/openfort-node@0.2.5
1
+ # Openfort Node.js Library
2
2
 
3
- ### Installation
3
+ [![Version](https://img.shields.io/npm/v/@openfort/openfort-node.svg)](https://www.npmjs.org/package/@openfort/openfort-node)
4
+
5
+ The Openfort Node library provides convenient access to the Openfort API from applications written in server-side JavaScript.
6
+
7
+ ## Documentation
8
+
9
+ See the [`openfort-node` API docs](https://openfort.xyz/docs/api?lang=node) for Node.js.
10
+
11
+ ## Requirements
12
+
13
+ Node 14 or higher.
14
+
15
+ ## Installation
4
16
 
5
17
  ```shell
6
18
  npm install @openfort/openfort-node
@@ -10,7 +22,37 @@ npm install @openfort/openfort-node
10
22
  yarn add @openfort/openfort-node
11
23
  ```
12
24
 
13
- ### Usage
25
+ ## Usage
26
+
27
+ The package needs to be configured with your account's secret key, which is
28
+ available in the [Openfort Dashboard][api-keys]. Require it with the key's
29
+ value:
30
+
31
+ <!-- prettier-ignore -->
32
+ ```js
33
+ const openfort = require('@openfort/openfort-node')('sk_test_...');
34
+
35
+ openfort.players.createPlayer(
36
+ 'Joan McCoain',
37
+ 'API created player'
38
+ )
39
+ .then(player => console.log(player.body.id))
40
+ .catch(error => console.error(error));
41
+ ```
42
+
43
+ Or using ES modules and `async`/`await`:
44
+
45
+ ```js
46
+ import Openfort from '@openfort/openfort-node';
47
+ const openfort = new Openfort('sk_test_...');
48
+
49
+ const player = await openfort.players.createPlayer(
50
+ 'customer@example.com',
51
+ 'API created player'
52
+ );
53
+
54
+ console.log(player.body.id);
55
+ ```
14
56
 
15
57
  Below code snippet shows exemplary usage of the configuration and the API.
16
58
 
@@ -35,3 +77,13 @@ async function example() {
35
77
 
36
78
  example().catch((e) => console.error(e));
37
79
  ```
80
+
81
+ ## Support
82
+
83
+ New features and bug fixes are released on the latest major version of the `openfort` package. If you are on an older major version, we recommend that you upgrade to the latest in order to use the new features and bug fixes including those for security vulnerabilities. Older major versions of the package will continue to be available for use, but will not be receiving any updates.
84
+
85
+ [api-keys]: https://dashboard.openfort.xyz/api-keys
86
+
87
+ <!--
88
+ # vim: set tw=79:
89
+ -->
@@ -0,0 +1,113 @@
1
+ /**
2
+ * Openfort API
3
+ * Complete Openfort API references and guides can be found at: https://openfort.xyz/docs
4
+ *
5
+ * The version of the OpenAPI document: 1.0.0
6
+ * Contact: founders@openfort.xyz
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
+ /// <reference types="node" />
13
+ import http from "http";
14
+ import { AccountResponse } from "../model/accountResponse";
15
+ import { AccountsResponse } from "../model/accountsResponse";
16
+ import { InventoryResponse } from "../model/inventoryResponse";
17
+ import { TransactionIntentResponse } from "../model/transactionIntentResponse";
18
+ import { Authentication, Interceptor } from "../model/models";
19
+ import { HttpBearerAuth } from "../model/models";
20
+ export declare enum AccountsApiApiKeys {
21
+ }
22
+ export declare class AccountsApi {
23
+ protected _basePath: string;
24
+ protected _defaultHeaders: any;
25
+ protected _useQuerystring: boolean;
26
+ protected authentications: {
27
+ default: Authentication;
28
+ pk: HttpBearerAuth;
29
+ };
30
+ protected interceptors: Interceptor[];
31
+ constructor(basePath?: string);
32
+ set useQuerystring(value: boolean);
33
+ set basePath(basePath: string);
34
+ set defaultHeaders(defaultHeaders: any);
35
+ get defaultHeaders(): any;
36
+ get basePath(): string;
37
+ setDefaultAuthentication(auth: Authentication): void;
38
+ setApiKey(key: AccountsApiApiKeys, value: string): void;
39
+ set accessToken(accessToken: string | (() => string));
40
+ addInterceptor(interceptor: Interceptor): void;
41
+ /**
42
+ * Creates an account object.
43
+ * @param chainId The chain_id
44
+ * @param player The player ID
45
+ * @param project The project ID
46
+ * @param externalOwnerAddress The address of the external owner
47
+ */
48
+ createAccount(chainId: number, player: string, project?: string, externalOwnerAddress?: string, options?: {
49
+ headers: {
50
+ [name: string]: string;
51
+ };
52
+ }): Promise<{
53
+ response: http.IncomingMessage;
54
+ body: AccountResponse;
55
+ }>;
56
+ /**
57
+ * Retrieves the details of an existing account. Supply the unique account ID from either a account creation request or the account list, and Openfort will return the corresponding account information.
58
+ * @param id Specifies the unique account ID.
59
+ * @param expand
60
+ * @param project Specifies the unique project ID.
61
+ */
62
+ getAccount(id: string, expand?: Array<string>, project?: string, options?: {
63
+ headers: {
64
+ [name: string]: string;
65
+ };
66
+ }): Promise<{
67
+ response: http.IncomingMessage;
68
+ body: AccountResponse;
69
+ }>;
70
+ /**
71
+ * Retrieves the inventory of an existing account. Supply the unique account ID from either a account creation request or the account list, and Openfort will return the corresponding account information.
72
+ * @param id Specifies the unique account ID.
73
+ * @param project Specifies the unique project ID.
74
+ */
75
+ getAccountInventory(id: string, project?: string, options?: {
76
+ headers: {
77
+ [name: string]: string;
78
+ };
79
+ }): Promise<{
80
+ response: http.IncomingMessage;
81
+ body: InventoryResponse;
82
+ }>;
83
+ /**
84
+ * Returns a list of accounts for the given player. The accounts are returned sorted by creation date, with the most recently created accounts appearing first.
85
+ * @param player Specifies the unique player ID.
86
+ * @param expand
87
+ * @param limit
88
+ * @param project Specifies the unique project ID.
89
+ */
90
+ getAccounts(player: string, expand?: Array<string>, limit?: number, project?: string, options?: {
91
+ headers: {
92
+ [name: string]: string;
93
+ };
94
+ }): Promise<{
95
+ response: http.IncomingMessage;
96
+ body: AccountsResponse;
97
+ }>;
98
+ /**
99
+ * Transfers ownership of an account to an address.
100
+ * @param id Specifies the unique account ID.
101
+ * @param newOwnerAddress The address of the new owner
102
+ * @param project The project ID
103
+ * @param policy The policy ID
104
+ */
105
+ transferOwnership(id: string, newOwnerAddress: string, project?: string, policy?: string, options?: {
106
+ headers: {
107
+ [name: string]: string;
108
+ };
109
+ }): Promise<{
110
+ response: http.IncomingMessage;
111
+ body: TransactionIntentResponse;
112
+ }>;
113
+ }
@@ -0,0 +1,489 @@
1
+ "use strict";
2
+ /**
3
+ * Openfort API
4
+ * Complete Openfort API references and guides can be found at: https://openfort.xyz/docs
5
+ *
6
+ * The version of the OpenAPI document: 1.0.0
7
+ * Contact: founders@openfort.xyz
8
+ *
9
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
10
+ * https://openapi-generator.tech
11
+ * Do not edit the class manually.
12
+ */
13
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.AccountsApi = exports.AccountsApiApiKeys = void 0;
18
+ const request_1 = __importDefault(require("request"));
19
+ const models_1 = require("../model/models");
20
+ const models_2 = require("../model/models");
21
+ const apis_1 = require("./apis");
22
+ let defaultBasePath = "https://api.openfort.xyz";
23
+ // ===============================================
24
+ // This file is autogenerated - Please do not edit
25
+ // ===============================================
26
+ var AccountsApiApiKeys;
27
+ (function (AccountsApiApiKeys) {
28
+ })(AccountsApiApiKeys = exports.AccountsApiApiKeys || (exports.AccountsApiApiKeys = {}));
29
+ class AccountsApi {
30
+ constructor(basePathOrUsername, password, basePath) {
31
+ this._basePath = defaultBasePath;
32
+ this._defaultHeaders = {};
33
+ this._useQuerystring = false;
34
+ this.authentications = {
35
+ default: new models_1.VoidAuth(),
36
+ pk: new models_2.HttpBearerAuth(),
37
+ };
38
+ this.interceptors = [];
39
+ if (password) {
40
+ if (basePath) {
41
+ this.basePath = basePath;
42
+ }
43
+ }
44
+ else {
45
+ if (basePathOrUsername) {
46
+ this.basePath = basePathOrUsername;
47
+ }
48
+ }
49
+ }
50
+ set useQuerystring(value) {
51
+ this._useQuerystring = value;
52
+ }
53
+ set basePath(basePath) {
54
+ this._basePath = basePath;
55
+ }
56
+ set defaultHeaders(defaultHeaders) {
57
+ this._defaultHeaders = defaultHeaders;
58
+ }
59
+ get defaultHeaders() {
60
+ return this._defaultHeaders;
61
+ }
62
+ get basePath() {
63
+ return this._basePath;
64
+ }
65
+ setDefaultAuthentication(auth) {
66
+ this.authentications.default = auth;
67
+ }
68
+ setApiKey(key, value) {
69
+ this.authentications[AccountsApiApiKeys[key]].apiKey = value;
70
+ }
71
+ set accessToken(accessToken) {
72
+ this.authentications.pk.accessToken = accessToken;
73
+ }
74
+ addInterceptor(interceptor) {
75
+ this.interceptors.push(interceptor);
76
+ }
77
+ /**
78
+ * Creates an account object.
79
+ * @param chainId The chain_id
80
+ * @param player The player ID
81
+ * @param project The project ID
82
+ * @param externalOwnerAddress The address of the external owner
83
+ */
84
+ async createAccount(chainId, player, project, externalOwnerAddress, options = { headers: {} }) {
85
+ const localVarPath = this.basePath + "/v1/accounts";
86
+ let localVarQueryParameters = {};
87
+ let localVarHeaderParams = Object.assign({}, this._defaultHeaders);
88
+ const produces = ["application/json"];
89
+ // give precedence to 'application/json'
90
+ if (produces.indexOf("application/json") >= 0) {
91
+ localVarHeaderParams.Accept = "application/json";
92
+ }
93
+ else {
94
+ localVarHeaderParams.Accept = produces.join(",");
95
+ }
96
+ let localVarFormParams = {};
97
+ // verify required parameter 'chainId' is not null or undefined
98
+ if (chainId === null || chainId === undefined) {
99
+ throw new Error("Required parameter chainId was null or undefined when calling createAccount.");
100
+ }
101
+ // verify required parameter 'player' is not null or undefined
102
+ if (player === null || player === undefined) {
103
+ throw new Error("Required parameter player was null or undefined when calling createAccount.");
104
+ }
105
+ Object.assign(localVarHeaderParams, options.headers);
106
+ let localVarUseFormData = false;
107
+ if (project !== undefined) {
108
+ localVarFormParams["project"] = models_1.ObjectSerializer.serialize(project, "string");
109
+ }
110
+ if (chainId !== undefined) {
111
+ localVarFormParams["chain_id"] = models_1.ObjectSerializer.serialize(chainId, "number");
112
+ }
113
+ if (player !== undefined) {
114
+ localVarFormParams["player"] = models_1.ObjectSerializer.serialize(player, "string");
115
+ }
116
+ if (externalOwnerAddress !== undefined) {
117
+ localVarFormParams["external_owner_address"] = models_1.ObjectSerializer.serialize(externalOwnerAddress, "string");
118
+ }
119
+ let localVarRequestOptions = {
120
+ method: "POST",
121
+ qs: localVarQueryParameters,
122
+ headers: localVarHeaderParams,
123
+ uri: localVarPath,
124
+ useQuerystring: this._useQuerystring,
125
+ json: true,
126
+ };
127
+ let authenticationPromise = Promise.resolve();
128
+ if (this.authentications.pk.accessToken) {
129
+ authenticationPromise = authenticationPromise.then(() => this.authentications.pk.applyToRequest(localVarRequestOptions));
130
+ }
131
+ authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
132
+ let interceptorPromise = authenticationPromise;
133
+ for (const interceptor of this.interceptors) {
134
+ interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions));
135
+ }
136
+ return interceptorPromise.then(() => {
137
+ if (Object.keys(localVarFormParams).length) {
138
+ if (localVarUseFormData) {
139
+ localVarRequestOptions.formData = localVarFormParams;
140
+ }
141
+ else {
142
+ localVarRequestOptions.form = localVarFormParams;
143
+ }
144
+ }
145
+ return new Promise((resolve, reject) => {
146
+ (0, request_1.default)(localVarRequestOptions, (error, response, body) => {
147
+ if (error) {
148
+ reject(error);
149
+ }
150
+ else {
151
+ if (response.statusCode &&
152
+ response.statusCode >= 200 &&
153
+ response.statusCode <= 299) {
154
+ body = models_1.ObjectSerializer.deserialize(body, "AccountResponse");
155
+ resolve({ response: response, body: body });
156
+ }
157
+ else {
158
+ reject(new apis_1.HttpError(response, body, response.statusCode));
159
+ }
160
+ }
161
+ });
162
+ });
163
+ });
164
+ }
165
+ /**
166
+ * Retrieves the details of an existing account. Supply the unique account ID from either a account creation request or the account list, and Openfort will return the corresponding account information.
167
+ * @param id Specifies the unique account ID.
168
+ * @param expand
169
+ * @param project Specifies the unique project ID.
170
+ */
171
+ async getAccount(id, expand, project, options = { headers: {} }) {
172
+ const localVarPath = this.basePath +
173
+ "/v1/accounts/{id}".replace("{" + "id" + "}", encodeURIComponent(String(id)));
174
+ let localVarQueryParameters = {};
175
+ let localVarHeaderParams = Object.assign({}, this._defaultHeaders);
176
+ const produces = ["application/json"];
177
+ // give precedence to 'application/json'
178
+ if (produces.indexOf("application/json") >= 0) {
179
+ localVarHeaderParams.Accept = "application/json";
180
+ }
181
+ else {
182
+ localVarHeaderParams.Accept = produces.join(",");
183
+ }
184
+ let localVarFormParams = {};
185
+ // verify required parameter 'id' is not null or undefined
186
+ if (id === null || id === undefined) {
187
+ throw new Error("Required parameter id was null or undefined when calling getAccount.");
188
+ }
189
+ if (expand !== undefined) {
190
+ localVarQueryParameters["expand"] = models_1.ObjectSerializer.serialize(expand, "Array<string>");
191
+ }
192
+ if (project !== undefined) {
193
+ localVarQueryParameters["project"] = models_1.ObjectSerializer.serialize(project, "string");
194
+ }
195
+ Object.assign(localVarHeaderParams, options.headers);
196
+ let localVarUseFormData = false;
197
+ let localVarRequestOptions = {
198
+ method: "GET",
199
+ qs: localVarQueryParameters,
200
+ headers: localVarHeaderParams,
201
+ uri: localVarPath,
202
+ useQuerystring: this._useQuerystring,
203
+ json: true,
204
+ };
205
+ let authenticationPromise = Promise.resolve();
206
+ if (this.authentications.pk.accessToken) {
207
+ authenticationPromise = authenticationPromise.then(() => this.authentications.pk.applyToRequest(localVarRequestOptions));
208
+ }
209
+ authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
210
+ let interceptorPromise = authenticationPromise;
211
+ for (const interceptor of this.interceptors) {
212
+ interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions));
213
+ }
214
+ return interceptorPromise.then(() => {
215
+ if (Object.keys(localVarFormParams).length) {
216
+ if (localVarUseFormData) {
217
+ localVarRequestOptions.formData = localVarFormParams;
218
+ }
219
+ else {
220
+ localVarRequestOptions.form = localVarFormParams;
221
+ }
222
+ }
223
+ return new Promise((resolve, reject) => {
224
+ (0, request_1.default)(localVarRequestOptions, (error, response, body) => {
225
+ if (error) {
226
+ reject(error);
227
+ }
228
+ else {
229
+ if (response.statusCode &&
230
+ response.statusCode >= 200 &&
231
+ response.statusCode <= 299) {
232
+ body = models_1.ObjectSerializer.deserialize(body, "AccountResponse");
233
+ resolve({ response: response, body: body });
234
+ }
235
+ else {
236
+ reject(new apis_1.HttpError(response, body, response.statusCode));
237
+ }
238
+ }
239
+ });
240
+ });
241
+ });
242
+ }
243
+ /**
244
+ * Retrieves the inventory of an existing account. Supply the unique account ID from either a account creation request or the account list, and Openfort will return the corresponding account information.
245
+ * @param id Specifies the unique account ID.
246
+ * @param project Specifies the unique project ID.
247
+ */
248
+ async getAccountInventory(id, project, options = { headers: {} }) {
249
+ const localVarPath = this.basePath +
250
+ "/v1/accounts/{id}/inventory".replace("{" + "id" + "}", encodeURIComponent(String(id)));
251
+ let localVarQueryParameters = {};
252
+ let localVarHeaderParams = Object.assign({}, this._defaultHeaders);
253
+ const produces = ["application/json"];
254
+ // give precedence to 'application/json'
255
+ if (produces.indexOf("application/json") >= 0) {
256
+ localVarHeaderParams.Accept = "application/json";
257
+ }
258
+ else {
259
+ localVarHeaderParams.Accept = produces.join(",");
260
+ }
261
+ let localVarFormParams = {};
262
+ // verify required parameter 'id' is not null or undefined
263
+ if (id === null || id === undefined) {
264
+ throw new Error("Required parameter id was null or undefined when calling getAccountInventory.");
265
+ }
266
+ if (project !== undefined) {
267
+ localVarQueryParameters["project"] = models_1.ObjectSerializer.serialize(project, "string");
268
+ }
269
+ Object.assign(localVarHeaderParams, options.headers);
270
+ let localVarUseFormData = false;
271
+ let localVarRequestOptions = {
272
+ method: "GET",
273
+ qs: localVarQueryParameters,
274
+ headers: localVarHeaderParams,
275
+ uri: localVarPath,
276
+ useQuerystring: this._useQuerystring,
277
+ json: true,
278
+ };
279
+ let authenticationPromise = Promise.resolve();
280
+ if (this.authentications.pk.accessToken) {
281
+ authenticationPromise = authenticationPromise.then(() => this.authentications.pk.applyToRequest(localVarRequestOptions));
282
+ }
283
+ authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
284
+ let interceptorPromise = authenticationPromise;
285
+ for (const interceptor of this.interceptors) {
286
+ interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions));
287
+ }
288
+ return interceptorPromise.then(() => {
289
+ if (Object.keys(localVarFormParams).length) {
290
+ if (localVarUseFormData) {
291
+ localVarRequestOptions.formData = localVarFormParams;
292
+ }
293
+ else {
294
+ localVarRequestOptions.form = localVarFormParams;
295
+ }
296
+ }
297
+ return new Promise((resolve, reject) => {
298
+ (0, request_1.default)(localVarRequestOptions, (error, response, body) => {
299
+ if (error) {
300
+ reject(error);
301
+ }
302
+ else {
303
+ if (response.statusCode &&
304
+ response.statusCode >= 200 &&
305
+ response.statusCode <= 299) {
306
+ body = models_1.ObjectSerializer.deserialize(body, "InventoryResponse");
307
+ resolve({ response: response, body: body });
308
+ }
309
+ else {
310
+ reject(new apis_1.HttpError(response, body, response.statusCode));
311
+ }
312
+ }
313
+ });
314
+ });
315
+ });
316
+ }
317
+ /**
318
+ * Returns a list of accounts for the given player. The accounts are returned sorted by creation date, with the most recently created accounts appearing first.
319
+ * @param player Specifies the unique player ID.
320
+ * @param expand
321
+ * @param limit
322
+ * @param project Specifies the unique project ID.
323
+ */
324
+ async getAccounts(player, expand, limit, project, options = { headers: {} }) {
325
+ const localVarPath = this.basePath + "/v1/accounts";
326
+ let localVarQueryParameters = {};
327
+ let localVarHeaderParams = Object.assign({}, this._defaultHeaders);
328
+ const produces = ["application/json"];
329
+ // give precedence to 'application/json'
330
+ if (produces.indexOf("application/json") >= 0) {
331
+ localVarHeaderParams.Accept = "application/json";
332
+ }
333
+ else {
334
+ localVarHeaderParams.Accept = produces.join(",");
335
+ }
336
+ let localVarFormParams = {};
337
+ // verify required parameter 'player' is not null or undefined
338
+ if (player === null || player === undefined) {
339
+ throw new Error("Required parameter player was null or undefined when calling getAccounts.");
340
+ }
341
+ if (player !== undefined) {
342
+ localVarQueryParameters["player"] = models_1.ObjectSerializer.serialize(player, "string");
343
+ }
344
+ if (expand !== undefined) {
345
+ localVarQueryParameters["expand"] = models_1.ObjectSerializer.serialize(expand, "Array<string>");
346
+ }
347
+ if (limit !== undefined) {
348
+ localVarQueryParameters["limit"] = models_1.ObjectSerializer.serialize(limit, "number");
349
+ }
350
+ if (project !== undefined) {
351
+ localVarQueryParameters["project"] = models_1.ObjectSerializer.serialize(project, "string");
352
+ }
353
+ Object.assign(localVarHeaderParams, options.headers);
354
+ let localVarUseFormData = false;
355
+ let localVarRequestOptions = {
356
+ method: "GET",
357
+ qs: localVarQueryParameters,
358
+ headers: localVarHeaderParams,
359
+ uri: localVarPath,
360
+ useQuerystring: this._useQuerystring,
361
+ json: true,
362
+ };
363
+ let authenticationPromise = Promise.resolve();
364
+ if (this.authentications.pk.accessToken) {
365
+ authenticationPromise = authenticationPromise.then(() => this.authentications.pk.applyToRequest(localVarRequestOptions));
366
+ }
367
+ authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
368
+ let interceptorPromise = authenticationPromise;
369
+ for (const interceptor of this.interceptors) {
370
+ interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions));
371
+ }
372
+ return interceptorPromise.then(() => {
373
+ if (Object.keys(localVarFormParams).length) {
374
+ if (localVarUseFormData) {
375
+ localVarRequestOptions.formData = localVarFormParams;
376
+ }
377
+ else {
378
+ localVarRequestOptions.form = localVarFormParams;
379
+ }
380
+ }
381
+ return new Promise((resolve, reject) => {
382
+ (0, request_1.default)(localVarRequestOptions, (error, response, body) => {
383
+ if (error) {
384
+ reject(error);
385
+ }
386
+ else {
387
+ if (response.statusCode &&
388
+ response.statusCode >= 200 &&
389
+ response.statusCode <= 299) {
390
+ body = models_1.ObjectSerializer.deserialize(body, "AccountsResponse");
391
+ resolve({ response: response, body: body });
392
+ }
393
+ else {
394
+ reject(new apis_1.HttpError(response, body, response.statusCode));
395
+ }
396
+ }
397
+ });
398
+ });
399
+ });
400
+ }
401
+ /**
402
+ * Transfers ownership of an account to an address.
403
+ * @param id Specifies the unique account ID.
404
+ * @param newOwnerAddress The address of the new owner
405
+ * @param project The project ID
406
+ * @param policy The policy ID
407
+ */
408
+ async transferOwnership(id, newOwnerAddress, project, policy, options = { headers: {} }) {
409
+ const localVarPath = this.basePath +
410
+ "/v1/accounts/{id}/transfer-ownership".replace("{" + "id" + "}", encodeURIComponent(String(id)));
411
+ let localVarQueryParameters = {};
412
+ let localVarHeaderParams = Object.assign({}, this._defaultHeaders);
413
+ const produces = ["application/json"];
414
+ // give precedence to 'application/json'
415
+ if (produces.indexOf("application/json") >= 0) {
416
+ localVarHeaderParams.Accept = "application/json";
417
+ }
418
+ else {
419
+ localVarHeaderParams.Accept = produces.join(",");
420
+ }
421
+ let localVarFormParams = {};
422
+ // verify required parameter 'id' is not null or undefined
423
+ if (id === null || id === undefined) {
424
+ throw new Error("Required parameter id was null or undefined when calling transferOwnership.");
425
+ }
426
+ // verify required parameter 'newOwnerAddress' is not null or undefined
427
+ if (newOwnerAddress === null || newOwnerAddress === undefined) {
428
+ throw new Error("Required parameter newOwnerAddress was null or undefined when calling transferOwnership.");
429
+ }
430
+ Object.assign(localVarHeaderParams, options.headers);
431
+ let localVarUseFormData = false;
432
+ if (project !== undefined) {
433
+ localVarFormParams["project"] = models_1.ObjectSerializer.serialize(project, "string");
434
+ }
435
+ if (newOwnerAddress !== undefined) {
436
+ localVarFormParams["new_owner_address"] = models_1.ObjectSerializer.serialize(newOwnerAddress, "string");
437
+ }
438
+ if (policy !== undefined) {
439
+ localVarFormParams["policy"] = models_1.ObjectSerializer.serialize(policy, "string");
440
+ }
441
+ let localVarRequestOptions = {
442
+ method: "POST",
443
+ qs: localVarQueryParameters,
444
+ headers: localVarHeaderParams,
445
+ uri: localVarPath,
446
+ useQuerystring: this._useQuerystring,
447
+ json: true,
448
+ };
449
+ let authenticationPromise = Promise.resolve();
450
+ if (this.authentications.pk.accessToken) {
451
+ authenticationPromise = authenticationPromise.then(() => this.authentications.pk.applyToRequest(localVarRequestOptions));
452
+ }
453
+ authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
454
+ let interceptorPromise = authenticationPromise;
455
+ for (const interceptor of this.interceptors) {
456
+ interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions));
457
+ }
458
+ return interceptorPromise.then(() => {
459
+ if (Object.keys(localVarFormParams).length) {
460
+ if (localVarUseFormData) {
461
+ localVarRequestOptions.formData = localVarFormParams;
462
+ }
463
+ else {
464
+ localVarRequestOptions.form = localVarFormParams;
465
+ }
466
+ }
467
+ return new Promise((resolve, reject) => {
468
+ (0, request_1.default)(localVarRequestOptions, (error, response, body) => {
469
+ if (error) {
470
+ reject(error);
471
+ }
472
+ else {
473
+ if (response.statusCode &&
474
+ response.statusCode >= 200 &&
475
+ response.statusCode <= 299) {
476
+ body = models_1.ObjectSerializer.deserialize(body, "TransactionIntentResponse");
477
+ resolve({ response: response, body: body });
478
+ }
479
+ else {
480
+ reject(new apis_1.HttpError(response, body, response.statusCode));
481
+ }
482
+ }
483
+ });
484
+ });
485
+ });
486
+ }
487
+ }
488
+ exports.AccountsApi = AccountsApi;
489
+ //# sourceMappingURL=accountsApi.js.map