Total Complexity | 4 |
Total Lines | 89 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
6 | trait CatalogProducts |
||
7 | { |
||
8 | /** |
||
9 | * Create a product. |
||
10 | * |
||
11 | * @param array $data |
||
12 | * @param string $request_id |
||
13 | * |
||
14 | * @throws \Throwable |
||
15 | * |
||
16 | * @return array|\Psr\Http\Message\StreamInterface|string |
||
17 | * |
||
18 | * @see https://developer.paypal.com/docs/api/catalog-products/v1/#products_create |
||
19 | */ |
||
20 | public function createProduct(array $data, $request_id) |
||
21 | { |
||
22 | $this->apiEndPoint = "v1/catalogs/products"; |
||
1 ignored issue
–
show
|
|||
23 | $this->apiUrl = collect([$this->apiUrl, $this->apiEndPoint])->implode('/'); |
||
1 ignored issue
–
show
|
|||
24 | |||
25 | $this->options['headers']['PayPal-Request-Id'] = $request_id; |
||
1 ignored issue
–
show
|
|||
26 | $this->options['json'] = $data; |
||
27 | |||
28 | $this->verb = 'post'; |
||
1 ignored issue
–
show
|
|||
29 | |||
30 | return $this->doPayPalRequest(); |
||
1 ignored issue
–
show
|
|||
31 | } |
||
32 | |||
33 | /** |
||
34 | * List products. |
||
35 | * |
||
36 | * @throws \Throwable |
||
37 | * |
||
38 | * @return array|\Psr\Http\Message\StreamInterface|string |
||
39 | * |
||
40 | * @see https://developer.paypal.com/docs/api/catalog-products/v1/#products_list |
||
41 | */ |
||
42 | public function listProducts() |
||
43 | { |
||
44 | $this->apiEndPoint = "v1/catalogs/products"; |
||
1 ignored issue
–
show
|
|||
45 | $this->apiUrl = collect([$this->apiUrl, $this->apiEndPoint])->implode('/'); |
||
1 ignored issue
–
show
|
|||
46 | |||
47 | $this->verb = 'get'; |
||
1 ignored issue
–
show
|
|||
48 | |||
49 | return $this->doPayPalRequest(); |
||
50 | } |
||
51 | |||
52 | /** |
||
53 | * Update a product. |
||
54 | * |
||
55 | * @param array $data |
||
56 | * @param string $product_id |
||
57 | * |
||
58 | * @throws \Throwable |
||
59 | * |
||
60 | * @return array|\Psr\Http\Message\StreamInterface|string |
||
61 | * |
||
62 | * @see https://developer.paypal.com/docs/api/catalog-products/v1/#products_patch |
||
63 | */ |
||
64 | public function updateProduct(array $data, $product_id) |
||
74 | } |
||
75 | |||
76 | /** |
||
77 | * Get product details. |
||
78 | * |
||
79 | * @param string $product_id |
||
80 | * |
||
81 | * @throws \Throwable |
||
82 | * |
||
83 | * @return array|\Psr\Http\Message\StreamInterface|string |
||
84 | * |
||
85 | * @see https://developer.paypal.com/docs/api/catalog-products/v1/#products_get |
||
86 | */ |
||
87 | public function showProductDetails($product_id) |
||
97 |