Skip to content

Commit

Permalink
fix: address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Justintime50 committed Oct 19, 2021
1 parent df2ccd1 commit 6b45680
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 119 deletions.
8 changes: 2 additions & 6 deletions lib/EasyPost/Requestor.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ public static function utf8($value)
*/
private static function _encodeObjects($data)
{
if ($data === "") {
return null;
} elseif (is_null($data)) {
if (is_null($data)) {
return array();
} elseif ($data instanceof EasypostResource) {
return array("id" => self::utf8($data->id));
Expand All @@ -68,9 +66,7 @@ private static function _encodeObjects($data)
} elseif (is_array($data)) {
$resource = array();
foreach ($data as $k => $v) {
if (empty($data)) {
return null;
} elseif (!is_null($v)) {
if (!is_null($v) and ($v !== "") and (!is_array($v) or !empty($v))) {
$resource[$k] = self::_encodeObjects($v);
}
}
Expand Down
4 changes: 3 additions & 1 deletion test/EasyPost/Test/ShipmentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,13 +218,15 @@ public function testCreateEmptyObjects()
),
"options" => null,
"tax_identifiers" => null,
"reference" => "",
));

$this->assertInstanceOf('\EasyPost\Shipment', $shipment);
$this->assertIsString($shipment->id);
$this->assertStringMatchesFormat('shp_%s', $shipment->id);
$this->assertNotEmpty($shipment->options); // The EasyPost API populates some default values here
$this->assertEmpty($shipment->customs_info->customs_items);
$this->assertEmpty($shipment->customs_info);
$this->assertNull($shipment->reference);
}

/**
Expand Down
50 changes: 25 additions & 25 deletions test/cassettes/shipments/buy.yml

Large diffs are not rendered by default.

61 changes: 30 additions & 31 deletions test/cassettes/shipments/create.yml

Large diffs are not rendered by default.

Loading

0 comments on commit 6b45680

Please sign in to comment.