line-bot-api 1.14.0 → 1.14.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/line/bot/api.rb +1 -1
- data/lib/line/bot/api/version.rb +1 -1
- data/lib/line/bot/client.rb +25 -17
- data/lib/line/bot/event/message.rb +2 -2
- data/lib/line/bot/event/things.rb +2 -2
- data/line-bot-api.gemspec +2 -2
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d265a003f523763063653537df89119ee79f3fc1c987640fbd78090d081045ca
|
4
|
+
data.tar.gz: a5fd82fa00d302b4b804432b87fde84034492e7245a9665d4ab9f480a0fd12df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d89224a7a2eae22ff20ff38e08d472d595500356b54c6836cdf0af9e7345edeb42c6a6fcfb3c4500402c76635cd8e4d3e932526a0718e403fc5fa2d858b2d48
|
7
|
+
data.tar.gz: f2de6de836fa6f95a93f98acb88021a1206506dfebabd7f734c38747b6bbb141c59d3bebd6b7c2cc3743564dc498b929f700bdf33dada17d65a1953972dbe9eb
|
data/lib/line/bot/api.rb
CHANGED
data/lib/line/bot/api/version.rb
CHANGED
data/lib/line/bot/client.rb
CHANGED
@@ -48,18 +48,18 @@ module Line
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def httpclient
|
51
|
-
@httpclient ||=
|
51
|
+
@httpclient ||= HTTPClient.new(http_options)
|
52
52
|
end
|
53
53
|
|
54
54
|
def endpoint
|
55
|
-
@endpoint ||=
|
55
|
+
@endpoint ||= API::DEFAULT_ENDPOINT
|
56
56
|
end
|
57
57
|
|
58
58
|
def blob_endpoint
|
59
59
|
return @blob_endpoint if @blob_endpoint
|
60
60
|
|
61
|
-
@blob_endpoint = if endpoint ==
|
62
|
-
|
61
|
+
@blob_endpoint = if endpoint == API::DEFAULT_ENDPOINT
|
62
|
+
API::DEFAULT_BLOB_ENDPOINT
|
63
63
|
else
|
64
64
|
# for backward compatible
|
65
65
|
endpoint
|
@@ -507,15 +507,8 @@ module Line
|
|
507
507
|
def create_rich_menu_image(rich_menu_id, file)
|
508
508
|
channel_token_required
|
509
509
|
|
510
|
-
content_type = case file.path
|
511
|
-
when /\.jpe?g\z/i then 'image/jpeg'
|
512
|
-
when /\.png\z/i then 'image/png'
|
513
|
-
else
|
514
|
-
raise ArgumentError, "invalid file extension: #{file.path}"
|
515
|
-
end
|
516
|
-
|
517
510
|
endpoint_path = "/bot/richmenu/#{rich_menu_id}/content"
|
518
|
-
headers = credentials.merge('Content-Type' => content_type)
|
511
|
+
headers = credentials.merge('Content-Type' => content_type(file))
|
519
512
|
post(blob_endpoint, endpoint_path, file.rewind && file.read, headers)
|
520
513
|
end
|
521
514
|
|
@@ -605,7 +598,7 @@ module Line
|
|
605
598
|
#
|
606
599
|
# @return [Net::HTTPResponse]
|
607
600
|
def get(endpoint_base, endpoint_path, headers = {})
|
608
|
-
headers =
|
601
|
+
headers = API::DEFAULT_HEADERS.merge(headers)
|
609
602
|
httpclient.get(endpoint_base + endpoint_path, headers)
|
610
603
|
end
|
611
604
|
|
@@ -618,7 +611,7 @@ module Line
|
|
618
611
|
#
|
619
612
|
# @return [Net::HTTPResponse]
|
620
613
|
def post(endpoint_base, endpoint_path, payload = nil, headers = {})
|
621
|
-
headers =
|
614
|
+
headers = API::DEFAULT_HEADERS.merge(headers)
|
622
615
|
httpclient.post(endpoint_base + endpoint_path, payload, headers)
|
623
616
|
end
|
624
617
|
|
@@ -630,7 +623,7 @@ module Line
|
|
630
623
|
#
|
631
624
|
# @return [Net::HTTPResponse]
|
632
625
|
def delete(endpoint_base, endpoint_path, headers = {})
|
633
|
-
headers =
|
626
|
+
headers = API::DEFAULT_HEADERS.merge(headers)
|
634
627
|
httpclient.delete(endpoint_base + endpoint_path, headers)
|
635
628
|
end
|
636
629
|
|
@@ -644,10 +637,10 @@ module Line
|
|
644
637
|
|
645
638
|
json['events'].map do |item|
|
646
639
|
begin
|
647
|
-
klass =
|
640
|
+
klass = Event.const_get(Util.camelize(item['type']))
|
648
641
|
klass.new(item)
|
649
642
|
rescue NameError
|
650
|
-
|
643
|
+
Event::Base.new(item)
|
651
644
|
end
|
652
645
|
end
|
653
646
|
end
|
@@ -691,6 +684,21 @@ module Line
|
|
691
684
|
res == 0
|
692
685
|
end
|
693
686
|
|
687
|
+
def content_type(file)
|
688
|
+
if file.respond_to?(:content_type)
|
689
|
+
content_type = file.content_type
|
690
|
+
raise ArgumentError, "invalid content type: #{content_type}" unless ['image/jpeg', 'image/png'].include?(content_type)
|
691
|
+
content_type
|
692
|
+
else
|
693
|
+
case file.path
|
694
|
+
when /\.jpe?g\z/i then 'image/jpeg'
|
695
|
+
when /\.png\z/i then 'image/png'
|
696
|
+
else
|
697
|
+
raise ArgumentError, "invalid file extension: #{file.path}"
|
698
|
+
end
|
699
|
+
end
|
700
|
+
end
|
701
|
+
|
694
702
|
def channel_token_required
|
695
703
|
raise ArgumentError, '`channel_token` is not configured' unless channel_token
|
696
704
|
end
|
@@ -31,9 +31,9 @@ module Line
|
|
31
31
|
# https://developers.line.biz/en/reference/messaging-api/#message-event
|
32
32
|
class Message < Base
|
33
33
|
def type
|
34
|
-
|
34
|
+
MessageType.const_get(@src['message']['type'].capitalize)
|
35
35
|
rescue NameError => e
|
36
|
-
|
36
|
+
MessageType::Unsupport
|
37
37
|
end
|
38
38
|
|
39
39
|
def message
|
@@ -29,9 +29,9 @@ module Line
|
|
29
29
|
# * https://developers.line.biz/en/reference/messaging-api/#scenario-result-event
|
30
30
|
class Things < Base
|
31
31
|
def type
|
32
|
-
|
32
|
+
ThingsType.const_get(Util.camelize(@src['things']['type']))
|
33
33
|
rescue NameError
|
34
|
-
|
34
|
+
ThingsType::Unsupport
|
35
35
|
end
|
36
36
|
|
37
37
|
def device_id
|
data/line-bot-api.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
|
22
22
|
spec.add_development_dependency "addressable", "~> 2.3"
|
23
23
|
spec.add_development_dependency "bundler", "~> 1.11" if RUBY_VERSION < "2.3"
|
24
|
-
spec.add_development_dependency 'rake', "~>
|
24
|
+
spec.add_development_dependency 'rake', "~> 13.0"
|
25
25
|
spec.add_development_dependency "rspec", "~> 3.0"
|
26
|
-
spec.add_development_dependency "webmock", "~>
|
26
|
+
spec.add_development_dependency "webmock", "~> 3.8"
|
27
27
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: line-bot-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.14.
|
4
|
+
version: 1.14.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- LINE Corporation
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '13.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '13.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '3.8'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '3.8'
|
69
69
|
description: Line::Bot::API - SDK of the LINE Messaging API for Ruby
|
70
70
|
email:
|
71
71
|
- kimoto@linecorp.com
|