/** * @param AccountNumber $accountNumber * @param BankCode $bankCode * @param Sepa $sepa * @throws BankCheckException * @return BankCheckResponse */ public static function request(AccountNumber $accountNumber, BankCode $bankCode, Sepa $sepa) { $client = new Client(); try { $response = $client->get(Ckonto::$url, ['query' => ['key' => Ckonto::getKey(), 'kontonummer' => $accountNumber->getValue(), 'bankleitzahl' => $bankCode->getValue(), 'sepa' => $sepa->isEnabled() ? 1 : 0]]); return new BankCheckResponse($response); } catch (RequestException $e) { throw new BankCheckException('BankCheckRequest error occurred'); } }
/** * @param Iban $iban * @param Bic $bic * @param Sepa $sepa * @return IbanCheckResponse * @throws IbanCheckException */ public static function request(Iban $iban, Bic $bic, Sepa $sepa) { $client = new Client(); try { $response = $client->get(Ckonto::$url, ['query' => ['key' => Ckonto::getKey(), 'iban' => $iban->getValue(), 'bic' => $bic->getValue(), 'sepa' => $sepa->isEnabled() ? 1 : 0]]); return new IbanCheckResponse($response); } catch (RequestException $e) { throw new IbanCheckException('IbanCheckRequest error occurred'); } }
/** * @param BankCode $bankCode * @param Location $location * @param Name $name * @param Zip $zip * @param Max $max * @return SearchResponse * @throws SearchException */ public static function request(BankCode $bankCode, Location $location, Name $name, Zip $zip, Max $max) { $client = new Client(); try { $query = ['key' => Ckonto::getKey(), 'search' => 1, 'zip' => $zip->getValue(), 'bankleitzahl' => $bankCode->getValue(), 'name' => $name->getValue(), 'location' => $location->getCity()]; if ($max->getValue() > 0) { $query['max'] = $max->getValue(); } $response = $client->get(Ckonto::$url, ['query' => $query]); return new SearchResponse($response); } catch (RequestException $e) { throw new SearchException('SearchRequest error: ' . $e->getMessage()); } }
/** @test */ public function it_returns_a_search_object() { $search = \Oneso\Ckonto\Webservice\Ckonto::search(\Oneso\Ckonto\Webservice\Objects\BankCode::fromCode('123456789'), \Oneso\Ckonto\Webservice\Objects\Location::fromCity('Berlin'), \Oneso\Ckonto\Webservice\Objects\Name::fromName(''), \Oneso\Ckonto\Webservice\Objects\Zip::fromZip(''), \Oneso\Ckonto\Webservice\Objects\Max::fromValue(0)); $this->assertTrue($search instanceof \Oneso\Ckonto\Webservice\Search\Search); }