* Executes request to create a record in API. * Can be replaced from a in custom helper. * * @param {*} factory * @param {*} data
(factory, data)
| 364 | * @param {*} data |
| 365 | */ |
| 366 | _requestCreate(factory, data) { |
| 367 | let request = createRequestFromFunction(this.factories[factory].create, data) |
| 368 | |
| 369 | if (!request) { |
| 370 | const method = Object.keys(this.factories[factory].create)[0] |
| 371 | const url = this.factories[factory].create[method] |
| 372 | request = { |
| 373 | method, |
| 374 | url, |
| 375 | data, |
| 376 | } |
| 377 | } |
| 378 | |
| 379 | request.baseURL = this.config.endpoint |
| 380 | |
| 381 | return this.restHelper._executeRequest(request).then(resp => { |
| 382 | const id = this._fetchId(resp.data, factory) |
| 383 | this.created[factory].push(id) |
| 384 | this.debugSection('Created', `Id: ${id}`) |
| 385 | if (this.config.returnId) return id |
| 386 | return resp.data |
| 387 | }) |
| 388 | } |
| 389 | |
| 390 | /** |
| 391 | * Executes request to delete a record in API |
no test coverage detected