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 / OrderFulfillmentRecipient.php

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

261 lines 7.8 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 * Information about the fulfillment recipient.
11 */
12 class OrderFulfillmentRecipient implements \JsonSerializable
13 {
14 /**
15 * @var array
16 */
17 private $customerId = [];
18
19 /**
20 * @var array
21 */
22 private $displayName = [];
23
24 /**
25 * @var array
26 */
27 private $emailAddress = [];
28
29 /**
30 * @var array
31 */
32 private $phoneNumber = [];
33
34 /**
35 * @var Address|null
36 */
37 private $address;
38
39 /**
40 * Returns Customer Id.
41 * The ID of the customer associated with the fulfillment.
42 * If `customer_id` is provided, the fulfillment recipient's `display_name`,
43 * `email_address`, and `phone_number` are automatically populated from the
44 * targeted customer profile. If these fields are set in the request, the request
45 * values override the information from the customer profile. If the
46 * targeted customer profile does not contain the necessary information and
47 * these fields are left unset, the request results in an error.
48 */
49 public function getCustomerId(): ?string
50 {
51 if (count($this->customerId) == 0) {
52 return null;
53 }
54 return $this->customerId['value'];
55 }
56
57 /**
58 * Sets Customer Id.
59 * The ID of the customer associated with the fulfillment.
60 * If `customer_id` is provided, the fulfillment recipient's `display_name`,
61 * `email_address`, and `phone_number` are automatically populated from the
62 * targeted customer profile. If these fields are set in the request, the request
63 * values override the information from the customer profile. If the
64 * targeted customer profile does not contain the necessary information and
65 * these fields are left unset, the request results in an error.
66 *
67 * @maps customer_id
68 */
69 public function setCustomerId(?string $customerId): void
70 {
71 $this->customerId['value'] = $customerId;
72 }
73
74 /**
75 * Unsets Customer Id.
76 * The ID of the customer associated with the fulfillment.
77 * If `customer_id` is provided, the fulfillment recipient's `display_name`,
78 * `email_address`, and `phone_number` are automatically populated from the
79 * targeted customer profile. If these fields are set in the request, the request
80 * values override the information from the customer profile. If the
81 * targeted customer profile does not contain the necessary information and
82 * these fields are left unset, the request results in an error.
83 */
84 public function unsetCustomerId(): void
85 {
86 $this->customerId = [];
87 }
88
89 /**
90 * Returns Display Name.
91 * The display name of the fulfillment recipient. This field is required.
92 * If provided, the display name overrides the corresponding customer profile value
93 * indicated by `customer_id`.
94 */
95 public function getDisplayName(): ?string
96 {
97 if (count($this->displayName) == 0) {
98 return null;
99 }
100 return $this->displayName['value'];
101 }
102
103 /**
104 * Sets Display Name.
105 * The display name of the fulfillment recipient. This field is required.
106 * If provided, the display name overrides the corresponding customer profile value
107 * indicated by `customer_id`.
108 *
109 * @maps display_name
110 */
111 public function setDisplayName(?string $displayName): void
112 {
113 $this->displayName['value'] = $displayName;
114 }
115
116 /**
117 * Unsets Display Name.
118 * The display name of the fulfillment recipient. This field is required.
119 * If provided, the display name overrides the corresponding customer profile value
120 * indicated by `customer_id`.
121 */
122 public function unsetDisplayName(): void
123 {
124 $this->displayName = [];
125 }
126
127 /**
128 * Returns Email Address.
129 * The email address of the fulfillment recipient.
130 * If provided, the email address overrides the corresponding customer profile value
131 * indicated by `customer_id`.
132 */
133 public function getEmailAddress(): ?string
134 {
135 if (count($this->emailAddress) == 0) {
136 return null;
137 }
138 return $this->emailAddress['value'];
139 }
140
141 /**
142 * Sets Email Address.
143 * The email address of the fulfillment recipient.
144 * If provided, the email address overrides the corresponding customer profile value
145 * indicated by `customer_id`.
146 *
147 * @maps email_address
148 */
149 public function setEmailAddress(?string $emailAddress): void
150 {
151 $this->emailAddress['value'] = $emailAddress;
152 }
153
154 /**
155 * Unsets Email Address.
156 * The email address of the fulfillment recipient.
157 * If provided, the email address overrides the corresponding customer profile value
158 * indicated by `customer_id`.
159 */
160 public function unsetEmailAddress(): void
161 {
162 $this->emailAddress = [];
163 }
164
165 /**
166 * Returns Phone Number.
167 * The phone number of the fulfillment recipient. This field is required.
168 * If provided, the phone number overrides the corresponding customer profile value
169 * indicated by `customer_id`.
170 */
171 public function getPhoneNumber(): ?string
172 {
173 if (count($this->phoneNumber) == 0) {
174 return null;
175 }
176 return $this->phoneNumber['value'];
177 }
178
179 /**
180 * Sets Phone Number.
181 * The phone number of the fulfillment recipient. This field is required.
182 * If provided, the phone number overrides the corresponding customer profile value
183 * indicated by `customer_id`.
184 *
185 * @maps phone_number
186 */
187 public function setPhoneNumber(?string $phoneNumber): void
188 {
189 $this->phoneNumber['value'] = $phoneNumber;
190 }
191
192 /**
193 * Unsets Phone Number.
194 * The phone number of the fulfillment recipient. This field is required.
195 * If provided, the phone number overrides the corresponding customer profile value
196 * indicated by `customer_id`.
197 */
198 public function unsetPhoneNumber(): void
199 {
200 $this->phoneNumber = [];
201 }
202
203 /**
204 * Returns Address.
205 * Represents a postal address in a country.
206 * For more information, see [Working with Addresses](https://developer.squareup.com/docs/build-
207 * basics/working-with-addresses).
208 */
209 public function getAddress(): ?Address
210 {
211 return $this->address;
212 }
213
214 /**
215 * Sets Address.
216 * Represents a postal address in a country.
217 * For more information, see [Working with Addresses](https://developer.squareup.com/docs/build-
218 * basics/working-with-addresses).
219 *
220 * @maps address
221 */
222 public function setAddress(?Address $address): void
223 {
224 $this->address = $address;
225 }
226
227 /**
228 * Encode this object to JSON
229 *
230 * @param bool $asArrayWhenEmpty Whether to serialize this model as an array whenever no fields
231 * are set. (default: false)
232 *
233 * @return array|stdClass
234 */
235 #[\ReturnTypeWillChange] // @phan-suppress-current-line PhanUndeclaredClassAttribute for (php < 8.1)
236 public function jsonSerialize(bool $asArrayWhenEmpty = false)
237 {
238 $json = [];
239 if (!empty($this->customerId)) {
240 $json['customer_id'] = $this->customerId['value'];
241 }
242 if (!empty($this->displayName)) {
243 $json['display_name'] = $this->displayName['value'];
244 }
245 if (!empty($this->emailAddress)) {
246 $json['email_address'] = $this->emailAddress['value'];
247 }
248 if (!empty($this->phoneNumber)) {
249 $json['phone_number'] = $this->phoneNumber['value'];
250 }
251 if (isset($this->address)) {
252 $json['address'] = $this->address;
253 }
254 $json = array_filter($json, function ($val) {
255 return $val !== null;
256 });
257
258 return (!$asArrayWhenEmpty && empty($json)) ? new stdClass() : $json;
259 }
260 }
261