PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.8.13
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.8.13
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 1.7.0.9 All 211 releases
charitable / vendor / square / square / src / Legacy / Models / UpdateItemTaxesRequest.php

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

165 lines 4.1 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 class UpdateItemTaxesRequest implements \JsonSerializable
10 {
11 /**
12 * @var string[]
13 */
14 private $itemIds;
15
16 /**
17 * @var array
18 */
19 private $taxesToEnable = [];
20
21 /**
22 * @var array
23 */
24 private $taxesToDisable = [];
25
26 /**
27 * @param string[] $itemIds
28 */
29 public function __construct(array $itemIds)
30 {
31 $this->itemIds = $itemIds;
32 }
33
34 /**
35 * Returns Item Ids.
36 * IDs for the CatalogItems associated with the CatalogTax objects being updated.
37 * No more than 1,000 IDs may be provided.
38 *
39 * @return string[]
40 */
41 public function getItemIds(): array
42 {
43 return $this->itemIds;
44 }
45
46 /**
47 * Sets Item Ids.
48 * IDs for the CatalogItems associated with the CatalogTax objects being updated.
49 * No more than 1,000 IDs may be provided.
50 *
51 * @required
52 * @maps item_ids
53 *
54 * @param string[] $itemIds
55 */
56 public function setItemIds(array $itemIds): void
57 {
58 $this->itemIds = $itemIds;
59 }
60
61 /**
62 * Returns Taxes to Enable.
63 * IDs of the CatalogTax objects to enable.
64 * At least one of `taxes_to_enable` or `taxes_to_disable` must be specified.
65 *
66 * @return string[]|null
67 */
68 public function getTaxesToEnable(): ?array
69 {
70 if (count($this->taxesToEnable) == 0) {
71 return null;
72 }
73 return $this->taxesToEnable['value'];
74 }
75
76 /**
77 * Sets Taxes to Enable.
78 * IDs of the CatalogTax objects to enable.
79 * At least one of `taxes_to_enable` or `taxes_to_disable` must be specified.
80 *
81 * @maps taxes_to_enable
82 *
83 * @param string[]|null $taxesToEnable
84 */
85 public function setTaxesToEnable(?array $taxesToEnable): void
86 {
87 $this->taxesToEnable['value'] = $taxesToEnable;
88 }
89
90 /**
91 * Unsets Taxes to Enable.
92 * IDs of the CatalogTax objects to enable.
93 * At least one of `taxes_to_enable` or `taxes_to_disable` must be specified.
94 */
95 public function unsetTaxesToEnable(): void
96 {
97 $this->taxesToEnable = [];
98 }
99
100 /**
101 * Returns Taxes to Disable.
102 * IDs of the CatalogTax objects to disable.
103 * At least one of `taxes_to_enable` or `taxes_to_disable` must be specified.
104 *
105 * @return string[]|null
106 */
107 public function getTaxesToDisable(): ?array
108 {
109 if (count($this->taxesToDisable) == 0) {
110 return null;
111 }
112 return $this->taxesToDisable['value'];
113 }
114
115 /**
116 * Sets Taxes to Disable.
117 * IDs of the CatalogTax objects to disable.
118 * At least one of `taxes_to_enable` or `taxes_to_disable` must be specified.
119 *
120 * @maps taxes_to_disable
121 *
122 * @param string[]|null $taxesToDisable
123 */
124 public function setTaxesToDisable(?array $taxesToDisable): void
125 {
126 $this->taxesToDisable['value'] = $taxesToDisable;
127 }
128
129 /**
130 * Unsets Taxes to Disable.
131 * IDs of the CatalogTax objects to disable.
132 * At least one of `taxes_to_enable` or `taxes_to_disable` must be specified.
133 */
134 public function unsetTaxesToDisable(): void
135 {
136 $this->taxesToDisable = [];
137 }
138
139 /**
140 * Encode this object to JSON
141 *
142 * @param bool $asArrayWhenEmpty Whether to serialize this model as an array whenever no fields
143 * are set. (default: false)
144 *
145 * @return array|stdClass
146 */
147 #[\ReturnTypeWillChange] // @phan-suppress-current-line PhanUndeclaredClassAttribute for (php < 8.1)
148 public function jsonSerialize(bool $asArrayWhenEmpty = false)
149 {
150 $json = [];
151 $json['item_ids'] = $this->itemIds;
152 if (!empty($this->taxesToEnable)) {
153 $json['taxes_to_enable'] = $this->taxesToEnable['value'];
154 }
155 if (!empty($this->taxesToDisable)) {
156 $json['taxes_to_disable'] = $this->taxesToDisable['value'];
157 }
158 $json = array_filter($json, function ($val) {
159 return $val !== null;
160 });
161
162 return (!$asArrayWhenEmpty && empty($json)) ? new stdClass() : $json;
163 }
164 }
165