|
1770 | 1770 | end |
1771 | 1771 | end |
1772 | 1772 |
|
1773 | | - context 'with a ThingsEvent' do |
1774 | | - let(:webhook) do |
1775 | | - <<~JSON |
1776 | | - { |
1777 | | - "destination": "Uc7472b39e21dab71c2347e02714630d6", |
1778 | | - "events": [ |
1779 | | - { |
1780 | | - "type": "things", |
1781 | | - "timestamp": 1650591346705, |
1782 | | - "replyToken": "nHuyWiB7yP5Zw52FIkcQobQuGDXCTA", |
1783 | | - "source": { |
1784 | | - "type": "user", |
1785 | | - "userId": "U8189cf6745fc0d808977bdb0b9f22995" |
1786 | | - }, |
1787 | | - "webhookEventId": "01G17EJCGAVV66J5WNA7ZCTF6H", |
1788 | | - "deliveryContext": { |
1789 | | - "isRedelivery": false |
1790 | | - }, |
1791 | | - "mode": "active", |
1792 | | - "things": { |
1793 | | - "type": "scenarioResult", |
1794 | | - "deviceId": "xxxxxxxxxxxxxxxxxxx", |
1795 | | - "result": { |
1796 | | - "scenarioId": "xxxxxxxxxxxxxxx", |
1797 | | - "revision": 0, |
1798 | | - "resultCode": "success", |
1799 | | - "startTime": 1650591345705, |
1800 | | - "endTime": 1650591346605, |
1801 | | - "bleNotificationPayload": "xxxxxxx", |
1802 | | - "actionResults": [ |
1803 | | - { |
1804 | | - "data": "xxxxxxx", |
1805 | | - "type": "binary" |
1806 | | - }, |
1807 | | - { |
1808 | | - "type": "void" |
1809 | | - }, |
1810 | | - { |
1811 | | - "type": "void" |
1812 | | - } |
1813 | | - ] |
1814 | | - } |
1815 | | - } |
1816 | | - } |
1817 | | - ] |
1818 | | - } |
1819 | | - JSON |
1820 | | - end |
1821 | | - |
1822 | | - it 'parses the webhook as a ThingsEvent' do |
1823 | | - events = parser.parse(body: webhook, signature: signature) |
1824 | | - expect(events).not_to be_empty |
1825 | | - |
1826 | | - event = events.first |
1827 | | - expect(event).to be_a(Line::Bot::V2::Webhook::ThingsEvent) |
1828 | | - expect(event.type).to eq('things') |
1829 | | - expect(event.timestamp).to eq(1650591346705) |
1830 | | - expect(event.reply_token).to eq('nHuyWiB7yP5Zw52FIkcQobQuGDXCTA') |
1831 | | - expect(event.source).to be_a(Line::Bot::V2::Webhook::UserSource) |
1832 | | - expect(event.source.type).to eq('user') |
1833 | | - expect(event.source.user_id).to eq('U8189cf6745fc0d808977bdb0b9f22995') |
1834 | | - expect(event.webhook_event_id).to eq('01G17EJCGAVV66J5WNA7ZCTF6H') |
1835 | | - expect(event.delivery_context).to be_a(Line::Bot::V2::Webhook::DeliveryContext) |
1836 | | - expect(event.delivery_context.is_redelivery).to be false |
1837 | | - expect(event.mode).to eq('active') |
1838 | | - expect(event.things).to be_a(Line::Bot::V2::Webhook::ScenarioResultThingsContent) |
1839 | | - expect(event.things.type).to eq('scenarioResult') |
1840 | | - expect(event.things.device_id).to eq('xxxxxxxxxxxxxxxxxxx') |
1841 | | - expect(event.things.result).to be_a(Line::Bot::V2::Webhook::ScenarioResult) |
1842 | | - expect(event.things.result.scenario_id).to eq('xxxxxxxxxxxxxxx') |
1843 | | - expect(event.things.result.revision).to eq(0) |
1844 | | - expect(event.things.result.result_code).to eq('success') |
1845 | | - expect(event.things.result.start_time).to eq(1650591345705) |
1846 | | - expect(event.things.result.end_time).to eq(1650591346605) |
1847 | | - expect(event.things.result.ble_notification_payload).to eq('xxxxxxx') |
1848 | | - expect(event.things.result.action_results).to be_an(Array) |
1849 | | - expect(event.things.result.action_results.size).to eq(3) |
1850 | | - expect(event.things.result.action_results[0].data).to eq('xxxxxxx') |
1851 | | - expect(event.things.result.action_results[0].type).to eq('binary') |
1852 | | - expect(event.things.result.action_results[1].type).to eq('void') |
1853 | | - expect(event.things.result.action_results[2].type).to eq('void') |
1854 | | - end |
1855 | | - end |
1856 | | - |
1857 | 1773 | context 'with a MembershioEvent' do |
1858 | 1774 | let(:webhook) do |
1859 | 1775 | <<~JSON |
|
0 commit comments