From 4d5b3ecad22d15468c14df22e8ad36f8072e480a Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Wed, 20 Jul 2016 21:24:00 +0200 Subject: [PATCH] Added 'availabilitiesType' to REST API (#185). --- doc/rest-api.md | 3 +++ src/engine/Api/V1/Parsers/Services.php | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/doc/rest-api.md b/doc/rest-api.md index 07824832..0996643c 100644 --- a/doc/rest-api.md +++ b/doc/rest-api.md @@ -186,6 +186,7 @@ You can also try the GET requests with your browser by navigating to the respeci "price": 10.00, "currency": "Euro", "description": "Male haircut trends.", + "availabilitiesType": "flexible", "categoryId": null } ``` @@ -195,6 +196,8 @@ You can also try the GET requests with your browser by navigating to the respeci - `PUT /api/v1/services/:id` Provide the updated service JSON in the request body to update an existing record. The ID in the URI is required. - `DELETLE /api/v1/services/:id` Remove an existing service record. +* The `availabilitiesType` must be either `flexible` or `fixed`. + ### Categories **Resource JSON** diff --git a/src/engine/Api/V1/Parsers/Services.php b/src/engine/Api/V1/Parsers/Services.php index af27cb67..25ab4b60 100644 --- a/src/engine/Api/V1/Parsers/Services.php +++ b/src/engine/Api/V1/Parsers/Services.php @@ -32,6 +32,7 @@ class Services implements ParsersInterface { 'price' => $response['price'], 'currency' => $response['currency'], 'description' => $response['description'], + 'availabilitiesType' => $response['availabilities_type'], 'categoryId' => $response['id_service_categories'] !== null ? (int)$response['id_service_categories'] : null ]; @@ -71,6 +72,10 @@ class Services implements ParsersInterface { $decodedRequest['description'] = $request['description']; } + if (!empty($request['availabilitiesType'])) { + $decodedRequest['availabilities_type'] = $request['availabilitiesType']; + } + if (!empty($request['categoryId'])) { $decodedRequest['id_service_categories'] = $request['categoryId']; }