Skip to content
This repository was archived by the owner on Apr 27, 2024. It is now read-only.

Commit 41cc65e

Browse files
author
Dirk Lemstra
committed
Added ImageAspectRatio and ImageSize to CarouselTemplate.
1 parent e45d24a commit 41cc65e

File tree

4 files changed

+79
-1
lines changed

4 files changed

+79
-1
lines changed

src/LineBot/Messages/Template/CarouselTemplate.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,19 @@ public IEnumerable<ICarouselColumn> Columns
6464
_columns = value;
6565
}
6666
}
67+
68+
/// <summary>
69+
/// Gets or sets the aspect ratio of the image.
70+
/// </summary>
71+
[JsonProperty("imageAspectRatio")]
72+
[JsonConverter(typeof(EnumConverter<ImageAspectRatio>))]
73+
public ImageAspectRatio ImageAspectRatio { get; set; } = ImageAspectRatio.Rectangle;
74+
75+
/// <summary>
76+
/// Gets or sets the size of the image.
77+
/// </summary>
78+
[JsonProperty("imageSize")]
79+
[JsonConverter(typeof(EnumConverter<MessageType>))]
80+
public ImageSize ImageSize { get; set; } = ImageSize.Cover;
6781
}
6882
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright 2017 Dirk Lemstra (https://github.com/dlemstra/line-bot-sdk-dotnet)
2+
//
3+
// Dirk Lemstra licenses this file to you under the Apache License,
4+
// version 2.0 (the "License"); you may not use this file except in compliance
5+
// with the License. You may obtain a copy of the License at:
6+
//
7+
// https://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11+
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12+
// License for the specific language governing permissions and limitations
13+
// under the License.
14+
15+
namespace Line
16+
{
17+
/// <summary>
18+
/// Encapsulates the image aspect ratios
19+
/// </summary>
20+
public enum ImageAspectRatio
21+
{
22+
/// <summary>
23+
/// 1.51:1
24+
/// </summary>
25+
Rectangle,
26+
27+
/// <summary>
28+
/// 1:1
29+
/// </summary>
30+
Square,
31+
}
32+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright 2017 Dirk Lemstra (https://github.com/dlemstra/line-bot-sdk-dotnet)
2+
//
3+
// Dirk Lemstra licenses this file to you under the Apache License,
4+
// version 2.0 (the "License"); you may not use this file except in compliance
5+
// with the License. You may obtain a copy of the License at:
6+
//
7+
// https://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11+
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12+
// License for the specific language governing permissions and limitations
13+
// under the License.
14+
15+
namespace Line
16+
{
17+
/// <summary>
18+
/// Encapsulates the image sizes
19+
/// </summary>
20+
public enum ImageSize
21+
{
22+
/// <summary>
23+
/// The image fills the entire image area. Parts of the image that do not fit in the area are not displayed.
24+
/// </summary>
25+
Cover,
26+
27+
/// <summary>
28+
/// 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.
29+
/// </summary>
30+
Contain,
31+
}
32+
}

tests/LineBot.Tests/Messages/Template/CarouselTemplateTests/TheConstructor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public void ShouldInitializeTheInstance()
2828
CarouselTemplate template = new CarouselTemplate();
2929

3030
string serialized = JsonConvert.SerializeObject(template);
31-
Assert.AreEqual(@"{""type"":""carousel"",""columns"":null}", serialized);
31+
Assert.AreEqual(@"{""type"":""carousel"",""columns"":null,""imageAspectRatio"":""rectangle"",""imageSize"":""cover""}", serialized);
3232
}
3333
}
3434
}

0 commit comments

Comments
 (0)