Repository: line/line-bot-sdk-python
Pull request #90 (2017-12-31 13:09:02)

Support 2017/11/30 "New options for template message images"
Support the following image options for buttons/carousel template
message:
- imageAspectRatio
- imageSize
- imageBackgroundColor


Patch:
diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md
index 9f32f91..4507dd2 100644
--- a/.github/ISSUE_TEMPLATE.md
+++ b/.github/ISSUE_TEMPLATE.md
@@ -1,7 +1,7 @@
 ## Do this before creating an issue
 
-- Check the [FAQ](https://github.com/line/line-bot-faq) for LINE bots
-- Make sure your issue is **related to** the LINE Bot SDK. For general questions or issues about LINE bots, create an issue on the [FAQ](https://github.com/line/line-bot-faq) repository. Note that we don't provide technical support.
+- Check our [developer documentation](https://developers.line.me/en/docs/) and [FAQ](https://developers.line.me/en/faq/messaging-api/) page for more information on LINE bots and the Messaging API
+- Make sure your issue is **related to** the LINE Bot SDK. For general questions or issues about LINE bots, create an issue on the [LINE Platform feedback](https://github.com/line/line-platform-feedback) repository. Note that we don't provide technical support.
 
 ## When creating an issue
 
diff --git a/README.rst b/README.rst
index 90e885a..a823ef7 100644
--- a/README.rst
+++ b/README.rst
@@ -10,9 +10,9 @@ About the LINE Messaging API
 
 See the official API documentation for more information.
 
-English: https://devdocs.line.me/en/
+English: https://developers.line.me/en/docs/messaging-api/reference/
 
-Japanese: https://devdocs.line.me/ja/
+Japanese: https://developers.line.me/ja/docs/messaging-api/reference/
 
 Install
 -------
@@ -97,7 +97,7 @@ reply\_message(self, reply\_token, messages, timeout=None)
 Respond to events from users, groups, and rooms. You can get a
 reply\_token from a webhook event object.
 
-https://devdocs.line.me/en/#reply-message
+https://developers.line.me/en/docs/messaging-api/reference/#send-reply-message
 
 .. code:: python
 
@@ -108,7 +108,7 @@ push\_message(self, to, messages, timeout=None)
 
 Send messages to users, groups, and rooms at any time.
 
-https://devdocs.line.me/en/#push-message
+https://developers.line.me/en/docs/messaging-api/reference/#send-push-message
 
 .. code:: python
 
@@ -119,7 +119,7 @@ multicast(self, to, messages, timeout=None)
 
 Send messages to multiple users at any time.
 
-https://devdocs.line.me/en/#multicast
+https://developers.line.me/en/docs/messaging-api/reference/#send-multicast-messages
 
 .. code:: python
 
@@ -130,7 +130,7 @@ get\_profile(self, user\_id, timeout=None)
 
 Get user profile information.
 
-https://devdocs.line.me/en/#bot-api-get-profile
+https://developers.line.me/en/docs/messaging-api/reference/#get-profile
 
 .. code:: python
 
@@ -148,7 +148,7 @@ Gets the user profile of a member of a group that the bot is in. This can be
 the user ID of a user who has not added the bot as a friend or has blocked
 the bot.
 
-https://devdocs.line.me/en/#get-group-room-member-profile
+https://developers.line.me/en/docs/messaging-api/reference/#get-group-member-profile
 
 .. code:: python
 
@@ -164,7 +164,7 @@ get\_room\_member\_profile(self, room\_id, user\_id, timeout=None)
 Gets the user profile of a member of a room that the bot is in. This can be the
 user ID of a user who has not added the bot as a friend or has blocked the bot.
 
-https://devdocs.line.me/en/#get-group-room-member-profile
+https://developers.line.me/en/docs/messaging-api/reference/#get-room-member-profile
 
 .. code:: python
 
@@ -180,7 +180,7 @@ get\_group\_member\_ids(self, group\_id, start=None, timeout=None)
 Gets the user IDs of the members of a group that the bot is in.
 This includes the user IDs of users who have not added the bot as a friend or has blocked the bot.
 
-https://devdocs.line.me/en/#get-group-room-member-ids
+https://developers.line.me/en/docs/messaging-api/reference/#get-group-member-user-ids
 
 .. code:: python
 
@@ -195,7 +195,7 @@ get\_room\_member\_ids(self, room\_id, start=None, timeout=None)
 Gets the user IDs of the members of a room that the bot is in.
 This includes the user IDs of users who have not added the bot as a friend or has blocked the bot.
 
-https://devdocs.line.me/en/#get-group-room-member-ids
+https://developers.line.me/en/docs/messaging-api/reference/#get-room-member-user-ids
 
 .. code:: python
 
@@ -209,7 +209,7 @@ get\_message\_content(self, message\_id, timeout=None)
 
 Retrieve image, video, and audio data sent by users.
 
-https://devdocs.line.me/en/#get-content
+https://developers.line.me/en/docs/messaging-api/reference/#get-content
 
 .. code:: python
 
@@ -224,7 +224,7 @@ leave\_group(self, group\_id, timeout=None)
 
 Leave a group.
 
-https://devdocs.line.me/en/#leave
+https://developers.line.me/en/docs/messaging-api/reference/#leave-group
 
 .. code:: python
 
@@ -235,7 +235,7 @@ leave\_room(self, room\_id, timeout=None)
 
 Leave a room.
 
-https://devdocs.line.me/en/#leave
+https://developers.line.me/en/docs/messaging-api/reference/#leave-room
 
 .. code:: python
 
@@ -246,7 +246,7 @@ https://devdocs.line.me/en/#leave
 
 If the LINE API server returns an error, LineBotApi raises LineBotApiError.
 
-https://devdocs.line.me/en/#error-response
+https://developers.line.me/en/docs/messaging-api/reference/#error-responses
 
 .. code:: python
 
@@ -257,12 +257,12 @@ https://devdocs.line.me/en/#error-response
         print(e.error.message)
         print(e.error.details)
 
-Send message object
+Message objects
 ~~~~~~~~~~~~~~~~~~~
 
-https://devdocs.line.me/en/#send-message-object
+https://developers.line.me/en/docs/messaging-api/reference/#message-objects
 
-These following classes are found in the ``linebot.models`` package.
+The following classes are found in the ``linebot.models`` package.
 
 TextSendMessage
 ^^^^^^^^^^^^^^^
@@ -568,7 +568,7 @@ If there is no handler for an event, this default handler method is called.
 Webhook event object
 ~~~~~~~~~~~~~~~~~~~~
 
-https://devdocs.line.me/en/#webhooks
+https://developers.line.me/en/docs/messaging-api/reference/#webhook-event-objects
 
 The following classes are found in the ``linebot.models`` package.
 
@@ -702,7 +702,7 @@ OR |Documentation Status|
 Requirements
 ------------
 
--  Python >= 2.7 or >= 3.3
+-  Python >= 2.7 or >= 3.4
 
 For SDK developers
 ------------------
@@ -719,7 +719,6 @@ Run tests
 Test by using tox. We test against the following versions.
 
 -  2.7
--  3.3
 -  3.4
 -  3.5
 -  3.6
diff --git a/linebot/models/template.py b/linebot/models/template.py
index f569321..f45b044 100644
--- a/linebot/models/template.py
+++ b/linebot/models/template.py
@@ -100,7 +100,10 @@ class ButtonsTemplate(Template):
     Template message with an image, title, text, and multiple action buttons.
     """
 
-    def __init__(self, text=None, title=None, thumbnail_image_url=None, actions=None, **kwargs):
+    def __init__(self, text=None, title=None, thumbnail_image_url=None,
+                 image_aspect_ratio=None,
+                 image_size=None, image_background_color=None,
+                 actions=None, **kwargs):
         """__init__ method.
 
         :param str text: Message text.
@@ -114,6 +117,19 @@ class ButtonsTemplate(Template):
             Aspect ratio: 1:1.51
             Max width: 1024px
             Max: 1 MB
+        :param str image_aspect_ratio: Aspect ratio of the image.
+            Specify one of the following values:
+            rectangle: 1.51:1
+            square: 1:1
+        :param str image_size: Size of the image.
+            Specify one of the following values:
+            cover: The image fills the entire image area.
+                Parts of the image that do not fit in the area are not displayed.
+            contain: The entire image is displayed in the image area.
+                A background is displayed in the unused areas to the left and right
+                of vertical images and in the areas above and below horizontal images.
+        :param str image_background_color: Background color of image.
+            Specify a RGB color value.
         :param actions: Action when tapped.
             Max: 4
         :type actions: list[T <= :py:class:`linebot.models.template.TemplateAction`]
@@ -125,6 +141,9 @@ class ButtonsTemplate(Template):
         self.text = text
         self.title = title
         self.thumbnail_image_url = thumbnail_image_url
+        self.image_aspect_ratio = image_aspect_ratio
+        self.image_size = image_size
+        self.image_background_color = image_background_color
         self.actions = _get_actions(actions)
 
 
@@ -161,12 +180,24 @@ class CarouselTemplate(Template):
     Template message with multiple columns which can be cycled like a carousel.
     """
 
-    def __init__(self, columns=None, **kwargs):
+    def __init__(self, columns=None, image_aspect_ratio=None,
+                 image_size=None, **kwargs):
         """__init__ method.
 
         :param columns: Array of columns.
-            Max: 5
+            Max: 10
         :type columns: list[T <= :py:class:`linebot.models.template.CarouselColumn`]
+        :param str image_aspect_ratio: Aspect ratio of the image.
+            Specify one of the following values:
+            rectangle: 1.51:1
+            square: 1:1
+        :param str image_size: Size of the image.
+            Specify one of the following values:
+            cover: The image fills the entire image area.
+                Parts of the image that do not fit in the area are not displayed.
+            contain: The entire image is displayed in the image area.
+                A background is displayed in the unused areas to the left and right
+                of vertical images and in the areas above and below horizontal images.
         :param kwargs:
         """
         super(CarouselTemplate, self).__init__(**kwargs)
@@ -180,6 +211,8 @@ class CarouselTemplate(Template):
                     column, CarouselColumn
                 ))
         self.columns = new_columns
+        self.image_aspect_ratio = image_aspect_ratio
+        self.image_size = image_size
 
 
 class ImageCarouselTemplate(Template):
@@ -194,7 +227,7 @@ class ImageCarouselTemplate(Template):
         """__init__ method.
 
         :param columns: Array of columns.
-            Max: 5
+            Max: 10
         :type columns: list[T <= :py:class:`linebot.models.template.ImageCarouselColumn`]
         :param kwargs:
         """
@@ -217,7 +250,8 @@ class CarouselColumn(Base):
     https://devdocs.line.me/en/#column-object
     """
 
-    def __init__(self, text=None, title=None, thumbnail_image_url=None, actions=None, **kwargs):
+    def __init__(self, text=None, title=None, thumbnail_image_url=None,
+                 image_background_color=None, actions=None, **kwargs):
         """__init__ method.
 
         :param str text: Message text.
@@ -231,6 +265,8 @@ class CarouselColumn(Base):
             Aspect ratio: 1:1.51
             Max width: 1024px
             Max: 1 MB
+        :param str image_background_color: Background color of image.
+            Specify a RGB color value.
         :param actions: Action when tapped.
             Max: 3
         :type actions: list[T <= :py:class:`linebot.models.template.TemplateAction`]
@@ -241,6 +277,7 @@ class CarouselColumn(Base):
         self.text = text
         self.title = title
         self.thumbnail_image_url = thumbnail_image_url
+        self.image_background_color = image_background_color
         self.actions = _get_actions(actions)
 
 


Test patch:
diff --git a/tests/api/test_send_template_message.py b/tests/api/test_send_template_message.py
index 9a92ed4..37e84fe 100644
--- a/tests/api/test_send_template_message.py
+++ b/tests/api/test_send_template_message.py
@@ -65,6 +65,9 @@ class TestLineBotApi(unittest.TestCase):
                 "type": "buttons",
                 "thumbnailImageUrl":
                     "https://example.com/image.jpg",
+                "imageAspectRatio": None,
+                "imageSize": None,
+                "imageBackgroundColor": None,
                 "title": "Menu",
                 "text": "Please select",
                 "actions": [
@@ -151,6 +154,7 @@ class TestLineBotApi(unittest.TestCase):
                     CarouselColumn(
                         thumbnail_image_url='https://example.com'
                                             '/item2.jpg',
+                        image_background_color='#000000',
                         title='this is menu2', text='description2',
                         actions=[
                             PostbackTemplateAction(
@@ -210,6 +214,7 @@ class TestLineBotApi(unittest.TestCase):
                     {
                         "thumbnailImageUrl":
                             "https://example.com/item1.jpg",
+                        "imageBackgroundColor": None,
                         "title": "this is menu1",
                         "text": "description1",
                         "actions": [
@@ -234,6 +239,7 @@ class TestLineBotApi(unittest.TestCase):
                     {
                         "thumbnailImageUrl":
                             "https://example.com/item2.jpg",
+                        "imageBackgroundColor": "#000000",
                         "title": "this is menu2",
                         "text": "description2",
                         "actions": [
@@ -258,6 +264,7 @@ class TestLineBotApi(unittest.TestCase):
                     {
                         "thumbnailImageUrl":
                             "https://example.com/item3.jpg",
+                        "imageBackgroundColor": None,
                         "title": "this is menu3",
                         "text": "description3",
                         "actions": [
@@ -290,7 +297,9 @@ class TestLineBotApi(unittest.TestCase):
                             }
                         ]
                     }
-                ]
+                ],
+                "imageAspectRatio": None,
+                "imageSize": None
             }
         }]