Skip to content

Commit a561a26

Browse files
authored
Merge pull request #365 from EasyPost/param_wrapper
param wrapper
2 parents 95c433b + 0f250a0 commit a561a26

21 files changed

+57
-98
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# CHANGELOG
22

3-
## Next Release
3+
## v8.2.0 (2025-06-18)
44

55
- Adds the following functions
66
- `shipment.createAndBuyLuma`

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "easypost/easypost-php",
33
"description": "EasyPost Shipping API Client Library for PHP",
4-
"version": "8.1.0",
4+
"version": "8.2.0",
55
"keywords": [
66
"shipping",
77
"api",

lib/EasyPost/Constant/Constants.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ abstract class Constants
1111
const BETA_API_VERSION = 'beta';
1212

1313
// Library constants
14-
const LIBRARY_VERSION = '8.0.1';
14+
const LIBRARY_VERSION = '8.2.0';
1515
const SUPPORT_EMAIL = '[email protected]';
1616

1717
// Validation

lib/EasyPost/Service/AddressService.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,7 @@ public function create(mixed $params = null): mixed
7979
*/
8080
public function createAndVerify(mixed $params = null): mixed
8181
{
82-
if (!isset($params['address']) || !is_array($params['address'])) {
83-
$clone = $params;
84-
unset($params);
85-
$params['address'] = $clone;
86-
}
82+
$params = InternalUtil::wrapParams($params, 'address');
8783

8884
$url = self::classUrl(self::serviceModelClassName(self::class));
8985
$response = Requestor::request($this->client, 'post', $url . '/create_and_verify', $params);

lib/EasyPost/Service/BatchService.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,7 @@ public function all(mixed $params = null): mixed
4040
*/
4141
public function create(mixed $params = null): mixed
4242
{
43-
if (!isset($params['batch']) || !is_array($params['batch'])) {
44-
$clone = $params;
45-
unset($params);
46-
$params['batch'] = $clone;
47-
}
43+
$params = InternalUtil::wrapParams($params, 'batch');
4844

4945
return self::createResource(self::serviceModelClassName(self::class), $params);
5046
}

lib/EasyPost/Service/CarrierAccountService.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,7 @@ public function all(mixed $params = null): mixed
4343
*/
4444
public function update(string $id, mixed $params): mixed
4545
{
46-
if (!isset($params['carrier_account']) || !is_array($params['carrier_account'])) {
47-
$clone = $params;
48-
unset($params);
49-
$params['carrier_account'] = $clone;
50-
}
46+
$params = InternalUtil::wrapParams($params, 'carrier_account');
5147

5248
return self::updateResource(self::serviceModelClassName(self::class), $id, $params);
5349
}

lib/EasyPost/Service/CustomsInfoService.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace EasyPost\Service;
44

5+
use EasyPost\Util\InternalUtil;
6+
57
/**
68
* CustomsInfo service containing all the logic to make API calls.
79
*/
@@ -26,11 +28,7 @@ public function retrieve(string $id): mixed
2628
*/
2729
public function create(mixed $params = null): mixed
2830
{
29-
if (!isset($params['customs_info']) || !is_array($params['customs_info'])) {
30-
$clone = $params;
31-
unset($params);
32-
$params['customs_info'] = $clone;
33-
}
31+
$params = InternalUtil::wrapParams($params, 'customs_info');
3432

3533
return self::createResource(self::serviceModelClassName(self::class), $params);
3634
}

lib/EasyPost/Service/CustomsItemService.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace EasyPost\Service;
44

5+
use EasyPost\Util\InternalUtil;
6+
57
/**
68
* CustomsItem service containing all the logic to make API calls.
79
*/
@@ -26,11 +28,7 @@ public function retrieve(string $id): mixed
2628
*/
2729
public function create(mixed $params = null): mixed
2830
{
29-
if (!isset($params['customs_item']) || !is_array($params['customs_item'])) {
30-
$clone = $params;
31-
unset($params);
32-
$params['customs_item'] = $clone;
33-
}
31+
$params = InternalUtil::wrapParams($params, 'customs_item');
3432

3533
return self::createResource(self::serviceModelClassName(self::class), $params);
3634
}

lib/EasyPost/Service/EndShipperService.php

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

33
namespace EasyPost\Service;
44

5+
use EasyPost\Util\InternalUtil;
6+
57
/**
68
* EndShipper service containing all the logic to make API calls.
79
*/
@@ -15,11 +17,7 @@ class EndShipperService extends BaseService
1517
*/
1618
public function create(mixed $params = null): mixed
1719
{
18-
if (!isset($params['address']) || !is_array($params['address'])) {
19-
$clone = $params;
20-
unset($params);
21-
$params['address'] = $clone;
22-
}
20+
$params = InternalUtil::wrapParams($params, 'address');
2321

2422
return self::createResource(self::serviceModelClassName(self::class), $params);
2523
}
@@ -55,11 +53,7 @@ public function all(mixed $params = null): mixed
5553
*/
5654
public function update(string $id, mixed $params): mixed
5755
{
58-
if (!isset($params['address']) || !is_array($params['address'])) {
59-
$clone = $params;
60-
unset($params);
61-
$params['address'] = $clone;
62-
}
56+
$params = InternalUtil::wrapParams($params, 'address');
6357

6458
return self::updateResource(self::serviceModelClassName(self::class), $id, $params, 'put');
6559
}

lib/EasyPost/Service/InsuranceService.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,7 @@ public function getNextPage(mixed $insurances, ?int $pageSize = null): mixed
5252
*/
5353
public function create(mixed $params = null): mixed
5454
{
55-
if (!isset($params['insurance']) || !is_array($params['insurance'])) {
56-
$clone = $params;
57-
unset($params);
58-
$params['insurance'] = $clone;
59-
}
55+
$params = InternalUtil::wrapParams($params, 'insurance');
6056

6157
return self::createResource(self::serviceModelClassName(self::class), $params);
6258
}

0 commit comments

Comments
 (0)