Roomify / bat_drupal

Booking and Availability Management Tools for Drupal 7 and Drupal 8
33 stars 7 forks source link

BAT API returns fatal error - www\includes\common.inc on line 8041 (& documentation?) #44

Closed CosyStudios closed 7 years ago

CosyStudios commented 7 years ago

I've installed the latest roomify distro via the build process/make file and have imported the quick setup content for B&Bs..

Just trying to query the BAT API as i intend to implement most of my search functionality & booking through REST.

I can get a token, login and query units/types successfully which outputs as expected.

But querying events, events-calender & others always gives me

Fatal error: Class name must be a valid object or a string in www\includes\common.inc on line 8041

I'm also unclear on the format for most of the parameters & wondering if/where that might be documented in the code.

querying bat/v2/events without parameters typically gives me Missing required argument *

bat/v2/eventsevents?target_ids=1&target_entity_type=room&start_date=2017-01-08&end_date=2017-01-14&event_types=availability for instance, give me the fatal error above.

I've noted through google that this error is commonly associated with the entity api but im unclear as to whether my query is both incorrect or there is a bug in the code.

Any ideas?

I realise this is early days for roomify community on github obviously. Can anyone help guide me to debug/establish a working model for querying the BAT API ?

acrollet commented 7 years ago

Hi there,

the thing that jumps out to me right away is bat/v2/eventsevents?target_ids=1&target_entity_type=room&start_date=2017-01-08&end_date=2017-01-14&event_types=availability (extra events bolded)

On a broader level, you'll probably want to spend some time looking at bat_api_services_resources() in bat_api.module (https://github.com/Roomify/bat_api/blob/7.x-2.x/bat_api.module#L106) - there you can see that bat/v2/events is a service for listing and manipulating BAT event entities, rather than searching for e.g. availability information. Probably the quickest approach is to perform operations with the unit calendar and use the inspector to copy the API calls, and work from there to modify them to suit your needs.

regards!

CosyStudios commented 7 years ago

Thanks acrollet, Oops yes a schoolboy typo there!

I think ive got a hang on the BAT API now. Trying to implement a restful approach to querying events-calendar in order to populate calendars for each room using angularjs. (mainly because im better versed at this approach than doing it in drupal/php)

acrollet commented 7 years ago

great, glad to hear it! Sounds like a cool project, would you mind sharing a link when it's up and running?