Skip to content

Commit

Permalink
fixed query options to Get's requests
Browse files Browse the repository at this point in the history
  • Loading branch information
Ednei Oliveira committed Aug 26, 2015
1 parent 1d0a544 commit d4610d7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
8 changes: 7 additions & 1 deletion src/Message/AbstractRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,19 @@ function ($event) {
$this->getHttpMethod(),
$this->getEndpoint(),
null,
$this->insertApiKeyToData($data)
$this->insertApiKeyToData($data),
$this->getOptions()
);
$httpResponse = $httpRequest->send();

return $this->response = new Response($this, $httpResponse->json());
}

protected function getOptions()
{
return array();
}

protected function getEndpoint()
{
return $this->endpoint;
Expand Down
15 changes: 13 additions & 2 deletions src/Message/InstallmentsRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,12 @@ public function getHttpMethod()
return 'GET';
}

public function getData()
public function getQuery()
{
$this->validate('amount', 'interest_rate', 'max_installments');

$data = array();

$data['api_key'] = $this->getApiKey();
$data['amount'] = $this->getAmountInteger();
$data['max_installments'] = $this->getMaxInstallments();
$data['free_installments'] = $this->getFreeInstallments();
Expand All @@ -121,6 +121,17 @@ public function getData()
return $data;
}

protected function getOptions() {
$options['query'] = $this->getQuery();

return $options;

}
public function getData()
{
return array();
}

public function getEndpoint()
{
return $this->endpoint.'transactions/calculate_installments_amount';
Expand Down
11 changes: 4 additions & 7 deletions tests/Message/InstallmentsRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ public function testGetData()
{
$data = $this->request->getData();

$this->assertSame(12, $data['max_installments']);
$this->assertSame(3, $data['free_installments']);
$this->assertSame(1.12, $data['interest_rate']);
$this->assertSame(120000, $data['amount']);
$this->assertSame(array(), $data);
}

public function testInterestRate()
Expand Down Expand Up @@ -54,7 +51,7 @@ public function testFreeInstallments()
public function testAmountRequired()
{
$this->request->setAmount(null);
$this->request->getData();
$this->request->getQuery();
}

/**
Expand All @@ -64,7 +61,7 @@ public function testAmountRequired()
public function testInterestRateRequired()
{
$this->request->setInterestRate(null);
$this->request->getData();
$this->request->getQuery();
}

/**
Expand All @@ -74,7 +71,7 @@ public function testInterestRateRequired()
public function testMaxInstallmentsRequired()
{
$this->request->setMaxInstallments(null);
$this->request->getData();
$this->request->getQuery();
}

public function testGetHttpMethod()
Expand Down

0 comments on commit d4610d7

Please sign in to comment.