1 <?php
2
3 namespace PayPal\Api;
4
5 use PayPal\Common\PayPalModel;
6 use PayPal\Validation\UrlValidator;
7
8 /**
9 * Class TemplateData
10 *
11 * Detailed template information.
12 *
13 * @package PayPal\Api
14 *
15 * @property \PayPal\Api\MerchantInfo merchant_info
16 * @property \PayPal\Api\BillingInfo[] billing_info
17 * @property string[] cc_info
18 * @property \PayPal\Api\ShippingInfo shipping_info
19 * @property \PayPal\Api\InvoiceItem[] items
20 * @property \PayPal\Api\PaymentTerm payment_term
21 * @property string reference
22 * @property \PayPal\Api\Cost discount
23 * @property \PayPal\Api\ShippingCost shipping_cost
24 * @property \PayPal\Api\CustomAmount custom
25 * @property bool allow_partial_payment
26 * @property \PayPal\Api\Currency minimum_amount_due
27 * @property bool tax_calculated_after_discount
28 * @property bool tax_inclusive
29 * @property string terms
30 * @property string note
31 * @property string merchant_memo
32 * @property string logo_url
33 * @property \PayPal\Api\Currency total_amount
34 * @property \PayPal\Api\FileAttachment[] attachments
35 */
36 class TemplateData extends PayPalModel
37 {
38 /**
39 * Information about the merchant who is sending the invoice.
40 *
41 * @param \PayPal\Api\MerchantInfo $merchant_info
42 *
43 * @return $this
44 */
45 public function setMerchantInfo($merchant_info)
46 {
47 $this->merchant_info = $merchant_info;
48 return $this;
49 }
50
51 /**
52 * Information about the merchant who is sending the invoice.
53 *
54 * @return \PayPal\Api\MerchantInfo
55 */
56 public function getMerchantInfo()
57 {
58 return $this->merchant_info;
59 }
60
61 /**
62 * The required invoice recipient email address and any optional billing information. One recipient is supported.
63 *
64 * @param \PayPal\Api\BillingInfo[] $billing_info
65 *
66 * @return $this
67 */
68 public function setBillingInfo($billing_info)
69 {
70 $this->billing_info = $billing_info;
71 return $this;
72 }
73
74 /**
75 * The required invoice recipient email address and any optional billing information. One recipient is supported.
76 *
77 * @return \PayPal\Api\BillingInfo[]
78 */
79 public function getBillingInfo()
80 {
81 return $this->billing_info;
82 }
83
84 /**
85 * Append BillingInfo to the list.
86 *
87 * @param \PayPal\Api\BillingInfo $billingInfo
88 * @return $this
89 */
90 public function addBillingInfo($billingInfo)
91 {
92 if (!$this->getBillingInfo()) {
93 return $this->setBillingInfo(array($billingInfo));
94 } else {
95 return $this->setBillingInfo(
96 array_merge($this->getBillingInfo(), array($billingInfo))
97 );
98 }
99 }
100
101 /**
102 * Remove BillingInfo from the list.
103 *
104 * @param \PayPal\Api\BillingInfo $billingInfo
105 * @return $this
106 */
107 public function removeBillingInfo($billingInfo)
108 {
109 return $this->setBillingInfo(
110 array_diff($this->getBillingInfo(), array($billingInfo))
111 );
112 }
113
114 /**
115 * For invoices sent by email, one or more email addresses to which to send a Cc: copy of the notification. Supports only email addresses under participant.
116 *
117 * @param string[] $cc_info
118 *
119 * @return $this
120 */
121 public function setCcInfo($cc_info)
122 {
123 $this->cc_info = $cc_info;
124 return $this;
125 }
126
127 /**
128 * For invoices sent by email, one or more email addresses to which to send a Cc: copy of the notification. Supports only email addresses under participant.
129 *
130 * @return string[]
131 */
132 public function getCcInfo()
133 {
134 return $this->cc_info;
135 }
136
137 /**
138 * Append CcInfo to the list.
139 *
140 * @param string $email
141 * @return $this
142 */
143 public function addCcInfo($email)
144 {
145 if (!$this->getCcInfo()) {
146 return $this->setCcInfo(array($email));
147 } else {
148 return $this->setCcInfo(
149 array_merge($this->getCcInfo(), array($email))
150 );
151 }
152 }
153
154 /**
155 * Remove CcInfo from the list.
156 *
157 * @param string $email
158 * @return $this
159 */
160 public function removeCcInfo($email)
161 {
162 return $this->setCcInfo(
163 array_diff($this->getCcInfo(), array($email))
164 );
165 }
166
167 /**
168 * The shipping information for entities to whom items are being shipped.
169 *
170 * @param \PayPal\Api\ShippingInfo $shipping_info
171 *
172 * @return $this
173 */
174 public function setShippingInfo($shipping_info)
175 {
176 $this->shipping_info = $shipping_info;
177 return $this;
178 }
179
180 /**
181 * The shipping information for entities to whom items are being shipped.
182 *
183 * @return \PayPal\Api\ShippingInfo
184 */
185 public function getShippingInfo()
186 {
187 return $this->shipping_info;
188 }
189
190 /**
191 * The list of items to include in the invoice. Maximum value is 100 items per invoice.
192 *
193 * @param \PayPal\Api\InvoiceItem[] $items
194 *
195 * @return $this
196 */
197 public function setItems($items)
198 {
199 $this->items = $items;
200 return $this;
201 }
202
203 /**
204 * The list of items to include in the invoice. Maximum value is 100 items per invoice.
205 *
206 * @return \PayPal\Api\InvoiceItem[]
207 */
208 public function getItems()
209 {
210 return $this->items;
211 }
212
213 /**
214 * Append Items to the list.
215 *
216 * @param \PayPal\Api\InvoiceItem $invoiceItem
217 * @return $this
218 */
219 public function addItem($invoiceItem)
220 {
221 if (!$this->getItems()) {
222 return $this->setItems(array($invoiceItem));
223 } else {
224 return $this->setItems(
225 array_merge($this->getItems(), array($invoiceItem))
226 );
227 }
228 }
229
230 /**
231 * Remove Items from the list.
232 *
233 * @param \PayPal\Api\InvoiceItem $invoiceItem
234 * @return $this
235 */
236 public function removeItem($invoiceItem)
237 {
238 return $this->setItems(
239 array_diff($this->getItems(), array($invoiceItem))
240 );
241 }
242
243 /**
244 * Optional. The payment deadline for the invoice. Value is either `term_type` or `due_date` but not both.
245 *
246 * @param \PayPal\Api\PaymentTerm $payment_term
247 *
248 * @return $this
249 */
250 public function setPaymentTerm($payment_term)
251 {
252 $this->payment_term = $payment_term;
253 return $this;
254 }
255
256 /**
257 * Optional. The payment deadline for the invoice. Value is either `term_type` or `due_date` but not both.
258 *
259 * @return \PayPal\Api\PaymentTerm
260 */
261 public function getPaymentTerm()
262 {
263 return $this->payment_term;
264 }
265
266 /**
267 * Reference data, such as PO number, to add to the invoice. Maximum length is 60 characters.
268 *
269 * @param string $reference
270 *
271 * @return $this
272 */
273 public function setReference($reference)
274 {
275 $this->reference = $reference;
276 return $this;
277 }
278
279 /**
280 * Reference data, such as PO number, to add to the invoice. Maximum length is 60 characters.
281 *
282 * @return string
283 */
284 public function getReference()
285 {
286 return $this->reference;
287 }
288
289 /**
290 * The invoice level discount, as a percent or an amount value.
291 *
292 * @param \PayPal\Api\Cost $discount
293 *
294 * @return $this
295 */
296 public function setDiscount($discount)
297 {
298 $this->discount = $discount;
299 return $this;
300 }
301
302 /**
303 * The invoice level discount, as a percent or an amount value.
304 *
305 * @return \PayPal\Api\Cost
306 */
307 public function getDiscount()
308 {
309 return $this->discount;
310 }
311
312 /**
313 * The shipping cost, as a percent or an amount value.
314 *
315 * @param \PayPal\Api\ShippingCost $shipping_cost
316 *
317 * @return $this
318 */
319 public function setShippingCost($shipping_cost)
320 {
321 $this->shipping_cost = $shipping_cost;
322 return $this;
323 }
324
325 /**
326 * The shipping cost, as a percent or an amount value.
327 *
328 * @return \PayPal\Api\ShippingCost
329 */
330 public function getShippingCost()
331 {
332 return $this->shipping_cost;
333 }
334
335 /**
336 * The custom amount to apply on an invoice. If you include a label, the amount cannot be empty.
337 *
338 * @param \PayPal\Api\CustomAmount $custom
339 *
340 * @return $this
341 */
342 public function setCustom($custom)
343 {
344 $this->custom = $custom;
345 return $this;
346 }
347
348 /**
349 * The custom amount to apply on an invoice. If you include a label, the amount cannot be empty.
350 *
351 * @return \PayPal\Api\CustomAmount
352 */
353 public function getCustom()
354 {
355 return $this->custom;
356 }
357
358 /**
359 * Indicates whether the invoice allows a partial payment. If set to `false`, invoice must be paid in full. If set to `true`, the invoice allows partial payments. Default is `false`.
360 *
361 * @param bool $allow_partial_payment
362 *
363 * @return $this
364 */
365 public function setAllowPartialPayment($allow_partial_payment)
366 {
367 $this->allow_partial_payment = $allow_partial_payment;
368 return $this;
369 }
370
371 /**
372 * Indicates whether the invoice allows a partial payment. If set to `false`, invoice must be paid in full. If set to `true`, the invoice allows partial payments. Default is `false`.
373 *
374 * @return bool
375 */
376 public function getAllowPartialPayment()
377 {
378 return $this->allow_partial_payment;
379 }
380
381 /**
382 * If `allow_partial_payment` is set to `true`, the minimum amount allowed for a partial payment.
383 *
384 * @param \PayPal\Api\Currency $minimum_amount_due
385 *
386 * @return $this
387 */
388 public function setMinimumAmountDue($minimum_amount_due)
389 {
390 $this->minimum_amount_due = $minimum_amount_due;
391 return $this;
392 }
393
394 /**
395 * If `allow_partial_payment` is set to `true`, the minimum amount allowed for a partial payment.
396 *
397 * @return \PayPal\Api\Currency
398 */
399 public function getMinimumAmountDue()
400 {
401 return $this->minimum_amount_due;
402 }
403
404 /**
405 * Indicates whether tax is calculated before or after a discount. If set to `false`, the tax is calculated before a discount. If set to `true`, the tax is calculated after a discount. Default is `false`.
406 *
407 * @param bool $tax_calculated_after_discount
408 *
409 * @return $this
410 */
411 public function setTaxCalculatedAfterDiscount($tax_calculated_after_discount)
412 {
413 $this->tax_calculated_after_discount = $tax_calculated_after_discount;
414 return $this;
415 }
416
417 /**
418 * Indicates whether tax is calculated before or after a discount. If set to `false`, the tax is calculated before a discount. If set to `true`, the tax is calculated after a discount. Default is `false`.
419 *
420 * @return bool
421 */
422 public function getTaxCalculatedAfterDiscount()
423 {
424 return $this->tax_calculated_after_discount;
425 }
426
427 /**
428 * Indicates whether the unit price includes tax. Default is `false`.
429 *
430 * @param bool $tax_inclusive
431 *
432 * @return $this
433 */
434 public function setTaxInclusive($tax_inclusive)
435 {
436 $this->tax_inclusive = $tax_inclusive;
437 return $this;
438 }
439
440 /**
441 * Indicates whether the unit price includes tax. Default is `false`.
442 *
443 * @return bool
444 */
445 public function getTaxInclusive()
446 {
447 return $this->tax_inclusive;
448 }
449
450 /**
451 * General terms of the invoice. 4000 characters max.
452 *
453 * @param string $terms
454 *
455 * @return $this
456 */
457 public function setTerms($terms)
458 {
459 $this->terms = $terms;
460 return $this;
461 }
462
463 /**
464 * General terms of the invoice. 4000 characters max.
465 *
466 * @return string
467 */
468 public function getTerms()
469 {
470 return $this->terms;
471 }
472
473 /**
474 * Note to the payer. 4000 characters max.
475 *
476 * @param string $note
477 *
478 * @return $this
479 */
480 public function setNote($note)
481 {
482 $this->note = $note;
483 return $this;
484 }
485
486 /**
487 * Note to the payer. 4000 characters max.
488 *
489 * @return string
490 */
491 public function getNote()
492 {
493 return $this->note;
494 }
495
496 /**
497 * A private bookkeeping memo for the merchant. Maximum length is 150 characters.
498 *
499 * @param string $merchant_memo
500 *
501 * @return $this
502 */
503 public function setMerchantMemo($merchant_memo)
504 {
505 $this->merchant_memo = $merchant_memo;
506 return $this;
507 }
508
509 /**
510 * A private bookkeeping memo for the merchant. Maximum length is 150 characters.
511 *
512 * @return string
513 */
514 public function getMerchantMemo()
515 {
516 return $this->merchant_memo;
517 }
518
519 /**
520 * Full URL of an external image to use as the logo. Maximum length is 4000 characters.
521 *
522 * @param string $logo_url
523 * @throws \InvalidArgumentException
524 * @return $this
525 */
526 public function setLogoUrl($logo_url)
527 {
528 UrlValidator::validate($logo_url, "LogoUrl");
529 $this->logo_url = $logo_url;
530 return $this;
531 }
532
533 /**
534 * Full URL of an external image to use as the logo. Maximum length is 4000 characters.
535 *
536 * @return string
537 */
538 public function getLogoUrl()
539 {
540 return $this->logo_url;
541 }
542
543 /**
544 * The total amount of the invoice.
545 *
546 * @param \PayPal\Api\Currency $total_amount
547 *
548 * @return $this
549 */
550 public function setTotalAmount($total_amount)
551 {
552 $this->total_amount = $total_amount;
553 return $this;
554 }
555
556 /**
557 * The total amount of the invoice.
558 *
559 * @return \PayPal\Api\Currency
560 */
561 public function getTotalAmount()
562 {
563 return $this->total_amount;
564 }
565
566 /**
567 * List of files attached to the invoice.
568 *
569 * @param \PayPal\Api\FileAttachment[] $attachments
570 *
571 * @return $this
572 */
573 public function setAttachments($attachments)
574 {
575 $this->attachments = $attachments;
576 return $this;
577 }
578
579 /**
580 * List of files attached to the invoice.
581 *
582 * @return \PayPal\Api\FileAttachment[]
583 */
584 public function getAttachments()
585 {
586 return $this->attachments;
587 }
588
589 /**
590 * Append Attachments to the list.
591 *
592 * @param \PayPal\Api\FileAttachment $fileAttachment
593 * @return $this
594 */
595 public function addAttachment($fileAttachment)
596 {
597 if (!$this->getAttachments()) {
598 return $this->setAttachments(array($fileAttachment));
599 } else {
600 return $this->setAttachments(
601 array_merge($this->getAttachments(), array($fileAttachment))
602 );
603 }
604 }
605
606 /**
607 * Remove Attachments from the list.
608 *
609 * @param \PayPal\Api\FileAttachment $fileAttachment
610 * @return $this
611 */
612 public function removeAttachment($fileAttachment)
613 {
614 return $this->setAttachments(
615 array_diff($this->getAttachments(), array($fileAttachment))
616 );
617 }
618
619 }
620