forked from Arkitecht/fedex-laravel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFedEx.php
101 lines (78 loc) · 2.56 KB
/
FedEx.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php
/**
* User: sutter
* Date: 1/4/16
* Time: 8:09 PM
*/
namespace Arkitecht\FedEx\Laravel;
use Arkitecht\FedEx\Services\RateService;
use Arkitecht\FedEx\Services\ShipService;
use Arkitecht\FedEx\Services\TrackService;
use Arkitecht\FedEx\Structs\ClientDetail;
use Arkitecht\FedEx\Structs\ProcessShipmentRequest;
use Arkitecht\FedEx\Structs\RateRequest;
use Arkitecht\FedEx\Structs\TrackRequest;
use Arkitecht\FedEx\Structs\WebAuthenticationCredential;
use Arkitecht\FedEx\Structs\WebAuthenticationDetail;
use Illuminate\Config\Repository;
class FedEx
{
/**
* @var array
*/
protected $config;
public function __construct(array $config)
{
$this->config = $config;
}
public function rateRequest()
{
$rateRequest = new RateRequest();
$this->setDetails($rateRequest);
return $rateRequest;
}
public function rateService(array $wsdlOptions = array(), $resetSoapClient = true)
{
$rateService = new RateService($wsdlOptions, $resetSoapClient, $this->config['beta']);
return $rateService;
}
public function trackRequest()
{
$trackRequest = new TrackRequest();
$this->setDetails($trackRequest);
return $trackRequest;
}
function trackService(array $wsdlOptions = array(), $resetSoapClient = true)
{
$trackService = new TrackService($wsdlOptions, $resetSoapClient, $this->config['beta']);
return $trackService;
}
public function shipRequest()
{
$shipRequest = new ProcessShipmentRequest();
$this->setDetails($shipRequest);
return $shipRequest;
}
function shipService(array $wsdlOptions = array(), $resetSoapClient = true)
{
$shipService = new ShipService($wsdlOptions, $resetSoapClient, $this->config['beta']);
return $shipService;
}
public function setDetails(&$request)
{
$request->setWebAuthenticationDetail($this->getWebAuthenticationDetail());
$request->setClientDetail($this->getClientDetail());
}
public function getWebAuthenticationDetail()
{
$webAuthenticationCredential = new WebAuthenticationCredential($this->config['key'], $this->config['password']);
$webAuthenticationDetail = new WebAuthenticationDetail();
$webAuthenticationDetail->setUserCredential($webAuthenticationCredential);
return $webAuthenticationDetail;
}
public function getClientDetail()
{
$clientDetail = new ClientDetail($this->config['account'], $this->config['meter']);
return $clientDetail;
}
}