/** * @param stdClass $response * @param bool $fromValidate * * @return Beneficiary */ private function createBeneficiaryFromResponse(stdClass $response, $fromValidate = false) { $beneficiary = new Beneficiary(); $beneficiary->setBankCountry($response->bank_country)->setCurrency($response->currency)->setBeneficiaryCountry($response->beneficiary_country)->setPaymentTypes($response->payment_types)->setBankName($response->bank_name)->setBankAddress($response->bank_address)->setAccountNumber($response->account_number)->setIban($response->iban)->setBicSwift($response->bic_swift)->setBankAccountType($response->bank_account_type)->setBeneficiaryAddress($response->beneficiary_address)->setBeneficiaryEntityType($response->beneficiary_entity_type)->setBeneficiaryCompanyName($response->beneficiary_company_name)->setBeneficiaryFirstName($response->beneficiary_first_name)->setBeneficiaryLastName($response->beneficiary_last_name)->setBeneficiaryCity($response->beneficiary_city)->setBeneficiaryPostcode($response->beneficiary_postcode)->setBeneficiaryStateOrProvince($response->beneficiary_state_or_province)->setBeneficiaryDateOfBirth(null !== $response->beneficiary_date_of_birth ? new DateTime($response->beneficiary_date_of_birth) : null)->setBeneficiaryIdentificationType($response->beneficiary_identification_type)->setBeneficiaryIdentificationValue($response->beneficiary_identification_value)->setRoutingCodeType1($response->routing_code_type_1)->setRoutingCodeValue1($response->routing_code_value_1)->setRoutingCodeType2($response->routing_code_type_2)->setRoutingCodeValue2($response->routing_code_value_2); if (!$fromValidate) { $beneficiary->setName($response->name)->setCreatorContactId($response->creator_contact_id)->setEmail($response->email)->setIsDefaultBeneficiary('true' === $response->default_beneficiary)->setBankAccountHolderName($response->bank_account_holder_name)->setCreatedAt(new DateTime($response->created_at))->setUpdatedAt(new DateTime($response->updated_at)); $this->setIdProperty($beneficiary, $response->id); } return $beneficiary; }