1
|
|
|
<?php namespace Stevenmaguire\Uber\Resources; |
2
|
|
|
|
3
|
|
|
trait Products |
4
|
|
|
{ |
5
|
|
|
/** |
6
|
|
|
* Fetches a specific product. |
7
|
|
|
* |
8
|
|
|
* @param string $productId Product id |
9
|
|
|
* |
10
|
|
|
* @return stdClass The JSON response from the request |
11
|
|
|
* |
12
|
|
|
* @see https://developer.uber.com/docs/riders/references/api/v1.2/products-product_id-get |
13
|
|
|
*/ |
14
|
2 |
|
public function getProduct($productId) |
15
|
|
|
{ |
16
|
2 |
|
return $this->request('get', 'products/'.$productId); |
|
|
|
|
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Lists available products. |
21
|
|
|
* |
22
|
|
|
* The Products endpoint returns information about the Uber products |
23
|
|
|
* offered at a given location. The response includes the display name and |
24
|
|
|
* other details about each product, and lists the products in the proper |
25
|
|
|
* display order. |
26
|
|
|
* |
27
|
|
|
* Some Products, such as experiments or promotions such as UberPOOL and |
28
|
|
|
* UberFRESH, will not be returned by this endpoint. |
29
|
|
|
* |
30
|
|
|
* @param array $attributes Query attributes |
31
|
|
|
* |
32
|
|
|
* @return stdClass The JSON response from the request |
33
|
|
|
* |
34
|
|
|
* @see https://developer.uber.com/docs/riders/references/api/v1.2/products-get |
35
|
|
|
*/ |
36
|
8 |
|
public function getProducts($attributes = []) |
37
|
|
|
{ |
38
|
8 |
|
return $this->request('get', 'products', $attributes); |
|
|
|
|
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Updates a specific product properties for sandbox responses. |
43
|
|
|
* |
44
|
|
|
* @param string $productId Product id |
45
|
|
|
* @param array $attributes Query attributes |
46
|
|
|
* |
47
|
|
|
* @return stdClass The JSON response from the request |
48
|
|
|
* @throws Exception |
49
|
|
|
* |
50
|
|
|
* @see https://developer.uber.com/docs/riders/guides/sandbox#product-types |
51
|
|
|
*/ |
52
|
4 |
|
public function setSandboxProduct($productId, $attributes = []) |
53
|
|
|
{ |
54
|
4 |
|
$this->enforceSandboxExpectation(); |
|
|
|
|
55
|
|
|
|
56
|
2 |
|
return $this->request('put', 'sandbox/products/'.$productId, $attributes); |
|
|
|
|
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
|
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idable
provides a methodequalsId
that in turn relies on the methodgetId()
. If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()
as an abstract method to the trait will make sure it is available.