/**
  * @param bool $isNew
  * @param array $data
  * @param array $billingData
  * @param array $expectedData
  * @param array $billingFormData
  * @dataProvider getFormDataProvider
  */
 public function testGetFormData($isNew, $data, $billingData, $expectedData, $billingFormData)
 {
     $this->billingAddressMock->expects($this->atLeastOnce())->method('importData')->with($billingData)->willReturnSelf();
     $this->billingAddressMock->expects($this->once())->method('getAsChildFormData')->with($isNew)->willReturn($billingFormData);
     $this->paymentProfile->importData($data);
     $this->assertEquals($expectedData, $this->paymentProfile->getFormData());
 }
 /**
  * @param \SubscribePro\Service\PaymentProfile\PaymentProfileInterface $paymentProfile
  * @return \SubscribePro\Service\PaymentProfile\PaymentProfileInterface
  * @throws \SubscribePro\Exception\EntityInvalidDataException
  * @throws \SubscribePro\Exception\HttpException
  */
 public function saveProfile(PaymentProfileInterface $paymentProfile)
 {
     if (!$paymentProfile->isValid()) {
         throw new EntityInvalidDataException('Not all required fields are set.');
     }
     $postData = [self::API_NAME_PROFILE => $paymentProfile->getFormData()];
     $response = $paymentProfile->isNew() ? $this->httpClient->post('/services/v1/vault/paymentprofile.json', $postData) : $this->httpClient->put("/services/v1/vault/paymentprofiles/{$paymentProfile->getId()}.json", $postData);
     return $this->retrieveItem($response, self::API_NAME_PROFILE, $paymentProfile);
 }