Skip to content

Commit 87a6cf1

Browse files
authored
Merge pull request #203 from line/feature/bot_info
Support bot info api
2 parents 4d49b9a + 79dbe1f commit 87a6cf1

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

lib/line/bot/client.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,16 @@ def get_friend_demographics
631631
get(endpoint, endpoint_path, credentials)
632632
end
633633

634+
# Gets a bot's basic information.
635+
#
636+
# @return [Net::HTTPResponse]
637+
def get_bot_info
638+
channel_token_required
639+
640+
endpoint_path = '/bot/info'
641+
get(endpoint, endpoint_path, credentials)
642+
end
643+
634644
# Fetch data, get content of specified URL.
635645
#
636646
# @param endpoint_base [String]

spec/line/bot/client_get_spec.rb

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,17 @@
189189
}
190190
EOS
191191

192+
BOT_INFO_CONTENT = <<"EOS"
193+
{
194+
"userId": "Ufr47556f2e40dba2456887320ba7c76d",
195+
"basicId": "@abcdefghijklmn",
196+
"displayName": "Example",
197+
"pictureUrl": "https://example.com/hogehoge",
198+
"chatMode": "chat",
199+
"markAsReadMode": "manual"
200+
}
201+
EOS
202+
192203
WebMock.allow_net_connect!
193204

194205
describe Line::Bot::Client do
@@ -453,4 +464,22 @@ def generate_client
453464
]
454465
)
455466
end
467+
468+
it 'get bot info' do
469+
uri_template = Addressable::Template.new Line::Bot::API::DEFAULT_ENDPOINT + '/bot/info'
470+
stub_request(:get, uri_template).to_return(body: BOT_INFO_CONTENT, status: 200)
471+
472+
client = generate_client
473+
response = client.get_bot_info
474+
475+
json = JSON.parse(response.body, symbolize_names: true)
476+
expect(json).to eq(
477+
userId: 'Ufr47556f2e40dba2456887320ba7c76d',
478+
basicId: '@abcdefghijklmn',
479+
displayName: 'Example',
480+
pictureUrl: 'https://example.com/hogehoge',
481+
chatMode: 'chat',
482+
markAsReadMode: 'manual'
483+
)
484+
end
456485
end

0 commit comments

Comments
 (0)