Safest way to update Square API? It’s 2 years out of date…
-
Hi,
In trying to get to the bottom of how to import custom attributes I discovered that the Square API that’s being used is almost 2 years out of date.
Looking in the composer.json file we have the following:
{ "name": "square/connect", "version": "2.20190814.2", "version_normalized": "2.20190814.2.0", "source": { "type": "git", "url": "https://github.com/square/connect-php-sdk.git", "reference": "d778579a9f42c06d4eb68bcd78e7371f1b2f8f94" }, etc etc... }
Crucially we can see that the version is
"version": "2.20190814.2"
. The versioning control is simply a date, and looking at all the API releases we can see that the version 2019-08-14 as used by this plugin is almost 2 years old and is 23 versions out of date.Using Square’s API explorer I’ve been able to understand why I can’t find the custom attributes anywhere when logging responses. It’s because the 2019-08-14 version doesn’t return them in the Search Catalog Objects that’s being used.
If you have a log in you can use the API explorer. If you view the output this is the difference:
Version 2019-08-14
https://developer.squareup.com/explorer/square_2019-08-14/catalog-api/search-catalog-objectsExample output:
{ "type": "ITEM", "id": "H2I7PCDDSU6T6F5JY4Y7BUYD", "updated_at": "2021-06-10T16:41:13.671Z", "version": 1623343273671, "is_deleted": false, "present_at_all_locations": true, "image_id": "KXHVKSG6Z6ZZOTRVYVJPCJIT", "item_data": { "name": "Mesmerism", "description": "10.0% ABV\n\nTriple IPA\n\nA mesmerisingly punchy triple IPA with a juicy explosion of flavour.\n\nBig hitting hops complement smooth malts to create a beer that's hypnotically moreish.", "label_color": "593c00", "visibility": "PRIVATE", "category_id": "5SSRTFVDYTIXNHY3BR4TCRLW", "variations": [ { "type": "ITEM_VARIATION", "id": "PN46PFCEFL53Y3YPNO3DY4CF", "updated_at": "2021-06-10T16:41:13.671Z", "version": 1623343273671, "is_deleted": false, "present_at_all_locations": true, "item_variation_data": { "item_id": "H2I7PCDDSU6T6F5JY4Y7BUYD", "name": "Regular", "sku": "2106-voc-mes", "ordinal": 1, "pricing_type": "FIXED_PRICING", "price_money": { "amount": 650, "currency": "GBP" }, "location_overrides": [ { "location_id": "LXTZYFD9F9350", "track_inventory": true } ] } } ], "product_type": "REGULAR", "skip_modifier_screen": false, "ecom_available": true, "ecom_visibility": "VISIBLE" } },
Latest version (at time of writing is Version 2021-06-16)
https://developer.squareup.com/explorer/square/catalog-api/search-catalog-objectsExample output of same product:
{ "type": "ITEM", "id": "H2I7PCDDSU6T6F5JY4Y7BUYD", "updated_at": "2021-06-10T16:41:13.671Z", "version": 1623343273671, "is_deleted": false, "present_at_all_locations": true, "image_id": "KXHVKSG6Z6ZZOTRVYVJPCJIT", "item_data": { "name": "Mesmerism", "description": "10.0% ABV\n\nTriple IPA\n\nA mesmerisingly punchy triple IPA with a juicy explosion of flavour.\n\nBig hitting hops complement smooth malts to create a beer that's hypnotically moreish.", "label_color": "593c00", "visibility": "PRIVATE", "category_id": "5SSRTFVDYTIXNHY3BR4TCRLW", "variations": [ { "type": "ITEM_VARIATION", "id": "PN46PFCEFL53Y3YPNO3DY4CF", "updated_at": "2021-06-10T16:41:13.671Z", "version": 1623343273671, "is_deleted": false, "custom_attribute_values": { "Square:13273a54-ddc5-4b0e-96ce-9193283a20ee": { "name": "Can Size", "string_value": "440ml", "custom_attribute_definition_id": "55EM4DQW4DOQTKN5IHAPKMEL", "type": "STRING", "key": "Square:13273a54-ddc5-4b0e-96ce-9193283a20ee" }, "Square:bbe746d0-63d2-42d4-84ac-9e5ca322c60c": { "name": "ABV", "custom_attribute_definition_id": "LKK2USVTVFJEN7CZVRP3LZPA", "type": "NUMBER", "number_value": "10.0", "key": "Square:bbe746d0-63d2-42d4-84ac-9e5ca322c60c" }, "Square:e742a6d8-8a7c-4372-88b7-fee64e079f6d": { "name": "Brewery", "string_value": "Vocation Brewery", "custom_attribute_definition_id": "JCQGGR7ZXCOFLNILFZTFLBT7", "type": "STRING", "key": "Square:e742a6d8-8a7c-4372-88b7-fee64e079f6d" } }, "present_at_all_locations": true, "item_variation_data": { "item_id": "H2I7PCDDSU6T6F5JY4Y7BUYD", "name": "Regular", "sku": "2106-voc-mes", "ordinal": 1, "pricing_type": "FIXED_PRICING", "price_money": { "amount": 650, "currency": "GBP" }, "location_overrides": [ { "location_id": "LXTZYFD9F9350", "track_inventory": true } ], "stockable": true } } ], "product_type": "REGULAR", "skip_modifier_screen": false, "ecom_available": true, "ecom_visibility": "VISIBLE" } },
As you can see those very important custom attributes are returned in the latest version, 2021-06-16 but not in the version that this plugin is using, 2019-08-14.
"custom_attribute_values": { "Square:13273a54-ddc5-4b0e-96ce-9193283a20ee": { "name": "Can Size", "string_value": "440ml", "custom_attribute_definition_id": "55EM4DQW4DOQTKN5IHAPKMEL", "type": "STRING", "key": "Square:13273a54-ddc5-4b0e-96ce-9193283a20ee" }, "Square:bbe746d0-63d2-42d4-84ac-9e5ca322c60c": { "name": "ABV", "custom_attribute_definition_id": "LKK2USVTVFJEN7CZVRP3LZPA", "type": "NUMBER", "number_value": "10.0", "key": "Square:bbe746d0-63d2-42d4-84ac-9e5ca322c60c" }, "Square:e742a6d8-8a7c-4372-88b7-fee64e079f6d": { "name": "Brewery", "string_value": "Vocation Brewery", "custom_attribute_definition_id": "JCQGGR7ZXCOFLNILFZTFLBT7", "type": "STRING", "key": "Square:e742a6d8-8a7c-4372-88b7-fee64e079f6d" } },
This is the key to making the filters work on my website without having to do laborious data entry jobs multiple times.
My Question
What is the safest way to update the Square API version that is being used?I need the custom attributes to be synced with my WooCommerce store, and they are not available under the version being used. Therefore I need to update the API version before I can sort out the custom attributes. Please advise.
Thanks in advance!
Joe
- The topic ‘Safest way to update Square API? It’s 2 years out of date…’ is closed to new replies.