Skip to content

Classes and Functions

Joshua Grierson edited this page Oct 26, 2017 · 2 revisions

Classes and Functions

Alot of the functions available have been shown in the README of this Repo.

Core Class

The core class required to start using our functions, we can also pass through a venue Id to the forge function

$dmn_api = WP_DMN::forge();

// pass a venue Id
$venue_id = '[venue-id]';
$dmn_api = WP_DMN::forge($venue_id);

Is Ready

This function should be used to check that our options in backend have been setup, if this check is not done before continuing with our request, this could break any custom form this is being used for.

if($dmn_api->is_ready()) {
  // ok we are all setup
}

Add Field

Alot of the resources require some fields in the request before they can be used

$dmn_api->add_field('field_type', 'field_value');

Add Rules

Rules are used to be strict on what booking types we want in return, the valid rules are guestlist and privateHire.

$dmn_api->add_rules(['privateHire' => true]);

The above example will return only rooms that are available for private hire.

Request

Of course to return results we need to make requests, after our request has been made this function will either return the current instance of the WP_DMN class or null if the API needs a breather.

$dmn_api->request();

As Array

For basic response, use this function to return the acceptance message and list of booking types.

$dmn_api->as_array();

Get Acceptance

Responsible for returning action type, which determines what action will be taken once the booking has been submitted, these are:

  • Accept Your booking will be accepted and automatically confirmed
  • Enquire Your booking will be processed as an enquiry, but you will need to wait for confirmation
  • May Enquire Venue has no availability, but you may choose to submit an enquiry anyway
  • Reject Bookings cannot be taken at this present time, please try again soon
$dmn_api->get_acceptance();

Get Booking Types

Returns all booking types available.

$dmn_api->get_booking_types();

Get Capacity

Tracks capacity available for a requested room, this requires type, num_people, date fields to be passed in request. This returns instance of Capacity_Handler class.

$capacity = $dmn_api->get_capacity();

// takes in optional param $amount for num people wanted for the requested booking type
$capacity = $dmn_api->get_capacity(30);

// functions available
$capacity->exceeds_limit();
$capacity->matched_minimum();
$capacity->get_limit();
$capacity->get_minimum();

Dates

Returns instance of Dates class.

$dates = $dmn_api->dates();

// takes in optional param $future for returning only dates from the current date
$dates = $dmn_api->dates(true);

// functions available
$dates->get_dates();
$dates->get_from_to('2017-11-05', '2017-11-25');
$dates->is_date_available('2017-11-10');

Times

Returns instance of Times class.

$times = $dmn_api->times();

// takes in optional param $future for returning only times from the current time
$times = $dmn_api->times(true);

// functions available
$dates->get_times();
$dates->get_from_to('12:15', '17:30');
$dates->is_date_available('14:15');

Duration

Returns instance of Duration_Times class.

$duration_times = $dmn_api->duration();

// functions available
$duration_times->get_times();
$duration_times->is_duration_available(15); // 15 means 15 mins, and 30 means 30 mins etc

Get Booking Details

DMN API kindly keeps track of booking information that has been given so far.

$deets = $dmn_api->get_booking_details();

Submit Booking

Once all the needed fields have been made in the request, DMN will return a web link to continue the booking process, if not enough info has been given to them, this will return null.

$web_link = $dmn_api->submit_booking();

Get Venue Id

Retrieves a single or all venue Id's provided within the plugin's options.

// returns list of venue Id's
$venue_ids = $dmn_api->get_venue_id();

// returns single venue Id
$venue_id = $dmn_api->get_venue_id('venue_id');

Clone this wiki locally