From f729ea4ce4a6bcd4ea5e870732f7f1e483c93183 Mon Sep 17 00:00:00 2001 From: Max Tepkeev Date: Sun, 31 Mar 2024 16:42:06 +0300 Subject: [PATCH] product image support --- docs/resources/product.rst | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/docs/resources/product.rst b/docs/resources/product.rst index 4253ec9..8edaeb4 100644 --- a/docs/resources/product.rst +++ b/docs/resources/product.rst @@ -42,6 +42,14 @@ create :param string description: (optional). Product description. :param list tag_list: (optional). List of tags. :param list custom_fields: (optional). Custom fields as [{'id': 1, 'value': 'foo'}]. + :param dict image: + .. raw:: html + + (optional). Image to be used for the product as dict, accepted keys are: + + - path (required). Absolute file path or file-like object that should be uploaded. + - filename (optional). Required if a file-like object is provided. + :param list uploads: .. raw:: html @@ -67,6 +75,7 @@ create ... description='product description', ... tag_list=['foo', 'bar'], ... custom_fields=[{'id': 1, 'value': '11'}], + ... image={'path': '/absolute/path/to/file.jpg'}, ... uploads=[{'path': '/absolute/path/to/file'}, {'path': BytesIO(b'I am content of file 2')}] ... ) >>> product @@ -98,6 +107,7 @@ new >>> product.description = 'product description' >>> product.tag_list = ['foo', 'bar'] >>> product.custom_fields = [{'id': 1, 'value': '11'}] + >>> product.image = {'path': '/absolute/path/to/file.jpg'} >>> product.uploads = [{'path': '/absolute/path/to/file'}, {'path': BytesIO(b'I am content of file 2')}] >>> product.save() @@ -251,6 +261,14 @@ update :param string description: (optional). Product description. :param list tag_list: (optional). List of tags. :param list custom_fields: (optional). Custom fields as [{'id': 1, 'value': 'foo'}]. + :param dict image: + .. raw:: html + + (optional). Image to be used for the product as dict, accepted keys are: + + - path (required). Absolute file path or file-like object that should be uploaded. + - filename (optional). Required if a file-like object is provided. + :param list uploads: .. raw:: html @@ -277,6 +295,7 @@ update ... description='product description', ... tag_list=['foo', 'bar'], ... custom_fields=[{'id': 1, 'value': '11'}], + ... image={'path': '/absolute/path/to/file.jpg'}, ... uploads=[{'path': '/absolute/path/to/file'}, {'path': BytesIO(b'I am content of file 2')}] ... ) True @@ -306,6 +325,7 @@ save >>> product.description = 'product description' >>> product.tag_list = ['foo', 'bar'] >>> product.custom_fields = [{'id': 1, 'value': '11'}] + >>> product.image = {'path': '/absolute/path/to/file.jpg'} >>> product.uploads = [{'path': '/absolute/path/to/file'}, {'path': BytesIO(b'I am content of file 2')}] >>> product.save() @@ -325,6 +345,7 @@ save ... description='product description', ... tag_list=['foo', 'bar'], ... custom_fields=[{'id': 1, 'value': '11'}], + ... image={'path': '/absolute/path/to/file.jpg'}, ... uploads=[{'path': '/absolute/path/to/file'}, {'path': BytesIO(b'I am content of file 2')}] ... ) >>> product