1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Actualys\Bundle\DrupalCommerceConnectorBundle\Webservice; |
4
|
|
|
|
5
|
|
|
use Actualys\Bundle\DrupalCommerceConnectorBundle\Webservice\Transport\DrupalRestClient; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Class Webservice |
9
|
|
|
* @package Actualys\Bundle\DrupalCommerceConnectorBundle\Webservice |
10
|
|
|
*/ |
11
|
|
|
class Webservice |
12
|
|
|
{ |
13
|
|
|
const REST_ACTION_SEND_FAMILY = 'family'; |
14
|
|
|
const REST_ACTION_SEND_PRODUCT = 'product'; |
15
|
|
|
const REST_ACTION_SEND_ATTRIBUTE_OPTION = 'option'; |
16
|
|
|
const REST_ACTION_SEND_CATEGORY = 'category'; |
17
|
|
|
const REST_ACTION_SEND_GROUP = 'group'; |
18
|
|
|
const REST_ACTION_SEND_ASSOCIATION = 'association'; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @var DrupalRestClient |
22
|
|
|
*/ |
23
|
|
|
protected $drupalRestClient; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @param DrupalRestClient $drupalRestClient |
27
|
|
|
*/ |
28
|
|
|
public function __construct(DrupalRestClient $drupalRestClient) |
29
|
|
|
{ |
30
|
|
|
$this->drupalRestClient = $drupalRestClient; |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @param array $parameters |
35
|
|
|
* @throws Exception\RestConnectionException |
36
|
|
|
*/ |
37
|
|
|
public function setParameters(array $parameters) |
38
|
|
|
{ |
39
|
|
|
$this->drupalRestClient->setParameters($parameters); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @param array $family |
44
|
|
|
* @return \Guzzle\Http\Message\Response|mixed |
45
|
|
|
*/ |
46
|
|
|
public function sendFamily($family) |
47
|
|
|
{ |
48
|
|
|
return $this->drupalRestClient->call( |
49
|
|
|
self::REST_ACTION_SEND_FAMILY, |
50
|
|
|
$family |
51
|
|
|
); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @param $option |
56
|
|
|
* @return \Guzzle\Http\Message\Response|mixed |
57
|
|
|
*/ |
58
|
|
|
public function sendAttributeOption($attributeOption) |
59
|
|
|
{ |
60
|
|
|
return $this->drupalRestClient->call( |
61
|
|
|
self::REST_ACTION_SEND_ATTRIBUTE_OPTION, |
62
|
|
|
$attributeOption |
63
|
|
|
); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @param array $category |
68
|
|
|
* @return \Guzzle\Http\Message\Response|mixed |
69
|
|
|
*/ |
70
|
|
|
public function sendCategory($category) |
71
|
|
|
{ |
72
|
|
|
return $this->drupalRestClient->call( |
73
|
|
|
self::REST_ACTION_SEND_CATEGORY, |
74
|
|
|
$category |
75
|
|
|
); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @param array $group |
80
|
|
|
* @return \Guzzle\Http\Message\Response|mixed |
81
|
|
|
*/ |
82
|
|
|
public function sendGroup($group) |
83
|
|
|
{ |
84
|
|
|
return $this->drupalRestClient->call( |
85
|
|
|
self::REST_ACTION_SEND_GROUP, |
86
|
|
|
$group |
87
|
|
|
); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* @param array $association |
92
|
|
|
* @return \Guzzle\Http\Message\Response|mixed |
93
|
|
|
*/ |
94
|
|
|
public function sendAssociation($association) |
95
|
|
|
{ |
96
|
|
|
return $this->drupalRestClient->call( |
97
|
|
|
self::REST_ACTION_SEND_ASSOCIATION, |
98
|
|
|
$association |
99
|
|
|
); |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* @param array $product |
104
|
|
|
* @return \Guzzle\Http\Message\Response|mixed |
105
|
|
|
*/ |
106
|
|
|
public function sendProduct($product) |
107
|
|
|
{ |
108
|
|
|
return $this->drupalRestClient->call( |
109
|
|
|
self::REST_ACTION_SEND_PRODUCT, |
110
|
|
|
$product |
111
|
|
|
); |
112
|
|
|
} |
113
|
|
|
} |
114
|
|
|
|