/**
  * @param \SubscribePro\Service\Address\AddressInterface $address
  * @return \SubscribePro\Service\Address\AddressInterface
  * @throws \SubscribePro\Exception\EntityInvalidDataException
  * @throws \SubscribePro\Exception\HttpException
  */
 public function findOrSave(AddressInterface $address)
 {
     if (!$address->isValid()) {
         throw new EntityInvalidDataException('Not all required fields are set.');
     }
     $response = $this->httpClient->post('/services/v2/address/find-or-create.json', [self::API_NAME_ADDRESS => $address->getFormData()]);
     return $this->retrieveItem($response, self::API_NAME_ADDRESS, $address);
 }
 /**
  * @param array $data
  * @param bool $isValid
  * @dataProvider isValidDataProvider
  */
 public function testIsValid($data, $isValid)
 {
     $this->address->importData($data);
     $this->assertEquals($isValid, $this->address->isValid());
 }