Place an Order
This page will guide you through how to place an order.
This should be a piece of π°
Replace ACCESS_TOKEN by your access_token obtained from authorization.
require "uri"
require "net/http"
url = URI("https://<<api_base_path>>/orders")
https = Net::HTTP.new(url.host, url.port);
https.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer <<access_token>>"
request["Content-Type"] = "application/json"
payload = {
vehicle_type: "<<default_vehicle_type>>",
payment_method: "<<default_payment_method>>",
pickup: {
schedule_at: Time.now.to_i,
location: {
lat: <<pickup_lat>>,
lng: <<pickup_lng>>,
},
contact: {
name: "<<user_name>>",
phone_number: "<<user_phone_number>>"
}
},
destinations:[ {
location: {
lat: <<dropoff_lat>>,
lng: <<dropoff_lng>>,
}
}
]
}
request.body = JSON.generate(payload)
response = https.request(request)
response_payload = JSON.parse(response.read_body)
pp response_payload
<?php
$curl = curl_init();
$payload = [
"vehicle_type" => "<<default_vehicle_type>>",
"payment_method" => "<<default_payment_method>>",
"pickup" => [
"schedule_at" => time(),
"location" => [
"lat" => <<pickup_lat>>,
"lng" => <<pickup_lng>>,
],
"contact" => [
"name" => "<<user_name>>",
"phone_number" => "<<user_phone_number>>",
],
],
"dropoff" => [
"location" => [
"lat" => <<dropoff_lat>>,
"lng" => <<dropoff_lng>>,
],
],
];
curl_setopt_array($curl, array(
CURLOPT_URL => "https://<<api_base_path>>/orders",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => array(
"Authorization: Bearer <<access_token>>",
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
Updated about 4 years ago