line-bot-api 0.1.9 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +43 -221
  3. data/lib/line/bot.rb +15 -8
  4. data/lib/line/bot/api.rb +15 -2
  5. data/lib/line/bot/api/errors.rb +14 -1
  6. data/lib/line/bot/api/version.rb +15 -1
  7. data/lib/line/bot/client.rb +89 -164
  8. data/lib/line/bot/event.rb +22 -0
  9. data/lib/line/bot/event/base.rb +30 -0
  10. data/lib/line/bot/event/beacon.rb +22 -0
  11. data/lib/line/bot/event/follow.rb +22 -0
  12. data/lib/line/bot/event/join.rb +22 -0
  13. data/lib/line/bot/event/leave.rb +22 -0
  14. data/lib/line/bot/event/message.rb +43 -0
  15. data/lib/line/bot/event/postback.rb +22 -0
  16. data/lib/line/bot/event/unfollow.rb +22 -0
  17. data/lib/line/bot/httpclient.rb +14 -0
  18. data/lib/line/bot/request.rb +19 -23
  19. data/line-bot-api.gemspec +1 -5
  20. metadata +31 -89
  21. data/lib/line/bot/builder/multiple_message.rb +0 -101
  22. data/lib/line/bot/builder/rich_message.rb +0 -154
  23. data/lib/line/bot/event_type.rb +0 -15
  24. data/lib/line/bot/message.rb +0 -9
  25. data/lib/line/bot/message/audio.rb +0 -25
  26. data/lib/line/bot/message/base.rb +0 -35
  27. data/lib/line/bot/message/contact.rb +0 -18
  28. data/lib/line/bot/message/content_type.rb +0 -16
  29. data/lib/line/bot/message/image.rb +0 -23
  30. data/lib/line/bot/message/location.rb +0 -28
  31. data/lib/line/bot/message/recipient_type.rb +0 -9
  32. data/lib/line/bot/message/sticker.rb +0 -26
  33. data/lib/line/bot/message/text.rb +0 -22
  34. data/lib/line/bot/message/video.rb +0 -23
  35. data/lib/line/bot/operation.rb +0 -3
  36. data/lib/line/bot/operation/added_as_friend.rb +0 -10
  37. data/lib/line/bot/operation/base.rb +0 -17
  38. data/lib/line/bot/operation/blocked_account.rb +0 -10
  39. data/lib/line/bot/operation/op_type.rb +0 -10
  40. data/lib/line/bot/receive/message.rb +0 -69
  41. data/lib/line/bot/receive/operation.rb +0 -42
  42. data/lib/line/bot/receive/request.rb +0 -35
  43. data/lib/line/bot/response/user/contact.rb +0 -22
  44. data/lib/line/bot/response/user/profile.rb +0 -30
  45. data/lib/line/bot/utils.rb +0 -16
@@ -0,0 +1,22 @@
1
+ # Copyright 2016 LINE
2
+ #
3
+ # LINE Corporation licenses this file to you under the Apache License,
4
+ # version 2.0 (the "License"); you may not use this file except in compliance
5
+ # with the License. You may obtain a copy of the License at:
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
+ # License for the specific language governing permissions and limitations
13
+ # under the License.
14
+
15
+ require 'line/bot/event/base'
16
+ require 'line/bot/event/beacon'
17
+ require 'line/bot/event/follow'
18
+ require 'line/bot/event/join'
19
+ require 'line/bot/event/leave'
20
+ require 'line/bot/event/message'
21
+ require 'line/bot/event/postback'
22
+ require 'line/bot/event/unfollow'
@@ -0,0 +1,30 @@
1
+ # Copyright 2016 LINE
2
+ #
3
+ # LINE Corporation licenses this file to you under the Apache License,
4
+ # version 2.0 (the "License"); you may not use this file except in compliance
5
+ # with the License. You may obtain a copy of the License at:
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
+ # License for the specific language governing permissions and limitations
13
+ # under the License.
14
+
15
+ module Line
16
+ module Bot
17
+ module Event
18
+ class Base
19
+ def initialize(src)
20
+ @src = src
21
+ end
22
+
23
+ def [](key)
24
+ @src[key]
25
+ end
26
+
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,22 @@
1
+ # Copyright 2016 LINE
2
+ #
3
+ # LINE Corporation licenses this file to you under the Apache License,
4
+ # version 2.0 (the "License"); you may not use this file except in compliance
5
+ # with the License. You may obtain a copy of the License at:
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
+ # License for the specific language governing permissions and limitations
13
+ # under the License.
14
+
15
+ module Line
16
+ module Bot
17
+ module Event
18
+ class Beacon < Base
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,22 @@
1
+ # Copyright 2016 LINE
2
+ #
3
+ # LINE Corporation licenses this file to you under the Apache License,
4
+ # version 2.0 (the "License"); you may not use this file except in compliance
5
+ # with the License. You may obtain a copy of the License at:
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
+ # License for the specific language governing permissions and limitations
13
+ # under the License.
14
+
15
+ module Line
16
+ module Bot
17
+ module Event
18
+ class Follow < Base
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,22 @@
1
+ # Copyright 2016 LINE
2
+ #
3
+ # LINE Corporation licenses this file to you under the Apache License,
4
+ # version 2.0 (the "License"); you may not use this file except in compliance
5
+ # with the License. You may obtain a copy of the License at:
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
+ # License for the specific language governing permissions and limitations
13
+ # under the License.
14
+
15
+ module Line
16
+ module Bot
17
+ module Event
18
+ class Join < Base
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,22 @@
1
+ # Copyright 2016 LINE
2
+ #
3
+ # LINE Corporation licenses this file to you under the Apache License,
4
+ # version 2.0 (the "License"); you may not use this file except in compliance
5
+ # with the License. You may obtain a copy of the License at:
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
+ # License for the specific language governing permissions and limitations
13
+ # under the License.
14
+
15
+ module Line
16
+ module Bot
17
+ module Event
18
+ class Leave < Base
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,43 @@
1
+ # Copyright 2016 LINE
2
+ #
3
+ # LINE Corporation licenses this file to you under the Apache License,
4
+ # version 2.0 (the "License"); you may not use this file except in compliance
5
+ # with the License. You may obtain a copy of the License at:
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
+ # License for the specific language governing permissions and limitations
13
+ # under the License.
14
+
15
+ module Line
16
+ module Bot
17
+ module Event
18
+ module MessageType
19
+ Text = 'text'
20
+ Image = 'image'
21
+ Video = 'video'
22
+ Audio = 'audio'
23
+ Location = 'location'
24
+ Sticker = 'sticker'
25
+ Unsupport = 'unsupport'
26
+ end
27
+
28
+ class Message < Base
29
+ def type
30
+ begin
31
+ Line::Bot::Event::MessageType.const_get(@src['message']['type'].capitalize)
32
+ rescue NameError => e
33
+ Line::Bot::Event::MessageType::Unsupport
34
+ end
35
+ end
36
+
37
+ def message
38
+ @src['message']
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,22 @@
1
+ # Copyright 2016 LINE
2
+ #
3
+ # LINE Corporation licenses this file to you under the Apache License,
4
+ # version 2.0 (the "License"); you may not use this file except in compliance
5
+ # with the License. You may obtain a copy of the License at:
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
+ # License for the specific language governing permissions and limitations
13
+ # under the License.
14
+
15
+ module Line
16
+ module Bot
17
+ module Event
18
+ class Postback < Base
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,22 @@
1
+ # Copyright 2016 LINE
2
+ #
3
+ # LINE Corporation licenses this file to you under the Apache License,
4
+ # version 2.0 (the "License"); you may not use this file except in compliance
5
+ # with the License. You may obtain a copy of the License at:
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
+ # License for the specific language governing permissions and limitations
13
+ # under the License.
14
+
15
+ module Line
16
+ module Bot
17
+ module Event
18
+ class Unfollow < Base
19
+ end
20
+ end
21
+ end
22
+ end
@@ -1,3 +1,17 @@
1
+ # Copyright 2016 LINE
2
+ #
3
+ # LINE Corporation licenses this file to you under the Apache License,
4
+ # version 2.0 (the "License"); you may not use this file except in compliance
5
+ # with the License. You may obtain a copy of the License at:
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
+ # License for the specific language governing permissions and limitations
13
+ # under the License.
14
+
1
15
  require 'line/bot/api/version'
2
16
  require 'json'
3
17
  require 'net/http'
@@ -1,5 +1,18 @@
1
+ # Copyright 2016 LINE
2
+ #
3
+ # LINE Corporation licenses this file to you under the Apache License,
4
+ # version 2.0 (the "License"); you may not use this file except in compliance
5
+ # with the License. You may obtain a copy of the License at:
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
+ # License for the specific language governing permissions and limitations
13
+ # under the License.
14
+
1
15
  require 'line/bot/api/version'
2
- require 'line/bot/utils'
3
16
  require 'json'
4
17
  require 'net/http'
5
18
  require 'uri'
@@ -7,9 +20,7 @@ require 'uri'
7
20
  module Line
8
21
  module Bot
9
22
  class Request
10
- attr_accessor :endpoint, :endpoint_path, :credentials, :to_mid, :message, :to_channel_id, :httpclient
11
-
12
- include Line::Bot::Utils
23
+ attr_accessor :endpoint, :endpoint_path, :credentials, :to, :reply_token, :messages, :httpclient
13
24
 
14
25
  # Initializes a new Request
15
26
  #
@@ -18,33 +29,22 @@ module Line
18
29
  yield(self) if block_given?
19
30
  end
20
31
 
21
- # @return [Array]
22
- def to
23
- to_mid.is_a?(String) ? [to_mid] : to_mid
24
- end
25
-
26
- # @return [Line::Bot::Message::Base#content]
27
- def content
28
- message.content
29
- end
30
-
31
32
  # @return [Hash]
32
33
  def payload
33
34
  payload = {
34
35
  to: to,
35
- toChannel: to_channel_id,
36
- eventType: message.event_type.to_s,
37
- content: content
36
+ replyToken: reply_token,
37
+ messages: messages
38
38
  }
39
39
 
40
- payload.to_json
40
+ payload.delete_if{|k, v| v.nil?}.to_json
41
41
  end
42
42
 
43
43
  # @return [Hash]
44
44
  def header
45
45
  header = {
46
46
  'Content-Type' => 'application/json; charset=UTF-8',
47
- 'User-Agent' => "LINE-BotSDK/#{Line::Bot::API::VERSION}",
47
+ 'User-Agent' => "LINE-BotSDK-Ruby/#{Line::Bot::API::VERSION}",
48
48
  }
49
49
  hash = credentials.inject({}) { |h, (k, v)| h[k] = v.to_s; h }
50
50
 
@@ -53,8 +53,6 @@ module Line
53
53
 
54
54
  # Get content of specified URL.
55
55
  #
56
- # @raise [ArgumentError]
57
- #
58
56
  # @return [Net::HTTPResponse]
59
57
  def get
60
58
  assert_for_getting_message
@@ -76,8 +74,6 @@ module Line
76
74
  end
77
75
 
78
76
  def assert_for_posting_message
79
- raise ArgumentError, 'Wrong argument type `to_mid`' unless validate_mids(to)
80
- raise ArgumentError, 'Invalid argument `message`' unless message.valid?
81
77
  raise ArgumentError, 'Wrong argument type `endpoint_path`' unless endpoint_path.is_a?(String)
82
78
  end
83
79
 
@@ -20,13 +20,9 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.required_ruby_version = '>= 2.0.0'
22
22
 
23
- spec.add_dependency 'rack', '>= 1.6'
24
-
23
+ spec.add_development_dependency 'rake', "~> 10.4"
25
24
  spec.add_development_dependency "bundler", "~> 1.11"
26
- spec.add_development_dependency "rake", "~> 10.0"
27
25
  spec.add_development_dependency "webmock", "~> 1.24"
28
- spec.add_development_dependency "rest-client", "~> 1.8"
29
- spec.add_development_dependency "httpclient", "~> 2.8"
30
26
  spec.add_development_dependency "addressable", "~> 2.3"
31
27
  spec.add_development_dependency "rspec", "~> 3.0"
32
28
  end
metadata CHANGED
@@ -1,125 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: line-bot-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - LINE Corporation
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-23 00:00:00.000000000 Z
11
+ date: 2016-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rack
14
+ name: rake
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.6'
20
- type: :runtime
19
+ version: '10.4'
20
+ type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.6'
26
+ version: '10.4'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '1.11'
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
40
  version: '1.11'
41
- - !ruby/object:Gem::Dependency
42
- name: rake
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ~>
46
- - !ruby/object:Gem::Version
47
- version: '10.0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ~>
53
- - !ruby/object:Gem::Version
54
- version: '10.0'
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: webmock
57
43
  requirement: !ruby/object:Gem::Requirement
58
44
  requirements:
59
- - - ~>
45
+ - - "~>"
60
46
  - !ruby/object:Gem::Version
61
47
  version: '1.24'
62
48
  type: :development
63
49
  prerelease: false
64
50
  version_requirements: !ruby/object:Gem::Requirement
65
51
  requirements:
66
- - - ~>
52
+ - - "~>"
67
53
  - !ruby/object:Gem::Version
68
54
  version: '1.24'
69
- - !ruby/object:Gem::Dependency
70
- name: rest-client
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ~>
74
- - !ruby/object:Gem::Version
75
- version: '1.8'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ~>
81
- - !ruby/object:Gem::Version
82
- version: '1.8'
83
- - !ruby/object:Gem::Dependency
84
- name: httpclient
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ~>
88
- - !ruby/object:Gem::Version
89
- version: '2.8'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ~>
95
- - !ruby/object:Gem::Version
96
- version: '2.8'
97
55
  - !ruby/object:Gem::Dependency
98
56
  name: addressable
99
57
  requirement: !ruby/object:Gem::Requirement
100
58
  requirements:
101
- - - ~>
59
+ - - "~>"
102
60
  - !ruby/object:Gem::Version
103
61
  version: '2.3'
104
62
  type: :development
105
63
  prerelease: false
106
64
  version_requirements: !ruby/object:Gem::Requirement
107
65
  requirements:
108
- - - ~>
66
+ - - "~>"
109
67
  - !ruby/object:Gem::Version
110
68
  version: '2.3'
111
69
  - !ruby/object:Gem::Dependency
112
70
  name: rspec
113
71
  requirement: !ruby/object:Gem::Requirement
114
72
  requirements:
115
- - - ~>
73
+ - - "~>"
116
74
  - !ruby/object:Gem::Version
117
75
  version: '3.0'
118
76
  type: :development
119
77
  prerelease: false
120
78
  version_requirements: !ruby/object:Gem::Requirement
121
79
  requirements:
122
- - - ~>
80
+ - - "~>"
123
81
  - !ruby/object:Gem::Version
124
82
  version: '3.0'
125
83
  description: Line::Bot::API - SDK of the LINE BOT API
@@ -132,39 +90,23 @@ files:
132
90
  - CONTRIBUTING.md
133
91
  - LICENSE
134
92
  - README.md
135
- - line-bot-api.gemspec
93
+ - lib/line/bot.rb
94
+ - lib/line/bot/api.rb
136
95
  - lib/line/bot/api/errors.rb
137
96
  - lib/line/bot/api/version.rb
138
- - lib/line/bot/api.rb
139
- - lib/line/bot/builder/multiple_message.rb
140
- - lib/line/bot/builder/rich_message.rb
141
97
  - lib/line/bot/client.rb
142
- - lib/line/bot/event_type.rb
98
+ - lib/line/bot/event.rb
99
+ - lib/line/bot/event/base.rb
100
+ - lib/line/bot/event/beacon.rb
101
+ - lib/line/bot/event/follow.rb
102
+ - lib/line/bot/event/join.rb
103
+ - lib/line/bot/event/leave.rb
104
+ - lib/line/bot/event/message.rb
105
+ - lib/line/bot/event/postback.rb
106
+ - lib/line/bot/event/unfollow.rb
143
107
  - lib/line/bot/httpclient.rb
144
- - lib/line/bot/message/audio.rb
145
- - lib/line/bot/message/base.rb
146
- - lib/line/bot/message/contact.rb
147
- - lib/line/bot/message/content_type.rb
148
- - lib/line/bot/message/image.rb
149
- - lib/line/bot/message/location.rb
150
- - lib/line/bot/message/recipient_type.rb
151
- - lib/line/bot/message/sticker.rb
152
- - lib/line/bot/message/text.rb
153
- - lib/line/bot/message/video.rb
154
- - lib/line/bot/message.rb
155
- - lib/line/bot/operation/added_as_friend.rb
156
- - lib/line/bot/operation/base.rb
157
- - lib/line/bot/operation/blocked_account.rb
158
- - lib/line/bot/operation/op_type.rb
159
- - lib/line/bot/operation.rb
160
- - lib/line/bot/receive/message.rb
161
- - lib/line/bot/receive/operation.rb
162
- - lib/line/bot/receive/request.rb
163
108
  - lib/line/bot/request.rb
164
- - lib/line/bot/response/user/contact.rb
165
- - lib/line/bot/response/user/profile.rb
166
- - lib/line/bot/utils.rb
167
- - lib/line/bot.rb
109
+ - line-bot-api.gemspec
168
110
  homepage: https://github.com/line/line-bot-sdk-ruby
169
111
  licenses:
170
112
  - Apache-2.0
@@ -175,17 +117,17 @@ require_paths:
175
117
  - lib
176
118
  required_ruby_version: !ruby/object:Gem::Requirement
177
119
  requirements:
178
- - - '>='
120
+ - - ">="
179
121
  - !ruby/object:Gem::Version
180
122
  version: 2.0.0
181
123
  required_rubygems_version: !ruby/object:Gem::Requirement
182
124
  requirements:
183
- - - '>='
125
+ - - ">="
184
126
  - !ruby/object:Gem::Version
185
127
  version: '0'
186
128
  requirements: []
187
129
  rubyforge_project:
188
- rubygems_version: 2.0.14.1
130
+ rubygems_version: 2.4.5
189
131
  signing_key:
190
132
  specification_version: 4
191
133
  summary: Line::Bot::API - SDK of the LINE BOT API