|
1012 | 1012 | end |
1013 | 1013 | end |
1014 | 1014 |
|
| 1015 | + describe 'Line::Bot::V2::MessagingApi::DatetimePickerAction#initialize' do |
| 1016 | + let(:client) { Line::Bot::V2::MessagingApi::ApiClient.new(channel_access_token: 'test-channel-access-token') } |
| 1017 | + |
| 1018 | + it 'creates DatetimePickerAction with minimal required fields and broadcasts correctly' do |
| 1019 | + text_message = Line::Bot::V2::MessagingApi::TextMessage.new( |
| 1020 | + text: "Please pick a date/time!", |
| 1021 | + quick_reply: Line::Bot::V2::MessagingApi::QuickReply.new( |
| 1022 | + items: [ |
| 1023 | + Line::Bot::V2::MessagingApi::QuickReplyItem.new( |
| 1024 | + action: Line::Bot::V2::MessagingApi::DatetimePickerAction.new( |
| 1025 | + data: 'some_data', |
| 1026 | + mode: 'datetime', |
| 1027 | + label: 'Pick' |
| 1028 | + ) |
| 1029 | + ) |
| 1030 | + ] |
| 1031 | + ) |
| 1032 | + ) |
| 1033 | + |
| 1034 | + expected_body = { |
| 1035 | + messages: [ |
| 1036 | + { |
| 1037 | + type: 'text', |
| 1038 | + text: "Please pick a date/time!", |
| 1039 | + quickReply: { |
| 1040 | + items: [ |
| 1041 | + { |
| 1042 | + type: 'action', |
| 1043 | + action: { |
| 1044 | + type: 'datetimepicker', # important: this is the fixed type |
| 1045 | + data: 'some_data', |
| 1046 | + mode: 'datetime', |
| 1047 | + label: 'Pick' |
| 1048 | + } |
| 1049 | + } |
| 1050 | + ] |
| 1051 | + } |
| 1052 | + } |
| 1053 | + ], |
| 1054 | + notificationDisabled: false |
| 1055 | + } |
| 1056 | + |
| 1057 | + stub_request(:post, "https://api.line.me/v2/bot/message/broadcast") |
| 1058 | + .with( |
| 1059 | + headers: { |
| 1060 | + 'Authorization' => "Bearer test-channel-access-token" |
| 1061 | + }, |
| 1062 | + body: hash_including(expected_body) |
| 1063 | + ) |
| 1064 | + .to_return(status: 200, body: "{}", headers: { 'Content-Type' => 'application/json' }) |
| 1065 | + |
| 1066 | + client.broadcast_with_http_info( |
| 1067 | + broadcast_request: Line::Bot::V2::MessagingApi::BroadcastRequest.new(messages: [text_message]) |
| 1068 | + ) |
| 1069 | + end |
| 1070 | + end |
| 1071 | + |
| 1072 | + describe 'Line::Bot::V2::MessagingApi::RichMenuSwitchAction#initialize' do |
| 1073 | + let(:client) { Line::Bot::V2::MessagingApi::ApiClient.new(channel_access_token: 'test-channel-access-token') } |
| 1074 | + |
| 1075 | + it 'creates RichMenuSwitchAction with minimal required fields and broadcasts correctly' do |
| 1076 | + flex_message = Line::Bot::V2::MessagingApi::FlexMessage.new( |
| 1077 | + alt_text: "Switch RichMenu", |
| 1078 | + contents: Line::Bot::V2::MessagingApi::FlexBubble.new( |
| 1079 | + body: Line::Bot::V2::MessagingApi::FlexBox.new( |
| 1080 | + layout: 'vertical', |
| 1081 | + contents: [ |
| 1082 | + Line::Bot::V2::MessagingApi::FlexButton.new( |
| 1083 | + action: Line::Bot::V2::MessagingApi::RichMenuSwitchAction.new( |
| 1084 | + data: 'switch_richmenu', |
| 1085 | + rich_menu_alias_id: 'alias_xxx', |
| 1086 | + label: 'Switch Menu' |
| 1087 | + ) |
| 1088 | + ) |
| 1089 | + ] |
| 1090 | + ) |
| 1091 | + ) |
| 1092 | + ) |
| 1093 | + |
| 1094 | + expected_body = { |
| 1095 | + messages: [ |
| 1096 | + { |
| 1097 | + type: 'flex', |
| 1098 | + altText: 'Switch RichMenu', |
| 1099 | + contents: { |
| 1100 | + type: 'bubble', |
| 1101 | + body: { |
| 1102 | + type: 'box', |
| 1103 | + layout: 'vertical', |
| 1104 | + contents: [ |
| 1105 | + { |
| 1106 | + type: 'button', |
| 1107 | + action: { |
| 1108 | + type: 'richmenuswitch', # important: this is the fixed type |
| 1109 | + data: 'switch_richmenu', |
| 1110 | + richMenuAliasId: 'alias_xxx', |
| 1111 | + label: 'Switch Menu' |
| 1112 | + } |
| 1113 | + } |
| 1114 | + ] |
| 1115 | + } |
| 1116 | + } |
| 1117 | + } |
| 1118 | + ], |
| 1119 | + notificationDisabled: false |
| 1120 | + } |
| 1121 | + |
| 1122 | + stub_request(:post, "https://api.line.me/v2/bot/message/broadcast") |
| 1123 | + .with( |
| 1124 | + headers: { |
| 1125 | + 'Authorization' => "Bearer test-channel-access-token" |
| 1126 | + }, |
| 1127 | + body: hash_including(expected_body) |
| 1128 | + ) |
| 1129 | + .to_return(status: 200, body: "{}", headers: { 'Content-Type' => 'application/json' }) |
| 1130 | + |
| 1131 | + client.broadcast_with_http_info( |
| 1132 | + broadcast_request: Line::Bot::V2::MessagingApi::BroadcastRequest.new(messages: [flex_message]) |
| 1133 | + ) |
| 1134 | + end |
| 1135 | + end |
| 1136 | + |
| 1137 | + describe 'Line::Bot::V2::MessagingApi::ImageCarouselTemplate#initialize' do |
| 1138 | + let(:client) { Line::Bot::V2::MessagingApi::ApiClient.new(channel_access_token: 'test-channel-access-token') } |
| 1139 | + |
| 1140 | + it 'creates ImageCarouselTemplate with minimal required fields and broadcasts correctly' do |
| 1141 | + template_message = Line::Bot::V2::MessagingApi::TemplateMessage.new( |
| 1142 | + alt_text: "This is an Image Carousel", |
| 1143 | + template: Line::Bot::V2::MessagingApi::ImageCarouselTemplate.new( |
| 1144 | + columns: [ |
| 1145 | + Line::Bot::V2::MessagingApi::ImageCarouselColumn.new( |
| 1146 | + image_url: 'https://example.com/image1.png', |
| 1147 | + action: Line::Bot::V2::MessagingApi::URIAction.new( |
| 1148 | + uri: 'https://example.com', |
| 1149 | + label: 'Go' |
| 1150 | + ) |
| 1151 | + ), |
| 1152 | + Line::Bot::V2::MessagingApi::ImageCarouselColumn.new( |
| 1153 | + image_url: 'https://example.com/image2.png', |
| 1154 | + action: Line::Bot::V2::MessagingApi::MessageAction.new( |
| 1155 | + text: 'Hello!', |
| 1156 | + label: 'Say Hello' |
| 1157 | + ) |
| 1158 | + ) |
| 1159 | + ] |
| 1160 | + ) |
| 1161 | + ) |
| 1162 | + |
| 1163 | + expected_body = { |
| 1164 | + messages: [ |
| 1165 | + { |
| 1166 | + type: 'template', |
| 1167 | + altText: 'This is an Image Carousel', |
| 1168 | + template: { |
| 1169 | + type: 'image_carousel', # important: this is the fixed type |
| 1170 | + columns: [ |
| 1171 | + { |
| 1172 | + imageUrl: 'https://example.com/image1.png', |
| 1173 | + action: { |
| 1174 | + type: 'uri', |
| 1175 | + uri: 'https://example.com', |
| 1176 | + label: 'Go' |
| 1177 | + } |
| 1178 | + }, |
| 1179 | + { |
| 1180 | + imageUrl: 'https://example.com/image2.png', |
| 1181 | + action: { |
| 1182 | + type: 'message', |
| 1183 | + text: 'Hello!', |
| 1184 | + label: 'Say Hello' |
| 1185 | + } |
| 1186 | + } |
| 1187 | + ] |
| 1188 | + } |
| 1189 | + } |
| 1190 | + ], |
| 1191 | + notificationDisabled: false |
| 1192 | + } |
| 1193 | + |
| 1194 | + stub_request(:post, "https://api.line.me/v2/bot/message/broadcast") |
| 1195 | + .with( |
| 1196 | + headers: { |
| 1197 | + 'Authorization' => "Bearer test-channel-access-token" |
| 1198 | + }, |
| 1199 | + body: hash_including(expected_body) |
| 1200 | + ) |
| 1201 | + .to_return(status: 200, body: "{}", headers: { 'Content-Type' => 'application/json' }) |
| 1202 | + |
| 1203 | + client.broadcast_with_http_info( |
| 1204 | + broadcast_request: Line::Bot::V2::MessagingApi::BroadcastRequest.new(messages: [template_message]) |
| 1205 | + ) |
| 1206 | + end |
| 1207 | + end |
| 1208 | + |
| 1209 | + describe 'Line::Bot::V2::MessagingApi::FlexBoxLinearGradient#initialize' do |
| 1210 | + let(:client) { Line::Bot::V2::MessagingApi::ApiClient.new(channel_access_token: 'test-channel-access-token') } |
| 1211 | + |
| 1212 | + it 'creates FlexBox with linearGradient background and broadcasts correctly' do |
| 1213 | + flex_message = Line::Bot::V2::MessagingApi::FlexMessage.new( |
| 1214 | + alt_text: 'Test FlexBox with LinearGradient', |
| 1215 | + contents: Line::Bot::V2::MessagingApi::FlexBubble.new( |
| 1216 | + body: Line::Bot::V2::MessagingApi::FlexBox.new( |
| 1217 | + layout: 'vertical', |
| 1218 | + contents: [ |
| 1219 | + Line::Bot::V2::MessagingApi::FlexText.new(text: 'Hello World!') |
| 1220 | + ], |
| 1221 | + background: Line::Bot::V2::MessagingApi::FlexBoxLinearGradient.new( |
| 1222 | + angle: '90deg', |
| 1223 | + start_color: '#FF0000', |
| 1224 | + end_color: '#0000FF' |
| 1225 | + ) |
| 1226 | + ) |
| 1227 | + ) |
| 1228 | + ) |
| 1229 | + |
| 1230 | + expected_body = { |
| 1231 | + messages: [ |
| 1232 | + { |
| 1233 | + type: 'flex', |
| 1234 | + altText: 'Test FlexBox with LinearGradient', |
| 1235 | + contents: { |
| 1236 | + type: 'bubble', |
| 1237 | + body: { |
| 1238 | + type: 'box', |
| 1239 | + layout: 'vertical', |
| 1240 | + contents: [ |
| 1241 | + { |
| 1242 | + type: 'text', |
| 1243 | + text: 'Hello World!' |
| 1244 | + } |
| 1245 | + ], |
| 1246 | + background: { |
| 1247 | + type: 'linearGradient', # important: this is the fixed type |
| 1248 | + angle: '90deg', |
| 1249 | + startColor: '#FF0000', |
| 1250 | + endColor: '#0000FF' |
| 1251 | + } |
| 1252 | + } |
| 1253 | + } |
| 1254 | + } |
| 1255 | + ], |
| 1256 | + notificationDisabled: false |
| 1257 | + } |
| 1258 | + |
| 1259 | + stub_request(:post, "https://api.line.me/v2/bot/message/broadcast") |
| 1260 | + .with( |
| 1261 | + headers: { |
| 1262 | + 'Authorization' => "Bearer test-channel-access-token" |
| 1263 | + }, |
| 1264 | + body: hash_including(expected_body) |
| 1265 | + ) |
| 1266 | + .to_return(status: 200, body: "{}", headers: { 'Content-Type' => 'application/json' }) |
| 1267 | + |
| 1268 | + client.broadcast_with_http_info( |
| 1269 | + broadcast_request: Line::Bot::V2::MessagingApi::BroadcastRequest.new(messages: [flex_message]) |
| 1270 | + ) |
| 1271 | + end |
| 1272 | + end |
| 1273 | + |
1015 | 1274 | describe 'Line::Bot::V2::MessagingApi::FlexMessage#initialize' do |
1016 | 1275 | let(:client) { Line::Bot::V2::MessagingApi::ApiClient.new(channel_access_token: 'test-channel-access-token') } |
1017 | 1276 |
|
|
0 commit comments