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 8 months ago
