@@ -14,6 +14,7 @@ class Ship extends Auth
14
14
private ShipQuery $ query ;
15
15
private ShipmentRequest $ shipmentRequest ;
16
16
private bool $ onlyLabel ;
17
+ private object $ apiResponse ;
17
18
18
19
public function __construct ()
19
20
{
@@ -65,10 +66,10 @@ public function createShipment(string $client_id, string $client_secret): array
65
66
"transId: string " ,
66
67
"transactionSrc: testing "
67
68
]);
68
- $ httpClient ->setPayload (json_encode ( $ this ->getPayload () ));
69
+ $ httpClient ->setPayload ($ this ->getRequest ( ));
69
70
$ httpClient ->setUrl ($ this ->_getAPIBaseURL () . "/api/shipments/ " . self ::VERSION . "/ship " . $ queryParams );
70
71
$ httpClient ->setMethod ("POST " );
71
- $ res = $ httpClient ->fetch ();
72
+ $ this -> apiResponse = $ res = $ httpClient ->fetch ();
72
73
73
74
if (!isset ($ res ->ShipmentResponse )) {
74
75
if (isset ($ res ->response )) {
@@ -101,13 +102,6 @@ public function createShipment(string $client_id, string $client_secret): array
101
102
return ['status ' => 'success ' , 'data ' => $ res ];
102
103
}
103
104
104
- private function getPayload (): array
105
- {
106
- return [
107
- "ShipmentRequest " => $ this ->shipmentRequest ->toArray ()
108
- ];
109
- }
110
-
111
105
public function setMode (string $ mode ): self
112
106
{
113
107
parent ::setMode ($ mode );
@@ -119,4 +113,16 @@ public function setOnlyLabel(bool $onlyLabel): self
119
113
$ this ->onlyLabel = $ onlyLabel ;
120
114
return $ this ;
121
115
}
116
+
117
+ public function getRequest (): string
118
+ {
119
+ return json_encode ([
120
+ "ShipmentRequest " => $ this ->shipmentRequest ->toArray ()
121
+ ]);
122
+ }
123
+
124
+ public function getResponse (): string
125
+ {
126
+ return json_encode ($ this ->apiResponse );
127
+ }
122
128
}
0 commit comments