Company public service methods: Difference between revisions

No edit summary
No edit summary
Line 126: Line 126:


* [http://wiki.simplybook.me/index.php/Settings#Timeframe Timeframe information]
* [http://wiki.simplybook.me/index.php/Settings#Timeframe Timeframe information]
----
=== calculateEndTime ===
<code>calculateEndTime($startDateTime, $eventId, $unitId)</code>
Parameters:
* '''$startDateTime''' String a date and time string in format 'Y-m-d H:i:s', eg. '2001-10-02 13:30:00'.
* '''$eventId''' Integer
* '''$unitId''' Integer
Returns String|Boolean.
Returns end datetime if booking is available, else return false


----
----
Line 233: Line 250:
Confirm booking payment. Signature is required.$sign = md5($bookingId . $bookingHash . $secretKey);
Confirm booking payment. Signature is required.$sign = md5($bookingId . $bookingHash . $secretKey);
Call this method from server side only
Call this method from server side only
----
=== createBatch ===
<code>createBatch()</code>
No arguments.
Returns Integer.
Creates new booking batch record. Returns newly created batch id. You can use this id in <code>[[#book|book]]</code>
API method.
----
=== filterAvailableUnits ===
<code>filterAvailableUnits($eventId, $dateTime, $unitIds, $count)</code>
Parameters:
* '''$eventId''' Integer
* '''$dateTime''' String a date and time string in format 'Y-m-d H:i:s'
* '''$unitIds''' 
* '''$count''' Integer
Returns Array.
Returns list of available unit ids for specified date and service from provided $unitIds list.You can use this method with location plugin.
Returns empty array if all units are not allowed.
Eg.: <code>[1, 2, 3]</code>
----
=== getAdditionalFields ===
<code>getAdditionalFields($eventId)</code>
Parameters:
* '''$eventId''' Integer
Returns Array.
Return additional fields for certain event if [[Plugins#Additional_fields|Additional fields plugin]] is
activated. Returns empty array otherwise. Call <code>[[#isPluginActivated|isPluginActivated('event_field')]]</code>
API method to check if 'event_field' plugin activated.
----
=== getAnyUnitData ===
<code>getAnyUnitData()</code>
No arguments.
Returns Object|null.
Returns information about [[Plugins#Any_Employee_selector|Any Employee selector plugin]] configuration. Returns
null if plugin not enabled.Example:
  {
    "description" : "Select this option, if you want to find an available time with any of the employees",
    "hide_other_units" : 1, // 1 or 0
    "image" : null,
    "name" : "Any employee",
    "picture_path" : null,
    "random_selection" : 0 // 1 or 0
  }
----
=== getAvailableTimeIntervals ===
<code>getAvailableTimeIntervals($dateFrom, $dateTo, $eventId, $unitId, $count)</code>
Parameters:
* '''$dateFrom''' String
* '''$dateTo''' String
* '''$eventId''' Integer
* '''$unitId''' Mixed can be Integer or Array of Integers
* '''$count''' Integer
Returns Object.
Returns available time intervals for all service providers for given period, taking into account breaktimes, start and end working time
Eg.: <code>{['2016-03-04': ['1': [['09:00:00','09:30:00'], ['11:15:00','14:45:00']] , ...], ...]}</code>
----
=== getAvailableUnits ===
<code>getAvailableUnits($eventId, $dateTime, $count)</code>
Parameters:
* '''$eventId''' Integer
* '''$dateTime''' String a date and time string in format 'Y-m-d H:i:s'
* '''$count''' Integer
Returns Array.
Returns list of available unit ids for specified date and service or empty array if all units are not allowed.Eg.: <code>[1, 2, 3]</code>




Line 267: Line 392:
Returns Object.
Returns Object.


Returns cart information by bookings ids.<code>cart_id</code> and <code>cart_hash</code> is used to create secure signature to confirm cart payment.
Returns cart information by bookings ids.
<code>amount</code> - is total amount to payment
 
<code>currency</code> - cart currency
* <code>cart_id</code> and <code>cart_hash</code> is used to create secure signature to confirm cart payment.
<code>cart</code> - contains cart items. You can use them to provide information for payment system. Each item is object with following fields:
* <code>amount</code> - is total amount to payment
<code>id</code> - booking id
* <code>currency</code> - cart currency
<code>event_id</code> - service id
* <code>cart</code> - contains cart items. You can use them to provide information for payment system. Each item is object with following fields:
<code>name</code> - event name + start date time (use it to provide cart information for payment system)
* <code>id</code> - booking id
<code>price</code> - booking price
* <code>event_id</code> - service id
<code>qty</code> - qty of bookings
* <code>name</code> - event name + start date time (use it to provide cart information for payment system)
* <code>price</code> - booking price
* <code>qty</code> - qty of bookings




Line 310: Line 437:
Returns Array.
Returns Array.


{@inheritdoc}
Returns company categories list if [[Plugins#Service categories|Service categories plugin]] is activated. Returns
an error with code -32001 if plugin is not activated. Use <code>[[#isPluginActivated|isPluginActivated('event_category')]]</code>
API method to check if plugin activated.
 
 
----
 
=== getCompanyInfo ===
 
<code>getCompanyInfo()</code>
 
No arguments.
Returns Object.
 
Returns an object with detailed information about company. See [[#getCompanyInfo response|example of response]].
 
 
----
 
=== getCompanyParam ===
 
<code>getCompanyParam($key)</code>
 
Parameters:
 
* '''$key''' String
 
Returns mixed.
 
Returns company config value for key. A different set of keys available for public API and for company
administration API. Method return 'invalid params' error (code -32602) in case if access to specified key not
allowed. See [[#Company_params|list of available keys]].
 
 
----
 
=== getCompanyParams ===
 
<code>getCompanyParams($keys)</code>
 
Parameters:
 
* '''$keys''' Array
 
Returns Array.
 
Returns company config values for keys. A different set of keys available for public API and for company
administration API. Method return 'invalid params' error (code -32602) in case if access to specified key not
allowed. See [[#Company_params|list of available keys]].For non-existent and not-allowed params it will return false as result
 
 
----
 
=== getCompanyTimezoneOffset ===
 
<code>getCompanyTimezoneOffset()</code>
 
No arguments.
Returns array.
 
Returns company timezone offset and company timezone
 
 
----
 
=== getCountryPhoneCodes ===
 
<code>getCountryPhoneCodes()</code>
 
No arguments.
Returns Array.
 
Returns country phone code list




Line 326: Line 525:
Returns Array.
Returns Array.


{@inheritdoc}
Returns company's events list. If <code>$asArray</code> is false then method returns a map with event id as key
and details object as value. If parameter set to true then method returns a list sorted by 'position' property of
event's details object.
 
 
----
 
=== getFirstWorkingDay ===
 
<code>getFirstWorkingDay($unitId)</code>
 
Parameters:
 
* '''$unitId''' Integer
 
Returns String.
 
Returns first working date for unit




Line 337: Line 553:
Parameters:
Parameters:


* '''$isPublic''' Boolean  
* '''$isPublic''' Boolean Optional. Default value is '''false'''.
* '''$asArray'''
* '''$asArray''' boolean Optional. Default value is '''false'''.


Returns Array.
Returns Array.


{@inheritdoc}
Returns available locations for company if plugin [[Plugins#Unit location|Unit location plugin]] is activated. Return
an error with code -32001 if plugin is not activated. Use <code>[[#isPluginActivated|isPluginActivated('location')]]</code>
API method to check if plugin activated.This method accepts two boolean flags as parameters. If '''isPublic''' flag is '''true''' then method returns only
public locations. If '''asArray''' flag is '''true''' method returns list of objects. Otherwise method returns
map of objects with object id as key. You can omit both parameters.




Line 358: Line 578:


Returns payment processor config
Returns payment processor config
----
=== getPluginPromoInfoByCode ===
<code>getPluginPromoInfoByCode($code)</code>
Parameters:
* '''$code''' 
Returns Array.
Returns an object with detailed information about promotion by promotion code. You can get promotion code
using <code>[[Catalogue#getPromotionList|getPromotionList]]</code> API method. If promotion record with specified
code not found then method returns an empty array (an empty object). If [[Plugins#Simply Smart Promotions|Simply Smart Promotions plugin]]
not enabled then method returns an error with code -32001 (Plugin is not activated). Use
<code>[[#isPluginActivated|isPluginActivated('promo')]]</code> API method call to check if plugin enabled.See [[#getPromotionList response|example]] of <code>getPromotionList</code> API method response. Please note that
response contains a list of services for wich promotion discount can be applied (<code>service_ids</code> key).
----
=== getPluginStatuses ===
<code>getPluginStatuses($pluginNames)</code>
Parameters:
* '''$pluginNames''' Array
Returns Array.
Return plugin status true if status active, else false. See [[#Plugin's identifiers|list of available plugin's names]].




Line 410: Line 665:


Get list of dates for recurring booking
Get list of dates for recurring booking
----
=== getReservedTime ===
<code>getReservedTime($from, $to, $eventId, $unitId, $count)</code>
Parameters:
* '''$from''' String
* '''$to''' String
* '''$eventId''' Integer
* '''$unitId''' Integer
* '''$count''' Integer
Returns Object.
Returns map of objects for each day in specified date range. The key of the result mps is a date string. The value
is an array of two objects. Both objects contains list of time slots for type <code>reserved_time</code> and type
<code>not_worked_time</code>. <code>reserved_time</code> type represents time slots working time but already booked
by clients. Nobody knows what kind of data represented by <code>not_worked_time</code> type. Please don't use it.If [[Plugins#Google calendar sync plugin|Google calendar sync plugin]] enabled then object with
<code>reserved_time</code> type will contain not empty list of time slots marked as busy in Google calendar. Call
<code>[[#isPluginActivated|isPluginActivated('google_calendar_export')]]</code> API method to check if Google
calendar sync plugin activated.
Example:
<pre>
  {
    "2016-02-05": [
      {
        "dd": [], // time slots from Google calendar
        "events": [ // reserved time slots
          { "from": "16:00", "to": "16:30" },
          { "from": "16:30", "to": "17:00" },
          ... ],
        "type": "reserved_time",
      },
      {
        "events": [
          { "from": "09:00", "to": "09:30" },
          { "from": "09:30", "to": "10:00" },
          ... ],
        "type": "not_worked_time"
    }],
    ...
  }
</pre>
----
=== getReservedTimeIntervals ===
<code>getReservedTimeIntervals($dateFrom, $dateTo, $eventId, $unitId, $count)</code>
Parameters:
* '''$dateFrom''' String
* '''$dateTo''' String
* '''$eventId''' Integer
* '''$unitId''' Integer|Array
* '''$count''' Integer
Returns Object.
Returns not available time
Eg.: <code>{'2014-05-14': [{'reserved_time': [{'from': '14:00', 'to': '16:30'}], 'type': "reserved_time"}, ...], ...}</code>
----
=== getStartTimeMatrix ===
<code>getStartTimeMatrix($from, $to, $eventId, $unitId, $count)</code>
Parameters:
* '''$from''' String
* '''$to''' String
* '''$eventId''' Integer
* '''$unitId''' Mixed can be Integer or Array of Integers
* '''$count''' Integer
Returns Object.
Returns available start time, taking into account breaktimes, start and end working time
Eg.: <code>{'2014-05-14': ['09:00:00', ...], ...}</code>
If locations plugin activated for company you should pass a list as $unitID parameter for filter results with
units available only for selected location. See [[Plugins#Unit_location|Unit location]] plugin description for
more details.
----
=== getTimeframe ===
<code>getTimeframe()</code>
No arguments.
Returns Integer.
Returns company's timeframe configuration (in minutes). Timeframe can be either 5, 10, 15, 20, 30 or 60 minutes.You can find more details about timeframe [[Settings#Timeframe|here]].
----
=== getTimelineType ===
<code>getTimelineType()</code>
No arguments.
Returns String.
Returns company timeline type




Line 425: Line 797:
Returns Array.
Returns Array.


{@inheritdoc}
Returns list of service performers. If <code>$asArray</code> is false then method returns a map with event id as
key and details object as value. If parameter set to true then method returns a list sorted by 'position' property
of event's details object.




Line 439: Line 813:
Returns user license text if user license plugin is turned on,
Returns user license text if user license plugin is turned on,
otherwise throws exception
otherwise throws exception
----
=== getWorkCalendar ===
<code>getWorkCalendar($year, $month, $unitId)</code>
Parameters:
* '''$year''' Integer
* '''$month''' Integer
* '''$unitId''' Integer
Returns Object.
Returns company work schedule as array
Eg.: <code>{'2014-05-01': {'from': '09:00:00', 'to': '21:00:00', 'is_day_off': '0'}, '2014-05-02': ...}</code>
----
=== getWorkDaysInfo ===
<code>getWorkDaysInfo($from, $to, $unitId, $eventId, $count)</code>
Parameters:
* '''$from''' String
* '''$to''' String
* '''$unitId''' Integer (optional)
* '''$eventId''' Integer (optional)
* '''$count''' Integer (optional)
Returns Object.
Returns an information about working hours and break times for specified service and performer for a period
between two dates. If only service specified then information about performer (or performers) will be taken from
service configuration. Method returns a list of objects for each date in specified period. Count of objects in
list depends on break times. For example if performer works from 9:00 till 19:00 with one hour break at 13:00 method
returns:
<pre>
  {'2014-05-14' : [
    {'from': '09:00:00', 'to': '13:00:00'},
    {'from': '14:00:00', 'to': '19:00:00'}
  ] }
</pre>
Warning! Method can return a time string '24:00:00' as right edge of time range. This happens in case if time
range finishes on midnight.




Line 467: Line 892:
Return true if event payments plugin is turned on and prices were set,
Return true if event payments plugin is turned on and prices were set,
else return false.
else return false.
----
=== isPluginActivated ===
<code>isPluginActivated($pluginName)</code>
Parameters:
* '''$pluginName''' String
Returns Boolean.
Return plugin status true if status active, else false. <var>$pluginName</var> parameter is a plugin identifier.See [[Plugins|plugins]] page for full plugins description. See [[#Plugin's identifiers|list of available plugin's names]].




Line 589: Line 1,029:
** flexible_week
** flexible_week
** modern_week
** modern_week
** classes
** classic
** classic
*: Please note that <code>classic</code> timeline type is deprecated and not supported anymore.
*: Please note that <code>classic</code> timeline type is deprecated and not supported anymore.