Skip to content

Commit 321af3d

Browse files
authored
Dx 1390 fixed file response header for post requests (#63)
* Fixed location header response * Fixed php warnings * Updated readme example * Added test
1 parent dc8bfc3 commit 321af3d

File tree

4 files changed

+21
-4
lines changed

4 files changed

+21
-4
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ PHP Client library for Bandwidth's Phone Number Dashboard (AKA: Dashboard, Iris)
2020
| 2.3.0 | Added `loas` endpoints for ImportTnOrders |
2121
| 2.4.0 | Added Emergency Calling Notification, Emergeny Notification Group, Emergency Notification Endpoint, and Alternate End User Identity methods |
2222
| 2.5.0 | Added `PortOutPasscode` for TnOption orders |
23+
| 2.5.1 | Fixed grabbing of response header for file uploads |
2324

2425
## Supported PHP Versions
2526

@@ -366,6 +367,14 @@ $portin->set_metadata('test.txt', $meta_new);
366367
$portin->delete_metadata('test.txt');
367368
```
368369

370+
#### PortIn File Management: Grab filename
371+
```PHP
372+
$response = $portin->loas_send('./hello.txt', array("Content-Type" => "text/plain"));
373+
$tmp = explode("/", $response);
374+
$id = end($tmp);
375+
print_r($id);
376+
```
377+
369378
## Rate Centers
370379
### List Ratecenters
371380
```PHP

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "Bandwidth's Iris SDK for PHP",
55
"keywords": ["iris","sdk","php"],
66
"homepage": "http://dev.bandwidth.com",
7-
"reference": "v2.5.0",
7+
"reference": "v2.5.1",
88
"license": "MIT",
99
"authors": [
1010
],

core/Client.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,11 +236,12 @@ public function raw_file_post($url, $content, $headers = [])
236236
];
237237
$response = $this->request('post', $url, $options, false);
238238

239-
if (!is_array($response) || !isset($response['Location']))
239+
if ($response->hasHeader('Location'))
240240
{
241-
return '';
241+
$header = $response->getHeader('Location');
242+
return reset($header);
242243
}
243-
return $response['Location'];
244+
return '';
244245
}
245246

246247
/**

tests/PortinsTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ public static function setUpBeforeClass() {
2626
new Response(200, [], "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><LnpOrderResponse> <ProcessingStatus>SUBMITTED</ProcessingStatus> <RequestedFocDate>2015-06-03T15:30:00Z</RequestedFocDate> <LoaAuthorizingPerson>Joe Blow</LoaAuthorizingPerson> <Subscriber> <SubscriberType>BUSINESS</SubscriberType> <BusinessName>Company</BusinessName> <ServiceAddress> <HouseNumber>123</HouseNumber> <StreetName>EZ Street</StreetName> <City>Raleigh</City> <StateCode>NC</StateCode> <Zip>27615</Zip> <County>Wake</County> <Country>United States</Country> <AddressType>Service</AddressType> </ServiceAddress> </Subscriber> <BillingTelephoneNumber>9193491234</BillingTelephoneNumber> <NewBillingTelephoneNumber>9175131245</NewBillingTelephoneNumber> <ListOfPhoneNumbers> <PhoneNumber>9193491234</PhoneNumber> </ListOfPhoneNumbers> <PON>BWC1433343996123</PON> <AccountId>9500249</AccountId> <SiteId>2297</SiteId> <PeerId>500655</PeerId> <LosingCarrierName>Test Losing Carrier L3</LosingCarrierName> <VendorName>Bandwidth CLEC</VendorName> <OrderCreateDate>2015-06-03T15:06:35.533Z</OrderCreateDate> <LastModifiedDate>2015-06-03T15:06:36.234Z</LastModifiedDate> <userId>System</userId> <LastModifiedBy>System</LastModifiedBy> <PartialPort>false</PartialPort> <Immediately>false</Immediately> <Triggered>false</Triggered></LnpOrderResponse>"),
2727
new Response(200, [], "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><OrderHistoryWrapper> <OrderHistory> <OrderDate>2015-06-03T15:06:35.765Z</OrderDate> <Note>LOA required</Note> <Author>byo_dev</Author> <Status>PENDING_DOCUMENTS</Status> </OrderHistory> <OrderHistory> <OrderDate>2015-06-03T15:06:36.234Z</OrderDate> <Note>Order has been created</Note> <Author>System</Author> <Status>SUBMITTED</Status> <Difference>LoaDate : \"\" --&gt; Wed Jun 03 15:06:35 UTC 2015</Difference> </OrderHistory></OrderHistoryWrapper>"),
2828
new Response(200, [], "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Quantity><Count>4</Count></Quantity>"),
29+
new Response(200),
30+
new Response(200, ["Location" => "filename"], ""),
2931
]);
3032

3133
self::$container = [];
@@ -275,5 +277,10 @@ public function testTotals() {
275277
self::$index++;
276278
}
277279

280+
public function testLoasSend() {
281+
$portin = self::$portins->portin("");
282+
$response = $portin->loas_send('./tests/test.txt', array("Content-Type" => "text/plain"));
283+
$this->assertEquals("filename", $response);
284+
}
278285

279286
}

0 commit comments

Comments
 (0)