Skip to content

Commit 769058a

Browse files
committed
Add import method
1 parent d74968f commit 769058a

File tree

6 files changed

+198
-2
lines changed

6 files changed

+198
-2
lines changed

models/.gitkeep

Whitespace-only changes.

src/Model/Entity/Payments/ApiGetInvoiceResponse.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,9 @@ class ApiGetInvoiceResponse extends SuccessResponse
175175
public $cancellable;
176176

177177
/**
178-
* @var \RetailCrm\Api\Model\Entity\Payments\ModuleRefund[]
178+
* @var \RetailCrm\Api\Model\Entity\Payments\PaymentRefund[]
179179
*
180-
* @JMS\Type("array<RetailCrm\Api\Model\Entity\Payments\ModuleRefund>")
180+
* @JMS\Type("array<RetailCrm\Api\Model\Entity\Payments\PaymentRefund>")
181181
* @JMS\SerializedName("refunds")
182182
*/
183183
public $refunds;
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
<?php
2+
3+
/**
4+
* PHP version 7.3
5+
*
6+
* @category ApiImportInvoiceRequest
7+
* @package RetailCrm\Api\Model\Entity\Payments
8+
*/
9+
10+
namespace RetailCrm\Api\Model\Entity\Payments;
11+
12+
use RetailCrm\Api\Component\Serializer\Annotation as JMS;
13+
14+
/**
15+
* Class ApiImportInvoiceRequest
16+
*
17+
* @category ApiImportInvoiceRequest
18+
* @package RetailCrm\Api\Model\Entity\Payments
19+
*/
20+
class ApiImportInvoiceRequest
21+
{
22+
/**
23+
* @var int
24+
*
25+
* @JMS\Type("int")
26+
* @JMS\SerializedName("paymentId")
27+
*/
28+
public $paymentId;
29+
30+
/**
31+
* @var string
32+
*
33+
* @JMS\Type("string")
34+
* @JMS\SerializedName("externalId")
35+
*/
36+
public $externalId;
37+
38+
/**
39+
* @var float
40+
*
41+
* @JMS\Type("float")
42+
* @JMS\SerializedName("amount")
43+
*/
44+
public $amount;
45+
46+
/**
47+
* @var string
48+
*
49+
* @JMS\Type("string")
50+
* @JMS\SerializedName("currency")
51+
*/
52+
public $currency;
53+
54+
/**
55+
* @var string
56+
*
57+
* @JMS\Type("string")
58+
* @JMS\SerializedName("status")
59+
*/
60+
public $status;
61+
62+
/**
63+
* @var string
64+
*
65+
* @JMS\Type("string")
66+
* @JMS\SerializedName("createdAt")
67+
*/
68+
public $createdAt;
69+
70+
/**
71+
* @var string
72+
*
73+
* @JMS\Type("string")
74+
* @JMS\SerializedName("paidAt")
75+
*/
76+
public $paidAt;
77+
78+
/**
79+
* @var float
80+
*
81+
* @JMS\Type("float")
82+
* @JMS\SerializedName("discountAmount")
83+
*/
84+
public $discountAmount;
85+
86+
/**
87+
* @var \RetailCrm\Api\Model\Entity\Payments\ModuleRefund[]
88+
*
89+
* @JMS\Type("array<RetailCrm\Api\Model\Entity\Payments\ModuleRefund>")
90+
* @JMS\SerializedName("refunds")
91+
*/
92+
public $refunds;
93+
94+
/**
95+
* @var bool
96+
*
97+
* @JMS\Type("bool")
98+
* @JMS\SerializedName("refundable")
99+
*/
100+
public $refundable;
101+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
/**
4+
* PHP version 7.3
5+
*
6+
* @category PaymentRefund
7+
* @package RetailCrm\Api\Model\Entity\Payments
8+
*/
9+
10+
namespace RetailCrm\Api\Model\Entity\Payments;
11+
12+
use RetailCrm\Api\Component\Serializer\Annotation as JMS;
13+
14+
/**
15+
* Class PaymentRefund
16+
*
17+
* @category PaymentRefund
18+
* @package RetailCrm\Api\Model\Entity\Payments
19+
*/
20+
class PaymentRefund extends ModuleRefund
21+
{
22+
/**
23+
* @var string
24+
*
25+
* @JMS\Type("string")
26+
* @JMS\SerializedName("externalId")
27+
*/
28+
public $externalId;
29+
30+
/**
31+
* @var string
32+
*
33+
* @JMS\Type("string")
34+
* @JMS\SerializedName("createdAt")
35+
*/
36+
public $createdAt;
37+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
/**
4+
* PHP version 7.3
5+
*
6+
* @category PaymentImportInvoiceRequest
7+
* @package RetailCrm\Api\Model\Request\Payments
8+
*/
9+
10+
namespace RetailCrm\Api\Model\Request\Payments;
11+
12+
use RetailCrm\Api\Component\FormData\Mapping as Form;
13+
use RetailCrm\Api\Interfaces\RequestInterface;
14+
use RetailCrm\Api\Model\Entity\Payments\ApiImportInvoiceRequest;
15+
16+
/**
17+
* Class PaymentImportInvoiceRequest
18+
*
19+
* @category PaymentImportInvoiceRequest
20+
* @package RetailCrm\Api\Model\Request\Payments
21+
*/
22+
class PaymentImportInvoiceRequest implements RequestInterface
23+
{
24+
/**
25+
* @var \RetailCrm\Api\Model\Entity\Payments\ApiImportInvoiceRequest
26+
*
27+
* @Form\Type("RetailCrm\Api\Model\Entity\Payments\ApiImportInvoiceRequest")
28+
* @Form\SerializedName("invoice")
29+
* @Form\JsonField()
30+
*/
31+
public $invoice;
32+
33+
/**
34+
* PaymentImportInvoiceRequest constructor.
35+
*
36+
* @param \RetailCrm\Api\Model\Entity\Payments\ApiImportInvoiceRequest|null $importInvoice
37+
*/
38+
public function __construct(?ApiImportInvoiceRequest $importInvoice = null)
39+
{
40+
if (null !== $importInvoice) {
41+
$this->invoice = $importInvoice;
42+
}
43+
}
44+
}

src/ResourceGroup/Payments.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use RetailCrm\Api\Enum\RequestMethod;
1313
use RetailCrm\Api\Model\Request\Payments\PaymentCheckRequest;
1414
use RetailCrm\Api\Model\Request\Payments\PaymentCreateInvoiceRequest;
15+
use RetailCrm\Api\Model\Request\Payments\PaymentImportInvoiceRequest;
1516
use RetailCrm\Api\Model\Request\Payments\PaymentUpdateInvoiceRequest;
1617
use RetailCrm\Api\Model\Response\Payments\PaymentCheckResponse;
1718
use RetailCrm\Api\Model\Response\Payments\PaymentCreateInvoiceResponse;
@@ -257,4 +258,17 @@ public function getInvoice(string $invoiceUuid): PaymentGetInvoiceResponse
257258

258259
return $response;
259260
}
261+
262+
public function importInvoice(PaymentImportInvoiceRequest $request)
263+
{
264+
/** @var SuccessResponse $response */
265+
$response = $this->sendRequest(
266+
RequestMethod::POST,
267+
'payment/invoice/import',
268+
$request,
269+
SuccessResponse::class
270+
);
271+
272+
return $response;
273+
}
260274
}

0 commit comments

Comments
 (0)