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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cc272a376d9eb4be79d9c92ee485737c6474f652c0873923010f5b25d1d78c1a
4
- data.tar.gz: 4beb042559850867763cec2920ac0715877c2b2a7b5538c8a749bd226de2571e
3
+ metadata.gz: d265a003f523763063653537df89119ee79f3fc1c987640fbd78090d081045ca
4
+ data.tar.gz: a5fd82fa00d302b4b804432b87fde84034492e7245a9665d4ab9f480a0fd12df
5
5
  SHA512:
6
- metadata.gz: 6ca96d2225493a374bc23497b075a740ff95f469d4b2b832143083c96a1d4d319482ccb1c7b4a4f6bc0dbd93774bd49a6425c3dbc0a4d552b6afa6795125061e
7
- data.tar.gz: 1809fa4bbadda5065d2f8ec1e8d4bc7fd266c1f0014623bd4606488ba6266cc8e4321fe498edf2aa63c8f6cab3bb397094d0c2aff12c37dad9c9bd5be5dfd439
6
+ metadata.gz: 6d89224a7a2eae22ff20ff38e08d472d595500356b54c6836cdf0af9e7345edeb42c6a6fcfb3c4500402c76635cd8e4d3e932526a0718e403fc5fa2d858b2d48
7
+ data.tar.gz: f2de6de836fa6f95a93f98acb88021a1206506dfebabd7f734c38747b6bbb141c59d3bebd6b7c2cc3743564dc498b929f700bdf33dada17d65a1953972dbe9eb
@@ -22,7 +22,7 @@ module Line
22
22
 
23
23
  DEFAULT_HEADERS = {
24
24
  'Content-Type' => 'application/json; charset=UTF-8',
25
- 'User-Agent' => "LINE-BotSDK-Ruby/#{Line::Bot::API::VERSION}"
25
+ 'User-Agent' => "LINE-BotSDK-Ruby/#{VERSION}"
26
26
  }.freeze
27
27
  end
28
28
  end
@@ -15,7 +15,7 @@
15
15
  module Line
16
16
  module Bot
17
17
  module API
18
- VERSION = "1.14.0"
18
+ VERSION = "1.14.1"
19
19
  end
20
20
  end
21
21
  end
@@ -48,18 +48,18 @@ module Line
48
48
  end
49
49
 
50
50
  def httpclient
51
- @httpclient ||= Line::Bot::HTTPClient.new(http_options)
51
+ @httpclient ||= HTTPClient.new(http_options)
52
52
  end
53
53
 
54
54
  def endpoint
55
- @endpoint ||= Line::Bot::API::DEFAULT_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 == Line::Bot::API::DEFAULT_ENDPOINT
62
- Line::Bot::API::DEFAULT_BLOB_ENDPOINT
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 = Line::Bot::API::DEFAULT_HEADERS.merge(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 = Line::Bot::API::DEFAULT_HEADERS.merge(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 = Line::Bot::API::DEFAULT_HEADERS.merge(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 = Line::Bot::Event.const_get(Line::Bot::Util.camelize(item['type']))
640
+ klass = Event.const_get(Util.camelize(item['type']))
648
641
  klass.new(item)
649
642
  rescue NameError
650
- Line::Bot::Event::Base.new(item)
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
- Line::Bot::Event::MessageType.const_get(@src['message']['type'].capitalize)
34
+ MessageType.const_get(@src['message']['type'].capitalize)
35
35
  rescue NameError => e
36
- Line::Bot::Event::MessageType::Unsupport
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
- Line::Bot::Event::ThingsType.const_get(Line::Bot::Util.camelize(@src['things']['type']))
32
+ ThingsType.const_get(Util.camelize(@src['things']['type']))
33
33
  rescue NameError
34
- Line::Bot::Event::ThingsType::Unsupport
34
+ ThingsType::Unsupport
35
35
  end
36
36
 
37
37
  def device_id
@@ -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', "~> 10.4"
24
+ spec.add_development_dependency 'rake', "~> 13.0"
25
25
  spec.add_development_dependency "rspec", "~> 3.0"
26
- spec.add_development_dependency "webmock", "~> 1.24"
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.0
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-03-02 00:00:00.000000000 Z
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: '10.4'
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: '10.4'
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: '1.24'
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: '1.24'
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