|
27 | 27 | }
|
28 | 28 | EOS
|
29 | 29 |
|
| 30 | +QUOTA_CONTENT = <<"EOS" |
| 31 | +{ |
| 32 | + "type":"none" |
| 33 | +} |
| 34 | +EOS |
| 35 | + |
| 36 | +QUOTA_CONSUMPTION_CONTENT = <<"EOS" |
| 37 | +{ |
| 38 | + "totalUsage":1 |
| 39 | +} |
| 40 | +EOS |
| 41 | + |
30 | 42 | WebMock.allow_net_connect!
|
31 | 43 |
|
32 | 44 | describe Line::Bot::Client do
|
@@ -120,11 +132,45 @@ def generate_client
|
120 | 132 | expect(delivery['success']).to eq 1
|
121 | 133 | end
|
122 | 134 |
|
| 135 | + it "gets the number of broadcast messages sent" do |
| 136 | + uri_template = Addressable::Template.new Line::Bot::API::DEFAULT_ENDPOINT + '/bot/message/delivery/broadcast?date={send_date}' |
| 137 | + stub_request(:get, uri_template).to_return(body: DELIVERY_NUMBER_CONTENT, status: 200) |
| 138 | + |
| 139 | + client = generate_client |
| 140 | + response = client.get_message_delivery_broadcast("20190101") |
| 141 | + |
| 142 | + delivery = JSON.parse(response.body) |
| 143 | + expect(delivery['status']).to eq "ready" |
| 144 | + expect(delivery['success']).to eq 1 |
| 145 | + end |
| 146 | + |
123 | 147 | it "gets number of messages sent whithout date will raise error" do
|
124 | 148 | client = generate_client
|
125 | 149 |
|
126 | 150 | expect { client.get_message_delivery_reply }.to raise_error(ArgumentError)
|
127 | 151 | expect { client.get_message_delivery_push }.to raise_error(ArgumentError)
|
128 | 152 | expect { client.get_message_delivery_multicast }.to raise_error(ArgumentError)
|
129 | 153 | end
|
| 154 | + |
| 155 | + it 'gets number of quota' do |
| 156 | + uri_template = Addressable::Template.new Line::Bot::API::DEFAULT_ENDPOINT + '/bot/message/quota' |
| 157 | + stub_request(:get, uri_template).to_return(body: QUOTA_CONTENT, status: 200) |
| 158 | + |
| 159 | + client = generate_client |
| 160 | + response = client.get_quota |
| 161 | + |
| 162 | + quota = JSON.parse(response.body) |
| 163 | + expect(quota['type']).to eq 'none' |
| 164 | + end |
| 165 | + |
| 166 | + it 'gets number of quota consumption' do |
| 167 | + uri_template = Addressable::Template.new Line::Bot::API::DEFAULT_ENDPOINT + '/bot/message/quota/consumption' |
| 168 | + stub_request(:get, uri_template).to_return(body: QUOTA_CONSUMPTION_CONTENT, status: 200) |
| 169 | + |
| 170 | + client = generate_client |
| 171 | + response = client.get_quota_consumption |
| 172 | + |
| 173 | + quota = JSON.parse(response.body) |
| 174 | + expect(quota['totalUsage']).to eq 1 |
| 175 | + end |
130 | 176 | end
|
0 commit comments