コード例 #1
0
 /**
  * @param \SubscribePro\Service\Customer\CustomerInterface $customer
  * @return \SubscribePro\Service\Customer\CustomerInterface
  * @throws \SubscribePro\Exception\EntityInvalidDataException
  * @throws \SubscribePro\Exception\HttpException
  */
 public function saveCustomer(CustomerInterface $customer)
 {
     if (!$customer->isValid()) {
         throw new EntityInvalidDataException('Not all required fields are set.');
     }
     $url = $customer->isNew() ? '/services/v2/customer.json' : "/services/v2/customers/{$customer->getId()}.json";
     $response = $this->httpClient->post($url, [self::API_NAME_CUSTOMER => $customer->getFormData()]);
     return $this->retrieveItem($response, self::API_NAME_CUSTOMER, $customer);
 }
コード例 #2
0
 /**
  * @param array $data
  * @param array $expectedData
  * @dataProvider getFormDataProvider
  */
 public function testGetFormData($data, $expectedData)
 {
     $this->customer->importData($data);
     $this->assertEquals($expectedData, $this->customer->getFormData());
 }