Skip to content

Commit f712139

Browse files
committed
- Copy EndShipper to main namespace
- Mark beta EndShipper as deprecated - Update unit tests - fail until endpoint is live
1 parent a767cc5 commit f712139

File tree

7 files changed

+79
-456
lines changed

7 files changed

+79
-456
lines changed

lib/EasyPost/Beta/EndShipper.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
* @property string $name
1717
* @property string $company
1818
* @property string $phone
19+
*
20+
* @deprecated Use EasyPost\EndShipper instead.
1921
*/
2022

2123
class EndShipper extends EasypostResource

lib/EasyPost/EndShipper.php

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?php
2+
3+
namespace EasyPost;
4+
5+
/**
6+
* @package EasyPost\Beta
7+
* @property string $id
8+
* @property string $street1
9+
* @property string $street2
10+
* @property string $city
11+
* @property string $state
12+
* @property string $zip
13+
* @property string $country
14+
* @property string $name
15+
* @property string $company
16+
* @property string $phone
17+
*/
18+
19+
class EndShipper extends EasypostResource
20+
{
21+
/**
22+
* Create an EndShipper object.
23+
*
24+
* @param mixed $params
25+
* @param string $apiKey
26+
* @return mixed
27+
*/
28+
public static function create($params = null, $apiKey = null)
29+
{
30+
$wrappedParams = [];
31+
$wrappedParams['address'] = $params;
32+
33+
return self::createResource(get_class(), $wrappedParams, $apiKey);
34+
}
35+
36+
/**
37+
* Retrieve an EndShipper object.
38+
*
39+
* @param string $id
40+
* @param string $apiKey
41+
* @return mixed
42+
*/
43+
public static function retrieve($id, $apiKey = null)
44+
{
45+
return self::retrieveResource(get_class(), $id, $apiKey);
46+
}
47+
48+
/**
49+
* Retrieve all EndShipper objects.
50+
*
51+
* @param mixed $params
52+
* @param string $apiKey
53+
* @return mixed
54+
*/
55+
public static function all($params = null, $apiKey = null)
56+
{
57+
return self::allResources(get_class(), $params, $apiKey);
58+
}
59+
60+
/**
61+
* Update (save) an EndShipper object.
62+
*
63+
* @return $this
64+
*/
65+
public function save()
66+
{
67+
// We are passing the `Address` class here so that the request gets properly wrapped in the required object.
68+
return $this->saveResource('EasyPost\Address', false, 'put');
69+
}
70+
}

test/EasyPost/Beta/EndShipperTest.php renamed to test/EasyPost/EndShipperTest.php

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

33
namespace EasyPost\Test;
44

5-
use EasyPost\Beta\EndShipper;
5+
use EasyPost\EndShipper;
66
use EasyPost\EasyPost;
77
use VCR\VCR;
88

@@ -63,12 +63,15 @@ public function testAll()
6363
{
6464
VCR::insertCassette('end_shipper/all.yml');
6565

66-
$endShipper = EndShipper::all([
66+
$endShippers = EndShipper::all([
6767
'page_size' => Fixture::pageSize(),
6868
]);
6969

70-
$this->assertLessThanOrEqual($endShipper, Fixture::pageSize());
71-
$this->assertContainsOnlyInstancesOf('\EasyPost\Beta\EndShipper', $endShipper);
70+
$endShipperArray = $endShippers['end_shippers'];
71+
72+
$this->assertLessThanOrEqual($endShipperArray, Fixture::pageSize());
73+
$this->assertNotNull($endShippers['has_more']);
74+
$this->assertContainsOnlyInstancesOf('\EasyPost\EndShipper', $endShipperArray);
7275
}
7376

7477
/**

test/cassettes/end_shipper/all.yml

Lines changed: 0 additions & 75 deletions
This file was deleted.

test/cassettes/end_shipper/create.yml

Lines changed: 0 additions & 76 deletions
This file was deleted.

0 commit comments

Comments
 (0)