rubychy 0.1.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.
- checksums.yaml +7 -0
- data/.gitignore +35 -0
- data/Gemfile +3 -0
- data/LICENSE +21 -0
- data/README.md +2 -0
- data/lib/rubychy/api_response.rb +34 -0
- data/lib/rubychy/bot.rb +94 -0
- data/lib/rubychy/data_types/attribution.rb +9 -0
- data/lib/rubychy/data_types/base.rb +7 -0
- data/lib/rubychy/data_types/features.rb +11 -0
- data/lib/rubychy/data_types/keyboard.rb +22 -0
- data/lib/rubychy/data_types/keyboard_response.rb +17 -0
- data/lib/rubychy/data_types/keyboards.rb +17 -0
- data/lib/rubychy/data_types/link.rb +30 -0
- data/lib/rubychy/data_types/message.rb +10 -0
- data/lib/rubychy/data_types/picture.rb +25 -0
- data/lib/rubychy/data_types/read_receipt.rb +23 -0
- data/lib/rubychy/data_types/received_message.rb +29 -0
- data/lib/rubychy/data_types/received_messages.rb +7 -0
- data/lib/rubychy/data_types/sent_message.rb +13 -0
- data/lib/rubychy/data_types/text.rb +24 -0
- data/lib/rubychy/data_types/typing.rb +23 -0
- data/lib/rubychy/data_types/user.rb +13 -0
- data/lib/rubychy/data_types/video.rb +33 -0
- data/lib/rubychy/version.rb +4 -0
- data/lib/rubychy.rb +66 -0
- data/rubychy.gemspec +26 -0
- metadata +140 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 333bc5bc3aee4fc79a6d6b59708e2b3d385b5ddb
|
4
|
+
data.tar.gz: 8ee862e01cbcd6674b496db4baf2dc22038a86b1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5c8339a59ab0946bc6956472fb38a0dbc616aa929bd311c31c7a7054938ca1da8e6227d79a2ee0998e3228ffe59f2ecabc1cefab1492250993a32536f59f5d05
|
7
|
+
data.tar.gz: fe1c6c9c0dba615116411fd26121d692f78fbae7982ddc4c1035bbb43f1301772eda2839ab3a52506ceb6003f8afc98857a0d6c350bee6f5414a9ad15411c3a1
|
data/.gitignore
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
*.rbc
|
2
|
+
capybara-*.html
|
3
|
+
.rspec
|
4
|
+
/log
|
5
|
+
/tmp
|
6
|
+
/db/*.sqlite3
|
7
|
+
/db/*.sqlite3-journal
|
8
|
+
/public/system
|
9
|
+
/coverage/
|
10
|
+
/spec/tmp
|
11
|
+
**.orig
|
12
|
+
rerun.txt
|
13
|
+
pickle-email-*.html
|
14
|
+
|
15
|
+
# TODO Comment out these rules if you are OK with secrets being uploaded to the repo
|
16
|
+
config/initializers/secret_token.rb
|
17
|
+
config/secrets.yml
|
18
|
+
|
19
|
+
## Environment normalization:
|
20
|
+
/.bundle
|
21
|
+
/vendor/bundle
|
22
|
+
|
23
|
+
# these should all be checked in to normalize the environment:
|
24
|
+
# Gemfile.lock, .ruby-version, .ruby-gemset
|
25
|
+
|
26
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
27
|
+
.rvmrc
|
28
|
+
|
29
|
+
# if using bower-rails ignore default bower_components path bower.json files
|
30
|
+
/vendor/assets/bower_components
|
31
|
+
*.bowerrc
|
32
|
+
bower.json
|
33
|
+
|
34
|
+
# Ignore pow environment settings
|
35
|
+
.powenv
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Nima Kaviani
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
module Rubychy
|
2
|
+
class ApiResponse
|
3
|
+
attr_reader :body
|
4
|
+
attr_reader :result
|
5
|
+
attr_reader :success
|
6
|
+
|
7
|
+
def initialize(response,fail_silently = false)
|
8
|
+
if response.status < 500
|
9
|
+
@body = response.body
|
10
|
+
data = MultiJson.load(@body)
|
11
|
+
@success = (response.status == 200)
|
12
|
+
|
13
|
+
if @success
|
14
|
+
@result = data
|
15
|
+
else
|
16
|
+
if !fail_silently
|
17
|
+
fail Rubychy::Errors::BadRequestError.new(data['error'], data['message'])
|
18
|
+
end
|
19
|
+
end
|
20
|
+
else
|
21
|
+
if !fail_silently
|
22
|
+
fail Rubychy::Errors::ServiceUnavailableError.new(response.status)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.parse(request)
|
28
|
+
Rubychy::DataTypes::ReceivedMessages.new(MultiJson.load(request.body))
|
29
|
+
end
|
30
|
+
|
31
|
+
alias_method :success?, :success
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
data/lib/rubychy/bot.rb
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
module Rubychy
|
2
|
+
class Bot
|
3
|
+
API_ENDPOINT = 'https://api.kik.com/v1'
|
4
|
+
|
5
|
+
attr_reader :me
|
6
|
+
|
7
|
+
def initialize(username, api_token)
|
8
|
+
@username = username
|
9
|
+
@api_token = api_token
|
10
|
+
@offset = 0
|
11
|
+
@timeout = 60
|
12
|
+
@fail_silently = false
|
13
|
+
@connection = HTTPClient.new
|
14
|
+
@connection.set_auth(nil, @username, @api_token)
|
15
|
+
end
|
16
|
+
|
17
|
+
def config(webhook, features = Rubychy::DataTypes::Features.new)
|
18
|
+
api_post('config', {webhook: webhook, features: features})
|
19
|
+
end
|
20
|
+
|
21
|
+
def send_message(*messages)
|
22
|
+
msgs = { messages: sanitize('message', messages) }
|
23
|
+
api_post('message', msgs)
|
24
|
+
end
|
25
|
+
|
26
|
+
def get_user(username)
|
27
|
+
response = api_get("user/#{username}")
|
28
|
+
Rubychy::DataTypes::User.new(response.result)
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def sanitize(action, messages)
|
34
|
+
validated_params = Array.new
|
35
|
+
messages.each do |message|
|
36
|
+
# Delete params not accepted by the API
|
37
|
+
validated_param = message.to_hash.delete_if { |k, _v|
|
38
|
+
!message.validations.key?(k) || (message.validations[k][:drop_empty] && _v.nil?)
|
39
|
+
}
|
40
|
+
|
41
|
+
# Check all required params by the action are present
|
42
|
+
message.validations.each do |key, _value|
|
43
|
+
if _value[:required] && (!validated_param.key?(key) || validated_param[key].nil?)
|
44
|
+
fail Rubychy::Errors::MissingParamsError.new(key, action)
|
45
|
+
end
|
46
|
+
|
47
|
+
# Check param types
|
48
|
+
unless _value[:class].include?(validated_param[key].class) || (_value[:drop_empty] && validated_param[key].nil?)
|
49
|
+
fail Rubychy::Errors::InvalidParamTypeError.new(key, validated_param[key].class, _value[:class])
|
50
|
+
end
|
51
|
+
validated_params[key] = validated_param[key].to_s if _value[:class] == Fixnum
|
52
|
+
end
|
53
|
+
|
54
|
+
validated_params << validated_param
|
55
|
+
end
|
56
|
+
return validated_params
|
57
|
+
end
|
58
|
+
|
59
|
+
def api_get(action)
|
60
|
+
api_uri = "#{action}"
|
61
|
+
begin
|
62
|
+
response = @connection.get(
|
63
|
+
"#{API_ENDPOINT}/#{api_uri}",
|
64
|
+
nil
|
65
|
+
)
|
66
|
+
|
67
|
+
ApiResponse.new(response,@fail_silently)
|
68
|
+
rescue HTTPClient::ReceiveTimeoutError => e
|
69
|
+
if !@fail_silently
|
70
|
+
fail Rubychy::Errors::TimeoutError, e.to_s
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def api_post(action, params)
|
76
|
+
api_uri = "#{action}"
|
77
|
+
|
78
|
+
begin
|
79
|
+
response = @connection.post(
|
80
|
+
"#{API_ENDPOINT}/#{api_uri}",
|
81
|
+
MultiJson.dump(params),
|
82
|
+
'Content-Type' => 'application/json'
|
83
|
+
)
|
84
|
+
|
85
|
+
ApiResponse.new(response,@fail_silently)
|
86
|
+
rescue HTTPClient::ReceiveTimeoutError => e
|
87
|
+
if !@fail_silently
|
88
|
+
fail Rubychy::Errors::TimeoutError, e.to_s
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module Rubychy
|
2
|
+
module DataTypes
|
3
|
+
class Features < Rubychy::DataTypes::Base
|
4
|
+
attribute :manuallySendReadReceipts, Boolean, :default => false
|
5
|
+
attribute :receiveReadReceipts, Boolean, :default => false
|
6
|
+
attribute :receiveDeliveryReceipts, Boolean, :default => false
|
7
|
+
attribute :receiveIsTyping, Boolean, :default => false
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Rubychy
|
2
|
+
module DataTypes
|
3
|
+
class Keyboard < Rubychy::DataTypes::Base
|
4
|
+
attribute :type, String, :default => "suggested"
|
5
|
+
attribute :to, String
|
6
|
+
attribute :hidden, Boolean, :default => "false"
|
7
|
+
attribute :responses, Array[KeyboardResponse]
|
8
|
+
|
9
|
+
def validations
|
10
|
+
{
|
11
|
+
type: { required: true, class: [String] },
|
12
|
+
to: { required: true, class: [String] },
|
13
|
+
hidden: {required: false, class: [Boolean] },
|
14
|
+
responses: {required: true, class: [Array] }
|
15
|
+
}
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Rubychy
|
2
|
+
module DataTypes
|
3
|
+
class KeyboardResponse < Rubychy::DataTypes::Base
|
4
|
+
attribute :type, String
|
5
|
+
attribute :body, String
|
6
|
+
|
7
|
+
def validations
|
8
|
+
{
|
9
|
+
type: { required: true, class: [String] },
|
10
|
+
body: { required: true, class: [String] },
|
11
|
+
}
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Rubychy
|
2
|
+
module DataTypes
|
3
|
+
class Keyboards < Rubychy::DataTypes::Base
|
4
|
+
attribute :keyboards, Array[Keyboard]
|
5
|
+
|
6
|
+
def validations
|
7
|
+
{
|
8
|
+
type: { required: true, class: [String] },
|
9
|
+
body: { required: true, class: [String] },
|
10
|
+
}
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Rubychy
|
2
|
+
module DataTypes
|
3
|
+
class Link < Rubychy::DataTypes::SentMessage
|
4
|
+
attribute :url, String
|
5
|
+
attribute :title, String, :default => ""
|
6
|
+
attribute :text, String, :default => ""
|
7
|
+
attribute :noForward, Boolean, :default => false
|
8
|
+
|
9
|
+
def initialize *params
|
10
|
+
super(*params)
|
11
|
+
@type = 'link'
|
12
|
+
end
|
13
|
+
|
14
|
+
def validations
|
15
|
+
{
|
16
|
+
url: { required: true, class: [String] },
|
17
|
+
title: { required: false, drop_empty: true, class: [String] },
|
18
|
+
text: { required: false, drop_empty: true, class: [String] },
|
19
|
+
to: { required: true, class: [String] },
|
20
|
+
type: { required: true, class: [String] },
|
21
|
+
chatId: { required: true, class: [String] },
|
22
|
+
keyboards: { required: false, class: [Array] },
|
23
|
+
}
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Rubychy
|
2
|
+
module DataTypes
|
3
|
+
class Picture < Rubychy::DataTypes::SentMessage
|
4
|
+
attribute :picUrl, String
|
5
|
+
attribute :attribution, String, :default => "gallery"
|
6
|
+
|
7
|
+
def initialize *params
|
8
|
+
super(*params)
|
9
|
+
@type = 'picture'
|
10
|
+
end
|
11
|
+
|
12
|
+
def validations
|
13
|
+
{
|
14
|
+
picUrl: { required: true, class: [String] },
|
15
|
+
to: { required: true, class: [String] },
|
16
|
+
type: { required: true, class: [String] },
|
17
|
+
chatId: { required: true, class: [String] },
|
18
|
+
keyboards: { required: false, class: [Array] },
|
19
|
+
}
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Rubychy
|
2
|
+
module DataTypes
|
3
|
+
class ReadReceipt < Rubychy::DataTypes::SentMessage
|
4
|
+
attribute :msgIds, Array[String]
|
5
|
+
|
6
|
+
def initialize *params
|
7
|
+
super(*params)
|
8
|
+
@type = 'read-receipt'
|
9
|
+
end
|
10
|
+
|
11
|
+
def validations
|
12
|
+
{
|
13
|
+
msgIds: { required: true, class: [Array] },
|
14
|
+
to: { required: true, class: [String] },
|
15
|
+
type: { required: true, class: [String] },
|
16
|
+
chatId: { required: true, class: [String] },
|
17
|
+
}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Rubychy
|
2
|
+
module DataTypes
|
3
|
+
class ReceivedMessage < Rubychy::DataTypes::Message
|
4
|
+
attribute :from, String
|
5
|
+
attribute :timestamp, Integer
|
6
|
+
attribute :readReceiptRequested, Boolean
|
7
|
+
attribute :participants, Array[String]
|
8
|
+
attribute :mention, String
|
9
|
+
|
10
|
+
attribute :body, String
|
11
|
+
|
12
|
+
attribute :attribution, Attribution
|
13
|
+
attribute :noForward, Boolean
|
14
|
+
attribute :readReceiptRequested, Boolean
|
15
|
+
|
16
|
+
attribute :picUrl, String
|
17
|
+
|
18
|
+
attribute :videoUrl, String
|
19
|
+
|
20
|
+
attribute :data, String
|
21
|
+
|
22
|
+
attribute :stickerPackId, String
|
23
|
+
attribute :stickerUrl, String
|
24
|
+
|
25
|
+
attribute :isTyping, Boolean
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Rubychy
|
2
|
+
module DataTypes
|
3
|
+
class Text < Rubychy::DataTypes::SentMessage
|
4
|
+
attribute :body, String
|
5
|
+
attribute :typeTime, Integer, :default => 0
|
6
|
+
|
7
|
+
def initialize *params
|
8
|
+
super(*params)
|
9
|
+
@type = 'text'
|
10
|
+
end
|
11
|
+
|
12
|
+
def validations
|
13
|
+
{
|
14
|
+
body: { required: true, class: [String] },
|
15
|
+
to: { required: true, class: [String] },
|
16
|
+
type: { required: true, class: [String] },
|
17
|
+
chatId: { required: true, class: [String] },
|
18
|
+
keyboards: { required: false, class: [Array] },
|
19
|
+
}
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Rubychy
|
2
|
+
module DataTypes
|
3
|
+
class Typing < Rubychy::DataTypes::SentMessage
|
4
|
+
attribute :isTyping, Boolean, :default => false
|
5
|
+
|
6
|
+
def initialize *params
|
7
|
+
super(*params)
|
8
|
+
@type = 'is-typing'
|
9
|
+
end
|
10
|
+
|
11
|
+
def validations
|
12
|
+
{
|
13
|
+
isTyping: { required: true, class: [Boolean] },
|
14
|
+
to: { required: true, class: [String] },
|
15
|
+
type: { required: true, class: [String] },
|
16
|
+
chatId: { required: true, class: [String] },
|
17
|
+
}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Rubychy
|
2
|
+
module DataTypes
|
3
|
+
class Video < Rubychy::DataTypes::SentMessage
|
4
|
+
attribute :videoUrl, String
|
5
|
+
attribute :loop, Boolean, :default => false
|
6
|
+
attribute :muted, Boolean, :default => false
|
7
|
+
attribute :autoplay, Boolean, :default => false
|
8
|
+
attribute :noSave, Boolean, :default => false
|
9
|
+
attribute :typeTime, Integer, :default => 0
|
10
|
+
|
11
|
+
def initialize *params
|
12
|
+
super(*params)
|
13
|
+
@type = 'video'
|
14
|
+
end
|
15
|
+
|
16
|
+
def validations
|
17
|
+
{
|
18
|
+
videoUrl: { required: true, class: [String] },
|
19
|
+
loop: { required: true, class: [TrueClass, FalseClass] },
|
20
|
+
muted: { required: false, drop_empty: true, class: [TrueClass, FalseClass] },
|
21
|
+
autoplay: { required: false, drop_empty: true, class: [TrueClass, FalseClass] },
|
22
|
+
typeTime: { required: false, drop_empty: true, class: [Fixnum] },
|
23
|
+
to: { required: true, class: [String] },
|
24
|
+
type: { required: true, class: [String] },
|
25
|
+
chatId: { required: true, class: [String] },
|
26
|
+
keyboards: { required: false, class: [Array] },
|
27
|
+
}
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
|
data/lib/rubychy.rb
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'httpclient'
|
2
|
+
require 'virtus'
|
3
|
+
require 'multi_json'
|
4
|
+
|
5
|
+
require 'rubychy/version'
|
6
|
+
require 'rubychy/data_types/base'
|
7
|
+
require 'rubychy/data_types/attribution'
|
8
|
+
require 'rubychy/data_types/user'
|
9
|
+
|
10
|
+
require 'rubychy/data_types/keyboard_response'
|
11
|
+
require 'rubychy/data_types/keyboard'
|
12
|
+
require 'rubychy/data_types/keyboards'
|
13
|
+
|
14
|
+
require 'rubychy/data_types/message'
|
15
|
+
require 'rubychy/data_types/sent_message'
|
16
|
+
require 'rubychy/data_types/received_message'
|
17
|
+
require 'rubychy/data_types/received_messages'
|
18
|
+
|
19
|
+
require 'rubychy/data_types/link'
|
20
|
+
require 'rubychy/data_types/text'
|
21
|
+
require 'rubychy/data_types/picture'
|
22
|
+
require 'rubychy/data_types/video'
|
23
|
+
require 'rubychy/data_types/typing'
|
24
|
+
require 'rubychy/data_types/read_receipt'
|
25
|
+
|
26
|
+
require 'rubychy/bot'
|
27
|
+
require 'rubychy/api_response'
|
28
|
+
|
29
|
+
module Rubychy
|
30
|
+
module Errors
|
31
|
+
# Error returned when a required param is missing
|
32
|
+
class MissingParamsError < StandardError
|
33
|
+
def initialize(parameter, action)
|
34
|
+
super("Missing parameter `#{parameter}` for `#{action}`")
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# Error returned when a param type is invalid
|
39
|
+
class InvalidParamTypeError < StandardError
|
40
|
+
def initialize(parameter, current_type, allowed_types)
|
41
|
+
super("Invalid parameter type: `#{parameter}`: `#{current_type}`. Allowed types: #{allowed_types.each { |type| type.class.to_s }.join(',')}.")
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
# Error returned when something goes bad with your request to the Rubychy API
|
46
|
+
class BadRequestError < StandardError
|
47
|
+
def initialize(error_code, message)
|
48
|
+
super("Bad request. Error code: `#{error_code}` - Message: `#{message}`")
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# Error returned when Rubychy API Service is unavailable
|
53
|
+
class ServiceUnavailableError < StandardError
|
54
|
+
def initialize(status_code)
|
55
|
+
super("Rubychy API Service unavailable (HTTP error code #{status_code})")
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
# Error returned when HTTPClient raise a timeout (?)
|
60
|
+
class TimeoutError < StandardError
|
61
|
+
def initialize(message)
|
62
|
+
super("Timeout reached. Message: #{message}")
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
data/rubychy.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'rubychy/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "rubychy"
|
7
|
+
spec.version = Rubychy::VERSION
|
8
|
+
spec.authors = ["Nima Kaviani"]
|
9
|
+
spec.email = ["nima@robochy.com"]
|
10
|
+
spec.description = %q{Ruby client for the Kik Bot API}
|
11
|
+
spec.summary = %q{Ruby client for the Kik Bot API}
|
12
|
+
spec.homepage = "https://github.com/nkaviani/rubychy"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files`.split($/)
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_dependency "httpclient", "~> 2.6"
|
21
|
+
spec.add_dependency "virtus", "~> 1.0"
|
22
|
+
spec.add_dependency "multi_json", "~> 1.11"
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.1"
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,140 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rubychy
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nima Kaviani
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-04-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: httpclient
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.6'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: virtus
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: multi_json
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.11'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.11'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.7'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.7'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '10.1'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '10.1'
|
83
|
+
description: Ruby client for the Kik Bot API
|
84
|
+
email:
|
85
|
+
- nima@robochy.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- Gemfile
|
92
|
+
- LICENSE
|
93
|
+
- README.md
|
94
|
+
- lib/rubychy.rb
|
95
|
+
- lib/rubychy/api_response.rb
|
96
|
+
- lib/rubychy/bot.rb
|
97
|
+
- lib/rubychy/data_types/attribution.rb
|
98
|
+
- lib/rubychy/data_types/base.rb
|
99
|
+
- lib/rubychy/data_types/features.rb
|
100
|
+
- lib/rubychy/data_types/keyboard.rb
|
101
|
+
- lib/rubychy/data_types/keyboard_response.rb
|
102
|
+
- lib/rubychy/data_types/keyboards.rb
|
103
|
+
- lib/rubychy/data_types/link.rb
|
104
|
+
- lib/rubychy/data_types/message.rb
|
105
|
+
- lib/rubychy/data_types/picture.rb
|
106
|
+
- lib/rubychy/data_types/read_receipt.rb
|
107
|
+
- lib/rubychy/data_types/received_message.rb
|
108
|
+
- lib/rubychy/data_types/received_messages.rb
|
109
|
+
- lib/rubychy/data_types/sent_message.rb
|
110
|
+
- lib/rubychy/data_types/text.rb
|
111
|
+
- lib/rubychy/data_types/typing.rb
|
112
|
+
- lib/rubychy/data_types/user.rb
|
113
|
+
- lib/rubychy/data_types/video.rb
|
114
|
+
- lib/rubychy/version.rb
|
115
|
+
- rubychy.gemspec
|
116
|
+
homepage: https://github.com/nkaviani/rubychy
|
117
|
+
licenses:
|
118
|
+
- MIT
|
119
|
+
metadata: {}
|
120
|
+
post_install_message:
|
121
|
+
rdoc_options: []
|
122
|
+
require_paths:
|
123
|
+
- lib
|
124
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '0'
|
129
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - ">="
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
requirements: []
|
135
|
+
rubyforge_project:
|
136
|
+
rubygems_version: 2.4.8
|
137
|
+
signing_key:
|
138
|
+
specification_version: 4
|
139
|
+
summary: Ruby client for the Kik Bot API
|
140
|
+
test_files: []
|