@@ -11,7 +11,7 @@ class Document implements \Iterator, \Countable
11
11
* @var \Goutte\Client
12
12
*/
13
13
protected $ http_client ;
14
-
14
+
15
15
/**
16
16
*
17
17
* @var \Bpi\Sdk\Authorization
@@ -23,7 +23,7 @@ class Document implements \Iterator, \Countable
23
23
* @var \Symfony\Component\DomCrawler\Crawler
24
24
*/
25
25
protected $ crawler ;
26
-
26
+
27
27
/**
28
28
*
29
29
* @param \Goutte\Client $client
@@ -34,7 +34,7 @@ public function __construct(Client $client, Authorization $authorization)
34
34
$ this ->http_client = $ client ;
35
35
$ this ->authorization = $ authorization ;
36
36
}
37
-
37
+
38
38
/**
39
39
* @param string $endpoint API URL
40
40
* @return \Bpi\Sdk\Document same instance
@@ -57,7 +57,7 @@ public function loadEndpoint($endpoint)
57
57
public function request ($ method , $ uri , array $ params = array ())
58
58
{
59
59
$ headers = array (
60
- 'HTTP_Authorization ' => $ this ->authorization ->toHTTPHeader (),
60
+ 'HTTP_Auth ' => $ this ->authorization ->toHTTPHeader (),
61
61
'HTTP_Content_Type ' => 'application/vnd.bpi.api+xml ' ,
62
62
);
63
63
@@ -67,7 +67,7 @@ public function request($method, $uri, array $params = array())
67
67
68
68
return $ this ;
69
69
}
70
-
70
+
71
71
/**
72
72
* Dump latest raw response data
73
73
*
@@ -77,6 +77,11 @@ public function dumpRawResponse()
77
77
{
78
78
return $ this ->http_client ->getResponse ();
79
79
}
80
+ public function dumpRawRequest ()
81
+ {
82
+ return $ this ->http_client ->getRequest ();
83
+ }
84
+
80
85
81
86
/**
82
87
* Access hypermedia link.
@@ -100,7 +105,7 @@ public function link($rel)
100
105
throw new Exception \UndefinedHypermedia ();
101
106
}
102
107
}
103
-
108
+
104
109
/**
105
110
* Click on link.
106
111
*
@@ -110,7 +115,7 @@ public function followLink(Link $link)
110
115
{
111
116
$ link ->follow ($ this );
112
117
}
113
-
118
+
114
119
/**
115
120
* Access hypermedia query.
116
121
*
@@ -137,7 +142,7 @@ public function query($rel)
137
142
138
143
/**
139
144
* Send query.
140
- *
145
+ *
141
146
* @param \Bpi\Sdk\Query $query
142
147
* @param array $params
143
148
*/
@@ -182,7 +187,7 @@ public function postTemplate(Template $template)
182
187
183
188
/**
184
189
* Checks current item type
185
- *
190
+ *
186
191
* @param string $type
187
192
* @return bool
188
193
*/
@@ -235,12 +240,11 @@ public function firstItem($attr, $value) {
235
240
* @return \Bpi\Sdk\Document same instance
236
241
*/
237
242
public function reduceItemsByAttr ($ attr , $ value ) {
238
- $ this ->crawler = $ this ->crawler
239
- ->filter ("item[ $ attr=' {$ value }'] " )
240
- ;
243
+ $ this ->crawler = $ this ->crawler ->filter ("item[ $ attr=' {$ value }'] " );
241
244
242
- if (!$ this ->crawler ->count ())
245
+ if (!$ this ->crawler ->count ()) {
243
246
throw new \InvalidArgumentException ();
247
+ }
244
248
245
249
$ this ->crawler ->rewind ();
246
250
return $ this ;
@@ -258,49 +262,49 @@ function rewind()
258
262
259
263
/**
260
264
* Returns same instance but with internal pointer to current item in collection
261
- *
265
+ *
262
266
* @group Iterator
263
267
* @return \Bpi\Sdk\Document will return same instance
264
268
*/
265
- function current ()
269
+ function current ()
266
270
{
267
271
return $ this ;
268
272
}
269
273
270
274
/**
271
275
* Key of current iteration position
272
- *
276
+ *
273
277
* @group Iterator
274
278
*/
275
- function key ()
279
+ function key ()
276
280
{
277
281
return $ this ->crawler ->key ();
278
282
}
279
283
280
284
/**
281
285
* Iterate to next item
282
- *
286
+ *
283
287
* @group Iterator
284
288
*/
285
- function next ()
289
+ function next ()
286
290
{
287
291
$ this ->crawler ->next ();
288
292
}
289
293
290
294
/**
291
295
* Checks if is ready for iteration
292
- *
296
+ *
293
297
* @group Iterator
294
298
* @return boolean
295
299
*/
296
- function valid ()
300
+ function valid ()
297
301
{
298
302
return $ this ->crawler ->valid ();
299
303
}
300
-
304
+
301
305
/**
302
306
* Length of items in document
303
- *
307
+ *
304
308
* @group Iterator
305
309
*/
306
310
public function count ()
0 commit comments