how we get uber api results in us dollar currency code with Indian account - uber-api

I have Indian uber developer account , so its give me results in INR currency _code , but I want results in us dollar , anybody tell me how it is possible.
{
"prices": [
{
"localized_display_name": "uberGO",
"distance": 0,
"display_name": "uberGO",
"product_id": "40269682-90dc-4d18-8c38-5b4035e35296",
"high_estimate": 40,
"surge_multiplier": 1,
"minimum": 40,
"low_estimate": 40,
"duration": 0,
"estimate": "₹ 40",
"currency_code": "INR"
},
{
"localized_display_name": "uberX",
"distance": 0,
"display_name": "uberX",
"product_id": "8e1107eb-82f3-4ed4-9969-e6c7c73d8c86",
"high_estimate": 50,
"surge_multiplier": 1,
"minimum": 50,
"low_estimate": 50,
"duration": 0,
"estimate": "₹ 50",
"currency_code": "INR"
}
]
}

I believe this link should help: https://developer.uber.com/docs/ride-requests/guides/localization
"Currency: Currency is rendered in the local currency of a given latitude & longitude pair. A fare estimate in San Francisco will be given in USD, while a fare estimate in Paris will be displayed in EUR. We also provide the ISO 4217 currency code for your own conversions."
Cheers.

Related

How to parse dynamic json?

I'm new to flutter development, I can't figure out how to parse json correctly, since lists are changeable.
Maybe there are some libraries that allow you to turn json into an object right away?
{
"name": "Nuan",
"key": "wqewewrwerer",
"places": {
"1": {
"place": 1,
"numberPlaces": 4,
"type": "TABLE"
},
"2": {
"place": 2,
"numberPlaces": 4,
"type": "TABLE"
},
"3": {
"place": 3,
"numberPlaces": 4,
"type": "TABLE"
}
},
"menu": {
"categories": [{
"name": "Salads",
"elements": [{
"id": 1,
"name": "Caesar salad",
"img": "cesar.jpg",
"price": 4,
"currency": "USD",
"weight": "222",
"typeWeight": "g",
"time": 3,
"calories": 500,
"description": "The salad\u0027s creation is generally attributed to the restaurateur Caesar Cardini, an Italian immigrant who operated restaurants in Mexico and the United States. His daughter Rosa recounted that her father invented the salad at his Prohibition-era restaurant in Tijuana, Mexico when a Fourth of July rush in 1924 depleted the kitchen\u0027s supplies. (Cardini lived in San Diego but ran the family restaurant in Tijuana to attract American customers seeking to circumvent the restrictions of the Prohibition). Cardini made do with what he had, adding the dramatic flair of the table-side tossing \"by the chef.\" A number of Cardini\u0027s staff have said that they invented the dish.",
"structure": "croutons, romaine, anchovies, parmeasan cheese, olive oil, vinegar and plenty of black pepper."
}, {
"id": 2,
"name": "Greek salad",
"img": "grek.jpg",
"price": 5,
"currency": "USD",
"weight": "220",
"typeWeight": "g",
"time": 3,
"calories": 300,
"description": "Various other salads have also been called \"Greek\" in the English language in the last century, including some with no apparent connection to Greek cuisine. A 1925 Australian newspaper described a Greek salad of boiled squash dressed with sour milk; a 1934 American newspaper described a mayonnaise-dressed lettuce salad with shredded cabbage and carrots",
"structure": "Lettuce, tomatoes, feta, olives, cucumber"
}, {
"id": 3,
"name": "Salmon salad",
"img": "semga.jpg",
"price": 8,
"currency": "USD",
"weight": "250",
"typeWeight": "g",
"time": 3,
"calories": 400
}, {
"id": 4,
"name": "Hunting salad",
"img": "hunting.jpg",
"price": 7,
"currency": "USD",
"weight": "220",
"typeWeight": "g",
"time": 4,
"calories": 390,
"description": "Hunting salad has such a name, since it includes meat of animals caught by hunters. History is silent at what point the game meat was replaced with beef, hunting sausages or even pork, but in our reality it is these meat products that are used for such a salad. The salad turns out to be very satisfying, nutritious and quite dense � ideal for men\u0027s snacks.",
"structure": "sausages, potatoes, greens"
}]
}, {
"name": "soups",
"elements": [{
"id": 5,
"name": "Solyanka soup",
"img": "solyanka.jpg",
"price": 10,
"currency": "USD",
"weight": "300",
"typeWeight": "g",
"time": 15,
"calories": 300,
"description": "There is no consensus on the correctness of the name selyanka in relation to soup. Russian linguist and writer L. I. Skvortsov writes about the traditionality of the name selyanka and the ambiguity of the etymology of the word \"solyanka\", at the same time, Russian historian, researcher and popularizer of cooking V. V. Pokhlebkin writes about the incorrectness and distortion of the name selyanka and claims that the name solyanka is fixed in the \"House-building\" of 1547, while the term selyanka took root only in the XIX century and at the beginning of the XX century was again replaced by the term solyanka. The Dictionary of the Russian Academy (1794) indicated the name solyanka as the main variant, and marked the selyanka variant as \"simple\"",
"structure": "sausage, potato, onion, tomato, pickle"
}, {
"id": 6,
"name": "Borsch soup",
"img": "borsch.jpg",
"price": 8,
"currency": "USD",
"weight": "300",
"typeWeight": "g",
"time": 15,
"calories": 300,
"description": "In the old days, borscht was called soup made from borscht. Later borscht was cooked on beet kvass: it was diluted with water, the mixture was poured into a clay pot or cast iron and brought to a boil. Chopped beets, cabbage, carrots and other vegetables were put in boiling water and put the pot in the oven. The cooked borscht was salted and refilled",
"structure": "meat, carrots, onions, potatoes, beets, white cabbage, beans, tomato paste, vegetable oil, bay leaf, sugar, vinegar"
}, {
"id": 7,
"name": "Mushroom soup",
"img": "mushroom.jpg",
"price": 10,
"currency": "USD",
"weight": "230",
"typeWeight": "g",
"time": 16,
"calories": 320,
"description": "Cream soup with mushrooms has been prepared since about the 17th century, when entrepreneurs already learned how to grow champignons in artificial conditions. It was in France, so this country is considered the birthplace of mushroom soups-puree. But the soup with dried porcini mushrooms is cooked on water and already only one aroma, spreading around the house, can drive even the most refined gourmets crazy.",
"structure": "potatoes, onions, herbs, salt, pepper, vegetable oil, mushrooms, soft processed cheese"
}]
}, {
"elements": [{
"id": 8,
"name": "Crackers",
"img": "crackers.png",
"price": 4,
"currency": "USD",
"weight": "200",
"typeWeight": "g",
"time": 12,
"calories": 600,
"description": "Crackers are second-baked bread, \"dried for the purpose of either storage or further culinary use in various dishes,\" is the definition of the product given by William Pohlebkin (1923-2000), a Russian historian and writer. The main distinguishing feature of crackers from all other bakery products is their reduced humidity, ideally no more than forty-nine percent, more often - up to eight.",
"structure": "bread, garlic, salt, oil"
}, {
"id": 9,
"name": "Croutons",
"img": "croutons.png",
"price": 4,
"currency": "USD",
"weight": "200",
"typeWeight": "g",
"time": 12,
"calories": 580,
"description": "Croutons are made from any bread and are used as a light snack, for example, croutons with garlic for beer, or as an ingredient in soups, broths, salads (\"Caesar\"), cutlets and other dishes. To add to soups (French onion soup), bread is simply fried with salt and/or black pepper.",
"structure": "white bread, garlic, salt, pepper, oil"
}, {
"id": 11,
"name": "Chips",
"img": "chips.png",
"price": 3,
"currency": "USD",
"weight": "100",
"typeWeight": "g",
"time": 3,
"calories": 330,
"structure": "potatoes, salt, pepper, oil"
}]
}]
},
"description": "There are many things in the world, friend Horatio, that our wise men never dreamed of"
}
I've seen standard ways where data is passed to the constructor, but it's not entirely clear how to embed large json there
You can use the json2Dart utility to generate your dart objects and call the fromJson() method on your root object :)

Better way to display images in Magento's default API response?

I am using Magento2 default API: /V1/carts/mine/payment-information.
The response from this API is:
{
"payment_methods": [
{
"code": "payu",
"title": "PayUMoney"
},
{
"code": "checkmo",
"title": "Check / Money order"
},
{
"code": "paytm",
"title": "Paytm PG"
}
],
"totals": {
"grand_total": 195,
"base_grand_total": 195,
"subtotal": 45,
"base_subtotal": 45,
"discount_amount": 0,
"base_discount_amount": 0,
"subtotal_with_discount": 45,
"base_subtotal_with_discount": 45,
"shipping_amount": 150,
"base_shipping_amount": 150,
"shipping_discount_amount": 0,
"base_shipping_discount_amount": 0,
"tax_amount": 0,
"base_tax_amount": 0,
"weee_tax_applied_amount": null,
"shipping_tax_amount": 0,
"base_shipping_tax_amount": 0,
"subtotal_incl_tax": 45,
"shipping_incl_tax": 150,
"base_shipping_incl_tax": 150,
"base_currency_code": "INR",
"quote_currency_code": "INR",
"items_qty": 1,
"items": [
{
"item_id": 41,
"price": 45,
"base_price": 45,
"qty": 1,
"row_total": 45,
"base_row_total": 45,
"row_total_with_discount": 0,
"tax_amount": 0,
"base_tax_amount": 0,
"tax_percent": 0,
"discount_amount": 0,
"base_discount_amount": 0,
"discount_percent": 0,
"price_incl_tax": 45,
"base_price_incl_tax": 45,
"row_total_incl_tax": 45,
"base_row_total_incl_tax": 45,
"options": "[{\"value\":\"Green\",\"label\":\"Color\"},{\"value\":\"29\",\"label\":\"Size\"}]",
"weee_tax_applied_amount": null,
"weee_tax_applied": null,
"name": "Erika Running Short"
}
],
"total_segments": [
{
"code": "subtotal",
"title": "Subtotal",
"value": 45
},
{
"code": "shipping",
"title": "Shipping & Handling (Fixed)",
"value": 150
},
{
"code": "tax",
"title": "Tax",
"value": 0,
"extension_attributes": {
"tax_grandtotal_details": []
}
},
{
"code": "grand_total",
"title": "Grand Total",
"value": 195,
"area": "footer"
}
]
}
}
I want to add the images tag inside items to display images of the items/products. But this tag is not defined in the interface of items, i.e
TotalsItemInterface.php
I replicated TotalsItemInterface in my custom module and added all getters and setters from Totalsinterface along with setImages and getImages Tag. Thus internally I call the method to use and show it by my custom apiInterfaces.
Is there a better or a proper "Magento 2 way" if we want to change the data displayed in the APIs?
You may use extension attributes for it. You can find more information about them in the devdocs there:
https://devdocs.magento.com/guides/v2.3/extension-dev-guide/extension_attributes/adding-attributes.html

Uber API GET/estimates/price response surge_multiplier disappeared

today, I found GET/estimates/price end point have a change, surge_multiplier disappeared, is to say, price has been fixed, no more surge?
Surging is based on the particular location and product setup - so if you try following request for example:
https://sandbox-api.uber.com//v1.2/estimates/price?start_latitude=-33.865535736083984&start_longitude=151.1958770751953&end_latitude=-33.88345718383789&end_longitude=151.0906982421875
"prices": [
{
"localized_display_name": "uberX",
"distance": 7.76,
"display_name": "uberX",
"product_id": "2d1d002b-d4d0-4411-98e1-673b244878b2",
"high_estimate": 35,
"surge_multiplier": 1,
"minimum": 9,
"low_estimate": 26,
"duration": 1260,
"estimate": "A$26-35",
"currency_code": "AUD"
},
If you try it for different location:
start_latitude=37.7752315&start_longitude=-122.418075&end_latitude=37.7752415&end_longitude=-122.518075
You will get response without 'surge_multiplier' parameter:
{
"localized_display_name": "uberXL",
"distance": 6.62,
"display_name": "uberXL",
"product_id": "821415d8-3bd5-4e27-9604-194e4359a449",
"high_estimate": 28,
"low_estimate": 22,
"duration": 1380,
"estimate": "$22-28",
"currency_code": "USD"
},
For more info on surging please read our documetation
EDIT done on 02/15/2018:
If you are using v1.2 request - response we are getting is based on the product setup. If the product used in the estimate request is configured to have "upfront_fare_enabled": true then we will get one fare_id - instead of estimate. So this is expected as in v1.2 with upfront_fare_enabled: true there will never be surge information (as you get a real fare + fare_id).
Please check following sentence from our documentation on "POST /v1.2/requests/estimate" endpoint:
You should use this endpoint to get an upfront fare before requesting
a ride. In some products upfront fares are not enabled so you can use
this endpoint to determine if surge pricing is in effect for the
product/location. Do this before attempting to make a ride request so
that you can preemptively have a user confirm surge by sending them to
the surge_confirmation_href provided in the response. This endpoint
will either return an upfront fare (in the fare key) or a range
estimate (in the estimate key) depending on the configuration of the
product.
So the response you are getting back depends on product configuration specifically: "upfront_fare_enabled" field. If there is upfront fare setup (upfront_fare_enabled = true) then there will not be "surge_confirmation_href" available in the response - and response type will be one "fare": {} response - example of this is below:
{
"fare": {
"value": 5.73,
"fare_id": "d30e732b8bba22c9cdc10513ee86380087cb4a6f89e37ad21ba2a39f3a1ba960",
"expires_at": 1476953293,
"display": "$5.73",
"currency_code": "USD",
"breakdown": [
{
"type": "promotion",
"value": -2.00,
"name": "Promotion"
},
{
"type": "base_fare",
"notice": "Fares are slightly higher due to increased demand",
"value": 7.73,
"name": "Base Fare"
}
]
},
"trip": {
"distance_unit": "mile",
"duration_estimate": 540,
"distance_estimate": 2.39
},
"pickup_estimate": 2
}
As you can see there is no "surge_confirmation_href" available.
If your product has "upfront_fare_enabled": false you will get estimate response with surge_confirmation_id and surge_confirmation_href as shown below:
{
"estimate": {
"surge_confirmation_href": "https:\/\/api.uber.com\/v1\/surge-confirmations\/7d604f5e",
"high_estimate": 11,
"surge_confirmation_id": "7d604f5e",
"minimum": 5,
"low_estimate": 8,
"fare_breakdown": [
{
"low_amount": 1.25,
"high_amount": 1.25,
"display_amount": "1.25",
"display_name": "Base Fare"
},
{
"low_amount": 1.92,
"high_amount": 2.57,
"display_amount": "1.92-2.57",
"display_name": "Distance"
},
{
"low_amount": 2.50,
"high_amount": 3.50,
"display_amount": "2.50-3.50",
"display_name": "Surge x1.5"
},
{
"low_amount": 1.25,
"high_amount": 1.25,
"display_amount": "1.25",
"display_name": "Booking Fee"
},
{
"low_amount": 1.36,
"high_amount": 1.81,
"display_amount": "1.36-1.81",
"display_name": "Time"
}
],
"surge_multiplier": 1.5,
"display": "$8-11",
"currency_code": "USD"
},
"trip": {
"distance_unit": "mile",
"duration_estimate": 480,
"distance_estimate": 1.95
},
"pickup_estimate": 2
}
And finally, if you update the product to have "surge_multiplier" > 1 and product have "upfront_fare_enabled = true" you will get "fare" response - but you will not know that surging is in place - until you do ride request. In this case, you will get the response with: "status": 409 and "title": "Surge pricing is currently in effect for this product." and "surge_confirmation" info that contains "href": "https://sandbox-api.uber.com/surge-confirmations/ride_request_id". So in order to complete your ride request - you need to redirect your user to that URL - and user needs to confirm surging. After that, you will be able to create new ride request.
resposne->
{
"meta": {
"surge_confirmation": {
"href": "https://sandbox-api.uber.com/surge-confirmations/48165d0e-f2f4-457d-98d0-058a31b15cd7",
"expires_at": 1510684778,
"multiplier": 1.2,
"surge_confirmation_id": "48165d0e-f2f4-457d-98d0-058a31b15cd7"
}
},
"errors": [
{
"status": 409,
"code": "surge",
"title": "Surge pricing is currently in effect for this product."
}
]
}

Why do I get two UberPool products in the APIs?

I get two UberPool products in the following APIs:
api.uber.com/v1/estimates/time
api.uber.com/v1/estimates/price
api.uber.com/v1/products
Why do I get two products? How are they different?
Example response:
Url:
api.uber.com/v1/estimates/price
Response:
{
"prices": [
{
"localized_display_name": "uberPOOL",
"high_estimate": 33,
"minimum": null,
"duration": 0,
"estimate": "₹32.50",
"distance": 0,
"display_name": "uberPOOL",
"product_id": "e0178e76-b13f-4ae6-9f72-6acadbb450c5",
"low_estimate": 32,
"surge_multiplier": 1,
"currency_code": "INR"
},
{
"localized_display_name": "uberPOOL",
"high_estimate": 51,
"minimum": null,
"duration": 0,
"estimate": "Unavailable",
"distance": 0,
"display_name": "uberPOOL",
"product_id": "f855a84b-a0ec-40d8-a455-fb0d2db58089",
"low_estimate": 50,
"surge_multiplier": 1,
"currency_code": "INR"
},
{
"localized_display_name": "uberGO",
"high_estimate": 50,
"minimum": 50,
"duration": 0,
"estimate": "₹50",
"distance": 0,
"display_name": "uberGO",
"product_id": "18ba4578-b11b-49a6-a992-a132f540b027",
"low_estimate": 50,
"surge_multiplier": 1,
"currency_code": "INR"
}
....
]
}
Thank you for the report. This is a known issue and we're working on a fix. In the meantime, you can use either uberPOOL product that is surfaced.
TL;DR Uber sometimes offers many products in a given location, and they're all returned from those two endpoints.
To expound on that... according to the docs, this is normal:
The Products endpoint returns information about the Uber products
offered at a given location. The response includes the display name
and other details about each product, and lists the products in the
proper display order.
Some products, such as uberEATS, are not returned by this endpoint.
We'll soon be making uberPOOL available in this endpoint.
Particularly: We'll soon be making uberPOOL available in this endpoint. It seems that time has come.
The same goes for the estimates endpoint.
The Price Estimates endpoint returns an estimated price range for each
product offered at a given location.
How are they different?
Uber offers different types of services in different countries.
UberGo is a cheaper version of UberX that seems to be specific to India.
UberPool is fairly straight forward in that it's a carpooling service offered to those who wish to split the fare with others that are heading in the same destination.
Since services vary by location, it's best to research them individually when constructing a service that's consuming the Uber API.

Trying to figure out how tax lines work when creating Shopify order via API

I am posting the following to the Shopify API create order endpoint and receiving a response without tax lines that are filled. I haven't seen anything on the internet on this, other than that Shopify doesn't offer another endpoint for just taxes. So, I am trying to figure out if tax lines are supposed to be generated automatically in the order response when creating an order via the API or if I have to include the tax lines in the request in order for tax lines to be included, because I know when I create an order in the admin the tax lines are automatically calculated and included for me?:
{
"order": {
"email": "some#email.com",
"financial_status": "paid",
"fulfillment_status": null,
"send_receipt": true,
"send_fulfillment_receipt": true,
"note": "Created by somename",
"line_items": [
{
"variant_id": 21718275463,
"quantity": 1,
"price": 99,
"requires_shipping": true,
"product_id": 6820646151
},
{
"variant_id": 21717700871,
"quantity": 1,
"price": 1000,
"requires_shipping": true,
"product_id": 6820646151
},
{
"variant_id": 21717690055,
"quantity": 1,
"price": 555,
"requires_shipping": true,
"product_id": 6821668807
}
],
"processing_method": "offsite",
"shipping_address": {
"first_name": "Chris",
"address1": "10101 Musick Road",
"phone": "9999999999",
"city": "St. Louis",
"zip": "63123",
"province": "MO",
"country": "United States",
"last_name": "Becker",
"name": "Chris Becker",
"country_code": "US",
"province_code": "MO"
},
"source_name": "somename",
"taxes_included": false,
"shipping_lines": [
{
"title": "standard",
"price": 0.00,
"code": null,
"source": "brand owner on shopify",
"carrier_identifier": null,
"tax_lines": null
}
],
"tags": "some Order"
}
}
Here is a useful documentation about tax: https://help.shopify.com/api/reference/location
Tax are not automatically calculated from cart.js ajax api. They just give a clue whether tax is already included in the price or not. If not, then it can be added with the bill.