Difference between revisions of "Company administration service methods"
Line 50: | Line 50: | ||
} | } | ||
</pre> | </pre> | ||
− | |||
Example of request with error response: | Example of request with error response: | ||
Line 84: | Line 83: | ||
===Authentication=== | ===Authentication=== | ||
− | Using Simplybook API methods require an authentification. To authorize in Simplybook API you need to get an access key — access-token. In order to get this access-token you should call the JSON-RPC method <code>[[Authentication#getUserToken|getUserToken]]</code> API method on https://user-api.simplybook.me/login service passing your personal API-key. You can copy your API-key at admin interface: go to the 'Plugins' link and select [[Plugins#API|API plugin]] 'Settings'. | + | Using Simplybook API methods require an authentification. To authorize in Simplybook API you need to get an access key — access-token. In order to get this access-token you should call the JSON-RPC method <code>[[Authentication#getUserToken|getUserToken]]</code> API method on https://user-api.simplybook.me/login service passing your personal API-key. You can copy your API-key at admin interface: go to the 'Plugins' link and select [[Plugins#API|API plugin]] 'Settings'. |
== Methods == | == Methods == | ||
Line 100: | Line 99: | ||
Adds new client with specified data. You can specify name, email, phone, address1, address2, city, zip, | Adds new client with specified data. You can specify name, email, phone, address1, address2, city, zip, | ||
country_id. If client record with specified data exists method will return an id of this record. Otherwise data | country_id. If client record with specified data exists method will return an id of this record. Otherwise data | ||
− | will be stored to database and method will return an id of newly created record. NOTE: name is mandatory field.Also email, phone number or both of them can be mandatory fields. You should call | + | will be stored to database and method will return an id of newly created record. NOTE: name is mandatory field. |
+ | |||
+ | Also email, phone number or both of them can be mandatory fields. You should call | ||
<code>getCompanyParam('require_fields')</code> method to check which fields are required. | <code>getCompanyParam('require_fields')</code> method to check which fields are required. | ||
Line 177: | Line 178: | ||
specify either <code>count</code> more then 1 or valid <code>batchId</code> (only one parameter can be | specify either <code>count</code> more then 1 or valid <code>batchId</code> (only one parameter can be | ||
specified). You should specify an <code>$additionalFields</code> parameter if service requires some additional | specified). You should specify an <code>$additionalFields</code> parameter if service requires some additional | ||
− | fields (see [[Plugins#Additional fields|Additional fields plugin]]). To create a booking with promo code you | + | fields (see [[Plugins#Additional fields|Additional fields plugin]]).To create a booking with promo code you should pass it as additional field. For example: <code>{"promocode": "some code"}</code> |
− | should pass it as additional field. For example: <code>{ | + | |
+ | If [[Plugins#Unit location|Unit location]] enabled you need to pass locations ID parameter as additional field | ||
+ | <code>location_id</code>. For example: <code>{"location_id": "1"}</code>. Use <code>[[#isPluginActivated|isPluginActivated('location')]]</code> | ||
+ | to check if plugin active and <code>[[#getLocationsList|getLocationsList()]]</code> method to get list of | ||
+ | available locations. | ||
+ | |||
+ | See [[#book response|example]] of <code>book</code> API method response. | ||
See also: | See also: | ||
* [http://wiki.simplybook.me/index.php/Settings#Timeframe Timeframe information] | * [http://wiki.simplybook.me/index.php/Settings#Timeframe Timeframe information] | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
---- | ---- | ||
Line 233: | Line 223: | ||
Cancels booking. Returns true on success. Returns an error with code -32080 (Appointment couldn't be found) if | Cancels booking. Returns true on success. Returns an error with code -32080 (Appointment couldn't be found) if | ||
no booking with specified id were found. | no booking with specified id were found. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
Line 306: | Line 283: | ||
---- | ---- | ||
− | === | + | === getBookingCancellationsInfo === |
− | <code> | + | <code>getBookingCancellationsInfo($dateStart, $dateEnd)</code> |
Parameters: | Parameters: | ||
− | * '''$ | + | * '''$dateStart''' String a date string in format 'Y-m-d'. Pass null to get data from first day of current week. |
+ | * '''$dateEnd''' String a date string in format 'Y-m-d'. Pass null to get data filtered to last day of current week. | ||
Returns Array. | Returns Array. | ||
− | + | Returns statistics about created bookings and cancellations for a time period. Data presented as array of hashes for | |
− | + | each type of operation (created or cancelled booking) groped by clients. <code>"type"</code> field can be either | |
− | + | "create", "cancel" or "nopayment_cancel". If <code>"user_id"</code> not specified then bookings where created or | |
+ | cancelled by admin or employee. Data with type <code>"nopayment_cancel"</code> represents bookings cancelled | ||
+ | automatically by system. | ||
+ | |||
+ | Example: | ||
+ | 3 bookings where created by admin or employee and 2 bookings where automatically cancelled by system. | ||
+ | [{ | ||
+ | "cnt" : 3, | ||
+ | "firstname" : null, | ||
+ | "lastname" : null, | ||
+ | "login" : null, | ||
+ | "type" : "create", | ||
+ | "user_id"" : null | ||
+ | }, { | ||
+ | "cnt" : 2, | ||
+ | "firstname" : null, | ||
+ | "lastname" : null, | ||
+ | "login" : null, | ||
+ | "type" : "nopayment_cancel", | ||
+ | "user_id"" : null | ||
+ | }] | ||
---- | ---- | ||
− | === | + | === getBookingComment === |
+ | |||
+ | <code>getBookingComment($id)</code> | ||
− | + | Parameters: | |
− | + | * '''$id''' Integer | |
− | Returns | + | |
+ | Returns String. | ||
− | Returns | + | Returns booking comment |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
---- | ---- | ||
− | === | + | === getBookingDetails === |
− | <code> | + | <code>getBookingDetails($id)</code> |
Parameters: | Parameters: | ||
− | * '''$ | + | * '''$id''' integer booking id |
− | |||
− | |||
Returns Array. | Returns Array. | ||
− | Returns | + | Returns detailed bookings object by booking id. See [[#getBookingDetails_response|response example]]. |
---- | ---- | ||
− | === | + | === getBookingLimitUnavailableTimeInterval === |
− | <code> | + | <code>getBookingLimitUnavailableTimeInterval($startDateTime, $endDateTime, $eventId)</code> |
Parameters: | Parameters: | ||
− | * '''$ | + | * '''$startDateTime''' string a date and time string in format 'Y-m-d H:i:s' |
− | * '''$ | + | * '''$endDateTime''' string a date and time string in format 'Y-m-d H:i:s' |
+ | * '''$eventId''' integer | ||
Returns Array. | Returns Array. | ||
− | Returns | + | Returns time intervals not available for bookings because of configuration of [[Plugins#Limit bookings|Limit bookings]] |
− | + | plugin for period of time. Returns empty array if plugin not available. | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
---- | ---- | ||
− | === | + | === getBookingRevenue === |
− | <code> | + | <code>getBookingRevenue($dateStart, $dateEnd, $unitGroupId, $serviceId)</code> |
Parameters: | Parameters: | ||
− | * '''$ | + | * '''$dateStart''' string a date string in format 'Y-m-d'. |
+ | * '''$dateEnd''' string a date string in format 'Y-m-d' | ||
+ | * '''$unitGroupId''' integer | ||
+ | * '''$serviceId''' integer | ||
+ | |||
+ | Returns Array. | ||
− | + | Return bookings count and revenue value for each date in specified period. Data grouped by unit id and | |
+ | represented as array with bookings count at index 0 and revenue amount at index 1. You can filter data either | ||
+ | by unit or by service. Set <code>$dateStart</code> and <code>$dateEnd</code> to null to get data for current week. | ||
− | + | Example: | |
+ | ['2015-11-12' : { | ||
+ | 3 : [ | ||
+ | 11, // bookings count | ||
+ | 128.53 // revenue | ||
+ | ]} | ||
---- | ---- | ||
− | === | + | === getBookingStats === |
− | <code> | + | <code>getBookingStats($groupBy)</code> |
Parameters: | Parameters: | ||
− | * '''$ | + | * '''$groupBy''' String either 'day', 'week' or 'month' |
Returns Array. | Returns Array. | ||
− | Returns | + | Returns statistic about bookings count grouped by 'day', 'week' or 'month'. A time period depends on selected |
+ | grouping parameter: | ||
+ | |||
+ | * for 'day' methods returns statistics for last 31 days | ||
+ | * for 'week' methods returns data last 10 weeks period | ||
+ | * for 'month' time period is last 12 months | ||
---- | ---- | ||
− | === | + | === getBookings === |
− | <code> | + | <code>getBookings($params)</code> |
Parameters: | Parameters: | ||
− | * '''$ | + | * '''$params''' |
− | |||
− | |||
Returns Array. | Returns Array. | ||
− | Returns | + | Returns list of bookings filtered by given params. Filter params represented as object with following fields: |
− | |||
+ | * '''date_from''' a date of booking in string format 'Y-m-d' | ||
+ | * '''time_from''' a time string in format 'H:i:s' | ||
+ | * '''date_to''' a date string in format 'Y-m-d' | ||
+ | * '''time_to''' a time string in format 'H:i:s' | ||
+ | * '''created_date_from''' a date string in format 'Y-m-d' | ||
+ | * '''created_date_to''' a date string in format 'Y-m-d' | ||
+ | * '''unit_group_id''' an integer. Use it to get bookings assigned for certain service provider. | ||
+ | * '''event_id''' an integer. Use it to get bookings only for certain service. | ||
+ | * '''is_confirmed''' 1 or 0. If [[Plugins#Approve booking|Approve booking]] plugin enabled then method will return confirmed bookings with approve status 'new'. | ||
+ | * '''client_id''' an integer. Use it to get bookings only for certain client. | ||
+ | * '''order''' string either 'record_date', 'date_start' or 'date_start_asc'. By default used 'date_start' value. | ||
+ | * '''booking_type''' a string. Value of this field depends on Approve booking plugin status. | ||
+ | *: If plugin not active: | ||
+ | ** '''all''' for all bookings (default value) | ||
+ | ** '''cancelled''' alias to 'is_confirmed' equal to 0 | ||
+ | ** '''non_cancelled''' alias to 'is_confirmed' equal to 1 | ||
+ | *: If plugin active: | ||
+ | ** '''all''' for all bookings (default value) | ||
+ | ** '''cancelled''' returns bookings with 'is_confirmed' field equals to 0 and approve booking status equals to 'cancelled' (or booking does not have any approve status) | ||
+ | ** '''non_cancelled''' returns bookings with either 'is_confirmed' field equals to 1 or approve booking status equals to 'new' | ||
+ | ** '''cancelled_by_client''' returns bookings approved by admin but cancelled by client | ||
+ | ** '''cancelled_by_admin''' returns bookings cancelled by admin | ||
+ | ** '''non_approved_yet''' returns bookings with approve status 'new' | ||
+ | ** '''approved''' returns bookings with either 'is_confirmed' field equals to 1 and approve booking status equals to 'approved' (or booking does not have any approve status) | ||
− | ---- | + | Example: |
− | + | { | |
− | === | + | "date_from":"2015-12-29", |
− | + | "date_to":"2015-12-29", | |
− | <code> | + | "booking_type":"cancelled", |
− | + | "event_id":"5", | |
− | + | "order":"start_date" | |
− | + | } | |
− | + | ||
− | + | ||
− | + | ---- | |
− | + | ||
+ | === getBookingsZapier === | ||
+ | |||
+ | <code>getBookingsZapier()</code> | ||
+ | No arguments. | ||
Returns Array. | Returns Array. | ||
− | + | Returns list of bookings filtered by given params | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
---- | ---- | ||
− | === | + | === getClient === |
− | <code> | + | <code>getClient($clientId)</code> |
Parameters: | Parameters: | ||
− | * '''$ | + | * '''$clientId''' |
Returns Array. | Returns Array. | ||
− | Returns | + | Returns client's data object. See <code>[[#addClient|addClient]]</code> API method for list of available fields |
− | + | of client data object. | |
− | |||
− | |||
− | |||
− | |||
---- | ---- | ||
− | === | + | === getClientComments === |
− | <code> | + | <code>getClientComments($clientId, $shedulerId)</code> |
Parameters: | Parameters: | ||
− | * '''$ | + | * '''$clientId''' Integer |
+ | * '''$shedulerId''' Integer | ||
Returns Array. | Returns Array. | ||
− | Returns list of | + | Returns list of all comments for given client |
+ | |||
+ | |||
+ | ---- | ||
− | + | === getClientList === | |
− | + | ||
− | + | <code>getClientList($searchString, $limit)</code> | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | Parameters: | |
− | + | ||
− | + | * '''$searchString''' String | |
− | + | * '''$limit''' Integer | |
− | + | ||
− | + | Returns Array. | |
− | + | ||
− | + | Returns list of clients associated with company. You can use either phone number, email address or name as value | |
+ | for <code>$searchString</code>. Pass an empty string for <code>$searchString</code> and null for <code>$limit</code> | ||
+ | parameters to get all records. See <code>[[#addClient|addClient]]</code> API method for list of available fields | ||
+ | of client data object. | ||
---- | ---- | ||
− | === | + | === getCompanyCurrency === |
− | <code> | + | <code>getCompanyCurrency()</code> |
No arguments. | No arguments. | ||
− | Returns | + | Returns String. |
− | Returns | + | Returns company's currency as three chars code (ISO 4217). |
---- | ---- | ||
− | === | + | === getCountryList === |
− | <code> | + | <code>getCountryList()</code> |
− | |||
− | |||
− | |||
− | |||
+ | No arguments. | ||
Returns Array. | Returns Array. | ||
− | + | Get list of all countries | |
− | |||
− | |||
---- | ---- | ||
− | === | + | === getCurrentTariffInfo === |
− | <code> | + | <code>getCurrentTariffInfo()</code> |
− | + | No arguments. | |
− | + | Returns Array. | |
− | |||
− | Returns | + | Returns all information about current tariff (subscription). For example: |
− | + | { | |
− | + | "name" : "gold", | |
+ | "expire_date" : "2016-02-11 12:32:00", | ||
+ | "rest" : 41, // number of days until subscription expiration | ||
+ | "color" : "#fcb322" | ||
+ | } | ||
---- | ---- | ||
− | === | + | === getCurrentUserDetails === |
− | <code> | + | <code>getCurrentUserDetails()</code> |
− | |||
− | |||
− | |||
− | |||
− | |||
+ | No arguments. | ||
Returns Array. | Returns Array. | ||
− | Returns | + | Returns current logged user info |
---- | ---- | ||
− | === | + | === getFeedbacks === |
− | <code> | + | <code>getFeedbacks($approvedOnly, $reviewsOnly, $lastOnly, $limit)</code> |
Parameters: | Parameters: | ||
− | * '''$ | + | * '''$approvedOnly''' Boolean |
+ | * '''$reviewsOnly''' Boolean | ||
+ | * '''$lastOnly''' Boolean | ||
* '''$limit''' Integer | * '''$limit''' Integer | ||
Returns Array. | Returns Array. | ||
− | + | Get list of feedbacks | |
− | |||
− | |||
− | |||
---- | ---- | ||
− | === | + | === getGoogleCalendarBusyTime === |
− | <code> | + | <code>getGoogleCalendarBusyTime($startDateTime, $endDateTime, $unitId)</code> |
− | + | Parameters: | |
− | Returns | + | |
+ | * '''$startDateTime''' string a date and time string in format 'Y-m-d H:i:s' | ||
+ | * '''$endDateTime''' string a date and time string in format 'Y-m-d H:i:s'. You can date string avoiding time in | ||
+ | this parameter. In this case method will use time value '23:59:59'. | ||
+ | * '''$unitId''' integer | ||
+ | |||
+ | Returns Array. | ||
+ | |||
+ | Returns a list of objects represented a time intervals marked as busy in Google Calendar. Each object of result | ||
+ | contains <code>from</code> and <code>to</code> properties with datetime string as value. This method only actual if | ||
+ | [Plugins#Google calendar sync plugin|Google calendar sync plugin] enabled. If plugin not enabled an empty list will | ||
+ | be returned. You should call <code>[[#isPluginActivated|isPluginActivated('google_calendar_export')]]</code> to | ||
+ | check status of the plugin. Each object of result contains <code>from</code> and <code>to</code> properties with | ||
+ | datetime string as value. Please note that this method may return not actual data because data synchronization | ||
+ | between server and Google Calendar may take some time and synchronized data are cached for 15 minutes. | ||
− | + | Example: | |
+ | [ | ||
+ | {"from" : "2016-02-16 13:30:00", | ||
+ | "to" : "2016-02-16 16:00:00"}, | ||
+ | ... | ||
+ | ] | ||
---- | ---- | ||
− | === | + | === getGoogleCalendarBusyTimeAvailableUnits === |
− | <code> | + | <code>getGoogleCalendarBusyTimeAvailableUnits()</code> |
No arguments. | No arguments. | ||
− | Returns | + | Returns Array. |
− | Returns | + | Returns configured unit ids, allowed to sync busy time |
---- | ---- | ||
− | === | + | === getLastNotificationUpdate === |
− | <code> | + | <code>getLastNotificationUpdate($type)</code> |
Parameters: | Parameters: | ||
− | * '''$ | + | * '''$type''' String |
− | Returns | + | Returns String. |
− | Returns | + | Returns last update datetime |
− | |||
− | |||
---- | ---- | ||
− | === | + | === getPluginList === |
− | <code> | + | <code>getPluginList()</code> |
No arguments. | No arguments. | ||
Returns Array. | Returns Array. | ||
− | + | Returns a list of all plugins associated with company with status. | |
---- | ---- | ||
− | === | + | === getRecentActions === |
− | <code> | + | <code>getRecentActions($lastOnly, $limit)</code> |
+ | |||
+ | Parameters: | ||
+ | |||
+ | * '''$lastOnly''' Boolean | ||
+ | * '''$limit''' Integer | ||
− | |||
Returns Array. | Returns Array. | ||
− | Returns | + | Returns latest actions |
---- | ---- | ||
− | === | + | === getRecurringDatetimes === |
+ | |||
+ | <code>getRecurringDatetimes($eventId, $unitId, $date, $time, $recurringData, $endDateTime)</code> | ||
+ | |||
+ | Parameters: | ||
− | + | * '''$eventId''' Integer | |
+ | * '''$unitId''' Integer | ||
+ | * '''$date''' String | ||
+ | * '''$time''' String | ||
+ | * '''$recurringData''' Array | ||
+ | * '''$endDateTime''' String (optional) | ||
− | |||
Returns Array. | Returns Array. | ||
− | + | Get list of dates for recurring booking | |
− | |||
− | |||
− | |||
− | |||
− | |||
---- | ---- | ||
− | === | + | === getRecurringSettings === |
+ | |||
+ | <code>getRecurringSettings($eventId)</code> | ||
+ | |||
+ | Parameters: | ||
− | + | * '''$eventId''' Integer | |
− | |||
Returns Array. | Returns Array. | ||
− | Returns | + | Returns an object with recurring settings for an event. Returns false if specified event does not configured as |
+ | recurring. | ||
+ | |||
+ | See also: | ||
+ | * [http://blog.simplybook.me/recurring-and-periodic-bookings/ Recurring services desription] | ||
---- | ---- | ||
− | === | + | === getRegistrations === |
− | <code> | + | <code>getRegistrations($groupBy)</code> |
Parameters: | Parameters: | ||
− | * '''$ | + | * '''$groupBy''' String either 'day', 'week' or 'month' |
− | |||
Returns Array. | Returns Array. | ||
− | Returns | + | Returns number of clients registrations by 'day', 'week' or 'month'. A time period depends on selected |
− | + | grouping parameter: | |
− | + | ||
+ | * for 'day' methods returns statistics for last 31 days | ||
+ | * for 'week' methods returns data last 10 weeks period | ||
+ | * for 'month' time period is last 12 months | ||
---- | ---- | ||
− | === | + | === getSocialCounterStats === |
− | <code> | + | <code>getSocialCounterStats($provider)</code> |
Parameters: | Parameters: | ||
− | * '''$ | + | * '''$provider''' String |
− | |||
− | |||
− | |||
− | Returns | + | Returns Integer. |
− | + | Returns social counters value for your domain | |
---- | ---- | ||
− | === | + | === getStatuses === |
− | <code> | + | <code>getStatuses()</code> |
− | + | No arguments. | |
+ | Returns Array. | ||
− | + | Returns list of available statuses or an empty list if [[Plugins#Status|Status plugin]] not enabled. | |
− | |||
− | + | ---- | |
+ | === getTopPerformers === | ||
− | + | <code>getTopPerformers()</code> | |
− | + | No arguments. | |
+ | Returns Array. | ||
− | + | Returns a list with statistics for performers. This data contains number of bookings and revenues value for each performer. | |
− | |||
− | + | ---- | |
− | |||
− | |||
− | + | === getTopServices === | |
− | + | <code>getTopServices($dateStart, $dateEnd)</code> | |
+ | Parameters: | ||
− | + | * '''$dateStart''' String | |
+ | * '''$dateEnd''' String | ||
− | |||
− | |||
− | |||
− | |||
− | |||
Returns Array. | Returns Array. | ||
− | Returns | + | Returns a list with statistics for services for a period of time. This data contains number of bookings and |
+ | revenues value for each service. | ||
---- | ---- | ||
− | === | + | === getUnitWorkdayInfo === |
− | <code> | + | <code>getUnitWorkdayInfo($dateStart, $dateEnd, $unitGroupId)</code> |
Parameters: | Parameters: | ||
− | * '''$ | + | * '''$dateStart''' string |
+ | * '''$dateEnd''' string | ||
+ | * '''$unitGroupId''' integer | ||
− | Returns | + | Returns Array. |
− | + | Return workday info (date_start and date_end) | |
---- | ---- | ||
− | === | + | === getUnitWorkingDurations === |
− | <code> | + | <code>getUnitWorkingDurations($dateStart, $dateEnd, $unitGroupId)</code> |
Parameters: | Parameters: | ||
− | * '''$ | + | * '''$dateStart''' string |
+ | * '''$dateEnd''' string | ||
+ | * '''$unitGroupId''' integer | ||
Returns Array. | Returns Array. | ||
− | + | Return working durations | |
− | |||
− | |||
---- | ---- | ||
− | === | + | === getVisitorStats === |
− | <code> | + | <code>getVisitorStats($groupBy)</code> |
− | + | Parameters: | |
− | |||
− | Returns | + | * '''$groupBy''' String |
+ | |||
+ | Returns Array. | ||
+ | |||
+ | Returns statistics about page visits if plugin [[Plugins#Visitor Counter|Visitor Counter plugin]] enabled. Returns | ||
+ | an empty list if plugin not enabled. Use <code>[[#isPluginActivated|isPluginActivated('counter')]]</code> API method | ||
+ | call to check if plugin enabled. Results can be grouped by 'day', 'week' or 'month'. A time period depends on | ||
+ | selected grouping parameter: | ||
+ | |||
+ | * for 'day' methods returns statistics for last 31 days | ||
+ | * for 'week' methods returns data last 10 weeks period | ||
+ | * for 'month' time period is last 12 months | ||
---- | ---- | ||
− | === | + | === getWarnings === |
− | <code> | + | <code>getWarnings($lastOnly)</code> |
Parameters: | Parameters: | ||
− | * '''$ | + | * '''$lastOnly''' |
Returns Array. | Returns Array. | ||
− | Returns | + | Returns warnings for admin |
− | + | (sms limit, bookings limit, etc) | |
− | |||
− | |||
− | |||
− | |||
---- | ---- | ||
− | === | + | === getWorkDaysTimes === |
− | <code> | + | <code>getWorkDaysTimes($startDateTime, $endDateTime)</code> |
Parameters: | Parameters: | ||
− | * '''$ | + | * '''$startDateTime''' string |
+ | * '''$endDateTime''' string | ||
Returns Array. | Returns Array. | ||
− | Return plugin | + | Return busy time by unit id by GoogleCalendar plugin if enabled.If cache is not expired will return from cache, else load from google and save to cache |
---- | ---- | ||
− | === | + | === getWorkload === |
− | <code> | + | <code>getWorkload($dateStart, $dateEnd, $unitGroupId)</code> |
Parameters: | Parameters: | ||
− | * '''$ | + | * '''$dateStart''' string |
− | * '''$ | + | * '''$dateEnd''' string |
+ | * '''$unitGroupId''' integer | ||
Returns Array. | Returns Array. | ||
− | + | Return workload data for units in period of time. Workload for each unit represented as array with work hours | |
+ | at index 0, confirmed booking hours as load at index 1 and cancelled bookings hours at index 2. | ||
− | + | Example: | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
['2015-10-21' : { | ['2015-10-21' : { | ||
5 : [ | 5 : [ | ||
Line 1,206: | Line 912: | ||
0 // cancelled bookings hours | 0 // cancelled bookings hours | ||
] }] | ] }] | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
Line 1,345: | Line 1,036: | ||
* -32011 Params is not array | * -32011 Params is not array | ||
* -32012 Sheduler id not found | * -32012 Sheduler id not found | ||
+ | * -32015 Passed event id is not reccuren | ||
* -32020 Sorry, you have no permissions to perform this action | * -32020 Sorry, you have no permissions to perform this action | ||
* -32030 Invalid promotion code | * -32030 Invalid promotion code | ||
Line 1,394: | Line 1,086: | ||
* borgun_payment_gateway_id | * borgun_payment_gateway_id | ||
* borgun_secret_code | * borgun_secret_code | ||
− | |||
* client_batch_cancel_template | * client_batch_cancel_template | ||
* client_batch_cancel_template_email | * client_batch_cancel_template_email | ||
Line 1,778: | Line 1,469: | ||
* modern_week | * modern_week | ||
* classic | * classic | ||
+ | * classes | ||
− | <code> | + | Please note that <code>classic</code> timeline type is deprecated and not supported anymore. |
<code>description</code> field contains raw data of company's description which can include HTML tags. <code>description_text</code> field contains only text information without HTML tags. | <code>description</code> field contains raw data of company's description which can include HTML tags. <code>description_text</code> field contains only text information without HTML tags. | ||
+ | For information about <code> timeframe</code>, <code>timezone</code>, <code>allow_event_day_break</code> and <code>allow_event_breaktime_break</code> see [[#Company params|Company params section]]. | ||
---- | ---- | ||
Revision as of 14:22, 29 April 2016
General Information
SimplyBook.me API service build on JSON-RPC remote procedure call protocol. A remote method is invoked by sending a request to a remote service using HTTPS. All transfer types are single objects, serialized using JSON. A request is a call to a specific method provided by a remote system. It must contain three certain properties:
jsonrpc
- a version of JSON-RPC protocol. Always"2.0"
method
- A String with the name of the method to be invoked.params
- An Array of objects to be passed as parameters to the defined method.id
- A value of any type, which is used to match the response with the request that it is replying to.
The receiver of the request must reply with a valid response to all received requests. A response must contain the properties mentioned below.
result
- The data returned by the invoked method. If an error occurred while invoking the method, this value must be null.error
- A specified error code if there was an error invoking the method, otherwise null.id
- The id of the request it is responding to.
Example
Request { "jsonrpc": "2.0", "method": "getEventList", "params":[], "id":1 } Response { "result": { "1": { "id": "1", "name": "Часовая фотосесcия", "duration": "60", "hide_duration": "0", "description": "<p>Если Вы хотите попробовать себя в роли модели, но не определились с образом. <br /> 5-7 отретушированных и готовых к печати фотографий + отснятый материал на диске</p>", "picture": "a200edab10b669225e22d2b3803a38b5.jpg", "is_public": "1", "is_active": "1", "position": "0", "is_recurring": "0", "picture_path": "/uploads/mib/event__picture/small/a200edab10b669225e22d2b3803a38b5.jpg", "price": "300.0000", "currency": "UAH", "categories": ["1"] }, ... }, "id": "1", "jsonrpc": "2.0" }
Example of request with error response:
Request { "jsonrpc": "2.0", "method": "someNotExistingMethod", "params":[], "id":1 } Response { "jsonrpc": "2.0", "id":1, "error": { "code": -32601, "message": "Method not found" } }
All calls of public service methods should have additional HTTP header:
X-Token
an authentication token. See authentication section.
Endpoint
Use URL https://user-api.simplybook.me/admin
for all administration service API calls.
Authentication
Using Simplybook API methods require an authentification. To authorize in Simplybook API you need to get an access key — access-token. In order to get this access-token you should call the JSON-RPC method getUserToken
API method on https://user-api.simplybook.me/login service passing your personal API-key. You can copy your API-key at admin interface: go to the 'Plugins' link and select API plugin 'Settings'.
Methods
addClient
addClient($clientData)
Parameters:
- $clientData Object
Returns Integer.
Adds new client with specified data. You can specify name, email, phone, address1, address2, city, zip, country_id. If client record with specified data exists method will return an id of this record. Otherwise data will be stored to database and method will return an id of newly created record. NOTE: name is mandatory field.
Also email, phone number or both of them can be mandatory fields. You should call
getCompanyParam('require_fields')
method to check which fields are required.
Method returns an error:
- -32061 Client name value is wrong
- -32062 Client email value is wrong
- -32063 Client phone value is wrong
Example:
{ name: "Frances T. Perez", phone: "+1502-810-4521", email: "FrancesTPerez@teleworm.us", address1: "3872 Earnhardt Drive", address2: "Louisville, KY 40219", city: Louisville, zip: 3872 }
addDeviceToken
addDeviceToken($token, $device)
Parameters:
- $token String a device token string
- $device String a device type ('android' or 'apple')
Returns boolean.
Subscribe a mobile device to push notifications about new bookings or changes in already created bookings. Use
'apple'
or 'android'
for device
parameter.
book
book($eventId, $unitId, $clientId, $startDate, $startTime, $endDate, $endTime, $clientTimeOffset, $additional, $count, $batchId, $recurringData)
Parameters:
- $eventId Integer
- $unitId Integer
- $clientId Integer
- $startDate string a date string in format 'Y-m-d'
- $startTime string a time string in format 'H:i:s'
- $endDate string a date string in format 'Y-m-d'
- $endTime string a time string in format 'H:i:s'
- $clientTimeOffset Integer
- $additional array|Object - additional params and fields.
- $count Integer bookings count used to make group bookings batch. This parameter can't be less than 1. (optional)
- $batchId Integer add booking to group bookings batch. You can't use $count and $batchId in one call. Please specify only one parameter. (optional)
- $recurringData Array - make booking recurrent. (optional)
Returns Object.
Creates new booking record. Returns an object with appointment information or throw exception if booking time not
available or any of required parameters missed. If appointment requires confirmation, in result object will be
require_confirm = true
. $startDate
and $startTime
specifies a date of
booking and time slot. Time value should be multiple to 'timeframe' configuration of company (see
getTimeframe
API method). $endDate
and $endTime
parameters
should be calculated according to service duration. However you can specify different values to make appointment
longer or shorter then service configuration. Note that $endDate
and $endTime
should be
later in time than $startDate
and $startTime
. If your clients located in different time
zone you should specify $clientTimeOffset
parameter as difference between company's time zone and
client's time zone in seconds. For example if company located in city with time zone GMT+2 and customer located
in city with GMT+3 then $clientTimeOffset
will be -3600 seconds. You can get information about company's
time zone using getCompanyInfo
API method. To create batch booking you can
specify either count
more then 1 or valid batchId
(only one parameter can be
specified). You should specify an $additionalFields
parameter if service requires some additional
fields (see Additional fields plugin).To create a booking with promo code you should pass it as additional field. For example: {"promocode": "some code"}
If Unit location enabled you need to pass locations ID parameter as additional field
location_id
. For example: {"location_id": "1"}
. Use isPluginActivated('location')
to check if plugin active and getLocationsList()
method to get list of
available locations.
See example of book
API method response.
See also:
cancelBatch
cancelBatch($id, $bookingIds)
Parameters:
- $id Integer identifier of batch. See
createBatch
API method. - $bookingIds Array ids of bookings included to batch.
Returns boolean.
Cancel batch of bookings. Returns true on success. Returns an error with code -32080 (Appointment couldn't be found)
if no booking with specified id were found. A booking with first id in $bookingIds
list is used for
information in notifications.
cancelBooking
cancelBooking($id)
Parameters:
- $id Integer
Returns Boolean.
Cancels booking. Returns true on success. Returns an error with code -32080 (Appointment couldn't be found) if no booking with specified id were found.
deleteDeviceToken
deleteDeviceToken($token)
Parameters:
- $token String - device token
Returns boolean.
Unsubscribe to push notifications gloabl or company
editBook
editBook($shedulerId, $eventId, $unitId, $clientId, $startDate, $startTime, $endDate, $endTime, $clientTimeOffset, $additional)
Parameters:
- $shedulerId Integer an id of booking to edit. See
book
orgetBookings
API methods. - $eventId Integer
- $unitId Integer
- $clientId Integer
- $startDate String - in Y-m-d format
- $startTime String - in H:i:s format
- $endDate String - in Y-m-d format
- $endTime String - in H:i:s format
- $clientTimeOffset Integer
- $additional array|Object - additional params and fields.
Returns Object.
Edit existing booking record. See book API method description for more details about date/time parameters, time zone handling and additional fields. Returns null if parameters not valid.
editClient
editClient($clientId, $clientData)
Parameters:
- $clientId Integer
- $clientData Object
Returns Integer.
Edits client's record. See addClient
method description for list of available fields.Method returns an id of client's record.
getBookingCancellationsInfo
getBookingCancellationsInfo($dateStart, $dateEnd)
Parameters:
- $dateStart String a date string in format 'Y-m-d'. Pass null to get data from first day of current week.
- $dateEnd String a date string in format 'Y-m-d'. Pass null to get data filtered to last day of current week.
Returns Array.
Returns statistics about created bookings and cancellations for a time period. Data presented as array of hashes for
each type of operation (created or cancelled booking) groped by clients. "type"
field can be either
"create", "cancel" or "nopayment_cancel". If "user_id"
not specified then bookings where created or
cancelled by admin or employee. Data with type "nopayment_cancel"
represents bookings cancelled
automatically by system.
Example:
3 bookings where created by admin or employee and 2 bookings where automatically cancelled by system. [{ "cnt" : 3, "firstname" : null, "lastname" : null, "login" : null, "type" : "create", "user_id"" : null }, { "cnt" : 2, "firstname" : null, "lastname" : null, "login" : null, "type" : "nopayment_cancel", "user_id"" : null }]
getBookingComment
getBookingComment($id)
Parameters:
- $id Integer
Returns String.
Returns booking comment
getBookingDetails
getBookingDetails($id)
Parameters:
- $id integer booking id
Returns Array.
Returns detailed bookings object by booking id. See response example.
getBookingLimitUnavailableTimeInterval($startDateTime, $endDateTime, $eventId)
Parameters:
- $startDateTime string a date and time string in format 'Y-m-d H:i:s'
- $endDateTime string a date and time string in format 'Y-m-d H:i:s'
- $eventId integer
Returns Array.
Returns time intervals not available for bookings because of configuration of Limit bookings plugin for period of time. Returns empty array if plugin not available.
getBookingRevenue
getBookingRevenue($dateStart, $dateEnd, $unitGroupId, $serviceId)
Parameters:
- $dateStart string a date string in format 'Y-m-d'.
- $dateEnd string a date string in format 'Y-m-d'
- $unitGroupId integer
- $serviceId integer
Returns Array.
Return bookings count and revenue value for each date in specified period. Data grouped by unit id and
represented as array with bookings count at index 0 and revenue amount at index 1. You can filter data either
by unit or by service. Set $dateStart
and $dateEnd
to null to get data for current week.
Example:
['2015-11-12' : { 3 : [ 11, // bookings count 128.53 // revenue ]}
getBookingStats
getBookingStats($groupBy)
Parameters:
- $groupBy String either 'day', 'week' or 'month'
Returns Array.
Returns statistic about bookings count grouped by 'day', 'week' or 'month'. A time period depends on selected grouping parameter:
- for 'day' methods returns statistics for last 31 days
- for 'week' methods returns data last 10 weeks period
- for 'month' time period is last 12 months
getBookings
getBookings($params)
Parameters:
- $params
Returns Array.
Returns list of bookings filtered by given params. Filter params represented as object with following fields:
- date_from a date of booking in string format 'Y-m-d'
- time_from a time string in format 'H:i:s'
- date_to a date string in format 'Y-m-d'
- time_to a time string in format 'H:i:s'
- created_date_from a date string in format 'Y-m-d'
- created_date_to a date string in format 'Y-m-d'
- unit_group_id an integer. Use it to get bookings assigned for certain service provider.
- event_id an integer. Use it to get bookings only for certain service.
- is_confirmed 1 or 0. If Approve booking plugin enabled then method will return confirmed bookings with approve status 'new'.
- client_id an integer. Use it to get bookings only for certain client.
- order string either 'record_date', 'date_start' or 'date_start_asc'. By default used 'date_start' value.
- booking_type a string. Value of this field depends on Approve booking plugin status.
- If plugin not active:
- all for all bookings (default value)
- cancelled alias to 'is_confirmed' equal to 0
- non_cancelled alias to 'is_confirmed' equal to 1
- If plugin active:
- all for all bookings (default value)
- cancelled returns bookings with 'is_confirmed' field equals to 0 and approve booking status equals to 'cancelled' (or booking does not have any approve status)
- non_cancelled returns bookings with either 'is_confirmed' field equals to 1 or approve booking status equals to 'new'
- cancelled_by_client returns bookings approved by admin but cancelled by client
- cancelled_by_admin returns bookings cancelled by admin
- non_approved_yet returns bookings with approve status 'new'
- approved returns bookings with either 'is_confirmed' field equals to 1 and approve booking status equals to 'approved' (or booking does not have any approve status)
Example:
{ "date_from":"2015-12-29", "date_to":"2015-12-29", "booking_type":"cancelled", "event_id":"5", "order":"start_date" }
getBookingsZapier
getBookingsZapier()
No arguments. Returns Array.
Returns list of bookings filtered by given params
getClient
getClient($clientId)
Parameters:
- $clientId
Returns Array.
Returns client's data object. See addClient
API method for list of available fields
of client data object.
getClientComments
getClientComments($clientId, $shedulerId)
Parameters:
- $clientId Integer
- $shedulerId Integer
Returns Array.
Returns list of all comments for given client
getClientList
getClientList($searchString, $limit)
Parameters:
- $searchString String
- $limit Integer
Returns Array.
Returns list of clients associated with company. You can use either phone number, email address or name as value
for $searchString
. Pass an empty string for $searchString
and null for $limit
parameters to get all records. See addClient
API method for list of available fields
of client data object.
getCompanyCurrency
getCompanyCurrency()
No arguments. Returns String.
Returns company's currency as three chars code (ISO 4217).
getCountryList
getCountryList()
No arguments. Returns Array.
Get list of all countries
getCurrentTariffInfo
getCurrentTariffInfo()
No arguments. Returns Array.
Returns all information about current tariff (subscription). For example:
{ "name" : "gold", "expire_date" : "2016-02-11 12:32:00", "rest" : 41, // number of days until subscription expiration "color" : "#fcb322" }
getCurrentUserDetails
getCurrentUserDetails()
No arguments. Returns Array.
Returns current logged user info
getFeedbacks
getFeedbacks($approvedOnly, $reviewsOnly, $lastOnly, $limit)
Parameters:
- $approvedOnly Boolean
- $reviewsOnly Boolean
- $lastOnly Boolean
- $limit Integer
Returns Array.
Get list of feedbacks
getGoogleCalendarBusyTime
getGoogleCalendarBusyTime($startDateTime, $endDateTime, $unitId)
Parameters:
- $startDateTime string a date and time string in format 'Y-m-d H:i:s'
- $endDateTime string a date and time string in format 'Y-m-d H:i:s'. You can date string avoiding time in
this parameter. In this case method will use time value '23:59:59'.
- $unitId integer
Returns Array.
Returns a list of objects represented a time intervals marked as busy in Google Calendar. Each object of result
contains from
and to
properties with datetime string as value. This method only actual if
[Plugins#Google calendar sync plugin|Google calendar sync plugin] enabled. If plugin not enabled an empty list will
be returned. You should call isPluginActivated('google_calendar_export')
to
check status of the plugin. Each object of result contains from
and to
properties with
datetime string as value. Please note that this method may return not actual data because data synchronization
between server and Google Calendar may take some time and synchronized data are cached for 15 minutes.
Example:
[ {"from" : "2016-02-16 13:30:00", "to" : "2016-02-16 16:00:00"}, ... ]
getGoogleCalendarBusyTimeAvailableUnits
getGoogleCalendarBusyTimeAvailableUnits()
No arguments. Returns Array.
Returns configured unit ids, allowed to sync busy time
getLastNotificationUpdate
getLastNotificationUpdate($type)
Parameters:
- $type String
Returns String.
Returns last update datetime
getPluginList
getPluginList()
No arguments. Returns Array.
Returns a list of all plugins associated with company with status.
getRecentActions
getRecentActions($lastOnly, $limit)
Parameters:
- $lastOnly Boolean
- $limit Integer
Returns Array.
Returns latest actions
getRecurringDatetimes
getRecurringDatetimes($eventId, $unitId, $date, $time, $recurringData, $endDateTime)
Parameters:
- $eventId Integer
- $unitId Integer
- $date String
- $time String
- $recurringData Array
- $endDateTime String (optional)
Returns Array.
Get list of dates for recurring booking
getRecurringSettings
getRecurringSettings($eventId)
Parameters:
- $eventId Integer
Returns Array.
Returns an object with recurring settings for an event. Returns false if specified event does not configured as recurring.
See also:
getRegistrations
getRegistrations($groupBy)
Parameters:
- $groupBy String either 'day', 'week' or 'month'
Returns Array.
Returns number of clients registrations by 'day', 'week' or 'month'. A time period depends on selected grouping parameter:
- for 'day' methods returns statistics for last 31 days
- for 'week' methods returns data last 10 weeks period
- for 'month' time period is last 12 months
getSocialCounterStats
getSocialCounterStats($provider)
Parameters:
- $provider String
Returns Integer.
Returns social counters value for your domain
getStatuses
getStatuses()
No arguments. Returns Array.
Returns list of available statuses or an empty list if Status plugin not enabled.
getTopPerformers
getTopPerformers()
No arguments. Returns Array.
Returns a list with statistics for performers. This data contains number of bookings and revenues value for each performer.
getTopServices
getTopServices($dateStart, $dateEnd)
Parameters:
- $dateStart String
- $dateEnd String
Returns Array.
Returns a list with statistics for services for a period of time. This data contains number of bookings and revenues value for each service.
getUnitWorkdayInfo
getUnitWorkdayInfo($dateStart, $dateEnd, $unitGroupId)
Parameters:
- $dateStart string
- $dateEnd string
- $unitGroupId integer
Returns Array.
Return workday info (date_start and date_end)
getUnitWorkingDurations
getUnitWorkingDurations($dateStart, $dateEnd, $unitGroupId)
Parameters:
- $dateStart string
- $dateEnd string
- $unitGroupId integer
Returns Array.
Return working durations
getVisitorStats
getVisitorStats($groupBy)
Parameters:
- $groupBy String
Returns Array.
Returns statistics about page visits if plugin Visitor Counter plugin enabled. Returns
an empty list if plugin not enabled. Use isPluginActivated('counter')
API method
call to check if plugin enabled. Results can be grouped by 'day', 'week' or 'month'. A time period depends on
selected grouping parameter:
- for 'day' methods returns statistics for last 31 days
- for 'week' methods returns data last 10 weeks period
- for 'month' time period is last 12 months
getWarnings
getWarnings($lastOnly)
Parameters:
- $lastOnly
Returns Array.
Returns warnings for admin (sms limit, bookings limit, etc)
getWorkDaysTimes
getWorkDaysTimes($startDateTime, $endDateTime)
Parameters:
- $startDateTime string
- $endDateTime string
Returns Array.
Return busy time by unit id by GoogleCalendar plugin if enabled.If cache is not expired will return from cache, else load from google and save to cache
getWorkload
getWorkload($dateStart, $dateEnd, $unitGroupId)
Parameters:
- $dateStart string
- $dateEnd string
- $unitGroupId integer
Returns Array.
Return workload data for units in period of time. Workload for each unit represented as array with work hours at index 0, confirmed booking hours as load at index 1 and cancelled bookings hours at index 2.
Example:
['2015-10-21' : { 5 : [ 10, // working hours 10, // load hours (confirmed bookings hours) 0 // cancelled bookings hours ] }]
pluginApproveBookingApprove
pluginApproveBookingApprove($id)
Parameters:
- $id Integer
Returns Array.
Sets approve booking status to 'approved' if Approve booking plugin enabled and returns
list of approved booking IDs. Returns false if plugin not enabled. Use isPluginActivated('approve_booking')
API method call to check if plugin enabled.
pluginApproveBookingCancel
pluginApproveBookingCancel($id)
Parameters:
- $id Integer
Returns Boolean.
Sets approve booking status to 'canceled' if Approve booking plugin enabled and returns
true. Returns false if plugin not enabled. Use isPluginActivated('approve_booking')
API method call to check if plugin enabled.
pluginApproveGetPendingBookings
pluginApproveGetPendingBookings()
No arguments. Returns array.
Returns list of objects with information about bookings pending approval if Approve booking
plugin enabled. Returns empty list if plugin not enabled. Use isPluginActivated('approve_booking')
API method call to check if plugin enabled.
pluginApproveGetPendingBookingsCount
pluginApproveGetPendingBookingsCount()
No arguments. Returns Integer.
Returns count of bookings pending approval if Approve booking plugin enabled. Returns
0 if plugin not enabled. Use isPluginActivated('approve_booking')
API method
call to check if plugin enabled.
setBookingComment
setBookingComment($id, $comment)
Parameters:
- $id Integer
- $comment String
Returns Integer.
Set booking comment
setStatus
setStatus($bookingId, $statusId)
Parameters:
- $bookingId Integer
- $statusId Integer
Returns Boolean.
Sets specified status for booking. Returns an error with code -32020 if logged in user don't have access to edit bookings. This method does nothing if Status plugin not enabled.
updateNotification
updateNotification($type)
Parameters:
- $type String
Returns .
Mark notifications as readed
Constants
Error codes
See Errors handling for details.
- -32001 Plugin is not activated
- -32010 Some required params are missed
- -32011 Params is not array
- -32012 Sheduler id not found
- -32015 Passed event id is not reccuren
- -32020 Sorry, you have no permissions to perform this action
- -32030 Invalid promotion code
- -32031 Promotion has expired
- -32032 Promotion is not active yet
- -32033 This promocode is not valid for selected service
- -32034 Exceed max usage limit
- -32035 Exceed max usage per customer limit'const
- -32036 This promocode is not available for datetime range
- -32051 Selected event id is not available
- -32052 Selected unit id is not available
- -32053 Selected date start is not available
- -32054 Selected time start is not available
- -32055 One or more appointments couldn't be reserved
- -32056 Booking is not allowed at this time
- -32061 Client name value is wrong
- -32062 Client email value is wrong
- -32063 Client phone value is wrong
- -32070 Additional field values are wrong
- -32080 Appointemnt couldn't be found
- -32085 Signature error
- -32090 Confirmation with this key type is not available
- -32095 Batch not found
- -32097 Unsupported payment system
- -32099 Payment failed
- -32600
- An error with this code can be thrown with one of the following messages:
- Access denied
- Company does not exists
- -32601 Method not found
- -32602 Invalid params
- -32603 Internal error
- -3264 Client with given id not found
Company params
Use these values to get configuration params for company with getCompanyParam
API method.
Administration API inherits all keys allowed for public API and extends this list with keys:
- attach_ical
- auto_redirect
- auto_redirect_text
- blockchain_address
- blockchain_secret
- borgun_merchant_id
- borgun_payment_gateway_id
- borgun_secret_code
- client_batch_cancel_template
- client_batch_cancel_template_email
- client_batch_cancel_template_email_subject
- client_event_cancel_template
- client_event_cancel_template_email
- client_event_cancel_template_email_subject
- client_event_change_template
- client_event_change_template_email
- client_event_change_template_email_subject
- client_event_creation_template
- client_event_creation_template_email
- client_event_creation_template_email_subject
- client_event_group_creation_template
- client_event_group_creation_template_email
- client_event_group_creation_template_email_subject
- client_event_multiple_creation_template
- client_event_multiple_creation_template_email
- client_event_multiple_creation_template_email_subject
- client_group_notification_template
- client_group_notification_template_email
- client_group_notification_template_email_subject
- client_multiple_notification_template
- client_multiple_notification_template_email
- client_multiple_notification_template_email_subject
- client_notification_template
- client_notification_template_email
- client_notification_template_email_subject
- client_notification_time
- client_recurring_event_creation_template
- client_recurring_event_creation_template_email
- client_recurring_event_creation_template_email_subject
- common_limit_booking
- company_currency
- company_ga_tracking_id
- default_phone
- disconnect_on_timeout
- dwolla_application_key
- dwolla_id
- dwolla_secret_key
- email_event_list
- email_events_list_template
- email_group_events_list_template
- event_list_style
- feed_back_interval
- feedback_invite_template_email
- feedback_invite_template_email_subject
- google_conversion_color
- google_conversion_currency
- google_conversion_format
- google_conversion_id
- google_conversion_label
- google_conversion_language
- google_conversion_value
- hide_working_hours_block
- include_cancel_link
- kortais_merchant
- kortais_secret_code
- kortais_terminal
- layout_background
- layout_background_repeat
- liqpay_merchant_id
- liqpay_merchant_pass
- mobile_site_link
- mobile_site_link_title
- no_show_period
- on_success_button_link
- on_success_button_text
- paypal_account
- recap_interval
- recap_send_after_time
- recap_send_canceled_bookings
- recap_send_new_bookings
- recap_send_upcomming_bookings
- send_cancel_to_client
- send_cancel_to_client_email
- send_cancel_to_unit
- send_cancel_to_unit_email
- send_contact_widget_email_notification
- send_contact_widget_sms_notification
- send_notify_to_client
- send_notify_to_client_email
- send_notify_to_unit
- send_notify_to_unit_email
- send_onchange_to_client
- send_onchange_to_client_email
- send_onchange_to_unit
- send_onchange_to_unit_email
- send_oncreate_to_client
- send_oncreate_to_client_email
- send_oncreate_to_unit
- send_oncreate_to_unit_email
- send_sms_if_push_enabled
- site_link
- site_link_title
- skip_limits_for_admin
- skip_show_mobile_app_ads
- skip_show_on_success_button
- skrill_account
- skrill_secret
- sms_event_list
- sms_events_list_template
- sms_group_events_list_template
- unit_batch_cancel_template
- unit_batch_cancel_template_email
- unit_batch_cancel_template_email_subject
- unit_event_cancel_template
- unit_event_cancel_template_email
- unit_event_cancel_template_email_subject
- unit_event_change_template
- unit_event_change_template_email
- unit_event_change_template_email_subject
- unit_event_creation_template
- unit_event_creation_template_email
- unit_event_creation_template_email_subject
- unit_event_group_creation_template
- unit_event_group_creation_template_email
- unit_event_group_creation_template_email_subject
- unit_group_notification_template
- unit_group_notification_template_email
- unit_group_notification_template_email_subject
- unit_notification_template
- unit_notification_template_email
- unit_notification_template_email_subject
- unit_notification_time
- unit_recurring_event_creation_template
- unit_recurring_event_creation_template_email
- unit_recurring_event_creation_template_email_subject
- use_common_client_db
- user_confirmation
- user_license_text
- user_public_layout
- user_public_theme
- waiting_video
- zooz_app_id
- zooz_app_key
Plugin's identifiers
Plugin identifier is a string constant which represents a plugin in system. These constants used in isPluginActivated
and getPluginStatuses
API methods.
- advanced_notification
- Book Soon notification system plugin
- any_unit
- Any Employee selector plugin
- api
- API plugin
- approve_booking
- Approve booking plugin
- back_to_site
- Take me back home plugin
- contact_widget
- Contact widget plugin
- counter
- Visitor Counter plugin
- custom_css
- Custom CSS plugin
- data_security
- Clean history plugin
- description
- HTML description field for events
- event_category
- Service categories plugin
- event_field
- Additional fields plugin
- facebookImage
- Facebook client info plugin
- financial_dashboard
- Insights plugin
- google_analytics
- Google Adwords and analytics plugin
- google_calendar_export
- Google calendar sync plugin
- group_booking
- Group bookings plugin
- hipaa
- HIPAA plugin
- limit_bookings
- Limit bookings plugin
- location
- Unit location plugin
- mobile_app_backend
- Mobile application plugin
- multiple_booking
- Multiple bookings plugin
- news
- News plugin
- paid_events
- Accept payments plugin
- promo
- Simply Smart Promotions plugin
- recap
- Daily report plugin
- secure
- SSL plugin
- status
- Status plugin
- unit_colors
- Providers color coding plugin
- user_license
- Terms and conditions plugin
See Plugins page for description for each plugin.
Examples
getBookingDetails response
An example of data returned by getBookingDetails API method.
{ "id": "321", "event_id": "5", "event_name": "Massage", "unit_id": "3", "unit_name": "John", "client_id": "1", "client_name": "Bob", "start_date_time": "2015-11-25 15:00:00", "end_date_time": "2015-11-25 16:00:00", "is_confirmed": "1", "code": "h8v8w5ls", "record_date": "2015-11-19 04:06:38", "comment": null, "company_login": "testzt", "company_name": "My Cool Company", "company_phone": "+1-555-55-55", "company_email": "into@mycoolcompany.com", "additional_fields": [{ "value": "on", "field_name": "201a89517de509f6b3a60858918faac3", "field_title": "Include washing", "field_position": "4", "field_type": "checkbox", "field_id": "4" }], "comments": [], "history": [{ "id": "536", "sheduler_id": "321", "datetime": "2015-11-19 11:06:38", "type": "create", "user_id": "1", "agent": "SimplyBook.me\/55 CFNetwork\/758.0.2 Darwin\/15.0.0", "ip": "213.174.0.53, 158.69.224.50:127.0.0.1", "referer": "", "login": "admin", "firstname": "Mikhail", "lastname": "" }], "status": { "id": "3", "name": "Fancy Status", "description": null, "color": "4cbadb", "is_default": "1" }, "location": { "id": "1", "title": "location", "description": null, "picture": "e1e9409fe9682c78b2f8f294dc151af0.jpg", "address1": null, "address2": "Saint Margaret Street", "city": "\u041b\u043e\u043d\u0434\u043e\u043d", "zip": null, "country_id": "GB", "lat": "51.50013000000000000000", "lng": "-0.12630500000000000000", "phone": "44", "position": "1", "is_default": "1" }, "price": [], "promo": false }
Location field is present in response only if Unit location plugin is enabled. Otherwise this field will be an empty array. If locations plugin is enabled but booking doesn't have any locations this fields also will be an empty array.
Status field is present in response only if Status plugin is enabled. Otherwise this field will be an empty array. If plugin enabled but booking doesn't have any statues specified the default status returned.
Price field is present in response only if Accept payments plugin is enabled. Otherwise this field will be an empty array. This field contains an empty array if plugin is enabled but booking was created for a free service.
Promo field is present in response only if Simply Smart Promotions plugin is enabled. Otherwise this field will be an empty array. This field contains false if plugin is enabled but booking was created without any promo codes.
additional_fields
field is present in response only if Additional fields plugin is enabled. Otherwise this field will be an empty array. This field contains an empty array if plugin is enabled but booking was created for a service with no additional fields.
book response
book
API method returns an object which contains list of objects with short description of newly create bookings. Method returns only one item in 'bookings' array for regular appointment and more than one item for recurring or batch bookings.
{ "require_confirm":false, "bookings":[ { "id":"434", "event_id":"7", "unit_id":"3", "client_id":"34", "start_date_time":"2015-12-30 13:00:00", "end_date_time":"2015-12-30 13:30:00", "is_confirmed":"1", "code":"h8vc14ca", "hash":"785cb8cce316e64765b94c05a635f4be" }, { "id":"435", "event_id":"7", "unit_id":"3", "client_id":"34", "start_date_time":"2015-12-31 13:00:00", "end_date_time":"2015-12-31 13:30:00", "is_confirmed":"1", "code":"h8vc2pge", "hash":"8b92d634541bfd93c0830967e56f4653" }, { "id":"436", "event_id":"7", "unit_id":"3", "client_id":"34", "start_date_time":"2016-01-04 13:00:00", "end_date_time":"2016-01-04 13:30:00", "is_confirmed":"1", "code":"h8vc3urb", "hash":"cd22a0bf183f7350e595988dd2486e5b" }, { "id":"437", "event_id":"7", "unit_id":"3", "client_id":"34", "start_date_time":"2016-01-05 13:00:00", "end_date_time":"2016-01-05 13:30:00", "is_confirmed":"1", "code":"h8vc44d9", "hash":"53f98ff4e4a0323aa907156c59c99362" } ], "batch_type":"batch_recurrent_booking", "recurrent_batch_id":"1", "batch_hash":"357178bce290381bb7235080941ec143" }
getCompanyInfo response
An example of data returned by getCompanyInfo API method.
{ "login": "pierrecoetzee", "name": "Pierre", "description": "Write a description about your company or about you as a service provider. You can add other service providers inside the system and each can have his own description.", "address1": "", "address2": "Storey's Gate, ", "city": "London", "country_id": "GB", "lat": "51.500435", "lng": "-0.129811", "email": "pierre.coe@gmail.com", "phone": "", "web": null, "skip_address": null, "logo": null, "address": "GB, London, Storey's Gate, ", "description_text": "Write a description about your company or about you as a service provider. You can add other service providers inside the system and each can have his own description.", "timezone": "Europe London", "show_in_client_timezone": false, "timeframe": "60", "timeline_type": "modern_week", "allow_event_day_break": "0", "allow_event_breaktime_break": "0" }
timeline_type
field can be one the following values:
- flexible
- modern
- flexible_week
- modern_week
- classic
- classes
Please note that classic
timeline type is deprecated and not supported anymore.
description
field contains raw data of company's description which can include HTML tags. description_text
field contains only text information without HTML tags.
For information about timeframe
, timezone
, allow_event_day_break
and allow_event_breaktime_break
see Company params section.
getPluginPromoInfoByCode response
{ "id": "1", "title": "[service\/services] with [discount]% discount!", "code": "yvuvugum", "description": "We are offering [service\/services] with an amazing [discount]% discount! We are running this deal for a limited time only.", "discount": "99.9999", "start_date": "2015-12-23", "expired_date": "2016-01-23", "sheduler_start_date": "2015-12-23", "sheduler_end_date": "2015-12-31", "sheduler_start_time": "09:00:00", "sheduler_end_time": "22:30:00", "allow_usage_count": "20", "fineprint_text": "Deal is limited for new clients only. Reward is claimable [client_claim_times_number] times per client. Deal is only claimable for the locations specified. Deal is cannot be combined with any other promotion. Must be redeemed prior to the expiration date shown on the deal.", "redemption_text": "Present your confirmation code when you want to redeem your deal. You may either to print off your confirmation email or show your confirmation code by loggin into Simplybook on your mobile phone\/Pc.\r\n[promocode]\r\n[discount]\r\n[reward]\r\n[referal_qty]", "headline": "[service\/services] with [discount]% discount!", "image": null, "allow_customer_count": "1", "show_in_catalogue": "1", "status": "active", "plugin_promo_message_id": "1", "common_promotion_id": "132", "service_ids": ["1"] }
service_ids
contains a list of services for wich promotion discount can be applied.