/**
  * @author nathanhelenihi
  * @group api
  * @dataProvider fixtureAuthCfgObject
  */
 public function testCallApi(array $fxt)
 {
     if (!$fxt['from_env']) {
         $this->markTestSkipped('Environment credentials not set.');
     }
     $obj = new BookingPaymentDownload($fxt);
     $obj->setConfig('dataFormat', 'array');
     if (!$obj->isEnabled()) {
         $this->markTestSkipped('API is disabled!');
     }
     // No required parameters should throw exception
     $caught = false;
     try {
         $rsp = $obj->callApi();
     } catch (\exception $e) {
         $caught = true;
         $this->assertInstanceOf('MyAllocator\\phpsdk\\src\\Exception\\ApiException', $e);
     }
     if (!$caught) {
         $this->fail('should have thrown an exception');
     }
     // Invalid booking id should fail
     $rsp = $obj->callApiWithParams(array('OrderId' => '99999999999999999', 'CreditCardPassword' => '123'));
     $this->assertTrue(isset($rsp['response']['body']['Errors']));
     $this->assertEquals($rsp['response']['body']['Errors'][0]['ErrorMsg'], 'No such booking id');
     /*
             // Valid booking id and invalid password should fail
             $rsp = $obj->callApiWithParams(array(
                 'OrderId' => '4304-63761582-4625',
                 'CreditCardPassword' => '123'
             ));
             $this->assertTrue(isset($rsp['response']['body']['Errors']));
             $this->assertEquals(
                 $rsp['response']['body']['Errors'][0]['ErrorMsg'],
                 'No such booking id'
             );
     */
     // Valid order id and valid password should succeed
     $rsp = $obj->callApiWithParams(array('OrderId' => '4304-87701676-62972', 'CreditCardPassword' => '1232'));
     $this->assertTrue(isset($rsp['response']['body']['Payments']));
     /*
             // Valid myallocator id and valid password should succeed
             $rsp = $obj->callApiWithParams(array(
                 'MyAllocatorId' => '5485e70e399dbd9a2451a744',
                 'CreditCardPassword' => '1232'
             ));
             $this->assertTrue(isset($rsp['response']['body']['Payments']));
     */
 }
 /**
  * @author nathanhelenihi
  * @group api
  * @dataProvider fixtureAuthCfgObject
  */
 public function testCallApi(array $fxt)
 {
     if (!$fxt['from_env']) {
         $this->markTestSkipped('Environment credentials not set.');
     }
     $obj = new BookingPaymentDownload($fxt);
     $obj->setConfig('dataFormat', 'xml');
     if (!$obj->isEnabled()) {
         $this->markTestSkipped('API is disabled!');
     }
     // Invalid booking id should fail
     $auth = $fxt['auth'];
     $xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n                <BookingPaymentDownload>\n                    <Auth>\n                        <VendorId>{$auth->vendorId}</VendorId>\n                        <VendorPassword>{$auth->vendorPassword}</VendorPassword>\n                        <UserId>{$auth->userId}</UserId>\n                        <UserPassword>{$auth->userPassword}</UserPassword>\n                        <PropertyId>{$auth->propertyId}</PropertyId>\n                    </Auth>\n                    <OrderId>99999999999999999</OrderId>\n                    <CreditCardPassword>!password1</CreditCardPassword>\n                </BookingPaymentDownload>\n        ";
     $rsp = $obj->callApiWithParams($xml);
     $this->assertEquals(200, $rsp['response']['code']);
     $this->assertNotFalse(strpos($rsp['response']['body'], '<Errors>'), 'Response contains errors!');
     // Valid order id and valid password should succeed
     $xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n                <BookingPaymentDownload>\n                    <Auth>\n                        <VendorId>{$auth->vendorId}</VendorId>\n                        <VendorPassword>{$auth->vendorPassword}</VendorPassword>\n                        <UserId>{$auth->userId}</UserId>\n                        <UserPassword>{$auth->userPassword}</UserPassword>\n                        <PropertyId>{$auth->propertyId}</PropertyId>\n                    </Auth>\n                    <OrderId>4304-63761582-4625</OrderId>\n                    <CreditCardPassword>!password1</CreditCardPassword>\n                </BookingPaymentDownload>\n        ";
     $rsp = $obj->callApiWithParams($xml);
     $this->assertEquals(200, $rsp['response']['code']);
     $this->assertFalse(strpos($rsp['response']['body'], '<Errors>'), 'Response contains errors!');
     // Valid myallocator id and valid password should succeed
     $xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n                <BookingPaymentDownload>\n                    <Auth>\n                        <VendorId>{$auth->vendorId}</VendorId>\n                        <VendorPassword>{$auth->vendorPassword}</VendorPassword>\n                        <UserId>{$auth->userId}</UserId>\n                        <UserPassword>{$auth->userPassword}</UserPassword>\n                        <PropertyId>{$auth->propertyId}</PropertyId>\n                    </Auth>\n                    <MyAllocatorId>5485e70e399dbd9a2451a744</MyAllocatorId>\n                    <CreditCardPassword>!password1</CreditCardPassword>\n                </BookingPaymentDownload>\n        ";
     $rsp = $obj->callApiWithParams($xml);
     $this->assertEquals(200, $rsp['response']['code']);
     $this->assertFalse(strpos($rsp['response']['body'], '<Errors>'), 'Response contains errors!');
 }