Created
March 10, 2021 19:52
-
-
Save davixz/5d057e712de1d288d175c0b43bb858eb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function cardLinkHolder($userWalletCard, $user, $token) { | |
$toolsSvc = $this->sc->get('tools'); | |
$userWalletCardSvc = $this->sc->get('rp_user_wallet_card'); | |
$userBirthdate = $user->getBirthdate(); | |
$userGender = $user->getGender(); | |
if($userGender) { | |
if($userGender == "M") { | |
$userGender = "male"; | |
} else if($userGender == "F") { | |
$userGender = "female"; | |
} | |
} else { | |
$userGender = 'male'; | |
} | |
$userAddress = $user->getAddress(); | |
$userAddressCity = $userAddress->getCity(); | |
$userAddressState = $userAddress->getState(); | |
$data['token'] = $token; | |
$data['url'] = '/partner-interface/cards/'.$userWalletCard->getIdExternal().'/holder'; | |
$data['post'] = json_encode([ | |
'name' => $userWalletCardSvc->cardIssuePrepareHolderNameDisplay($user->getFullName()), | |
'document' => $user->getDocument(), | |
'email' => $user->getEmail(), | |
'homePhone' => $toolsSvc->removeNonDigits($user->getPhoneNumberMobile()), | |
'mobilePhone' => $toolsSvc->removeNonDigits($user->getPhoneNumberMobile()), | |
'birthDate' => $userBirthdate->format('Y-m-d'), | |
'gender' => $userGender, | |
'address' => [ | |
'street' => $userAddress->getStreet(), | |
'number' => $userAddress->getNumber(), | |
'complement' => $userAddress->getComplement(), | |
'district' => ($userAddress->getNeighborhood())?$userAddress->getNeighborhood():'n/a', | |
'zipcode' => str_replace('-', '', $userAddress->getPostCode()), | |
'city' => $userAddressCity->getName(), | |
'state' => $userAddressState->getIsoCode() | |
] | |
]); | |
return $this->send($data, "PUT"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment