Skip to content

Commit 8d45955

Browse files
committed
Add an ability to update customer's properties
1 parent f0b3481 commit 8d45955

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

src/Api/Operator/Customer.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function getAll()
6666
*/
6767
public function enable(string $field, $value): bool
6868
{
69-
return $this->setProperty($field, $value, 'status', 0);
69+
return $this->setProperties($field, $value, ['status' => 0]);
7070
}
7171

7272
/**
@@ -77,24 +77,25 @@ public function enable(string $field, $value): bool
7777
*/
7878
public function disable(string $field, $value): bool
7979
{
80-
return $this->setProperty($field, $value, 'status', 1);
80+
return $this->setProperties($field, $value, ['status' => 1]);
8181
}
8282

8383
/**
8484
* @param string $field
8585
* @param int|string $value
86-
* @param string $property
87-
* @param int|string $propertyValue
86+
* @param array $properties
8887
*
8988
* @return bool
9089
*/
91-
public function setProperty(string $field, $value, string $property, $propertyValue): bool
90+
public function setProperties(string $field, $value, array $properties): bool
9291
{
9392
$packet = $this->_client->getPacket();
9493
$setTag = $packet->addChild($this->_wrapperTag)->addChild('set');
9594
$setTag->addChild('filter')->addChild($field, (string) $value);
9695
$genInfoTag = $setTag->addChild('values')->addChild('gen_info');
97-
$genInfoTag->addChild($property, (string) $propertyValue);
96+
foreach ($properties as $property => $propertyValue) {
97+
$genInfoTag->addChild($property, (string) $propertyValue);
98+
}
9899

99100
$response = $this->_client->request($packet);
100101

tests/CustomerTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,4 +105,18 @@ public function testDisable()
105105

106106
static::$_client->customer()->delete('id', $customer->id);
107107
}
108+
109+
public function testSetProperties()
110+
{
111+
$customer = static::$_client->customer()->create($this->_customerProperties);
112+
static::$_client->customer()->setProperties('id', $customer->id, [
113+
'pname' => 'Mike Black',
114+
'email' => 'mike@black.com',
115+
]);
116+
$customerInfo = static::$_client->customer()->get('id', $customer->id);
117+
$this->assertEquals('Mike Black', $customerInfo->personalName);
118+
$this->assertEquals('mike@black.com', $customerInfo->email);
119+
120+
static::$_client->customer()->delete('id', $customer->id);
121+
}
108122
}

0 commit comments

Comments
 (0)