Skip to content

Commit a83159a

Browse files
support get webhook endpoint
1 parent 31db9a0 commit a83159a

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

lib/line/bot/client.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,16 @@ def get_bot_info
645645
get(endpoint, endpoint_path, credentials)
646646
end
647647

648+
# Gets information on a webhook endpoint.
649+
#
650+
# @return [Net::HTTPResponse]
651+
def get_webhook_endpoint
652+
channel_token_required
653+
654+
endpoint_path = '/bot/channel/webhook/endpoint'
655+
get(endpoint, endpoint_path, credentials)
656+
end
657+
648658
def get_liff_apps
649659
channel_token_required
650660

spec/line/bot/client_get_spec.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,13 @@
200200
}
201201
EOS
202202

203+
WEBHOOK_ENDPOINT_CONTENT = <<"EOS"
204+
{
205+
"endpoint": "https://example.com/test",
206+
"active": true
207+
}
208+
EOS
209+
203210
describe Line::Bot::Client do
204211
before do
205212
end
@@ -480,4 +487,18 @@ def generate_client
480487
markAsReadMode: 'manual'
481488
)
482489
end
490+
491+
it 'get webhook endpoint' do
492+
uri_template = Addressable::Template.new Line::Bot::API::DEFAULT_ENDPOINT + '/bot/channel/webhook/endpoint'
493+
stub_request(:get, uri_template).to_return(body: WEBHOOK_ENDPOINT_CONTENT, status: 200)
494+
495+
client = generate_client
496+
response = client.get_webhook_endpoint
497+
498+
json = JSON.parse(response.body, symbolize_names: true)
499+
expect(json).to eq(
500+
endpoint: 'https://example.com/test',
501+
active: true
502+
)
503+
end
483504
end

0 commit comments

Comments
 (0)