Contents
On this page

Add Numbered Spaces - Plugixa Car Parking

POST /plugixa-car-parking/v1/location-spaces/numbered

Add a run of individually identified, numbered spaces to a location in one call, for example A-1 to A-20.

The user needs the plugixa_carparking_create capability.

Needs a location that identifies each space, which is the assigned inventory mode of Plugixa Car Parking Pro. On a free site no location can, so every call is refused with plugixa_carparking_mode_unsupported.

Each number becomes its own space row: label is the prefix followed by the number, quantity is 1, is_assigned is true, status is active and display_order is the number.

Note. Labels are not checked against the spaces the location already has: running the same range twice adds the spaces twice.

Request

POST https://your-site.example/wp-json/plugixa-car-parking/v1/location-spaces/numbered

Request body

Content type: application/json

Field Type Required Description
location_id integer Yes A live location whose inventory_mode is assigned.
space_type_id integer Yes A live space type.
prefix string No Put before each number. Plain text.
from integer No First number, 0 or more. Defaults to 1.
to integer Yes Last number, no smaller than from. At most 500 numbers in one call.

Every row is checked before any is written, so a refused request adds nothing.

{
  "location_id": 4,
  "space_type_id": 2,
  "prefix": "A-",
  "from": 1,
  "to": 20
}

Responses

201 Created. data.ids lists the new space rows.

{
  "success": true,
  "data": {
    "ids": [52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71]
  }
}
Field Type Meaning
data.ids integer[] The ids of the rows created, in number order

Read the rows with List Spaces.

Errors

Status Code When
422 plugixa_carparking_invalid_to to is missing or smaller than from, from is negative, or the range holds more than 500 numbers.
422 plugixa_carparking_invalid_location_id location_id is missing, 0, or not a live location.
422 plugixa_carparking_invalid_space_type_id space_type_id is missing, 0, or not a live space type.
400 plugixa_carparking_mode_unsupported The location does not identify each space.
422 plugixa_carparking_too_long A label would be longer than 100 characters.

Plus the errors every endpoint can return.

Examples

curl -s -X POST "https://your-site.example/wp-json/plugixa-car-parking/v1/location-spaces/numbered" \
  -u "admin:$WP_APP_PASSWORD" \
  -H "Content-Type: application/json" \
  -d '{"location_id":4,"space_type_id":2,"prefix":"A-","from":1,"to":20}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-car-parking/v1/location-spaces/numbered');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST  => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_USERPWD        => 'admin:' . getenv('WP_APP_PASSWORD'),
    CURLOPT_HTTPHEADER     => ['Content-Type: application/json'],
    CURLOPT_POSTFIELDS     => json_encode([
        'location_id'   => 4,
        'space_type_id' => 2,
        'prefix'        => 'A-',
        'from'          => 1,
        'to'            => 20,
    ]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-site.example/wp-json/plugixa-car-parking/v1/location-spaces/numbered', {
  method: 'POST',
  headers: {
    'Authorization': 'Basic ' + btoa(`admin:${process.env.WP_APP_PASSWORD}`),
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    location_id: 4,
    space_type_id: 2,
    prefix: 'A-',
    from: 1,
    to: 20,
  }),
});
const { data } = await response.json();

Quick Links

Share