Currency format standard for Square? - square-connect

What is the currency standard for Square's developer API and where can I find the reference for it?
{
"amount": 50,
"currency_code": "USD"
}
In example this page references the amount and currency though it does not clarify how to format currency formats, e.g. USD is the United States Dollar, what about the Canadian Dollar?

From your reference link: "Square represents the exchange as a Money object with a specific currency in ISO 4217 format and a positive or negative amount, where the amount is given in the smallest denomination of the given currency.". It means, you should use ISO 4217 for currency code. For Canadian Dollar it will be CAD.

Related

Why Sheets IMPORTXML doesn't honor the currency of the URL

I'm trying to create a report for work by using ImportXML but I noticed that the result shows only the USD value and not the EUR value is on the website, Is there a reason behind that?
Here is the formula in Google Sheets
=IMPORTXML("https://www.suissegold.eu/en/category/buy-gold-coins/2021-gold-coins?&change-currency=EUR","//div[#class='info']")
I expect to get a result like:
2021 Australian Kangaroo 1 Ounce Gold Coin 1558.36 EUR
But I get it as
2021 Australian Kangaroo 1 Ounce Gold Coin 1850.24 USD
I can't figure out why it doesn't honor the URL for the EUR or any other currency and keep showing the USD.
I tried to inspect the EUR element to see the website JS function that is converting USD to EUR to know which exchange rate or from which website the exchange rate is but I failed.
Thank you in advance
try to run it via proxy:
=IMPORTXML("https://de.4everproxy.com/direct/aHR0cHM6Ly93d3cuc3Vpc3NlZ29sZC5ldS9lbi9jYXRlZ29yeS9idXktZ29sZC1jb2lucy8yMDIxLWdvbGQtY29pbnM-",
"//div[#class='info']")

How to localize country names in phrases?

I want to localize phrases like "Places in {country name}" where the country name is dynamically obtained (e.g. by -[NSLocale localizedStringForCountryCode:]).
The problem is that for some country names, an article must be prepended:
Places in the United States (en)
Sometimes in plural form, male or female, capitalized or not:
Lugares en los estados unidos (es)
Lugares en las Maldivas (es)
The article might even have to be declined according to the casus (nominative, dative etc) of the country name in the phrase:
Orte in der Schweiz (de)
Wir fahren in die Schweiz (de for "we go to Switzerland")
Or we even might might a different preposition:
Orte auf den Malediven (de, using "auf" instead of "in" because the Maldives are islands)
Is there either a library or a good set of rules (e.g. regular expression based) that one could use to accomplish this?
While I'm primarily searching for an iOS solution, I'm open to port any solution from other platforms.
This problem is best solved by avoiding it altogether: localise the entire phrases, and key them by the ISO country code.
The reason is that the rules are complex, not necessarily regular, and differ from language to language. Take Russian for example, where the country name itself (as opposed to just a preposition) has to be modified based on the casus in which the word appears in the sentence — I assume the same holds for various other Slavic languages.

Google Place API street type list

I am using google place to retrieve address, and somehow we want the street(route in google terminology) to be separated into street name and street type. We also want the street type to match an existing column in database.
But things get difficult when google place sometimes use XXXX Street and some times XXXX st
For instance, this is a typical google address
{
administrative_area_level_1: ['short_name', 'VIC'],
locality: ['long_name', 'Carlton'],
postal_code: ['long_name', '3053'],
route: ['long_name', 'Canada Ln'],
street_number: ['short_name', '12'],
subpremise: ['short_name', '13']
}
But it always shows Canada Lane in the suggestion box.
And sometimes even worse when the abbreviation does not match my local data model. For instance we use la instead of ln for short of lane.
It will be appreciated if anyone could tell me where to find a list of street type (and abbreviation) used by google API. Or Is there a way to disable the abbreviation option?
Sounds like you're after "street suffixes". These are complicated.
Not only they change across countries and languages, even within the same country and language they can be used in different ways; abbreviations can have multiple meanings: "St" can be "Street" of "Saint"; abbreviations are used or not depending on subtle rules that also change from place to place.
Same goes for cardinal points (North, South, East, West) that are parts of road / street names: "North St" or "N 11st Street"? It's complicated.
If you already have a good amount of addresses, and you only care about addresses in English, you could take the last word from each street name as the suffix. When matching to your own data, allow for abbreviations when matching, rather than trying to expand them.
For instance, don't try to expand "Canada La" into "Canada Lane" so that it matches "Lane". Instead, expand "Lane" into ["Lane", "La", "Ln"] and match suffixes to all values.
Then you'd need a strategy for "collisions", abbreviations that can mean 2+ suffixes. These seem to be rare, I can't remember any ("St" isn't, because "Saint" isn't a suffix) and USPS' http://pe.usps.gov/text/pub28/28apc_002.htm doesn't seem to have any.

How to Remove Trailing Zeros in XPath?

I have some not very clean 3rd party data that included numbers like:
PRICE
118.0000
99.0000
etc etc
normally would just use:
{price[1]}
but I just get price like $18,000,000.00 where it should be $118
I tried this (just guessing) ...
number{('price[1]')}
but nothing showed up for the price.
I also tried
format-number{(., 'price[1]')}
but that did not work.
Then I read I can use
translate(#Price, ',.', '.')
I tried that as
translate(#price, ',.', '.')
but no price showed
I then tried several variations using the [1] part , I'm only guessing as I'm not really a coder:
{translate(#price[1], ',.', '.')}
{translate(#price[1],',.','.')} ( I clean the spaces out)
then this one
translate(#price[1], ',.', '.')
and it finally showed a price but only as $1.00 where it should have been $1055 or another one should have been $1145 but they all showed $1.00
What can I do, it must be all on one line as it goes in my web based form to be submitted to import the data?
UPDATED:
Here is what I tried to write in the comments:
I tried these below and this is the results.I used your exact examples including the price as in the first 2 examples, then I tried with the "price" code but that is producing a $1 price again.
substring-before(118.00, '.') $11,800.00
substring-before('118.00','.')$11,800.00
substring-before('price[1]','.')$1.00
substring-before(price[1], '.')$1.00
I also tried using the brackets as I would normaly but that produces no price...
{substring-before(price[1], '.')}
{substring-before('price[1]','.')}
{substring-before('118.00','.')}
{substring-before(118.00, '.')}
I have tried to upload a much smaller copy of some of the input document and just changed some private details with "privatedomain" but I have no permission to include the links so they were deleted.
PROGRAMNAME PROGRAMURL CATALOGNAME LASTUPDATED NAME KEYWORDS DESCRIPTION SKU MANUFACTURER MANUFACTURERID UPC ISBN CURRENCY SALEPRICE PRICE RETAILPRICE FROMPRICE BUYURL IMPRESSIONURL IMAGEURL ADVERTISERCATEGORY THIRDPARTYID THIRDPARTYCATEGORY AUTHOR ARTIST TITLE PUBLISHER LABEL FORMAT SPECIAL GIFT PROMOTIONALTEXT STARTDATE ENDDATE OFFLINE ONLINE INSTOCK CONDITION WARRANTY STANDARDSHIPPINGCOST
PrivateName (deleted link) PrivateName - Product Catalog 2015-03-21 23:06:21.558 Ainsley Cuff, Gold $100-$299, cuff, gold, Open Cuff Captivatingly colorful, Kendra Scott’s collection will spruce up a basic sweater and can simultaneously fancy up a dressier cocktail frock. Her pieces have a southern influence, which brings fun, festivity, and charm to the collection’s aesthetic. 14k Gold Plated 2 Inches Wide Malleable kens-00005B Kendra Scott USD 120.0000 (deleted link) (deleted link)/jpeg_1.jpg Bracelets All Jewelry ,Designers,Shop All,All Jewelry,A-Z Designers,Shop by Occasion,Best of PrivateName,Kendra Scott,Office,Everyday,Vacation,Classic,Casual,Byzantine,Black and White,Gold,Cuff,Destination: Morocco,Back in Stock,Kendra Scott,Bracelets yes
PrivateName (deleted link) PrivateName - Product Catalog 2015-03-21 23:06:21.559 Crystal Deco Brooch $100-$299, crystal "Part of the Ben-Amun Evening Collection. Antique silver-plated over brass Clear Swarovski crystals Length 2.5"" NOTES: This product is made-to-order. Please allow up to 2-3 weeks for delivery. Expedited shipping is not available." BAMU-00037P Ben-Amun Bridal USD 195.0000 (deleted link) (deleted link)/jpg_2.jpg Brooches Collections,Shop By,Designers,Brooches,All Jewelry,Bridal,A-Z Designers,Jewelry Trends,Evening,Bridal,Deco,Crystal,Estate,Ben-Amun Bridal,Shop All yes
PrivateName (deleted link) PrivateName - Product Catalog 2015-03-21 23:06:21.559 Gold Teardrop Cutout Earrings $0-$100, gold "Wendy Mink’s jewelry mixes aspects of traditional Eastern jewelry with classic European design principles. Her pieces are carefully handmade with simple yet unexpected combinations of colors, materials, and shapes. Her collection draws inspiration from textiles created by women in India, Nepal, and Tibet—three regions she spent a great deal of time in while holding a position at the World Bank prior to reinventing herself as a jewelry designer. Gold-plated, 18kt Length 2.5"" Width 1.75"" French wire hook NOTES: This item is made to order and may take up to 3 weeks for delivery." wndm-00107E Wendy Mink USD 73.0000
Please let me know if you need anything else:
If you are using XPATH 1.0 you might be able to use substring-before(xpath, expression)
substring-before(118.00, '.')
should give 118 if I'm not mistaking.

iphone's phone number splitting algorithm?

iPhone has a pretty good telephone number splitting function, for example:
Singapore mobile: +65 9852 4135
Singapore resident line: +65 6325 6524
China mobile: +86 135-6952-3685
China resident line: +86 10-65236528
HongKong: +886 956-238-82
USA: +1 (732) 865-3286
Notice the nice features here:
- the splitting of country code, area code, and the rest is automatic;
- the delimiter is also nicely adopted to different countries, e.g. "()", "-" and space.
Note the parsing logic is doable to me, however, I don't know where to get the knowledge of most countries' telephone number format.
where could i found such knowledge, or an open source code that implemented it?
You can get similar functionality with the libphonenumber code library.
Interestingly enough, you cannot use an NSNumberFormatter for this, but you can write your own custom class for it. Just create a new class, set properties such as countryCode, areaCode and number, and then create a method that formats the number based on the countryCode.
Here's a great example: http://the-lost-beauty.blogspot.com/2010/01/locale-sensitive-phone-number.html
As an aside: a friend told me about a gigantic regular expression he had to maintain that could pick telephone numbers out of intercepted communications from hundreds of countries around the world. It was very non-trivial.
Thankfully your problem is easier, as you can just have a table with the per-country formats:
format[usa] = "+d (ddd) ddd-dddd";
format[hk] = "+ddd ddd-ddd-dd";
format[china_mobile] = "+dd ddd-dddd-dddd";
...
Then when you're printing, you simply output one digit from the phone number string in each d spot as needed. This assumes you know the country, which is a safe enough assumption for telephone devices -- pick "default" formats for the few surrounding countries.
Since some countries have different formats with different lengths you might need to store your table with additional information:
format[germany][10] = "..."
format[germany][11] = "....."

Resources