x

Need more info on using the Python create_catalog_image call.

I'm trying to  use the create_catalog_image call from the Python api (https://github.com/square/square-python-sdk/blob/master/doc/api/catalog.md#create-catalog-image) , but more information is needed.  The example shows:

request = {}
request['idempotency_key'] = '528dea59-7bfb-43c1-bd48-4a6bba7dd61f86'
request['object_id'] = 'ND6EA5AAJEO5WL3JNNIAQA32'
request['image'] = {}
request['image']['type'] = 'IMAGE'
request['image']['id'] = '#TEMP_ID'
request['image']['updated_at'] = 'updated_at4'
request['image']['version'] = 68
request['image']['is_deleted'] = False
request['image']['custom_attribute_values'] = {}
request['image']['catalog_v1_ids'] = []

request['image']['catalog_v1_ids'].append({})
request['image']['catalog_v1_ids'][0]['catalog_v1_id'] = 'catalog_v1_id4'
request['image']['catalog_v1_ids'][0]['location_id'] = 'location_id4'

request['image']['image_data'] = {}
request['image']['image_data']['name'] = 'name0'
request['image']['image_data']['url'] = 'url4'
request['image']['image_data']['caption'] = 'A picture of a cup of coffee'
request['image']['image_data']['photo_studio_order_id'] = 'photo_studio_order_id2'
request['is_primary'] = False
image_file = FileWrapper(open('dummy_file', 'rb'), 'optional-content-type')

result = catalog_api.create_catalog_image(request, image_file)

if result.is_success():
    print(result.body)
elif result.is_error():
    print(result.errors)

 But the import statement for the FileWrapper object is not shown.  There are multiple FileWrapper objects available, which should I use?

 

Also what I would like to do is read the image from an HTTP response and send it directly to the call without having to save it first, so any pointers there would be helpful.

546 Views
Message 1 of 3
Report
2 REPLIES 2
Square Community Moderator

Welcome to the Community, @travbow

 

This is definitely not my forte, but I can try to find out an answer for you to pass along. Can you give me a little more context into what you are trying to do? I just want to make sure I am asking the proper question to the team. Is this for an external/third party website? 

 

Thanks! 

 

 

 

480 Views
Message 2 of 3
Report

Hello,

 

from square.utilities.file_wrapper import FileWrapper

 

Thank you.

Powered by Custom Software Square Developers
393 Views
Message 3 of 3
Report