/** * @author nathanhelenihi * @group common */ public function testToArray() { new MaError(); // Just to load error definitions. $obj = new MaResponse(); $data = 'Bad data'; $obj->error(MA_OTA_ERR_JSON_INVALID, $data); $errors = $obj->errors[0]->getMappings(); $this->assertSame($obj->toArray(), array('success' => false, 'errors' => array(array('id' => MA_OTA_ERR_JSON_INVALID, 'type' => $errors[MA_OTA_ERR_JSON_INVALID]['type'], 'msg' => $errors[MA_OTA_ERR_JSON_INVALID]['msg'], 'data' => $data)))); }
/** * Get information for a specific booking for a property. * * args['verb']* string Defines the API endpoint method. * args['guid']* string A unique 36 character code that identifies a request. * args['mya_property_id']* string The property_id in MyAllocator. * args['ota_property_id']* string The property_id in OTA. * args['booking_id']* string The booking identifier. * args['booking_id_version'] string The OTA version at time of booking. * * @param array $args (See above) * * @return \MyAllocator\phpsdkota\src\Object\MaResponse */ public function getBookingId($args) { $rsp = new \MyAllocator\phpsdkota\src\Object\MaResponse(); // Use channel test bookings from github $bookings = array('boo-235872225.json' => 'https://raw.githubusercontent.com/MyAllocator/bookingsamples/master/boo-235872225.json', 'exp-503365981.json' => 'https://raw.githubusercontent.com/MyAllocator/bookingsamples/master/exp-503365981.json'); // Assert booking with id exists if (!isset($bookings[$args['booking_id']])) { return $rsp->error(MA_OTA_ERR_BOOKING_NONEXIST, $args['booking_id']); } // Pull json booking and decode $booking = file_get_contents($bookings[$args['booking_id']]); $booking = json_decode($booking, true); $data = array('Booking' => $booking); return $rsp->success($data); }