/** * @param Beneficiary $beneficiary * @param bool $convertForValidate * @param bool $convertForUpdate * * @return array */ protected function convertBeneficiaryToRequest(Beneficiary $beneficiary, $convertForValidate = false, $convertForUpdate = false) { $isDefaultBeneficiary = $beneficiary->isDefaultBeneficiary(); $common = ['bank_country' => $beneficiary->getBankCountry(), 'currency' => $beneficiary->getCurrency(), 'beneficiary_country' => $beneficiary->getBeneficiaryCountry(), 'account_number' => $beneficiary->getAccountNumber(), 'routing_code_type_1' => $beneficiary->getRoutingCodeType1(), 'routing_code_value_1' => $beneficiary->getRoutingCodeValue1(), 'routing_code_type_2' => $beneficiary->getRoutingCodeType2(), 'routing_code_value_2' => $beneficiary->getRoutingCodeValue2(), 'bic_swift' => $beneficiary->getBicSwift(), 'iban' => $beneficiary->getIban(), 'bank_address' => $beneficiary->getBankAddress(), 'bank_name' => $beneficiary->getBankName(), 'default_beneficiary' => null === $isDefaultBeneficiary ? null : ($isDefaultBeneficiary ? 'true' : 'false'), 'bank_account_type' => $beneficiary->getBankAccountType(), 'beneficiary_entity_type' => $beneficiary->getBeneficiaryEntityType(), 'beneficiary_company_name' => $beneficiary->getBeneficiaryCompanyName(), 'beneficiary_address' => $beneficiary->getBeneficiaryAddress(), 'beneficiary_first_name' => $beneficiary->getBeneficiaryFirstName(), 'beneficiary_last_name' => $beneficiary->getBeneficiaryLastName(), 'beneficiary_city' => $beneficiary->getBeneficiaryCity(), 'beneficiary_postcode' => $beneficiary->getBeneficiaryPostCode(), 'beneficiary_state_or_province' => $beneficiary->getBeneficiaryStateOrProvince(), 'beneficiary_date_of_birth' => null === $beneficiary->getBeneficiaryDateOfBirth() ? null : $beneficiary->getBeneficiaryDateOfBirth()->format('Y-m-d'), 'beneficiary_identification_type' => $beneficiary->getBeneficiaryIdentificationType(), 'beneficiary_identification_value' => $beneficiary->getBeneficiaryIdentificationValue(), 'payment_types' => $beneficiary->getPaymentTypes()]; if ($convertForValidate) { return $common; } $common += ['bank_account_holder_name' => $beneficiary->getBankAccountHolderName(), 'name' => $beneficiary->getName(), 'email' => $beneficiary->getEmail()]; if ($convertForUpdate) { return $common; } return $common + ['creator_contact_id' => $beneficiary->getCreatorContactId()]; }