Riders::getPlace()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php namespace Stevenmaguire\Uber\Resources;
2
3
trait Riders
4
{
5
    /**
6
     * Lists history events for the current rider.
7
     *
8
     * The User Activity endpoint returns a limited amount of data about a
9
     * user's lifetime activity with Uber. The response will include pickup and
10
     * dropoff times, the distance of past requests, and information about
11
     * which products were requested.
12
     *
13
     * The history array in the response will have a maximum length based on
14
     * the limit parameter. The response value count may exceed limit,
15
     * therefore subsequent API requests may be necessary.
16
     *
17
     * @param    array    $attributes   Query attributes
18
     *
19
     * @return   stdClass               The JSON response from the request
20
     *
21
     * @see      https://developer.uber.com/docs/riders/references/api/v1.2/history-get
22
     */
23 2
    public function getHistory($attributes = [])
24
    {
25 2
        return $this->request('get', 'history', $attributes);
26
    }
27
28
    /**
29
     * Lists available payment methods for the current rider.
30
     *
31
     * The Payment Methods endpoint allows retrieving the list of the user’s
32
     * available payment methods. These can be leveraged in order to supply a
33
     * payment_method_id to the POST /requests endpoint.
34
     *
35
     * @return   stdClass               The JSON response from the request
36
     *
37
     * @see      https://developer.uber.com/docs/riders/references/api/v1.2/payment-methods-get
38
     */
39 2
    public function getPaymentMethods()
40
    {
41 2
        return $this->request('get', 'payment-methods');
42
    }
43
44
    /**
45
     * Fetches a specific place.
46
     *
47
     * The Places endpoint allows retrieving the home and work addresses from
48
     * an Uber user's profile.
49
     *
50
     * Only home and work are acceptable.
51
     *
52
     * @param    string   $placeId      Place id
53
     *
54
     * @return   stdClass               The JSON response from the request
55
     *
56
     * @see      https://developer.uber.com/docs/riders/references/api/v1.2/places-place_id-get
57
     */
58 2
    public function getPlace($placeId)
59
    {
60 2
        return $this->request('get', 'places/'.$placeId);
61
    }
62
63
    /**
64
     * Fetches the profile for the current rider.
65
     *
66
     * The User Profile endpoint returns information about the Uber user that
67
     * has authorized with the application.
68
     *
69
     * @return   stdClass               The JSON response from the request
70
     *
71
     * @see      https://developer.uber.com/docs/riders/references/api/v1.2/me-get
72
     */
73 4
    public function getProfile()
74
    {
75 4
        return $this->request('get', 'me');
76
    }
77
78
    /**
79
     * Makes a request to the Uber API and returns the response.
80
     *
81
     * @param    string $verb       The Http verb to use
82
     * @param    string $path       The path of the APi after the domain
83
     * @param    array  $parameters Parameters
84
     *
85
     * @return   stdClass The JSON response from the request
86
     * @throws   Exception
87
     */
88
    abstract protected function request($verb, $path, $parameters = []);
89
90
    /**
91
     * Updates a specific place.
92
     *
93
     * The Places endpoint allows updating the home and work addresses from an
94
     * Uber user's profile.
95
     *
96
     * Only home and work are acceptable.
97
     *
98
     * @param    string   $placeId      Place id
99
     * @param    array    $attributes   Query attributes
100
     *
101
     * @return   stdClass
102
     *
103
     * @see      https://developer.uber.com/docs/riders/references/api/v1.2/places-place_id-put
104
     */
105 2
    public function setPlace($placeId, $attributes = [])
106
    {
107 2
        return $this->request('put', 'places/'.$placeId, $attributes);
108
    }
109
110
    /**
111
     * Updates the profile for the current rider.
112
     *
113
     * @param array $attributes
114
     *
115
     * @return   stdClass
116
     *
117
     * @see      https://developer.uber.com/docs/riders/references/api/v1.2/me-patch
118
     */
119 2
    public function setProfile($attributes = [])
120
    {
121 2
        return $this->request('patch', 'me', $attributes);
122
    }
123
}
124