/**
  * resolves identification
  *
  * @param \Abobereich\ApiClient\Models\Model|Account $model
  * @param array $data
  *
  * @return array|bool
  */
 protected function resolveIdentification(Model $model, array $data)
 {
     if (!empty($model->getId())) {
         $data['account_id'] = $model->getId();
         return $data;
     }
     if (!empty($model->getExternalIdentifier())) {
         $data['account_identifier'] = $model->getExternalIdentifier();
         return $data;
     }
     return false;
 }
 /**
  * resolves identification
  *
  * @param \Abobereich\ApiClient\Models\Model|Subscription $model
  * @param array $data
  *
  * @return array|bool
  */
 protected function resolveIdentification(Model $model, array $data)
 {
     if (!empty($model->getId())) {
         $data['subscription_id'] = $model->getId();
         return $data;
     }
     if (!empty($model->getExternalIdentifier())) {
         $data['subscription_identifier'] = $model->getExternalIdentifier();
         return $data;
     }
     if (!empty($model->getSubscriptionNumber())) {
         $data['subscription_number'] = $model->getSubscriptionNumber();
         return $data;
     }
     return false;
 }
Пример #3
0
 /**
  * creates a model via api
  *
  * @param string $uri
  * @param \Abobereich\ApiClient\Models\Model|array $model
  * @param string $indexOfResponse
  *
  * @return Account|null
  */
 protected function post($uri, $model, $indexOfResponse = 'data')
 {
     /**
      * reset id, created_at and updated_at to null, because a new model does not have any valid values there
      */
     if ($model instanceof Model) {
         $model->setId(null);
     }
     $response = $this->postRequest($uri, $model);
     $result = $this->toArray($response);
     if (null !== $result && array_key_exists($indexOfResponse, $result)) {
         return $this->transformer()->transform($result[$indexOfResponse]);
     }
     return null;
 }