| Total Complexity | 5 |
| Total Lines | 112 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 5 | trait InvoicesTemplates |
||
| 6 | { |
||
| 7 | /** |
||
| 8 | * Create a new invoice template. |
||
| 9 | * |
||
| 10 | * @param array $data |
||
| 11 | * |
||
| 12 | * @throws \Throwable |
||
| 13 | * |
||
| 14 | * @return array|\Psr\Http\Message\StreamInterface|string |
||
| 15 | * |
||
| 16 | * @see https://developer.paypal.com/docs/api/invoicing/v2/#templates_create |
||
| 17 | */ |
||
| 18 | public function createInvoiceTemplate(array $data) |
||
| 19 | { |
||
| 20 | $this->apiEndPoint = "v2/invoicing/templates"; |
||
|
1 ignored issue
–
show
|
|||
| 21 | $this->apiUrl = collect([$this->apiUrl, $this->apiEndPoint])->implode('/'); |
||
|
1 ignored issue
–
show
|
|||
| 22 | |||
| 23 | $this->options['json'] = $data; |
||
|
1 ignored issue
–
show
|
|||
| 24 | |||
| 25 | $this->verb = 'post'; |
||
|
1 ignored issue
–
show
|
|||
| 26 | |||
| 27 | return $this->doPayPalRequest(); |
||
|
1 ignored issue
–
show
|
|||
| 28 | } |
||
| 29 | |||
| 30 | /** |
||
| 31 | * Get list of invoice templates. |
||
| 32 | * |
||
| 33 | * @param int $page |
||
| 34 | * @param int $size |
||
| 35 | * @param string $fields |
||
| 36 | * |
||
| 37 | * @throws \Throwable |
||
| 38 | * |
||
| 39 | * @return array|\Psr\Http\Message\StreamInterface|string |
||
| 40 | * |
||
| 41 | * @see https://developer.paypal.com/docs/api/invoicing/v2/#templates_list |
||
| 42 | */ |
||
| 43 | public function listInvoiceTemplates($page=1, $size=20, $fields='all') |
||
| 44 | { |
||
| 45 | $this->apiEndPoint = "v2/invoicing/templates?page={$page}&page_size={$size}&fields={$fields}"; |
||
|
1 ignored issue
–
show
|
|||
| 46 | $this->apiUrl = collect([$this->apiUrl, $this->apiEndPoint])->implode('/'); |
||
|
1 ignored issue
–
show
|
|||
| 47 | |||
| 48 | $this->verb = 'get'; |
||
|
1 ignored issue
–
show
|
|||
| 49 | |||
| 50 | return $this->doPayPalRequest(); |
||
| 51 | } |
||
| 52 | |||
| 53 | /** |
||
| 54 | * Delete an invoice template. |
||
| 55 | * |
||
| 56 | * @param string $template_id |
||
| 57 | * |
||
| 58 | * @throws \Throwable |
||
| 59 | * |
||
| 60 | * @return array|\Psr\Http\Message\StreamInterface|string |
||
| 61 | * |
||
| 62 | * @see https://developer.paypal.com/docs/api/invoicing/v2/#templates_delete |
||
| 63 | */ |
||
| 64 | public function deleteInvoiceTemplate($template_id) |
||
| 65 | { |
||
| 66 | $this->apiEndPoint = "v2/invoicing/templates/{$template_id}"; |
||
|
1 ignored issue
–
show
|
|||
| 67 | $this->apiUrl = collect([$this->apiUrl, $this->apiEndPoint])->implode('/'); |
||
|
1 ignored issue
–
show
|
|||
| 68 | |||
| 69 | $this->verb = 'delete'; |
||
|
1 ignored issue
–
show
|
|||
| 70 | |||
| 71 | return $this->doPayPalRequest(); |
||
| 72 | } |
||
| 73 | |||
| 74 | /** |
||
| 75 | * Update an existing invoice template. |
||
| 76 | * |
||
| 77 | * @param string $template_id |
||
| 78 | * @param array $data |
||
| 79 | * |
||
| 80 | * @throws \Throwable |
||
| 81 | * |
||
| 82 | * @return array|\Psr\Http\Message\StreamInterface|string |
||
| 83 | * |
||
| 84 | * @see https://developer.paypal.com/docs/api/invoicing/v2/#templates_update |
||
| 85 | */ |
||
| 86 | public function updateInvoiceTemplate($template_id, array $data) |
||
| 87 | { |
||
| 88 | $this->apiEndPoint = "v2/invoicing/templates/{$template_id}"; |
||
|
1 ignored issue
–
show
|
|||
| 89 | $this->apiUrl = collect([$this->apiUrl, $this->apiEndPoint])->implode('/'); |
||
|
1 ignored issue
–
show
|
|||
| 90 | |||
| 91 | $this->options['json'] = $data; |
||
|
1 ignored issue
–
show
|
|||
| 92 | |||
| 93 | $this->verb = 'put'; |
||
|
1 ignored issue
–
show
|
|||
| 94 | |||
| 95 | return $this->doPayPalRequest(); |
||
| 96 | } |
||
| 97 | |||
| 98 | /** |
||
| 99 | * Show details for an existing invoice. |
||
| 100 | * |
||
| 101 | * @param string $template_id |
||
| 102 | * |
||
| 103 | * @throws \Throwable |
||
| 104 | * |
||
| 105 | * @return array|\Psr\Http\Message\StreamInterface|string |
||
| 106 | * |
||
| 107 | * @see https://developer.paypal.com/docs/api/invoicing/v2/#templates_get |
||
| 108 | */ |
||
| 109 | public function showInvoiceTemplateDetails($template_id) |
||
| 117 | } |
||
| 118 | } |
||
| 119 |