Passed
Push — master ( 25b3e2...08b0e3 )
by Nicholas
01:35
created

Atdconnect::getLocation()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Nickcheek\Atdconnect;
4
5
use SoapClient;
6
7
8
class Atdconnect
9
{
10
    
11
    public static $wsshead;
12
    private static $statuswsdl		= 'https://testws.atdconnect.com/ws/3_4/orderStatus.wsdl';
13
    private static $brandwsdl 		= 'https://testws.atdconnect.com/ws/3_4/brandstyles.wsdl';
14
    private static $locationwsdl	= 'https://testws.atdconnect.com/ws/3_4/locations.wsdl';
15
    private static $productwsdl 	= 'https://testws.atdconnect.com/ws/3_4/products.wsdl';
16
    private static $orderwsdl		= 'https://testws.atdconnect.com/ws/3_4/orders.wsdl';
17
    
18
    protected static $location;
19
    
20
    
21
    public function __construct()
22
    {
23
        $config = include('config/config.php');
24
        self::$wsshead = $this->getWSSHeader($config->user, $config->pass, $config->client);
25
    }
26
    
27
    public static function getWSSHeader($user, $pass, $client)
28
    {
29
        $xml = '
30
		<wsse:Security SOAP-ENV:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
31
		    <wsse:UsernameToken atd:clientId="' . $client . '" xmlns:atd="http://api.atdconnect.com/atd">
32
		        <wsse:Username>' . $user . '</wsse:Username>
33
		        <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">' . $pass . '</wsse:Password>
34
		    </wsse:UsernameToken>
35
		</wsse:Security>
36
		';
37
        
38
        return new \SoapHeader('http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd', 'Security', new \SoapVar($xml, XSD_ANYXML), true);
39
    }
40
    
41
    public static function apiCall($call,$query,$service)
42
    {
43
        $client     = new \SoapClient($service);
44
        $client->__setSoapHeaders(self::$wsshead);
45
        $response 	= $client->$call($query);
46
        return $response;
47
    }
48
    
49
    public function setLocation($location)
50
    {
51
	    static::$location = $location;
52
        return static::$location;
53
    }
54
    
55
    public function getLocation()
56
    {
57
	    return static::$location;
58
    }
59
    
60
    //************************************************
61
    //               Location Service
62
    //************************************************
63
    
64
    public static function getLocationByCriteria()
65
    {
66
        return self::apiCall('getLocationByCriteria','',self::$locationwsdl);
67
    }
68
    
69
    public static function getLocationCutoffTimes()
70
    {
71
        return self::apiCall('getLocationCutoffTimes',['location' => static::$location],self::$locationwsdl);
72
    }
73
    
74
    public static function getDistributionCenter($dc = '059')
75
    {
76
        return self::apiCall('getDistributionCenter',array('servicingDC' => $dc),self::$locationwsdl);
77
    }
78
    
79
        
80
    //************************************************
81
    //               Brand Styles Service
82
    //************************************************
83
    
84
    
85
    public static function getBrand($product = null)
86
    {
87
    	return self::apiCall('getBrand',array('locationNumber' => static::$location,'productGroup' => $product),self::$brandwsdl);
88
    }
89
    
90
    public static function getStyle($brand = null)
91
    {
92
    	return self::apiCall('getStyle',array('locationNumber' => static::$location,'brand' => $brand),self::$brandwsdl);
93
    }
94
    
95
    
96
    //************************************************
97
    //               Products Service
98
    //************************************************
99
    
100
    
101
    
102
    
103
    public static function getProdBrand($product = null)
104
    {
105
    	return self::apiCall('getProdBrand',array('locationNumber' => static::$location,'productGroup' => $product),self::$productwsdl);
106
    }
107
    
108
    public static function getProductByCriteria($search)
109
    {
110
        return self::apiCall('getProductByCriteria',$search,self::$productwsdl);
111
    }
112
    
113
    public static function getProductByKeyword($search)
114
    {
115
        return self::apiCall('getProductByKeyword',$search,self::$productwsdl);
116
    }
117
    
118
    //************************************************
119
    //               Order Service
120
    //************************************************
121
    
122
    public static function placeOrder($order)
123
    {
124
        return self::apiCall('placeOrder',$order,self::$orderwsdl);
125
    }
126
    
127
    public static function previewOrder($order)
128
    {
129
        return self::apiCall('previewOrder',$order,self::$orderwsdl);
130
    }
131
    
132
    //************************************************
133
    //               Order Status Service
134
    //************************************************
135
    
136
    public static function getOrderDetail($status)
137
    {
138
        return self::apiCall('getOrderDetail',$status,self::$statuswsdl);
139
    }
140
    
141
    public static function getOrderStatusByCriteria($criteria)
142
    {
143
        return self::apiCall('getOrderStatusByCriteria',$status,self::$statuswsdl);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $status seems to be never defined.
Loading history...
144
    }
145
    
146
    
147
    
148
    
149
    
150
}
151