Skip to content

Commit

Permalink
Update to UPS-API 0.8. (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
ptondereau authored Aug 19, 2019
1 parent eedc667 commit 4405275
Show file tree
Hide file tree
Showing 23 changed files with 125 additions and 295 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"php": "^7.1.3",
"illuminate/contracts": "5.5.*|5.6.*|5.7.*|5.8.*",
"illuminate/support": "5.5.*|5.6.*|5.7.*|5.8.*",
"gabrielbull/ups-api": "^0.7.6"
"gabrielbull/ups-api": "^0.8"
},
"require-dev": {
"graham-campbell/analyzer": "^2.1",
Expand Down
7 changes: 1 addition & 6 deletions src/Facades/UpsAddressValidation.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,7 @@
*/
class UpsAddressValidation extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
protected static function getFacadeAccessor(): string
{
return 'ups.address-validation';
}
Expand Down
7 changes: 1 addition & 6 deletions src/Facades/UpsLocator.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,7 @@
*/
class UpsLocator extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
protected static function getFacadeAccessor(): string
{
return 'ups.locator';
}
Expand Down
7 changes: 1 addition & 6 deletions src/Facades/UpsQuantumView.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,7 @@
*/
class UpsQuantumView extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
protected static function getFacadeAccessor(): string
{
return 'ups.quantum-view';
}
Expand Down
7 changes: 1 addition & 6 deletions src/Facades/UpsRate.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,7 @@
*/
class UpsRate extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
protected static function getFacadeAccessor(): string
{
return 'ups.rate';
}
Expand Down
18 changes: 18 additions & 0 deletions src/Facades/UpsRateTimeInTransit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Ptondereau\LaravelUpsApi\Facades;

use Illuminate\Support\Facades\Facade;

/**
* This is the RateTimeInTransit facade class.
*
* @author Pierre Tondereau <[email protected]>
*/
class UpsRateTimeInTransit extends Facade
{
protected static function getFacadeAccessor(): string
{
return 'ups.ratetimeintransit';
}
}
7 changes: 1 addition & 6 deletions src/Facades/UpsShipping.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,7 @@
*/
class UpsShipping extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
protected static function getFacadeAccessor(): string
{
return 'ups.shipping';
}
Expand Down
7 changes: 1 addition & 6 deletions src/Facades/UpsSimpleAddressValidation.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,7 @@
*/
class UpsSimpleAddressValidation extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
protected static function getFacadeAccessor(): string
{
return 'ups.simple-address-validation';
}
Expand Down
7 changes: 1 addition & 6 deletions src/Facades/UpsTimeInTransit.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,7 @@
*/
class UpsTimeInTransit extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
protected static function getFacadeAccessor(): string
{
return 'ups.time-in-transit';
}
Expand Down
7 changes: 1 addition & 6 deletions src/Facades/UpsTracking.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,7 @@
*/
class UpsTracking extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
protected static function getFacadeAccessor(): string
{
return 'ups.tracking';
}
Expand Down
7 changes: 1 addition & 6 deletions src/Facades/UpsTradeability.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,7 @@
*/
class UpsTradeability extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
protected static function getFacadeAccessor(): string
{
return 'ups.tradeability';
}
Expand Down
109 changes: 31 additions & 78 deletions src/UpsApiServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Ups\Locator;
use Ups\QuantumView;
use Ups\Rate;
use Ups\RateTimeInTransit;
use Ups\Shipping;
use Ups\SimpleAddressValidation;
use Ups\TimeInTransit;
Expand All @@ -23,22 +24,12 @@
*/
class UpsApiServiceProvider extends ServiceProvider
{
/**
* Boot the service provider.
*
* @return void
*/
public function boot()
public function boot(): void
{
$this->setupConfig();
}

/**
* Register the service provider.
*
* @return void
*/
public function register()
public function register(): void
{
$this->registerAddressValidation();
$this->registerSimpleAddressValidation();
Expand All @@ -49,14 +40,10 @@ public function register()
$this->registerLocator();
$this->registerTradeability();
$this->registerShipping();
$this->registerRateTimeInTransit();
}

/**
* Setup the config.
*
* @return void
*/
protected function setupConfig()
protected function setupConfig(): void
{
$source = realpath(__DIR__.'/../config/ups.php');
if ($this->app instanceof LaravelApplication && $this->app->runningInConsole()) {
Expand All @@ -67,12 +54,7 @@ protected function setupConfig()
$this->mergeConfigFrom($source, 'ups');
}

/**
* Register the AddressValidation class.
*
* @return void
*/
protected function registerAddressValidation()
protected function registerAddressValidation(): void
{
$this->app->singleton('ups.address-validation', function (Container $app) {
$config = $app->config->get('ups');
Expand All @@ -88,12 +70,7 @@ protected function registerAddressValidation()
});
}

/**
* Register the SimpleAddressValidation class.
*
* @return void
*/
protected function registerSimpleAddressValidation()
protected function registerSimpleAddressValidation(): void
{
$this->app->singleton('ups.simple-address-validation', function (Container $app) {
$config = $app->config->get('ups');
Expand All @@ -109,12 +86,7 @@ protected function registerSimpleAddressValidation()
});
}

/**
* Register the QuantumView class.
*
* @return void
*/
protected function registerQuantumView()
protected function registerQuantumView(): void
{
$this->app->singleton('ups.quantum-view', function (Container $app) {
$config = $app->config->get('ups');
Expand All @@ -130,12 +102,7 @@ protected function registerQuantumView()
});
}

/**
* Register the Tracking class.
*
* @return void
*/
protected function registerTracking()
protected function registerTracking(): void
{
$this->app->singleton('ups.tracking', function (Container $app) {
$config = $app->config->get('ups');
Expand All @@ -151,12 +118,7 @@ protected function registerTracking()
});
}

/**
* Register the Rate class.
*
* @return void
*/
protected function registerRate()
protected function registerRate(): void
{
$this->app->singleton('ups.rate', function (Container $app) {
$config = $app->config->get('ups');
Expand All @@ -171,12 +133,7 @@ protected function registerRate()
});
}

/**
* Register the TimeInTransit class.
*
* @return void
*/
protected function registerTimeInTransit()
protected function registerTimeInTransit(): void
{
$this->app->singleton('ups.time-in-transit', function (Container $app) {
$config = $app->config->get('ups');
Expand All @@ -192,12 +149,7 @@ protected function registerTimeInTransit()
});
}

/**
* Register the Locator class.
*
* @return void
*/
protected function registerLocator()
protected function registerLocator(): void
{
$this->app->singleton('ups.locator', function (Container $app) {
$config = $app->config->get('ups');
Expand All @@ -213,12 +165,7 @@ protected function registerLocator()
});
}

/**
* Register the Tradeability class.
*
* @return void
*/
protected function registerTradeability()
protected function registerTradeability(): void
{
$this->app->singleton('ups.tradeability', function (Container $app) {
$config = $app->config->get('ups');
Expand All @@ -234,12 +181,7 @@ protected function registerTradeability()
});
}

/**
* Register the Tradeability class.
*
* @return void
*/
protected function registerShipping()
protected function registerShipping(): void
{
$this->app->singleton('ups.shipping', function (Container $app) {
$config = $app->config->get('ups');
Expand All @@ -255,12 +197,22 @@ protected function registerShipping()
});
}

/**
* Get the services provided by the provider.
*
* @return string[]
*/
public function provides()
protected function registerRateTimeInTransit(): void
{
$this->app->singleton('ups.ratetimeintransit', function (Container $app) {
$config = $app->config->get('ups');

return new RateTimeInTransit(
$config['access_key'],
$config['user_id'],
$config['password'],
$config['sandbox'],
$app->make('log')
);
});
}

public function provides(): array
{
return [
'ups.address-validation',
Expand All @@ -272,6 +224,7 @@ public function provides()
'ups.locator',
'ups.tradeability',
'ups.shipping',
'ups.ratetimeintransit',
];
}
}
Loading

0 comments on commit 4405275

Please sign in to comment.