|
20 | 20 | }
|
21 | 21 | EOS
|
22 | 22 |
|
| 23 | +DELIVERY_NUMBER_CONTENT = <<"EOS" |
| 24 | +{ |
| 25 | + "status": "ready", |
| 26 | + "success": 1 |
| 27 | +} |
| 28 | +EOS |
| 29 | + |
23 | 30 | WebMock.allow_net_connect!
|
24 | 31 |
|
25 | 32 | describe Line::Bot::Client do
|
@@ -76,4 +83,48 @@ def generate_client
|
76 | 83 | contact = JSON.parse(response.body)
|
77 | 84 | expect(contact['displayName']).to eq "Brown"
|
78 | 85 | end
|
| 86 | + |
| 87 | + it "gets the number of reply messages sent" do |
| 88 | + uri_template = Addressable::Template.new Line::Bot::API::DEFAULT_ENDPOINT + '/bot/message/delivery/reply?date={sended_date}' |
| 89 | + stub_request(:get, uri_template).to_return(body: DELIVERY_NUMBER_CONTENT, status: 200) |
| 90 | + |
| 91 | + client = generate_client |
| 92 | + response = client.get_message_delivery_reply("20190101") |
| 93 | + |
| 94 | + delivery = JSON.parse(response.body) |
| 95 | + expect(delivery['status']).to eq "ready" |
| 96 | + expect(delivery['success']).to eq 1 |
| 97 | + end |
| 98 | + |
| 99 | + it "gets the number of push messages sent" do |
| 100 | + uri_template = Addressable::Template.new Line::Bot::API::DEFAULT_ENDPOINT + '/bot/message/delivery/push?date={sended_date}' |
| 101 | + stub_request(:get, uri_template).to_return(body: DELIVERY_NUMBER_CONTENT, status: 200) |
| 102 | + |
| 103 | + client = generate_client |
| 104 | + response = client.get_message_delivery_push("20190101") |
| 105 | + |
| 106 | + delivery = JSON.parse(response.body) |
| 107 | + expect(delivery['status']).to eq "ready" |
| 108 | + expect(delivery['success']).to eq 1 |
| 109 | + end |
| 110 | + |
| 111 | + it "gets the number of multicast messages sent" do |
| 112 | + uri_template = Addressable::Template.new Line::Bot::API::DEFAULT_ENDPOINT + '/bot/message/delivery/multicast?date={send_date}' |
| 113 | + stub_request(:get, uri_template).to_return(body: DELIVERY_NUMBER_CONTENT, status: 200) |
| 114 | + |
| 115 | + client = generate_client |
| 116 | + response = client.get_message_delivery_multicast("20190101") |
| 117 | + |
| 118 | + delivery = JSON.parse(response.body) |
| 119 | + expect(delivery['status']).to eq "ready" |
| 120 | + expect(delivery['success']).to eq 1 |
| 121 | + end |
| 122 | + |
| 123 | + it "gets number of messages sent whithout date will raise error" do |
| 124 | + client = generate_client |
| 125 | + |
| 126 | + expect { client.get_message_delivery_reply }.to raise_error(ArgumentError) |
| 127 | + expect { client.get_message_delivery_push }.to raise_error(ArgumentError) |
| 128 | + expect { client.get_message_delivery_multicast }.to raise_error(ArgumentError) |
| 129 | + end |
79 | 130 | end
|
0 commit comments