|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Ipag\Classes\Services; |
|
4
|
|
|
|
|
5
|
|
|
use Ipag\Classes\Serializer\Serializer; |
|
6
|
|
|
use Ipag\Classes\Transaction; |
|
7
|
|
|
|
|
8
|
|
|
abstract class BaseService |
|
9
|
|
|
{ |
|
10
|
|
|
/** |
|
11
|
|
|
* @var Transaction |
|
12
|
|
|
*/ |
|
13
|
|
|
private $transaction; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* @var Serializer |
|
17
|
|
|
*/ |
|
18
|
|
|
private $serializer; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* @var string |
|
22
|
|
|
*/ |
|
23
|
|
|
private $operation; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* @var string |
|
27
|
|
|
*/ |
|
28
|
|
|
private $action; |
|
29
|
|
|
|
|
30
|
|
|
public function __construct(Transaction $transaction) |
|
31
|
|
|
{ |
|
32
|
|
|
$this->transaction = $transaction; |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
public function executeAction() |
|
36
|
|
|
{ |
|
37
|
|
|
$this->transaction->getOrder()->setOperation($this->getOperation()); |
|
38
|
|
|
|
|
39
|
|
|
$action = $this->getAction(); |
|
40
|
|
|
|
|
41
|
|
|
$response = $this->transaction->sendHttpRequest( |
|
42
|
|
|
$this->transaction->getIpag()->getEndpoint()->$action(), |
|
43
|
|
|
$this->serializer->serialize() |
|
44
|
|
|
); |
|
45
|
|
|
|
|
46
|
|
|
return $this->transaction->populate($response); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @return Serializer |
|
51
|
|
|
*/ |
|
52
|
|
|
public function getSerializer() |
|
53
|
|
|
{ |
|
54
|
|
|
return $this->serializer; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* @param Serializer $serializer |
|
59
|
|
|
*/ |
|
60
|
|
|
public function setSerializer(Serializer $serializer) |
|
61
|
|
|
{ |
|
62
|
|
|
$this->serializer = $serializer; |
|
63
|
|
|
|
|
64
|
|
|
return $this; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* @return Transaction |
|
69
|
|
|
*/ |
|
70
|
|
|
public function getTransaction() |
|
71
|
|
|
{ |
|
72
|
|
|
return $this->transaction; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* @param Transaction $transaction |
|
77
|
|
|
*/ |
|
78
|
|
|
public function setTransaction(Transaction $transaction) |
|
79
|
|
|
{ |
|
80
|
|
|
$this->transaction = $transaction; |
|
81
|
|
|
|
|
82
|
|
|
return $this; |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* @return string |
|
87
|
|
|
*/ |
|
88
|
|
|
public function getOperation() |
|
89
|
|
|
{ |
|
90
|
|
|
return $this->operation; |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
/** |
|
94
|
|
|
* @param string $operation |
|
95
|
|
|
*/ |
|
96
|
|
|
public function setOperation($operation) |
|
97
|
|
|
{ |
|
98
|
|
|
$this->operation = $operation; |
|
99
|
|
|
|
|
100
|
|
|
return $this; |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
/** |
|
104
|
|
|
* @return string |
|
105
|
|
|
*/ |
|
106
|
|
|
public function getAction() |
|
107
|
|
|
{ |
|
108
|
|
|
return $this->action; |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
/** |
|
112
|
|
|
* @param string $action |
|
113
|
|
|
*/ |
|
114
|
|
|
public function setAction($action) |
|
115
|
|
|
{ |
|
116
|
|
|
$this->action = $action; |
|
117
|
|
|
|
|
118
|
|
|
return $this; |
|
119
|
|
|
} |
|
120
|
|
|
} |
|
121
|
|
|
|