blob: 679f9975e574f7dab44a19d3e78b0f58f1a1eeaa [file] [log] [blame]
Avi Ziv61070c92017-07-26 17:37:57 +03001/*!
2 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
13 * or implied. See the License for the specific language governing
14 * permissions and limitations under the License.
15 */
16
17// items/{itemId}/users
18
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020019let list = [];
Avi Ziv61070c92017-07-26 17:37:57 +030020
21export default {
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020022 fetch() {
23 return Promise.resolve({
24 listCount: list.length,
25 results: list
26 });
27 },
Avi Ziv61070c92017-07-26 17:37:57 +030028
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020029 put(url, payload) {
30 // let {removedUsers, addedUsers} = payload;
31 // users = users.filter(user => !removedUsers.map(user => user.userId).includes(user.userId)).concat(addedUsers);
32 payload.id = Math.random() * (1000 - 1) + 1;
33 list.push(payload);
34 return Promise.resolve();
35 },
Avi Ziv61070c92017-07-26 17:37:57 +030036
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020037 destroy(url) {
38 const parts = url.split('/');
39 const id = parts[parts.length - 1];
40 let newList = list.filter(item => item.id !== id);
41 list = newList;
42 return Promise.resolve();
43 }
44};