Skip to content

Commit c7452de

Browse files
authored
Merge pull request #22 from khiminrm/21-fix-transaction-response
Fix TransactionResponse, move duplicated code to Response class.
2 parents 861c22a + 03186f3 commit c7452de

7 files changed

+66
-320
lines changed

lib/Core/Response.php

Lines changed: 60 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,72 @@ public function __construct($response = [])
3434

3535
}
3636

37-
/**
38-
* Setting the error for the object
37+
/**
38+
* Set the error
3939
*
40-
* @param int|string $httpCode The http status code
41-
* @param string $error The error message
40+
* @param int $httpCode The response code
41+
* @param string $error The response
4242
*
4343
* @return void
4444
*/
4545
public function setError($httpCode, $error)
4646
{
47+
$this->setIsError(true);
48+
$this->setErrorMessage($error);
49+
}
50+
51+
/**
52+
* Set the error for the response object
53+
*
54+
* @param bool $isError The error state
55+
*
56+
* @return void
57+
*/
58+
public function setIsError($isError)
59+
{
60+
$this->isError = $isError;
61+
}
62+
63+
/**
64+
* Is the response in error
65+
*
66+
* @return bool
67+
*/
68+
public function isError()
69+
{
70+
return $this->isError;
71+
}
72+
73+
/**
74+
* Get the error message
75+
*
76+
* @return string
77+
*/
78+
public function getErrorMessage()
79+
{
80+
return $this->errorMessage;
81+
}
4782

83+
/**
84+
* Set the error message
85+
*
86+
* @param string $errorMessage The error message
87+
*
88+
* @return void
89+
*/
90+
public function setErrorMessage($errorMessage)
91+
{
92+
$this->errorMessage = $errorMessage;
93+
}
94+
95+
/**
96+
* Get if there is an error
97+
*
98+
* @return bool
99+
*/
100+
public function isError()
101+
{
102+
return $this->isError;
48103
}
49104

50105
/**
@@ -58,4 +113,4 @@ public function setObject($response)
58113
{
59114

60115
}
61-
}
116+
}

lib/Core/Response/CaseResponse.php

Lines changed: 1 addition & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -279,20 +279,6 @@ public function setMethod($method, $item)
279279
}
280280
}
281281

282-
/**
283-
* Set the error
284-
*
285-
* @param int $httpCode The response code
286-
* @param string $error The response
287-
*
288-
* @return void
289-
*/
290-
public function setError($httpCode, $error)
291-
{
292-
$this->setIsError(true);
293-
$this->setErrorMessage($error);
294-
}
295-
296282
/**
297283
* Get the eligible for guarantee
298284
*
@@ -625,51 +611,6 @@ public function setUpdatedAt($updatedAt)
625611
$this->updatedAt = $updatedAt;
626612
}
627613

628-
/**
629-
* Is the response in error
630-
*
631-
* @return bool
632-
*/
633-
public function isError()
634-
{
635-
return $this->isError;
636-
}
637-
638-
/**
639-
* Set the error for the response object
640-
*
641-
* @param bool $isError The error state
642-
*
643-
* @return void
644-
*/
645-
public function setIsError($isError)
646-
{
647-
$this->isError = $isError;
648-
}
649-
650-
/**
651-
* Get the error message
652-
*
653-
* @return string
654-
*/
655-
public function getErrorMessage()
656-
{
657-
return $this->errorMessage;
658-
}
659-
660-
/**
661-
* Set the error message
662-
*
663-
* @param string $errorMessage The error message
664-
*
665-
* @return void
666-
*/
667-
public function setErrorMessage($errorMessage)
668-
{
669-
$this->errorMessage = $errorMessage;
670-
}
671-
672-
673614
/**
674615
* Set the investigation id to the case id
675616
*
@@ -851,9 +792,4 @@ public function setGuaranteeIneligibleReason($guaranteeIneligibleReason)
851792
{
852793
$this->guaranteeIneligibleReason = $guaranteeIneligibleReason;
853794
}
854-
855-
public function addMessage($message)
856-
{
857-
$this->message[] = $message;
858-
}
859-
}
795+
}

lib/Core/Response/FulfillmentBulkResponse.php

Lines changed: 1 addition & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -72,51 +72,6 @@ public function __construct($logger)
7272
$this->logger = $logger;
7373
}
7474

75-
/**
76-
* Is the response in error
77-
*
78-
* @return bool
79-
*/
80-
public function isError()
81-
{
82-
return $this->isError;
83-
}
84-
85-
/**
86-
* Set the response error
87-
*
88-
* @param bool $isError If response is in error
89-
*
90-
* @return void
91-
*/
92-
public function setIsError($isError)
93-
{
94-
$this->isError = $isError;
95-
}
96-
97-
/**
98-
* Get the error message
99-
*
100-
* @return string
101-
*/
102-
public function getErrorMessage()
103-
{
104-
return $this->errorMessage;
105-
}
106-
107-
/**
108-
* Set the error message
109-
*
110-
* @param string $errorMessage The error message
111-
*
112-
* @return void
113-
*/
114-
public function setErrorMessage($errorMessage)
115-
{
116-
$this->errorMessage = $errorMessage;
117-
}
118-
119-
12075
/**
12176
* Get the response objects
12277
*
@@ -143,17 +98,4 @@ public function setObject($response)
14398
}
14499
}
145100

146-
/**
147-
* Set the error
148-
*
149-
* @param int $httpCode The response code
150-
* @param string $error The response
151-
*
152-
* @return void
153-
*/
154-
public function setError($httpCode, $error)
155-
{
156-
$this->setIsError(true);
157-
$this->setErrorMessage($error);
158-
}
159-
}
101+
}

lib/Core/Response/GuaranteeResponse.php

Lines changed: 1 addition & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -149,63 +149,6 @@ public function setObject($response)
149149
return true;
150150
}
151151

152-
/**
153-
* Set the error
154-
*
155-
* @param int $httpCode The response code
156-
* @param string $error The response
157-
*
158-
* @return void
159-
*/
160-
public function setError($httpCode, $error)
161-
{
162-
$this->setIsError(true);
163-
$this->setErrorMessage($error);
164-
}
165-
166-
/**
167-
* Is the response in error
168-
*
169-
* @return bool
170-
*/
171-
public function isError()
172-
{
173-
return $this->isError;
174-
}
175-
176-
/**
177-
* Set the error for the response object
178-
*
179-
* @param bool $isError The error state
180-
*
181-
* @return void
182-
*/
183-
public function setIsError($isError)
184-
{
185-
$this->isError = $isError;
186-
}
187-
188-
/**
189-
* Get the error message
190-
*
191-
* @return string
192-
*/
193-
public function getErrorMessage()
194-
{
195-
return $this->errorMessage;
196-
}
197-
198-
/**
199-
* Set the error message
200-
*
201-
* @param string $errorMessage The error message
202-
*
203-
* @return void
204-
*/
205-
public function setErrorMessage($errorMessage)
206-
{
207-
$this->errorMessage = $errorMessage;
208-
}
209152

210153
/**
211154
* Get the case id
@@ -383,4 +326,4 @@ public function setGuaranteeId($guaranteeId)
383326
$this->guaranteeId = $guaranteeId;
384327
}
385328

386-
}
329+
}

lib/Core/Response/TransactionsResponse.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44

55
use Signifyd\Core\Exceptions\LoggerException;
66
use Signifyd\Core\Model;
7+
use Signifyd\Core\Response;
78
use Signifyd\Models\Transaction;
89

9-
class TransactionsResponse extends Model
10+
class TransactionsResponse extends Response
1011
{
1112
/**
1213
* A unique id for a particular checkout.
@@ -121,9 +122,4 @@ public function addTransaction($transaction)
121122
{
122123
$this->transactions[] = $transaction;
123124
}
124-
125-
public function addMessage($message)
126-
{
127-
$this->message[] = $message;
128-
}
129125
}

0 commit comments

Comments
 (0)