PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.8.13.1
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.8.13.1
1.8.13.1 1.8.13 1.8.12.3 1.8.12.2 1.8.12.1 1.8.12 1.8.11.3 1.8.11.2 1.8.11.1 1.8.11 1.6.6 1.6.60 1.6.7 1.6.8 1.6.9 1.7.0 1.7.0.1 1.7.0.11 1.7.0.12 1.7.0.14 1.7.0.2 1.7.0.3 1.7.0.5 1.7.0.6 1.7.0.7 All 212 releases
charitable / vendor / square / square / src / Legacy / Models / CreateInvoiceRequest.php

CreateInvoiceRequest.php in Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) 1.8.13.1, at vendor/square/square/src/Legacy/Models/CreateInvoiceRequest.php

110 lines 3.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare(strict_types=1);
4
5 namespace Square\Legacy\Models;
6
7 use stdClass;
8
9 /**
10 * Describes a `CreateInvoice` request.
11 */
12 class CreateInvoiceRequest implements \JsonSerializable
13 {
14 /**
15 * @var Invoice
16 */
17 private $invoice;
18
19 /**
20 * @var string|null
21 */
22 private $idempotencyKey;
23
24 /**
25 * @param Invoice $invoice
26 */
27 public function __construct(Invoice $invoice)
28 {
29 $this->invoice = $invoice;
30 }
31
32 /**
33 * Returns Invoice.
34 * Stores information about an invoice. You use the Invoices API to create and manage
35 * invoices. For more information, see [Invoices API Overview](https://developer.squareup.
36 * com/docs/invoices-api/overview).
37 */
38 public function getInvoice(): Invoice
39 {
40 return $this->invoice;
41 }
42
43 /**
44 * Sets Invoice.
45 * Stores information about an invoice. You use the Invoices API to create and manage
46 * invoices. For more information, see [Invoices API Overview](https://developer.squareup.
47 * com/docs/invoices-api/overview).
48 *
49 * @required
50 * @maps invoice
51 */
52 public function setInvoice(Invoice $invoice): void
53 {
54 $this->invoice = $invoice;
55 }
56
57 /**
58 * Returns Idempotency Key.
59 * A unique string that identifies the `CreateInvoice` request. If you do not
60 * provide `idempotency_key` (or provide an empty string as the value), the endpoint
61 * treats each request as independent.
62 *
63 * For more information, see [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-
64 * patterns/idempotency).
65 */
66 public function getIdempotencyKey(): ?string
67 {
68 return $this->idempotencyKey;
69 }
70
71 /**
72 * Sets Idempotency Key.
73 * A unique string that identifies the `CreateInvoice` request. If you do not
74 * provide `idempotency_key` (or provide an empty string as the value), the endpoint
75 * treats each request as independent.
76 *
77 * For more information, see [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-
78 * patterns/idempotency).
79 *
80 * @maps idempotency_key
81 */
82 public function setIdempotencyKey(?string $idempotencyKey): void
83 {
84 $this->idempotencyKey = $idempotencyKey;
85 }
86
87 /**
88 * Encode this object to JSON
89 *
90 * @param bool $asArrayWhenEmpty Whether to serialize this model as an array whenever no fields
91 * are set. (default: false)
92 *
93 * @return array|stdClass
94 */
95 #[\ReturnTypeWillChange] // @phan-suppress-current-line PhanUndeclaredClassAttribute for (php < 8.1)
96 public function jsonSerialize(bool $asArrayWhenEmpty = false)
97 {
98 $json = [];
99 $json['invoice'] = $this->invoice;
100 if (isset($this->idempotencyKey)) {
101 $json['idempotency_key'] = $this->idempotencyKey;
102 }
103 $json = array_filter($json, function ($val) {
104 return $val !== null;
105 });
106
107 return (!$asArrayWhenEmpty && empty($json)) ? new stdClass() : $json;
108 }
109 }
110