1
0
mirror of synced 2024-11-21 21:06:07 +03:00

Payment delete & custom dictionary creation fix (#46)

This commit is contained in:
Alex Lushpai 2017-07-24 15:12:13 +03:00 committed by GitHub
parent 4f57734e92
commit 9aab02c189
3 changed files with 38 additions and 12 deletions

View File

@ -196,7 +196,7 @@ trait CustomFields
} }
return $this->client->makeRequest( return $this->client->makeRequest(
"/custom-fields/dictionaries/{$customDictionary['code']}/create", "/custom-fields/dictionaries/create",
"POST", "POST",
['customDictionary' => json_encode($customDictionary)] ['customDictionary' => json_encode($customDictionary)]
); );

View File

@ -94,14 +94,14 @@ trait Orders
} }
/** /**
* Edit an order payment * Edit an order payment
* *
* @param array $payment order data * @param array $payment order data
* @param string $by by key * @param string $by by key
* @param null $site site code * @param null $site site code
* *
* @return \RetailCrm\Response\ApiResponse * @return \RetailCrm\Response\ApiResponse
*/ */
public function ordersPaymentEdit(array $payment, $by = 'id', $site = null) public function ordersPaymentEdit(array $payment, $by = 'id', $site = null)
{ {
if (!count($payment)) { if (!count($payment)) {
@ -127,4 +127,25 @@ trait Orders
) )
); );
} }
/**
* Edit an order payment
*
* @param string $id payment id
*
* @return \RetailCrm\Response\ApiResponse
*/
public function ordersPaymentDelete($id)
{
if (!$id) {
throw new \InvalidArgumentException(
'Parameter `id` must be set'
);
}
return $this->client->makeRequest(
sprintf('/orders/payments/%s/delete', $id),
"POST"
);
}
} }

View File

@ -403,10 +403,8 @@ class ApiClientOrdersTest extends TestCase
$paymentEdit = [ $paymentEdit = [
'id' => $response['id'], 'id' => $response['id'],
'externalId' => $externalId,
'amount' => 1500, 'amount' => 1500,
'comment' => 'test payment!', 'comment' => 'test payment!',
'type' => 'cash',
'status' => 'paid' 'status' => 'paid'
]; ];
@ -414,7 +412,14 @@ class ApiClientOrdersTest extends TestCase
static::assertTrue( static::assertTrue(
$responseAgain->isSuccessful(), $responseAgain->isSuccessful(),
'Got payment' 'Edit payment'
);
$responseLast = $client->request->ordersPaymentDelete($response['id']);
static::assertTrue(
$responseLast->isSuccessful(),
'Delete payment'
); );
} }
} }