Skip to content

Commit

Permalink
chore: bumps easypost lib from v5 to v6
Browse files Browse the repository at this point in the history
  • Loading branch information
Justintime50 committed Feb 10, 2023
1 parent e0d9ed0 commit b51df39
Show file tree
Hide file tree
Showing 12 changed files with 505 additions and 7,821 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# CHANGELOG

## v0.7.0 (2022-09-10)
## v0.8.0 (2023-02-10)

- Bumps EasyPost library from v5 to v6 which introduces thread-safety and various other improvements

## v0.7.0 (2023-02-10)

- Bumps PHP from 8.1 to 8.2
- Bumps all minor dependency versions
Expand Down
20 changes: 13 additions & 7 deletions src/app/Http/Controllers/AddressController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Http\Controllers;

use EasyPost\Address;
use EasyPost\Exception\General\EasyPostException;

class AddressController extends Controller
{
Expand All @@ -26,8 +26,10 @@ public function createAddress()
'email' => 'nullable|string',
]);

$client = request()->get('client');

try {
$address = Address::create(
$address = $client->address->create(
[
'name' => request()->get('name'),
'company' => request()->get('company'),
Expand All @@ -41,7 +43,7 @@ public function createAddress()
'email' => request()->get('email'),
]
);
} catch (\EasyPost\Error $exception) {
} catch (EasyPostException $exception) {
return back()->withError($exception->getMessage())->withInput();
}

Expand All @@ -56,9 +58,11 @@ public function createAddress()
*/
public function retrieveAddress(string $id)
{
$client = request()->get('client');

try {
$json = Address::retrieve($id);
} catch (\EasyPost\Error $exception) {
$json = $client->address->retrieve($id);
} catch (EasyPostException $exception) {
return back()->withError($exception->getMessage())->withInput();
}

Expand All @@ -72,9 +76,11 @@ public function retrieveAddress(string $id)
*/
public function retrieveAddresses()
{
$client = request()->get('client');

try {
$json = Address::all();
} catch (\EasyPost\Error $exception) {
$json = $client->address->all();
} catch (EasyPostException $exception) {
return back()->withError($exception->getMessage())->withInput();
}

Expand Down
16 changes: 9 additions & 7 deletions src/app/Http/Controllers/CarrierController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

namespace App\Http\Controllers;

use EasyPost\CarrierAccount;
use EasyPost\EasyPost;
use Illuminate\Http\Request;
use EasyPost\Exception\General\EasyPostException;

class CarrierController extends Controller
{
Expand All @@ -16,9 +14,11 @@ class CarrierController extends Controller
*/
public function retrieveCarrier(string $id)
{
$client = request()->get('client');

try {
$carriers = CarrierAccount::retrieve($id);
} catch (\EasyPost\Error $exception) {
$carriers = $client->carrierAccount->retrieve($id);
} catch (EasyPostException $exception) {
return back()->withError($exception->getMessage())->withInput();
}

Expand All @@ -35,9 +35,11 @@ public function retrieveCarrier(string $id)
*/
public function retrieveCarriers()
{
$client = request()->get('client');

try {
$response = CarrierAccount::all();
} catch (\EasyPost\Error $exception) {
$response = $client->carrierAccount->all();
} catch (EasyPostException $exception) {
return back()->withError($exception->getMessage())->withInput();
}

Expand Down
25 changes: 15 additions & 10 deletions src/app/Http/Controllers/InsuranceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

namespace App\Http\Controllers;

use EasyPost\Address;
use EasyPost\Insurance;
use EasyPost\Exception\General\EasyPostException;

class InsuranceController extends Controller
{
Expand Down Expand Up @@ -56,9 +55,11 @@ public function createInsurance()
'amount' => 'required|string|max:5000',
]);

$client = request()->get('client');

try {
if (request()->get('to_address') != null) {
$toAddress = Address::retrieve(request()->get('to_address'));
$toAddress = $client->address->retrieve(request()->get('to_address'));
} else {
$toAddress = [
'verify' => ['delivery'],
Expand All @@ -74,7 +75,7 @@ public function createInsurance()
}

if (request()->get('from_address') != null) {
$fromAddress = Address::retrieve(request()->get('from_address'));
$fromAddress = $client->address->retrieve(request()->get('from_address'));
} else {
$fromAddress = [
'verify' => ['delivery'],
Expand All @@ -89,7 +90,7 @@ public function createInsurance()
];
}

$insurance = Insurance::create(
$insurance = $client->insurance->create(
[
'to_address' => $toAddress,
'from_address' => $fromAddress,
Expand All @@ -98,7 +99,7 @@ public function createInsurance()
'amount' => request()->get('amount'),
]
);
} catch (\EasyPost\Error $exception) {
} catch (EasyPostException $exception) {
return back()->withError($exception->getMessage())->withInput();
}

Expand All @@ -116,9 +117,11 @@ public function createInsurance()
*/
public function retrieveInsurance(string $id)
{
$client = request()->get('client');

try {
$response = Insurance::retrieve($id);
} catch (\EasyPost\Error $exception) {
$response = $client->insurance->retrieve($id);
} catch (EasyPostException $exception) {
return back()->withError($exception->getMessage())->withInput();
}

Expand All @@ -133,9 +136,11 @@ public function retrieveInsurance(string $id)
*/
public function retrieveInsurances()
{
$client = request()->get('client');

try {
$json = Insurance::all();
} catch (\EasyPost\Error $exception) {
$json = $client->insurance->all();
} catch (EasyPostException $exception) {
return back()->withError($exception->getMessage())->withInput();
}

Expand Down
14 changes: 7 additions & 7 deletions src/app/Http/Controllers/ParcelController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Http\Controllers;

use EasyPost\Parcel;
use EasyPost\Exception\General\EasyPostException;

class ParcelController extends Controller
{
Expand All @@ -25,14 +25,16 @@ public function createParcel()
]);
}

$client = request()->get('client');

try {
if (request()->get('predefined_package') != null) {
$parcel = Parcel::create([
$parcel = $client->parcel->create([
'predefined_package' => request()->get('predefined_package'),
'weight' => request()->get('weight'),
]);
} else {
$parcel = Parcel::create(
$parcel = $client->parcel->create(
[
'length' => request()->get('length'),
'width' => request()->get('width'),
Expand All @@ -41,13 +43,11 @@ public function createParcel()
]
);
}
} catch (\EasyPost\Error $exception) {
} catch (EasyPostException $exception) {
return back()->withError($exception->getMessage())->withInput();
}

$response = $parcel;

session()->flash('message', 'PARCEL CREATED');
return view('app')->with(['json' => $response]);
return view('app')->with(['json' => $parcel]);
}
}
3 changes: 2 additions & 1 deletion src/app/Http/Controllers/SearchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Http\Controllers;

use EasyPost;
use EasyPost\Exception\General\EasyPostException;

const OBJECT_ID_PREFIXES = [
'adr' => EasyPost\Address::class,
Expand Down Expand Up @@ -48,7 +49,7 @@ public function searchRecord()

try {
$response = OBJECT_ID_PREFIXES[$idPrefix]::retrieve($id);
} catch (\EasyPost\Error $exception) {
} catch (EasyPostException $exception) {
return back()->withError($exception->getMessage())->withInput();
}

Expand Down
Loading

0 comments on commit b51df39

Please sign in to comment.