Avi Ziv | 61070c9 | 2017-07-26 17:37:57 +0300 | [diff] [blame] | 1 | /*! |
| 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 | |
| 19 | let list = [ |
| 20 | |
| 21 | ]; |
| 22 | |
| 23 | export default { |
| 24 | fetch() { |
| 25 | return Promise.resolve({ |
| 26 | listCount: list.length, |
| 27 | results: list |
| 28 | }); |
| 29 | }, |
| 30 | |
| 31 | put(url, payload) { |
| 32 | // let {removedUsers, addedUsers} = payload; |
| 33 | // users = users.filter(user => !removedUsers.map(user => user.userId).includes(user.userId)).concat(addedUsers); |
| 34 | payload.id = Math.random() * (1000 - 1) + 1; |
| 35 | list.push(payload); |
| 36 | return Promise.resolve(); |
| 37 | }, |
| 38 | |
| 39 | destroy(url) { |
| 40 | const parts = url.split('/'); |
| 41 | const id = parts[parts.length - 1]; |
| 42 | let newList = list.filter(item => item.id !== id); |
| 43 | list = newList; |
| 44 | return Promise.resolve(); |
| 45 | } |
| 46 | }; |