Skip to content

Commit

Permalink
Merge pull request #45 from cultuurnet/feature/UBR-446
Browse files Browse the repository at this point in the history
feature/ubr-446
  • Loading branch information
alduya committed Feb 23, 2016
2 parents d3d4daf + 27ed5a3 commit f00adba
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 14 deletions.
17 changes: 17 additions & 0 deletions CultureFeed/CultureFeed/Uitpas.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,23 @@ public function getPrice($consumer_key_counter = NULL);
*/
public function getPriceByUitpas($uitpas_number, $reason, $date_of_birth = null, $postal_code = null, $voucher_number = null, $consumer_key_counter = NULL);

/**
* @param string $card_system_id
* @param int $date_of_birth
* @param string|null $postal_code
* @param string|null $voucher_number
* @param string|null $consumer_key_counter
*
* @return CultureFeed_Uitpas_Passholder_UitpasPrice
*
* @throws CultureFeed_ParseException
* When the response XML could not be parsed.
*
* @throws LogicException
* When the response contains no uitpasPrice object.
*/
public function getPriceForUpgrade($card_system_id, $date_of_birth, $postal_code = null, $voucher_number = null, $consumer_key_counter = null);

/**
* Create a new UitPas passholder.
*
Expand Down
37 changes: 23 additions & 14 deletions CultureFeed/CultureFeed/Uitpas/Default.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,27 +182,35 @@ public function getPrice($consumer_key_counter = NULL) {
}

/**
* @param string $uitpas_number
* @param string $reason
* @param int $date_of_birth
* @param string $postal_code
* @param string $voucher_number
* @param string $consumer_key_counter
*
* @return CultureFeed_Uitpas_Passholder_UitpasPrice
*
* @throws CultureFeed_ParseException
* When the response XML could not be parsed.
*
* @throws LogicException
* When the response contains no uitpasPrice object.
* @inheritdoc
*/
public function getPriceByUitpas($uitpas_number, $reason, $date_of_birth = null, $postal_code = null, $voucher_number = null, $consumer_key_counter = NULL) {
$data = array(
'reason' => $reason,
'uitpasNumber' => $uitpas_number,
);

return $this->requestPrice($data, $date_of_birth, $postal_code, $voucher_number, $consumer_key_counter);
}

/**
* @inheritdoc
*/
public function getPriceForUpgrade($card_system_id, $date_of_birth, $postal_code = null, $voucher_number = null, $consumer_key_counter = null) {
$reason = CultureFeed_Uitpas_Passholder_UitpasPrice::REASON_CARD_UPGRADE;

$data = array(
'reason' => $reason,
'cardSystemId' => $card_system_id
);

return $this->requestPrice($data, $date_of_birth, $postal_code, $voucher_number, $consumer_key_counter);
}

/**
* @param $data
*/
private function requestPrice($data, $date_of_birth = null, $postal_code = null, $voucher_number = null, $consumer_key_counter = null) {
if (!is_null($date_of_birth)) {
$data['dateOfBirth'] = date('Y-m-d', $date_of_birth);
}
Expand Down Expand Up @@ -233,6 +241,7 @@ public function getPriceByUitpas($uitpas_number, $reason, $date_of_birth = null,
return CultureFeed_Uitpas_Passholder_UitpasPrice::createFromXML($price_xml);
}


/**
* Create a new UitPas passholder.
*
Expand Down

0 comments on commit f00adba

Please sign in to comment.