1
|
|
|
<?php namespace Stevenmaguire\Uber\Resources; |
2
|
|
|
|
3
|
|
|
trait Requests |
4
|
|
|
{ |
5
|
|
|
/** |
6
|
|
|
* Cancels the current ride request. |
7
|
|
|
* |
8
|
|
|
* @return stdClass The JSON response from the request |
9
|
|
|
* |
10
|
|
|
* @see https://developer.uber.com/docs/riders/references/api/v1.2/requests-current-delete |
11
|
|
|
*/ |
12
|
2 |
|
public function cancelCurrentRequest() |
13
|
|
|
{ |
14
|
2 |
|
return $this->cancelRequest('current'); |
15
|
|
|
} |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Cancels a specific ride request. |
19
|
|
|
* |
20
|
|
|
* @param string $requestId Request id |
21
|
|
|
* |
22
|
|
|
* @return stdClass The JSON response from the request |
23
|
|
|
* |
24
|
|
|
* @see https://developer.uber.com/docs/riders/references/api/v1.2/requests-request_id-delete |
25
|
|
|
*/ |
26
|
4 |
|
public function cancelRequest($requestId) |
27
|
|
|
{ |
28
|
4 |
|
return $this->request('delete', 'requests/'.$requestId); |
|
|
|
|
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Fetches the current ride request. |
33
|
|
|
* |
34
|
|
|
* The Ride Request endpoint allows retrieving real-time details for an |
35
|
|
|
* ongoing trip. |
36
|
|
|
* |
37
|
|
|
* This endpoint behaves similarly to the GET /requests/{request_id} |
38
|
|
|
* endpoint, except you do not need to provide a request_id. If there is |
39
|
|
|
* no trip in progress the endpoint will result in a 404 not found error. |
40
|
|
|
* This endpoint will only work for trips requested through your app unless |
41
|
|
|
* you have the all_trips scope. |
42
|
|
|
* |
43
|
|
|
* By default, only details about trips your app requested will be returned. |
44
|
|
|
* If your app has all_trips scope, however, trip details will be returned |
45
|
|
|
* for all trips irrespective of which application initiated them. |
46
|
|
|
* |
47
|
|
|
* See the Ride Request tutorial for a step-by-step guide to requesting |
48
|
|
|
* rides on behalf of an Uber user. Please review the Sandbox documentation |
49
|
|
|
* on how to develop and test against these endpoints without making |
50
|
|
|
* real-world Ride Requests and being charged. |
51
|
|
|
* |
52
|
|
|
* @return stdClass The JSON response from the request |
53
|
|
|
* |
54
|
|
|
* @see https://developer.uber.com/docs/riders/references/api/v1.2/requests-current-get |
55
|
|
|
*/ |
56
|
2 |
|
public function getCurrentRequest() |
57
|
|
|
{ |
58
|
2 |
|
return $this->getRequest('current'); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Fetches a specific ride request. |
63
|
|
|
* |
64
|
|
|
* @param string $requestId Request id |
65
|
|
|
* |
66
|
|
|
* @return stdClass The JSON response from the request |
67
|
|
|
* |
68
|
|
|
* @see https://developer.uber.com/docs/riders/references/api/v1.2/requests-request_id-get |
69
|
|
|
*/ |
70
|
4 |
|
public function getRequest($requestId) |
71
|
|
|
{ |
72
|
4 |
|
return $this->request('get', 'requests/'.$requestId); |
|
|
|
|
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* Creates a ride request estimate. |
77
|
|
|
* |
78
|
|
|
* The Request Estimate endpoint allows a ride to be estimated given the |
79
|
|
|
* desired product, start, and end locations. If the end location is |
80
|
|
|
* not provided, only the pickup ETA and details of surge pricing |
81
|
|
|
* information are provided. If the pickup ETA is null, there are no cars |
82
|
|
|
* available, but an estimate may still be given to the user. |
83
|
|
|
* |
84
|
|
|
* @param array $attributes Query attributes |
85
|
|
|
* |
86
|
|
|
* @return stdClass The JSON response from the request |
87
|
|
|
* |
88
|
|
|
* @see https://developer.uber.com/docs/riders/references/api/v1.2/requests-estimate-post |
89
|
|
|
*/ |
90
|
2 |
|
public function getRequestEstimate($attributes = []) |
91
|
|
|
{ |
92
|
2 |
|
return $this->request('post', 'requests/estimate', $attributes); |
|
|
|
|
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* Fetches the map for a specific ride request. |
97
|
|
|
* |
98
|
|
|
* @param string $requestId Request id |
99
|
|
|
* |
100
|
|
|
* @return stdClass The JSON response from the request |
101
|
|
|
* |
102
|
|
|
* @see https://developer.uber.com/docs/riders/references/api/v1.2/requests-request_id-map-get |
103
|
|
|
*/ |
104
|
2 |
|
public function getRequestMap($requestId) |
105
|
|
|
{ |
106
|
2 |
|
return $this->request('get', 'requests/'.$requestId.'/map'); |
|
|
|
|
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* Fetches the receipt for a specific ride request. |
111
|
|
|
* |
112
|
|
|
* @param string $requestId Request id |
113
|
|
|
* |
114
|
|
|
* @return stdClass The JSON response from the request |
115
|
|
|
* |
116
|
|
|
* @see https://developer.uber.com/docs/riders/references/api/v1.2/requests-request_id-receipt-get |
117
|
|
|
*/ |
118
|
2 |
|
public function getRequestReceipt($requestId) |
119
|
|
|
{ |
120
|
2 |
|
return $this->request('get', 'requests/'.$requestId.'/receipt'); |
|
|
|
|
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* Creates a new ride request. |
125
|
|
|
* |
126
|
|
|
* The Request endpoint allows a ride to be requested on behalf of an Uber |
127
|
|
|
* user given their desired product, start, and end locations. |
128
|
|
|
* |
129
|
|
|
* @param array $attributes Query attributes |
130
|
|
|
* |
131
|
|
|
* @return stdClass The JSON response from the request |
132
|
|
|
* |
133
|
|
|
* @see https://developer.uber.com/docs/riders/references/api/v1.2/requests-post |
134
|
|
|
*/ |
135
|
2 |
|
public function requestRide($attributes = []) |
136
|
|
|
{ |
137
|
2 |
|
return $this->request('post', 'requests', $attributes); |
|
|
|
|
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* Updates the current ride request. |
142
|
|
|
* |
143
|
|
|
* The Ride Request endpoint allows updating an ongoing request’s |
144
|
|
|
* destination. |
145
|
|
|
* |
146
|
|
|
* This endpoint behaves similarly to the PATCH /v1.2/requests/{request_id} |
147
|
|
|
* endpoint, except you do not need to provide a request_id. If there is no |
148
|
|
|
* trip in progress the endpoint will result in a 404 not found error. This |
149
|
|
|
* endpoint will only work for trips requested through your app unless you |
150
|
|
|
* have the all_trips scope. |
151
|
|
|
* |
152
|
|
|
* @param array $attributes Query attributes |
153
|
|
|
* |
154
|
|
|
* @return stdClass The JSON response from the request |
155
|
|
|
* |
156
|
|
|
* @see https://developer.uber.com/docs/riders/references/api/v1.2/requests-current-patch |
157
|
|
|
*/ |
158
|
2 |
|
public function setCurrentRequest($attributes = []) |
159
|
|
|
{ |
160
|
2 |
|
return $this->setRequest('current', $attributes); |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
/** |
164
|
|
|
* Updates a specific ride request. |
165
|
|
|
* |
166
|
|
|
* The Ride Request endpoint allows updating an ongoing request’s |
167
|
|
|
* destination using the Ride Request endpoint. |
168
|
|
|
* |
169
|
|
|
* @param string $requestId Request id |
170
|
|
|
* @param array $attributes Query attributes |
171
|
|
|
* |
172
|
|
|
* @return stdClass The JSON response from the request |
173
|
|
|
* |
174
|
|
|
* @see https://developer.uber.com/docs/riders/references/api/v1.2/requests-request_id-patch |
175
|
|
|
*/ |
176
|
4 |
|
public function setRequest($requestId, $attributes = []) |
177
|
|
|
{ |
178
|
4 |
|
return $this->request('put', 'requests/'.$requestId, $attributes); |
|
|
|
|
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
/** |
182
|
|
|
* Updates a specific ride request properties for sandbox responses. |
183
|
|
|
* |
184
|
|
|
* @param string $requestId Request id |
185
|
|
|
* @param array $attributes Query attributes |
186
|
|
|
* |
187
|
|
|
* @return stdClass The JSON response from the request |
188
|
|
|
* @throws Exception |
189
|
|
|
* |
190
|
|
|
* @see https://developer.uber.com/docs/riders/references/api/v1.2/requests-estimate-post |
191
|
|
|
*/ |
192
|
4 |
|
public function setSandboxRequest($requestId, $attributes = []) |
193
|
|
|
{ |
194
|
4 |
|
$this->enforceSandboxExpectation(); |
|
|
|
|
195
|
|
|
|
196
|
2 |
|
return $this->request('put', 'sandbox/requests/'.$requestId, $attributes); |
|
|
|
|
197
|
|
|
} |
198
|
|
|
} |
199
|
|
|
|
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.