files.com 1.0.288 → 1.0.290
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.
- package/_VERSION +1 -1
- package/docs/models/ShareGroup.md +132 -0
- package/docs/models/ShareGroupMember.md +15 -0
- package/lib/models/File.js +34 -29
- package/lib/models/ShareGroup.js +394 -0
- package/lib/models/ShareGroupMember.js +58 -0
- package/package.json +1 -1
- package/src/models/File.js +8 -2
- package/src/models/ShareGroup.js +235 -0
- package/src/models/ShareGroupMember.js +37 -0
package/_VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.0.
|
|
1
|
+
1.0.290
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# ShareGroup
|
|
2
|
+
|
|
3
|
+
## Example ShareGroup Object
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
{
|
|
7
|
+
"id": 1,
|
|
8
|
+
"name": "Test group 1",
|
|
9
|
+
"notes": "This group is defined for testing purposes",
|
|
10
|
+
"user_id": 1,
|
|
11
|
+
"share_group_members": [
|
|
12
|
+
{
|
|
13
|
+
"name": "John Doe",
|
|
14
|
+
"company": "Acme Ltd",
|
|
15
|
+
"email": "johndoe@gmail.com"
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
* `id` (int64): Share Group ID
|
|
22
|
+
* `name` (string): Name of the share group
|
|
23
|
+
* `notes` (string): Additional notes of the share group
|
|
24
|
+
* `user_id` (int64): Owner User ID
|
|
25
|
+
* `share_group_members` (array): A list of share group members
|
|
26
|
+
* `members` (array(object)): A list of share group members.
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## List Share Groups
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
await ShareGroup.list({
|
|
34
|
+
'user_id': 1,
|
|
35
|
+
'per_page': 1,
|
|
36
|
+
})
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
### Parameters
|
|
41
|
+
|
|
42
|
+
* `user_id` (int64): User ID. Provide a value of `0` to operate the current session's user.
|
|
43
|
+
* `cursor` (string): Used for pagination. When a list request has more records available, cursors are provided in the response headers `X-Files-Cursor-Next` and `X-Files-Cursor-Prev`. Send one of those cursor value here to resume an existing list from the next available record. Note: many of our SDKs have iterator methods that will automatically handle cursor-based pagination.
|
|
44
|
+
* `per_page` (int64): Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## Show Share Group
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
await ShareGroup.find(id)
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
### Parameters
|
|
56
|
+
|
|
57
|
+
* `id` (int64): Required - Share Group ID.
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## Create Share Group
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
await ShareGroup.create({
|
|
65
|
+
'user_id': 1,
|
|
66
|
+
'notes': "This group is defined for testing purposes",
|
|
67
|
+
'name': "Test group 1",
|
|
68
|
+
'members': [{"name":"John Doe","company":"Acme Ltd","email":"johndoe@gmail.com"}],
|
|
69
|
+
})
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
### Parameters
|
|
74
|
+
|
|
75
|
+
* `user_id` (int64): User ID. Provide a value of `0` to operate the current session's user.
|
|
76
|
+
* `notes` (string): Additional notes of the share group
|
|
77
|
+
* `name` (string): Required - Name of the share group
|
|
78
|
+
* `members` (array(object)): Required - A list of share group members.
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## Update Share Group
|
|
83
|
+
|
|
84
|
+
```
|
|
85
|
+
const [share_group] = await ShareGroup.list()
|
|
86
|
+
|
|
87
|
+
await share_group.update({
|
|
88
|
+
'notes': "This group is defined for testing purposes",
|
|
89
|
+
'name': "Test group 1",
|
|
90
|
+
'members': [{"name":"John Doe","company":"Acme Ltd","email":"johndoe@gmail.com"}],
|
|
91
|
+
})
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Parameters
|
|
95
|
+
|
|
96
|
+
* `id` (int64): Required - Share Group ID.
|
|
97
|
+
* `notes` (string): Additional notes of the share group
|
|
98
|
+
* `name` (string): Name of the share group
|
|
99
|
+
* `members` (array(object)): A list of share group members.
|
|
100
|
+
|
|
101
|
+
### Example Response
|
|
102
|
+
|
|
103
|
+
```json
|
|
104
|
+
{
|
|
105
|
+
"id": 1,
|
|
106
|
+
"name": "Test group 1",
|
|
107
|
+
"notes": "This group is defined for testing purposes",
|
|
108
|
+
"user_id": 1,
|
|
109
|
+
"share_group_members": [
|
|
110
|
+
{
|
|
111
|
+
"name": "John Doe",
|
|
112
|
+
"company": "Acme Ltd",
|
|
113
|
+
"email": "johndoe@gmail.com"
|
|
114
|
+
}
|
|
115
|
+
]
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## Delete Share Group
|
|
122
|
+
|
|
123
|
+
```
|
|
124
|
+
const [share_group] = await ShareGroup.list()
|
|
125
|
+
|
|
126
|
+
await share_group.delete()
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Parameters
|
|
130
|
+
|
|
131
|
+
* `id` (int64): Required - Share Group ID.
|
|
132
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# ShareGroupMember
|
|
2
|
+
|
|
3
|
+
## Example ShareGroupMember Object
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
{
|
|
7
|
+
"name": "John Doe",
|
|
8
|
+
"company": "Acme Ltd",
|
|
9
|
+
"email": "johndoe@gmail.com"
|
|
10
|
+
}
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
* `name` (string): Name of the share group member
|
|
14
|
+
* `company` (string): Company of the share group member
|
|
15
|
+
* `email` (string): Email of the share group member
|
package/lib/models/File.js
CHANGED
|
@@ -902,6 +902,9 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
|
|
902
902
|
return _ref16.apply(this, arguments);
|
|
903
903
|
};
|
|
904
904
|
}());
|
|
905
|
+
(0, _defineProperty2.default)(File, "_determinePartUploadUri", function (fileUploadPart) {
|
|
906
|
+
return fileUploadPart.upload_uri;
|
|
907
|
+
});
|
|
905
908
|
/**
|
|
906
909
|
* @note see File.copy() for list of supported params
|
|
907
910
|
*/
|
|
@@ -933,7 +936,7 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
|
|
933
936
|
});
|
|
934
937
|
readableStream.on('data', /*#__PURE__*/function () {
|
|
935
938
|
var _ref18 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee15(chunk) {
|
|
936
|
-
var nextLength, excessLength, chunkBuffer, tailLength, lastChunkForPart, firstChunkForNextPart, buffer, nextFileUploadPart, uploadPromise;
|
|
939
|
+
var nextLength, excessLength, chunkBuffer, tailLength, lastChunkForPart, firstChunkForNextPart, buffer, nextFileUploadPart, upload_uri, uploadPromise;
|
|
937
940
|
return _regenerator.default.wrap(function _callee15$(_context15) {
|
|
938
941
|
while (1) switch (_context15.prev = _context15.next) {
|
|
939
942
|
case 0:
|
|
@@ -942,7 +945,7 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
|
|
942
945
|
excessLength = nextLength - firstFileUploadPart.partsize;
|
|
943
946
|
chunkBuffer = _safeBuffer.Buffer.from(chunk);
|
|
944
947
|
if (!(excessLength > 0)) {
|
|
945
|
-
_context15.next =
|
|
948
|
+
_context15.next = 27;
|
|
946
949
|
break;
|
|
947
950
|
}
|
|
948
951
|
readableStream.pause();
|
|
@@ -957,51 +960,52 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
|
|
957
960
|
return File._continueUpload(destinationPath, ++part, firstFileUploadPart, options);
|
|
958
961
|
case 13:
|
|
959
962
|
nextFileUploadPart = _context15.sent;
|
|
960
|
-
|
|
963
|
+
upload_uri = File._determinePartUploadUri(nextFileUploadPart);
|
|
964
|
+
uploadPromise = _Api.default.sendFilePart(upload_uri, 'PUT', buffer);
|
|
961
965
|
if (!firstFileUploadPart.parallel_parts) {
|
|
962
|
-
_context15.next =
|
|
966
|
+
_context15.next = 20;
|
|
963
967
|
break;
|
|
964
968
|
}
|
|
965
969
|
concurrentUploads.push(uploadPromise);
|
|
966
|
-
_context15.next =
|
|
970
|
+
_context15.next = 22;
|
|
967
971
|
break;
|
|
968
|
-
case
|
|
969
|
-
_context15.next =
|
|
972
|
+
case 20:
|
|
973
|
+
_context15.next = 22;
|
|
970
974
|
return uploadPromise;
|
|
971
|
-
case
|
|
975
|
+
case 22:
|
|
972
976
|
chunks = [firstChunkForNextPart];
|
|
973
977
|
length = firstChunkForNextPart.length;
|
|
974
978
|
readableStream.resume();
|
|
975
|
-
_context15.next =
|
|
979
|
+
_context15.next = 29;
|
|
976
980
|
break;
|
|
977
|
-
case
|
|
981
|
+
case 27:
|
|
978
982
|
chunks.push(chunkBuffer);
|
|
979
983
|
length += chunk.length;
|
|
980
|
-
case
|
|
981
|
-
_context15.next =
|
|
984
|
+
case 29:
|
|
985
|
+
_context15.next = 34;
|
|
982
986
|
break;
|
|
983
|
-
case
|
|
984
|
-
_context15.prev =
|
|
987
|
+
case 31:
|
|
988
|
+
_context15.prev = 31;
|
|
985
989
|
_context15.t0 = _context15["catch"](0);
|
|
986
990
|
reject(_context15.t0);
|
|
987
|
-
case
|
|
991
|
+
case 34:
|
|
988
992
|
case "end":
|
|
989
993
|
return _context15.stop();
|
|
990
994
|
}
|
|
991
|
-
}, _callee15, null, [[0,
|
|
995
|
+
}, _callee15, null, [[0, 31]]);
|
|
992
996
|
}));
|
|
993
997
|
return function (_x20) {
|
|
994
998
|
return _ref18.apply(this, arguments);
|
|
995
999
|
};
|
|
996
1000
|
}());
|
|
997
1001
|
readableStream.on('end', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee16() {
|
|
998
|
-
var buffer, nextFileUploadPart, response, createdFile;
|
|
1002
|
+
var buffer, nextFileUploadPart, upload_uri, response, createdFile;
|
|
999
1003
|
return _regenerator.default.wrap(function _callee16$(_context16) {
|
|
1000
1004
|
while (1) switch (_context16.prev = _context16.next) {
|
|
1001
1005
|
case 0:
|
|
1002
1006
|
_context16.prev = 0;
|
|
1003
1007
|
if (!(chunks.length > 0)) {
|
|
1004
|
-
_context16.next =
|
|
1008
|
+
_context16.next = 8;
|
|
1005
1009
|
break;
|
|
1006
1010
|
}
|
|
1007
1011
|
buffer = _safeBuffer.Buffer.concat(chunks);
|
|
@@ -1009,28 +1013,29 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
|
|
1009
1013
|
return File._continueUpload(destinationPath, ++part, firstFileUploadPart, options);
|
|
1010
1014
|
case 5:
|
|
1011
1015
|
nextFileUploadPart = _context16.sent;
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1016
|
+
upload_uri = File._determinePartUploadUri(nextFileUploadPart);
|
|
1017
|
+
concurrentUploads.push(_Api.default.sendFilePart(upload_uri, 'PUT', buffer));
|
|
1018
|
+
case 8:
|
|
1019
|
+
_context16.next = 10;
|
|
1015
1020
|
return Promise.all(concurrentUploads);
|
|
1016
|
-
case
|
|
1017
|
-
_context16.next =
|
|
1021
|
+
case 10:
|
|
1022
|
+
_context16.next = 12;
|
|
1018
1023
|
return File._completeUpload(firstFileUploadPart, options);
|
|
1019
|
-
case
|
|
1024
|
+
case 12:
|
|
1020
1025
|
response = _context16.sent;
|
|
1021
1026
|
createdFile = new File(response.data, options);
|
|
1022
1027
|
resolve(createdFile);
|
|
1023
|
-
_context16.next =
|
|
1028
|
+
_context16.next = 20;
|
|
1024
1029
|
break;
|
|
1025
|
-
case
|
|
1026
|
-
_context16.prev =
|
|
1030
|
+
case 17:
|
|
1031
|
+
_context16.prev = 17;
|
|
1027
1032
|
_context16.t0 = _context16["catch"](0);
|
|
1028
1033
|
reject(_context16.t0);
|
|
1029
|
-
case
|
|
1034
|
+
case 20:
|
|
1030
1035
|
case "end":
|
|
1031
1036
|
return _context16.stop();
|
|
1032
1037
|
}
|
|
1033
|
-
}, _callee16, null, [[0,
|
|
1038
|
+
}, _callee16, null, [[0, 17]]);
|
|
1034
1039
|
})));
|
|
1035
1040
|
});
|
|
1036
1041
|
case 8:
|
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
+
exports.__esModule = true;
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
8
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
11
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
12
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
+
var _Api = _interopRequireDefault(require("../Api"));
|
|
14
|
+
var errors = _interopRequireWildcard(require("../Errors"));
|
|
15
|
+
var _Logger = _interopRequireDefault(require("../Logger"));
|
|
16
|
+
var _utils = require("../utils");
|
|
17
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
18
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
19
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
20
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
21
|
+
/**
|
|
22
|
+
* Class ShareGroup
|
|
23
|
+
*/
|
|
24
|
+
var ShareGroup = /*#__PURE__*/(0, _createClass2.default)(function ShareGroup() {
|
|
25
|
+
var _this = this;
|
|
26
|
+
var attributes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
27
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
28
|
+
(0, _classCallCheck2.default)(this, ShareGroup);
|
|
29
|
+
(0, _defineProperty2.default)(this, "attributes", {});
|
|
30
|
+
(0, _defineProperty2.default)(this, "options", {});
|
|
31
|
+
(0, _defineProperty2.default)(this, "isLoaded", function () {
|
|
32
|
+
return !!_this.attributes.id;
|
|
33
|
+
});
|
|
34
|
+
// int64 # Share Group ID
|
|
35
|
+
(0, _defineProperty2.default)(this, "getId", function () {
|
|
36
|
+
return _this.attributes.id;
|
|
37
|
+
});
|
|
38
|
+
(0, _defineProperty2.default)(this, "setId", function (value) {
|
|
39
|
+
_this.attributes.id = value;
|
|
40
|
+
});
|
|
41
|
+
// string # Name of the share group
|
|
42
|
+
(0, _defineProperty2.default)(this, "getName", function () {
|
|
43
|
+
return _this.attributes.name;
|
|
44
|
+
});
|
|
45
|
+
(0, _defineProperty2.default)(this, "setName", function (value) {
|
|
46
|
+
_this.attributes.name = value;
|
|
47
|
+
});
|
|
48
|
+
// string # Additional notes of the share group
|
|
49
|
+
(0, _defineProperty2.default)(this, "getNotes", function () {
|
|
50
|
+
return _this.attributes.notes;
|
|
51
|
+
});
|
|
52
|
+
(0, _defineProperty2.default)(this, "setNotes", function (value) {
|
|
53
|
+
_this.attributes.notes = value;
|
|
54
|
+
});
|
|
55
|
+
// int64 # Owner User ID
|
|
56
|
+
(0, _defineProperty2.default)(this, "getUserId", function () {
|
|
57
|
+
return _this.attributes.user_id;
|
|
58
|
+
});
|
|
59
|
+
(0, _defineProperty2.default)(this, "setUserId", function (value) {
|
|
60
|
+
_this.attributes.user_id = value;
|
|
61
|
+
});
|
|
62
|
+
// array # A list of share group members
|
|
63
|
+
(0, _defineProperty2.default)(this, "getShareGroupMembers", function () {
|
|
64
|
+
return _this.attributes.share_group_members;
|
|
65
|
+
});
|
|
66
|
+
(0, _defineProperty2.default)(this, "setShareGroupMembers", function (value) {
|
|
67
|
+
_this.attributes.share_group_members = value;
|
|
68
|
+
});
|
|
69
|
+
// array(object) # A list of share group members.
|
|
70
|
+
(0, _defineProperty2.default)(this, "getMembers", function () {
|
|
71
|
+
return _this.attributes.members;
|
|
72
|
+
});
|
|
73
|
+
(0, _defineProperty2.default)(this, "setMembers", function (value) {
|
|
74
|
+
_this.attributes.members = value;
|
|
75
|
+
});
|
|
76
|
+
// Parameters:
|
|
77
|
+
// notes - string - Additional notes of the share group
|
|
78
|
+
// name - string - Name of the share group
|
|
79
|
+
// members - array(object) - A list of share group members.
|
|
80
|
+
(0, _defineProperty2.default)(this, "update", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
81
|
+
var params,
|
|
82
|
+
response,
|
|
83
|
+
_args = arguments;
|
|
84
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
85
|
+
while (1) switch (_context.prev = _context.next) {
|
|
86
|
+
case 0:
|
|
87
|
+
params = _args.length > 0 && _args[0] !== undefined ? _args[0] : {};
|
|
88
|
+
if (_this.attributes.id) {
|
|
89
|
+
_context.next = 3;
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
throw new errors.EmptyPropertyError('Current object has no id');
|
|
93
|
+
case 3:
|
|
94
|
+
if ((0, _utils.isObject)(params)) {
|
|
95
|
+
_context.next = 5;
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
throw new errors.InvalidParameterError("Bad parameter: params must be of type object, received ".concat((0, _utils.getType)(params)));
|
|
99
|
+
case 5:
|
|
100
|
+
params.id = _this.attributes.id;
|
|
101
|
+
if (!(params['id'] && !(0, _utils.isInt)(params['id']))) {
|
|
102
|
+
_context.next = 8;
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
throw new errors.InvalidParameterError("Bad parameter: id must be of type Int, received ".concat((0, _utils.getType)(id)));
|
|
106
|
+
case 8:
|
|
107
|
+
if (!(params['notes'] && !(0, _utils.isString)(params['notes']))) {
|
|
108
|
+
_context.next = 10;
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
throw new errors.InvalidParameterError("Bad parameter: notes must be of type String, received ".concat((0, _utils.getType)(notes)));
|
|
112
|
+
case 10:
|
|
113
|
+
if (!(params['name'] && !(0, _utils.isString)(params['name']))) {
|
|
114
|
+
_context.next = 12;
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
throw new errors.InvalidParameterError("Bad parameter: name must be of type String, received ".concat((0, _utils.getType)(name)));
|
|
118
|
+
case 12:
|
|
119
|
+
if (!(params['members'] && !(0, _utils.isArray)(params['members']))) {
|
|
120
|
+
_context.next = 14;
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
throw new errors.InvalidParameterError("Bad parameter: members must be of type Array, received ".concat((0, _utils.getType)(members)));
|
|
124
|
+
case 14:
|
|
125
|
+
if (params['id']) {
|
|
126
|
+
_context.next = 20;
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
if (!_this.attributes.id) {
|
|
130
|
+
_context.next = 19;
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
params['id'] = _this.id;
|
|
134
|
+
_context.next = 20;
|
|
135
|
+
break;
|
|
136
|
+
case 19:
|
|
137
|
+
throw new errors.MissingParameterError('Parameter missing: id');
|
|
138
|
+
case 20:
|
|
139
|
+
_context.next = 22;
|
|
140
|
+
return _Api.default.sendRequest("/share_groups/".concat(encodeURIComponent(params['id'])), 'PATCH', params, _this.options);
|
|
141
|
+
case 22:
|
|
142
|
+
response = _context.sent;
|
|
143
|
+
return _context.abrupt("return", new ShareGroup(response === null || response === void 0 ? void 0 : response.data, _this.options));
|
|
144
|
+
case 24:
|
|
145
|
+
case "end":
|
|
146
|
+
return _context.stop();
|
|
147
|
+
}
|
|
148
|
+
}, _callee);
|
|
149
|
+
})));
|
|
150
|
+
(0, _defineProperty2.default)(this, "delete", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
151
|
+
var params,
|
|
152
|
+
response,
|
|
153
|
+
_args2 = arguments;
|
|
154
|
+
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
155
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
156
|
+
case 0:
|
|
157
|
+
params = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {};
|
|
158
|
+
if (_this.attributes.id) {
|
|
159
|
+
_context2.next = 3;
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
throw new errors.EmptyPropertyError('Current object has no id');
|
|
163
|
+
case 3:
|
|
164
|
+
if ((0, _utils.isObject)(params)) {
|
|
165
|
+
_context2.next = 5;
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
throw new errors.InvalidParameterError("Bad parameter: params must be of type object, received ".concat((0, _utils.getType)(params)));
|
|
169
|
+
case 5:
|
|
170
|
+
params.id = _this.attributes.id;
|
|
171
|
+
if (!(params['id'] && !(0, _utils.isInt)(params['id']))) {
|
|
172
|
+
_context2.next = 8;
|
|
173
|
+
break;
|
|
174
|
+
}
|
|
175
|
+
throw new errors.InvalidParameterError("Bad parameter: id must be of type Int, received ".concat((0, _utils.getType)(id)));
|
|
176
|
+
case 8:
|
|
177
|
+
if (params['id']) {
|
|
178
|
+
_context2.next = 14;
|
|
179
|
+
break;
|
|
180
|
+
}
|
|
181
|
+
if (!_this.attributes.id) {
|
|
182
|
+
_context2.next = 13;
|
|
183
|
+
break;
|
|
184
|
+
}
|
|
185
|
+
params['id'] = _this.id;
|
|
186
|
+
_context2.next = 14;
|
|
187
|
+
break;
|
|
188
|
+
case 13:
|
|
189
|
+
throw new errors.MissingParameterError('Parameter missing: id');
|
|
190
|
+
case 14:
|
|
191
|
+
_context2.next = 16;
|
|
192
|
+
return _Api.default.sendRequest("/share_groups/".concat(encodeURIComponent(params['id'])), 'DELETE', params, _this.options);
|
|
193
|
+
case 16:
|
|
194
|
+
response = _context2.sent;
|
|
195
|
+
return _context2.abrupt("return", response === null || response === void 0 ? void 0 : response.data);
|
|
196
|
+
case 18:
|
|
197
|
+
case "end":
|
|
198
|
+
return _context2.stop();
|
|
199
|
+
}
|
|
200
|
+
}, _callee2);
|
|
201
|
+
})));
|
|
202
|
+
(0, _defineProperty2.default)(this, "destroy", function () {
|
|
203
|
+
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
204
|
+
return _this.delete(params);
|
|
205
|
+
});
|
|
206
|
+
(0, _defineProperty2.default)(this, "save", function () {
|
|
207
|
+
if (_this.attributes['id']) {
|
|
208
|
+
return _this.update(_this.attributes);
|
|
209
|
+
} else {
|
|
210
|
+
var newObject = ShareGroup.create(_this.attributes, _this.options);
|
|
211
|
+
_this.attributes = _objectSpread({}, newObject.attributes);
|
|
212
|
+
return true;
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
Object.entries(attributes).forEach(function (_ref3) {
|
|
216
|
+
var _ref4 = (0, _slicedToArray2.default)(_ref3, 2),
|
|
217
|
+
key = _ref4[0],
|
|
218
|
+
value = _ref4[1];
|
|
219
|
+
var normalizedKey = key.replace('?', '');
|
|
220
|
+
_this.attributes[normalizedKey] = value;
|
|
221
|
+
Object.defineProperty(_this, normalizedKey, {
|
|
222
|
+
value: value,
|
|
223
|
+
writable: false
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
this.options = _objectSpread({}, options);
|
|
227
|
+
});
|
|
228
|
+
// Parameters:
|
|
229
|
+
// user_id - int64 - User ID. Provide a value of `0` to operate the current session's user.
|
|
230
|
+
// cursor - string - Used for pagination. When a list request has more records available, cursors are provided in the response headers `X-Files-Cursor-Next` and `X-Files-Cursor-Prev`. Send one of those cursor value here to resume an existing list from the next available record. Note: many of our SDKs have iterator methods that will automatically handle cursor-based pagination.
|
|
231
|
+
// per_page - int64 - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
|
|
232
|
+
(0, _defineProperty2.default)(ShareGroup, "list", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
|
|
233
|
+
var _response$data;
|
|
234
|
+
var params,
|
|
235
|
+
options,
|
|
236
|
+
response,
|
|
237
|
+
_args3 = arguments;
|
|
238
|
+
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
239
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
240
|
+
case 0:
|
|
241
|
+
params = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : {};
|
|
242
|
+
options = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : {};
|
|
243
|
+
if (!(params['user_id'] && !(0, _utils.isInt)(params['user_id']))) {
|
|
244
|
+
_context3.next = 4;
|
|
245
|
+
break;
|
|
246
|
+
}
|
|
247
|
+
throw new errors.InvalidParameterError("Bad parameter: user_id must be of type Int, received ".concat((0, _utils.getType)(params['user_id'])));
|
|
248
|
+
case 4:
|
|
249
|
+
if (!(params['cursor'] && !(0, _utils.isString)(params['cursor']))) {
|
|
250
|
+
_context3.next = 6;
|
|
251
|
+
break;
|
|
252
|
+
}
|
|
253
|
+
throw new errors.InvalidParameterError("Bad parameter: cursor must be of type String, received ".concat((0, _utils.getType)(params['cursor'])));
|
|
254
|
+
case 6:
|
|
255
|
+
if (!(params['per_page'] && !(0, _utils.isInt)(params['per_page']))) {
|
|
256
|
+
_context3.next = 8;
|
|
257
|
+
break;
|
|
258
|
+
}
|
|
259
|
+
throw new errors.InvalidParameterError("Bad parameter: per_page must be of type Int, received ".concat((0, _utils.getType)(params['per_page'])));
|
|
260
|
+
case 8:
|
|
261
|
+
_context3.next = 10;
|
|
262
|
+
return _Api.default.sendRequest("/share_groups", 'GET', params, options);
|
|
263
|
+
case 10:
|
|
264
|
+
response = _context3.sent;
|
|
265
|
+
return _context3.abrupt("return", (response === null || response === void 0 ? void 0 : (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.map(function (obj) {
|
|
266
|
+
return new ShareGroup(obj, options);
|
|
267
|
+
})) || []);
|
|
268
|
+
case 12:
|
|
269
|
+
case "end":
|
|
270
|
+
return _context3.stop();
|
|
271
|
+
}
|
|
272
|
+
}, _callee3);
|
|
273
|
+
})));
|
|
274
|
+
(0, _defineProperty2.default)(ShareGroup, "all", function () {
|
|
275
|
+
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
276
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
277
|
+
return ShareGroup.list(params, options);
|
|
278
|
+
});
|
|
279
|
+
// Parameters:
|
|
280
|
+
// id (required) - int64 - Share Group ID.
|
|
281
|
+
(0, _defineProperty2.default)(ShareGroup, "find", /*#__PURE__*/function () {
|
|
282
|
+
var _ref6 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(id) {
|
|
283
|
+
var params,
|
|
284
|
+
options,
|
|
285
|
+
response,
|
|
286
|
+
_args4 = arguments;
|
|
287
|
+
return _regenerator.default.wrap(function _callee4$(_context4) {
|
|
288
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
289
|
+
case 0:
|
|
290
|
+
params = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {};
|
|
291
|
+
options = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : {};
|
|
292
|
+
if ((0, _utils.isObject)(params)) {
|
|
293
|
+
_context4.next = 4;
|
|
294
|
+
break;
|
|
295
|
+
}
|
|
296
|
+
throw new errors.InvalidParameterError("Bad parameter: params must be of type object, received ".concat((0, _utils.getType)(params)));
|
|
297
|
+
case 4:
|
|
298
|
+
params['id'] = id;
|
|
299
|
+
if (params['id']) {
|
|
300
|
+
_context4.next = 7;
|
|
301
|
+
break;
|
|
302
|
+
}
|
|
303
|
+
throw new errors.MissingParameterError('Parameter missing: id');
|
|
304
|
+
case 7:
|
|
305
|
+
if (!(params['id'] && !(0, _utils.isInt)(params['id']))) {
|
|
306
|
+
_context4.next = 9;
|
|
307
|
+
break;
|
|
308
|
+
}
|
|
309
|
+
throw new errors.InvalidParameterError("Bad parameter: id must be of type Int, received ".concat((0, _utils.getType)(params['id'])));
|
|
310
|
+
case 9:
|
|
311
|
+
_context4.next = 11;
|
|
312
|
+
return _Api.default.sendRequest("/share_groups/".concat(encodeURIComponent(params['id'])), 'GET', params, options);
|
|
313
|
+
case 11:
|
|
314
|
+
response = _context4.sent;
|
|
315
|
+
return _context4.abrupt("return", new ShareGroup(response === null || response === void 0 ? void 0 : response.data, options));
|
|
316
|
+
case 13:
|
|
317
|
+
case "end":
|
|
318
|
+
return _context4.stop();
|
|
319
|
+
}
|
|
320
|
+
}, _callee4);
|
|
321
|
+
}));
|
|
322
|
+
return function (_x) {
|
|
323
|
+
return _ref6.apply(this, arguments);
|
|
324
|
+
};
|
|
325
|
+
}());
|
|
326
|
+
(0, _defineProperty2.default)(ShareGroup, "get", function (id) {
|
|
327
|
+
var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
328
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
329
|
+
return ShareGroup.find(id, params, options);
|
|
330
|
+
});
|
|
331
|
+
// Parameters:
|
|
332
|
+
// user_id - int64 - User ID. Provide a value of `0` to operate the current session's user.
|
|
333
|
+
// notes - string - Additional notes of the share group
|
|
334
|
+
// name (required) - string - Name of the share group
|
|
335
|
+
// members (required) - array(object) - A list of share group members.
|
|
336
|
+
(0, _defineProperty2.default)(ShareGroup, "create", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
|
|
337
|
+
var params,
|
|
338
|
+
options,
|
|
339
|
+
response,
|
|
340
|
+
_args5 = arguments;
|
|
341
|
+
return _regenerator.default.wrap(function _callee5$(_context5) {
|
|
342
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
343
|
+
case 0:
|
|
344
|
+
params = _args5.length > 0 && _args5[0] !== undefined ? _args5[0] : {};
|
|
345
|
+
options = _args5.length > 1 && _args5[1] !== undefined ? _args5[1] : {};
|
|
346
|
+
if (params['name']) {
|
|
347
|
+
_context5.next = 4;
|
|
348
|
+
break;
|
|
349
|
+
}
|
|
350
|
+
throw new errors.MissingParameterError('Parameter missing: name');
|
|
351
|
+
case 4:
|
|
352
|
+
if (params['members']) {
|
|
353
|
+
_context5.next = 6;
|
|
354
|
+
break;
|
|
355
|
+
}
|
|
356
|
+
throw new errors.MissingParameterError('Parameter missing: members');
|
|
357
|
+
case 6:
|
|
358
|
+
if (!(params['user_id'] && !(0, _utils.isInt)(params['user_id']))) {
|
|
359
|
+
_context5.next = 8;
|
|
360
|
+
break;
|
|
361
|
+
}
|
|
362
|
+
throw new errors.InvalidParameterError("Bad parameter: user_id must be of type Int, received ".concat((0, _utils.getType)(params['user_id'])));
|
|
363
|
+
case 8:
|
|
364
|
+
if (!(params['notes'] && !(0, _utils.isString)(params['notes']))) {
|
|
365
|
+
_context5.next = 10;
|
|
366
|
+
break;
|
|
367
|
+
}
|
|
368
|
+
throw new errors.InvalidParameterError("Bad parameter: notes must be of type String, received ".concat((0, _utils.getType)(params['notes'])));
|
|
369
|
+
case 10:
|
|
370
|
+
if (!(params['name'] && !(0, _utils.isString)(params['name']))) {
|
|
371
|
+
_context5.next = 12;
|
|
372
|
+
break;
|
|
373
|
+
}
|
|
374
|
+
throw new errors.InvalidParameterError("Bad parameter: name must be of type String, received ".concat((0, _utils.getType)(params['name'])));
|
|
375
|
+
case 12:
|
|
376
|
+
if (!(params['members'] && !(0, _utils.isArray)(params['members']))) {
|
|
377
|
+
_context5.next = 14;
|
|
378
|
+
break;
|
|
379
|
+
}
|
|
380
|
+
throw new errors.InvalidParameterError("Bad parameter: members must be of type Array, received ".concat((0, _utils.getType)(params['members'])));
|
|
381
|
+
case 14:
|
|
382
|
+
_context5.next = 16;
|
|
383
|
+
return _Api.default.sendRequest("/share_groups", 'POST', params, options);
|
|
384
|
+
case 16:
|
|
385
|
+
response = _context5.sent;
|
|
386
|
+
return _context5.abrupt("return", new ShareGroup(response === null || response === void 0 ? void 0 : response.data, options));
|
|
387
|
+
case 18:
|
|
388
|
+
case "end":
|
|
389
|
+
return _context5.stop();
|
|
390
|
+
}
|
|
391
|
+
}, _callee5);
|
|
392
|
+
})));
|
|
393
|
+
var _default = ShareGroup;
|
|
394
|
+
exports.default = _default;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
+
exports.__esModule = true;
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
8
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
9
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
var _Api = _interopRequireDefault(require("../Api"));
|
|
12
|
+
var errors = _interopRequireWildcard(require("../Errors"));
|
|
13
|
+
var _Logger = _interopRequireDefault(require("../Logger"));
|
|
14
|
+
var _utils = require("../utils");
|
|
15
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
16
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
17
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
18
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
19
|
+
/**
|
|
20
|
+
* Class ShareGroupMember
|
|
21
|
+
*/
|
|
22
|
+
var ShareGroupMember = /*#__PURE__*/(0, _createClass2.default)(function ShareGroupMember() {
|
|
23
|
+
var _this = this;
|
|
24
|
+
var attributes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
25
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
26
|
+
(0, _classCallCheck2.default)(this, ShareGroupMember);
|
|
27
|
+
(0, _defineProperty2.default)(this, "attributes", {});
|
|
28
|
+
(0, _defineProperty2.default)(this, "options", {});
|
|
29
|
+
(0, _defineProperty2.default)(this, "isLoaded", function () {
|
|
30
|
+
return !!_this.attributes.id;
|
|
31
|
+
});
|
|
32
|
+
// string # Name of the share group member
|
|
33
|
+
(0, _defineProperty2.default)(this, "getName", function () {
|
|
34
|
+
return _this.attributes.name;
|
|
35
|
+
});
|
|
36
|
+
// string # Company of the share group member
|
|
37
|
+
(0, _defineProperty2.default)(this, "getCompany", function () {
|
|
38
|
+
return _this.attributes.company;
|
|
39
|
+
});
|
|
40
|
+
// string # Email of the share group member
|
|
41
|
+
(0, _defineProperty2.default)(this, "getEmail", function () {
|
|
42
|
+
return _this.attributes.email;
|
|
43
|
+
});
|
|
44
|
+
Object.entries(attributes).forEach(function (_ref) {
|
|
45
|
+
var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
|
|
46
|
+
key = _ref2[0],
|
|
47
|
+
value = _ref2[1];
|
|
48
|
+
var normalizedKey = key.replace('?', '');
|
|
49
|
+
_this.attributes[normalizedKey] = value;
|
|
50
|
+
Object.defineProperty(_this, normalizedKey, {
|
|
51
|
+
value: value,
|
|
52
|
+
writable: false
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
this.options = _objectSpread({}, options);
|
|
56
|
+
});
|
|
57
|
+
var _default = ShareGroupMember;
|
|
58
|
+
exports.default = _default;
|
package/package.json
CHANGED
package/src/models/File.js
CHANGED
|
@@ -76,6 +76,10 @@ class File {
|
|
|
76
76
|
return Api.sendRequest(`/files/${encodeURIComponent(firstFileUploadPart.path)}`, 'POST', params, options)
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
+
static _determinePartUploadUri = fileUploadPart => {
|
|
80
|
+
return fileUploadPart.upload_uri
|
|
81
|
+
}
|
|
82
|
+
|
|
79
83
|
/**
|
|
80
84
|
* @note see File.copy() for list of supported params
|
|
81
85
|
*/
|
|
@@ -116,7 +120,8 @@ class File {
|
|
|
116
120
|
const buffer = Buffer.concat(chunks)
|
|
117
121
|
const nextFileUploadPart = await File._continueUpload(destinationPath, ++part, firstFileUploadPart, options)
|
|
118
122
|
|
|
119
|
-
const
|
|
123
|
+
const upload_uri = File._determinePartUploadUri(nextFileUploadPart)
|
|
124
|
+
const uploadPromise = Api.sendFilePart(upload_uri, 'PUT', buffer)
|
|
120
125
|
|
|
121
126
|
if (firstFileUploadPart.parallel_parts) {
|
|
122
127
|
concurrentUploads.push(uploadPromise)
|
|
@@ -143,7 +148,8 @@ class File {
|
|
|
143
148
|
const buffer = Buffer.concat(chunks)
|
|
144
149
|
const nextFileUploadPart = await File._continueUpload(destinationPath, ++part, firstFileUploadPart, options)
|
|
145
150
|
|
|
146
|
-
|
|
151
|
+
const upload_uri = File._determinePartUploadUri(nextFileUploadPart)
|
|
152
|
+
concurrentUploads.push(Api.sendFilePart(upload_uri, 'PUT', buffer))
|
|
147
153
|
}
|
|
148
154
|
|
|
149
155
|
await Promise.all(concurrentUploads)
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import Api from '../Api'
|
|
2
|
+
import * as errors from '../Errors'
|
|
3
|
+
import Logger from '../Logger'
|
|
4
|
+
import { getType, isArray, isBrowser, isInt, isObject, isString } from '../utils'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Class ShareGroup
|
|
8
|
+
*/
|
|
9
|
+
class ShareGroup {
|
|
10
|
+
attributes = {}
|
|
11
|
+
options = {}
|
|
12
|
+
|
|
13
|
+
constructor(attributes = {}, options = {}) {
|
|
14
|
+
Object.entries(attributes).forEach(([key, value]) => {
|
|
15
|
+
const normalizedKey = key.replace('?', '')
|
|
16
|
+
|
|
17
|
+
this.attributes[normalizedKey] = value
|
|
18
|
+
|
|
19
|
+
Object.defineProperty(this, normalizedKey, { value, writable: false })
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
this.options = { ...options }
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
isLoaded = () => !!this.attributes.id
|
|
26
|
+
// int64 # Share Group ID
|
|
27
|
+
getId = () => this.attributes.id
|
|
28
|
+
|
|
29
|
+
setId = value => {
|
|
30
|
+
this.attributes.id = value
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// string # Name of the share group
|
|
34
|
+
getName = () => this.attributes.name
|
|
35
|
+
|
|
36
|
+
setName = value => {
|
|
37
|
+
this.attributes.name = value
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// string # Additional notes of the share group
|
|
41
|
+
getNotes = () => this.attributes.notes
|
|
42
|
+
|
|
43
|
+
setNotes = value => {
|
|
44
|
+
this.attributes.notes = value
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// int64 # Owner User ID
|
|
48
|
+
getUserId = () => this.attributes.user_id
|
|
49
|
+
|
|
50
|
+
setUserId = value => {
|
|
51
|
+
this.attributes.user_id = value
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// array # A list of share group members
|
|
55
|
+
getShareGroupMembers = () => this.attributes.share_group_members
|
|
56
|
+
|
|
57
|
+
setShareGroupMembers = value => {
|
|
58
|
+
this.attributes.share_group_members = value
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// array(object) # A list of share group members.
|
|
62
|
+
getMembers = () => this.attributes.members
|
|
63
|
+
|
|
64
|
+
setMembers = value => {
|
|
65
|
+
this.attributes.members = value
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
// Parameters:
|
|
70
|
+
// notes - string - Additional notes of the share group
|
|
71
|
+
// name - string - Name of the share group
|
|
72
|
+
// members - array(object) - A list of share group members.
|
|
73
|
+
update = async (params = {}) => {
|
|
74
|
+
if (!this.attributes.id) {
|
|
75
|
+
throw new errors.EmptyPropertyError('Current object has no id')
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (!isObject(params)) {
|
|
79
|
+
throw new errors.InvalidParameterError(`Bad parameter: params must be of type object, received ${getType(params)}`)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
params.id = this.attributes.id
|
|
83
|
+
if (params['id'] && !isInt(params['id'])) {
|
|
84
|
+
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(id)}`)
|
|
85
|
+
}
|
|
86
|
+
if (params['notes'] && !isString(params['notes'])) {
|
|
87
|
+
throw new errors.InvalidParameterError(`Bad parameter: notes must be of type String, received ${getType(notes)}`)
|
|
88
|
+
}
|
|
89
|
+
if (params['name'] && !isString(params['name'])) {
|
|
90
|
+
throw new errors.InvalidParameterError(`Bad parameter: name must be of type String, received ${getType(name)}`)
|
|
91
|
+
}
|
|
92
|
+
if (params['members'] && !isArray(params['members'])) {
|
|
93
|
+
throw new errors.InvalidParameterError(`Bad parameter: members must be of type Array, received ${getType(members)}`)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (!params['id']) {
|
|
97
|
+
if (this.attributes.id) {
|
|
98
|
+
params['id'] = this.id
|
|
99
|
+
} else {
|
|
100
|
+
throw new errors.MissingParameterError('Parameter missing: id')
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const response = await Api.sendRequest(`/share_groups/${encodeURIComponent(params['id'])}`, 'PATCH', params, this.options)
|
|
105
|
+
|
|
106
|
+
return new ShareGroup(response?.data, this.options)
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
delete = async (params = {}) => {
|
|
110
|
+
if (!this.attributes.id) {
|
|
111
|
+
throw new errors.EmptyPropertyError('Current object has no id')
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (!isObject(params)) {
|
|
115
|
+
throw new errors.InvalidParameterError(`Bad parameter: params must be of type object, received ${getType(params)}`)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
params.id = this.attributes.id
|
|
119
|
+
if (params['id'] && !isInt(params['id'])) {
|
|
120
|
+
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(id)}`)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (!params['id']) {
|
|
124
|
+
if (this.attributes.id) {
|
|
125
|
+
params['id'] = this.id
|
|
126
|
+
} else {
|
|
127
|
+
throw new errors.MissingParameterError('Parameter missing: id')
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const response = await Api.sendRequest(`/share_groups/${encodeURIComponent(params['id'])}`, 'DELETE', params, this.options)
|
|
132
|
+
|
|
133
|
+
return response?.data
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
destroy = (params = {}) =>
|
|
137
|
+
this.delete(params)
|
|
138
|
+
|
|
139
|
+
save = () => {
|
|
140
|
+
if (this.attributes['id']) {
|
|
141
|
+
return this.update(this.attributes)
|
|
142
|
+
} else {
|
|
143
|
+
const newObject = ShareGroup.create(this.attributes, this.options)
|
|
144
|
+
this.attributes = { ...newObject.attributes }
|
|
145
|
+
return true
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// Parameters:
|
|
150
|
+
// user_id - int64 - User ID. Provide a value of `0` to operate the current session's user.
|
|
151
|
+
// cursor - string - Used for pagination. When a list request has more records available, cursors are provided in the response headers `X-Files-Cursor-Next` and `X-Files-Cursor-Prev`. Send one of those cursor value here to resume an existing list from the next available record. Note: many of our SDKs have iterator methods that will automatically handle cursor-based pagination.
|
|
152
|
+
// per_page - int64 - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
|
|
153
|
+
static list = async (params = {}, options = {}) => {
|
|
154
|
+
if (params['user_id'] && !isInt(params['user_id'])) {
|
|
155
|
+
throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params['user_id'])}`)
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (params['cursor'] && !isString(params['cursor'])) {
|
|
159
|
+
throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params['cursor'])}`)
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if (params['per_page'] && !isInt(params['per_page'])) {
|
|
163
|
+
throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params['per_page'])}`)
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const response = await Api.sendRequest(`/share_groups`, 'GET', params, options)
|
|
167
|
+
|
|
168
|
+
return response?.data?.map(obj => new ShareGroup(obj, options)) || []
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
static all = (params = {}, options = {}) =>
|
|
172
|
+
ShareGroup.list(params, options)
|
|
173
|
+
|
|
174
|
+
// Parameters:
|
|
175
|
+
// id (required) - int64 - Share Group ID.
|
|
176
|
+
static find = async (id, params = {}, options = {}) => {
|
|
177
|
+
if (!isObject(params)) {
|
|
178
|
+
throw new errors.InvalidParameterError(`Bad parameter: params must be of type object, received ${getType(params)}`)
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
params['id'] = id
|
|
182
|
+
|
|
183
|
+
if (!params['id']) {
|
|
184
|
+
throw new errors.MissingParameterError('Parameter missing: id')
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
if (params['id'] && !isInt(params['id'])) {
|
|
188
|
+
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params['id'])}`)
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
const response = await Api.sendRequest(`/share_groups/${encodeURIComponent(params['id'])}`, 'GET', params, options)
|
|
192
|
+
|
|
193
|
+
return new ShareGroup(response?.data, options)
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
static get = (id, params = {}, options = {}) =>
|
|
197
|
+
ShareGroup.find(id, params, options)
|
|
198
|
+
|
|
199
|
+
// Parameters:
|
|
200
|
+
// user_id - int64 - User ID. Provide a value of `0` to operate the current session's user.
|
|
201
|
+
// notes - string - Additional notes of the share group
|
|
202
|
+
// name (required) - string - Name of the share group
|
|
203
|
+
// members (required) - array(object) - A list of share group members.
|
|
204
|
+
static create = async (params = {}, options = {}) => {
|
|
205
|
+
if (!params['name']) {
|
|
206
|
+
throw new errors.MissingParameterError('Parameter missing: name')
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
if (!params['members']) {
|
|
210
|
+
throw new errors.MissingParameterError('Parameter missing: members')
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
if (params['user_id'] && !isInt(params['user_id'])) {
|
|
214
|
+
throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params['user_id'])}`)
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
if (params['notes'] && !isString(params['notes'])) {
|
|
218
|
+
throw new errors.InvalidParameterError(`Bad parameter: notes must be of type String, received ${getType(params['notes'])}`)
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
if (params['name'] && !isString(params['name'])) {
|
|
222
|
+
throw new errors.InvalidParameterError(`Bad parameter: name must be of type String, received ${getType(params['name'])}`)
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
if (params['members'] && !isArray(params['members'])) {
|
|
226
|
+
throw new errors.InvalidParameterError(`Bad parameter: members must be of type Array, received ${getType(params['members'])}`)
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
const response = await Api.sendRequest(`/share_groups`, 'POST', params, options)
|
|
230
|
+
|
|
231
|
+
return new ShareGroup(response?.data, options)
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export default ShareGroup
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import Api from '../Api'
|
|
2
|
+
import * as errors from '../Errors'
|
|
3
|
+
import Logger from '../Logger'
|
|
4
|
+
import { getType, isArray, isBrowser, isInt, isObject, isString } from '../utils'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Class ShareGroupMember
|
|
8
|
+
*/
|
|
9
|
+
class ShareGroupMember {
|
|
10
|
+
attributes = {}
|
|
11
|
+
options = {}
|
|
12
|
+
|
|
13
|
+
constructor(attributes = {}, options = {}) {
|
|
14
|
+
Object.entries(attributes).forEach(([key, value]) => {
|
|
15
|
+
const normalizedKey = key.replace('?', '')
|
|
16
|
+
|
|
17
|
+
this.attributes[normalizedKey] = value
|
|
18
|
+
|
|
19
|
+
Object.defineProperty(this, normalizedKey, { value, writable: false })
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
this.options = { ...options }
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
isLoaded = () => !!this.attributes.id
|
|
26
|
+
// string # Name of the share group member
|
|
27
|
+
getName = () => this.attributes.name
|
|
28
|
+
|
|
29
|
+
// string # Company of the share group member
|
|
30
|
+
getCompany = () => this.attributes.company
|
|
31
|
+
|
|
32
|
+
// string # Email of the share group member
|
|
33
|
+
getEmail = () => this.attributes.email
|
|
34
|
+
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export default ShareGroupMember
|