Capturing Partoo App events with callbacks¶
When integrating Partoo App view, you might want to get notified when some Partoo App event occurs. To achieve that, it is possible to define callbacks that will be triggered on specific Partoo app event.
Depending on the event, the callback can be blocking, meaning the default action in Partoo app will not be triggered, or non-blocking, meaning the callback will be called but the default action will occure.
Configuring a callback¶
To configure a callback, you need to use the on
, see on (eventId: string, callback: Function), function of the page
instance generated with Partoo.init
, see init (divId: string, options: Option Object).
- This function expects 2 parameters:
the eventId: the event for which we want to define a callback
the callback: a JS function that will be triggered when the event occurs. This function should expect an argument
data
. The content and type ofdata
change depending on the event.
For instance, the following code will log the data
of the subscribe
event.
const subscribeCallback = (data) => console.log(data);
partooPage.on(
'subscribe', // the subcribe event id
subscribeCallback, // the callback to be called on subscribe event
)
Available callback events¶
Subscribe business¶
This event happens when a user clicks on subscribe.
Event id: subscribe
.
Event data: a JS object with the following stucture
{
"productName": "presence_management", // or "review_management"
"businesses": [
{
"id": "5a2ab4edb12ff67cba1b7e1b",
"org_id": 709,
"name": "SCEP du Caire",
}
]
}
Open business¶
This event happens when a user click a link to open a business page.
Event id: open_business
.
Event data: the business id (a string). For instance: 5a2ab4edb12ff67cba1b7e1b
Business created¶
This event happens when the user has created a business, has clicked on save and the business has been saved in the Partoo DB.
Warning
This callback does not prevent redirection to the business edit page
Event id: business_created
.
Event data: the business id (a string). For instance: 5a2ab4edb12ff67cba1b7e1b
Business additional info updated¶
This event happens when then user has successfully updated the additionnal info of his/her business (in the additionnal info tab, he/she clicked on save).
Warning
This is a none blocking callback
Event id: business_additional_info_updated
.
Event data: a JS object
Business address updated¶
This event happens when then user has successfully updated the address of his/her business (in the address tab, he/she clicked on save).
Warning
This is a none blocking callback
Event id: business_address_updated
.
Event data: a JS object
Business contact updated¶
This event happens when then user has successfully updated contact of his/her business (in the contact tab, he/she clicked on save).
Warning
This is a none blocking callback
Event id: business_address_updated
.
Event data: a JS object
Business description updated¶
This event happens when then user has successfully updated the description of his/her business (in the description tab, he/she clicked on save).
Warning
This is a none blocking callback
Event id: business_address_updated
.
Event data: a JS object
Business open hours updated¶
This event happens when then user has successfully updated the open hours of his/her business (in the open hours tab, he/she clicked on save).
Warning
This is a none blocking callback
Event id: business_open_hours_updated
.
Event data: a JS object
Error¶
This event happens when an error 400, 403, 404, 500 happens during page rendering.
Event id: error
.
- Event data: the HTTP response code:
400
, client error403
, not authorized404
, not found500
, server error
Presence Management go to edit click¶
This event happens when a use click on a Edit link in the presence management view that should redirect him to business edit view.
partooPage.on('pm_view_go_to_edit_click', function() { /* the code you want to be executed on click */});
Presence Management go to partner connection click¶
This event happens when a use click on a Edit link in the presence management view that should redirect him to connection view.
partooPage.on('pm_view_go_to_partner_connection_click', function() { /* the code you want to be executed on click */});