|
| 1 | +# Features |
| 2 | + |
| 3 | +## `list(type)` |
| 4 | +List all avaiable features for a given `type`(optional). |
| 5 | + |
| 6 | +```js |
| 7 | +const data = await deskbookers.feature.list() |
| 8 | +``` |
| 9 | +#### Example response |
| 10 | +```json |
| 11 | +[ |
| 12 | + { |
| 13 | + "description": "Review widgets", |
| 14 | + "id": 3, |
| 15 | + "name": "reviewWidgets", |
| 16 | + "parentId": null, |
| 17 | + "readonly": false, |
| 18 | + "type": "venue" |
| 19 | + }, |
| 20 | + { |
| 21 | + "description": "Book button widgets", |
| 22 | + "id": 4, |
| 23 | + "name": "bookButtonWidgets", |
| 24 | + "parentId": null, |
| 25 | + "readonly": false, |
| 26 | + "type": "venue" |
| 27 | + }, |
| 28 | + { |
| 29 | + "description": "Regular customer discounts", |
| 30 | + "features": [ |
| 31 | + { |
| 32 | + "description": "Regular customer discounts son 1", |
| 33 | + "features": [ |
| 34 | + { |
| 35 | + "description": "Regular customer discounts grandson 1", |
| 36 | + "id": 7, |
| 37 | + "name": "rcdGrandson1", |
| 38 | + "parentId": 5, |
| 39 | + "readonly": true, |
| 40 | + "type": "venue" |
| 41 | + } |
| 42 | + ], |
| 43 | + "id": 5, |
| 44 | + "name": "rcdSon1", |
| 45 | + "parentId": 1, |
| 46 | + "readonly": true, |
| 47 | + "type": "venue" |
| 48 | + }, |
| 49 | + { |
| 50 | + "description": "Regular customer discounts son 2", |
| 51 | + "id": 6, |
| 52 | + "name": "rcdSon2", |
| 53 | + "parentId": 1, |
| 54 | + "readonly": true, |
| 55 | + "type": "venue" |
| 56 | + } |
| 57 | + ], |
| 58 | + "id": 1, |
| 59 | + "name": "regularCustomerDiscounts", |
| 60 | + "parentId": null, |
| 61 | + "readonly": true, |
| 62 | + "type": "venue" |
| 63 | + }, |
| 64 | + { |
| 65 | + "description": "Booking tool", |
| 66 | + "features": [ |
| 67 | + { |
| 68 | + "description": "Booking Tool Son 1", |
| 69 | + "id": 8, |
| 70 | + "name": "btSon1", |
| 71 | + "parentId": 2, |
| 72 | + "readonly": true, |
| 73 | + "type": "booking" |
| 74 | + } |
| 75 | + ], |
| 76 | + "id": 2, |
| 77 | + "name": "bookingTool", |
| 78 | + "parentId": null, |
| 79 | + "readonly": true, |
| 80 | + "type": "booking" |
| 81 | + } |
| 82 | +] |
| 83 | +``` |
| 84 | + |
| 85 | +```js |
| 86 | +const data = await deskbookers.feature.list('booking') |
| 87 | +``` |
| 88 | +#### Example response |
| 89 | +```json |
| 90 | +[ |
| 91 | + { |
| 92 | + "description": "Booking tool", |
| 93 | + "features": [ |
| 94 | + { |
| 95 | + "description": "Booking Tool Son 1", |
| 96 | + "id": 8, |
| 97 | + "name": "btSon1", |
| 98 | + "parentId": 2, |
| 99 | + "readonly": true, |
| 100 | + "type": "booking" |
| 101 | + } |
| 102 | + ], |
| 103 | + "id": 2, |
| 104 | + "name": "bookingTool", |
| 105 | + "parentId": null, |
| 106 | + "readonly": true, |
| 107 | + "type": "booking" |
| 108 | + } |
| 109 | +] |
| 110 | +``` |
| 111 | + |
| 112 | +## `create(feature)` |
| 113 | +Create a new feature for a given `Object`. |
| 114 | + |
| 115 | +#### Body (feature) |
| 116 | +Name | Type | Description | Required |
| 117 | +--- | --- | --- | --- |
| 118 | +name | String | Alphanumeric feature name | Yes |
| 119 | +parentId | Integer | Id of the parent feature | No |
| 120 | +description | String | Short description of the feature | No |
| 121 | +type | String | Alphanumeric type name | Yes |
| 122 | + |
| 123 | +```js |
| 124 | +const data = await deskbookers.feature.create( |
| 125 | + { |
| 126 | + name: 'testName', |
| 127 | + description: 'teste description', |
| 128 | + type: 'venue' |
| 129 | + } |
| 130 | +) |
| 131 | +``` |
| 132 | +#### Example response |
| 133 | +```json |
| 134 | +{ |
| 135 | + "status": "ok" |
| 136 | +} |
| 137 | +``` |
| 138 | + |
| 139 | +## `update(featureName, feature)` |
| 140 | +Update a feature for a given `featureName` with the `Object`. |
| 141 | + |
| 142 | +#### Body (feature) |
| 143 | +Name | Type | Description | Required |
| 144 | +--- | --- | --- | --- |
| 145 | +name | String | Alphanumeric feature name | Yes |
| 146 | +parentId | Integer | Id of the parent feature | No |
| 147 | +description | String | Short description of the feature | No |
| 148 | +type | String | Alphanumeric type name | Yes |
| 149 | + |
| 150 | +```js |
| 151 | +const data = await deskbookers.feature.update( |
| 152 | + 'testName', |
| 153 | + { |
| 154 | + name: 'testName', |
| 155 | + description: 'teste description 2', |
| 156 | + type: 'venue2', |
| 157 | + parentId: null |
| 158 | + } |
| 159 | +) |
| 160 | +``` |
| 161 | +#### Example response |
| 162 | +```json |
| 163 | +{ |
| 164 | + "status": "ok" |
| 165 | +} |
| 166 | +``` |
| 167 | + |
| 168 | +## `delete(featureName)` |
| 169 | +Delete a feature for a given `featureName`. |
| 170 | + |
| 171 | +```js |
| 172 | +const data = await deskbookers.feature.delete('testName') |
| 173 | +``` |
| 174 | +#### Example response |
| 175 | +```json |
| 176 | +{ |
| 177 | + "status": "ok" |
| 178 | +} |
| 179 | +``` |
| 180 | + |
| 181 | +## `listByVenue(venueId)` |
| 182 | +List all active features for a given `venueId`. |
| 183 | + |
| 184 | +```js |
| 185 | +const data = await deskbookers.feature.listByVenue(1) |
| 186 | +``` |
| 187 | +#### Example response |
| 188 | +```json |
| 189 | +[ |
| 190 | + { |
| 191 | + "description": "Regular custumer discounts", |
| 192 | + "end": null, |
| 193 | + "features": [ |
| 194 | + { |
| 195 | + "description": "Regular custumer discounts son 1", |
| 196 | + "end": null, |
| 197 | + "features": [ |
| 198 | + { |
| 199 | + "description": "Regular custumer discounts grandson 1", |
| 200 | + "end": "2017-07-20T10:37:17.313Z", |
| 201 | + "id": 7, |
| 202 | + "name": "rcdGrandson1", |
| 203 | + "parentId": 5, |
| 204 | + "start": "2017-06-20T10:37:17.313Z", |
| 205 | + "type": "venue" |
| 206 | + } |
| 207 | + ], |
| 208 | + "id": 5, |
| 209 | + "name": "rcdSon1", |
| 210 | + "parentId": 1, |
| 211 | + "start": "2017-06-20T10:37:17.217Z", |
| 212 | + "type": "venue" |
| 213 | + }, |
| 214 | + { |
| 215 | + "description": "Regular custumer discounts son 2", |
| 216 | + "end": null, |
| 217 | + "id": 6, |
| 218 | + "name": "rcdSon2", |
| 219 | + "parentId": 1, |
| 220 | + "start": "2017-06-20T10:37:17.260Z", |
| 221 | + "type": "venue" |
| 222 | + } |
| 223 | + ], |
| 224 | + "id": 1, |
| 225 | + "name": "regularCustumerDiscounts", |
| 226 | + "parentId": null, |
| 227 | + "start": "2017-06-20T10:37:17.172Z", |
| 228 | + "type": "venue" |
| 229 | + } |
| 230 | +] |
| 231 | +``` |
| 232 | + |
| 233 | +## `checkFeatureByVenue(venueId, featureName)` |
| 234 | +List all active features for a given `venueId` and `featureName`. |
| 235 | + |
| 236 | +```js |
| 237 | + const data = await deskbookers.feature.checkFeatureByVenue( |
| 238 | + 1, |
| 239 | + 'regularCustumerDiscounts' |
| 240 | + ) |
| 241 | +``` |
| 242 | +#### Example response |
| 243 | +```json |
| 244 | +false |
| 245 | +``` |
| 246 | + |
| 247 | +## `updateFeatureByVenue(venueId, featureName, feature)` |
| 248 | +Update features for a given `venueId`, `featureName` and `feature`. |
| 249 | + |
| 250 | +#### Body (feature) |
| 251 | +Name | Type | Description | Required |
| 252 | +--- | --- | --- | --- |
| 253 | +enabled | boolean | Set enabled status | Yes |
| 254 | +start | Timestamp | Feature active start date | No |
| 255 | +end | Timestamp | Feature active end date | No |
| 256 | + |
| 257 | +```js |
| 258 | + let start = new Date().setDate(new Date().getDate()-20) |
| 259 | + let end = new Date().setDate(new Date().getDate()+5) |
| 260 | + const data = await deskbookers.feature.updateFeatureByVenue( |
| 261 | + 2, |
| 262 | + 'bookingTool', |
| 263 | + { |
| 264 | + enabled: true, |
| 265 | + start, |
| 266 | + end |
| 267 | + } |
| 268 | + ) |
| 269 | +``` |
| 270 | +#### Example response |
| 271 | +```json |
| 272 | +{ |
| 273 | + "status": "ok" |
| 274 | +} |
| 275 | +``` |
0 commit comments