gateway-sdk 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -0
- data/lib/gateway/client.rb +5 -1
- data/lib/gateway/config.yml +4 -0
- data/lib/gateway/requests/client.rb +13 -0
- data/lib/gateway/requests/common_request.rb +6 -2
- data/lib/gateway/requests/inbox_message_request.rb +8 -0
- data/lib/gateway/requests/send_message_request.rb +2 -1
- data/lib/gateway/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97a5a30ab2e4bcd30f06b47688c8d058af21b770
|
4
|
+
data.tar.gz: c33c0e8617c931fe55e231f157f388b496b28265
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d06fb18915c1807b6c1abee653011645e806cc184b2f09d9870cb7166ba542efcb5d748fd9fa18b9defa15a3cedb9afad8bc6e727cef65c2ec9d7672226efff1
|
7
|
+
data.tar.gz: cc25e145f5e38745a50c991a0cf706b5f90bcb73e66fe466dbd73a94e24018e5adf4743bc6b8ca7cc9e2397e7a34c1b4e586fc00b5b063c8751abf693dbd3bc8
|
data/Gemfile
CHANGED
data/lib/gateway/client.rb
CHANGED
@@ -49,7 +49,11 @@ module Gateway
|
|
49
49
|
query_params.merge! request.attributes
|
50
50
|
response = RestClient.get(url(query_params))
|
51
51
|
when METHOD_POST
|
52
|
-
|
52
|
+
if config_data.content_type == 'json'
|
53
|
+
response = RestClient.post(url(query_params), request.attributes.to_json, content_type: :json, Authorization: @token)
|
54
|
+
else
|
55
|
+
response = RestClient.post(url(query_params), request.attributes, Authorization: @token)
|
56
|
+
end
|
53
57
|
else
|
54
58
|
raise Gateway::ArgumentError.new("http method #{config_data.http_method} is not supported")
|
55
59
|
end
|
data/lib/gateway/config.yml
CHANGED
@@ -5,6 +5,10 @@ api_methods:
|
|
5
5
|
SendMessageRequest:
|
6
6
|
route: "scheduler/by-phone-and-transport"
|
7
7
|
http_method: "post"
|
8
|
+
InboxMessageRequest:
|
9
|
+
route: "external/receiver"
|
10
|
+
http_method: "post"
|
11
|
+
content_type: "json"
|
8
12
|
SetProfileRequest:
|
9
13
|
route: "scheduler/profile"
|
10
14
|
http_method: "post"
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Gateway
|
2
|
+
module Requests
|
3
|
+
class Client < CommonRequest
|
4
|
+
attr_accessor :key, :avatar, :nickname
|
5
|
+
|
6
|
+
def initialize(attributes)
|
7
|
+
attributes.each do |name, value|
|
8
|
+
send("#{name}=", value) if respond_to? "#{name}="
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -15,11 +15,15 @@ module Gateway
|
|
15
15
|
def attributes
|
16
16
|
hash = {}
|
17
17
|
instance_variables.each do |attr|
|
18
|
-
|
18
|
+
value = instance_variable_get attr
|
19
|
+
if value.is_a? Gateway::Requests::CommonRequest
|
20
|
+
hash[attr[1..-1]] = value.attributes
|
21
|
+
else
|
22
|
+
hash[attr[1..-1]] = value
|
23
|
+
end
|
19
24
|
end
|
20
25
|
hash
|
21
26
|
end
|
22
|
-
|
23
27
|
end
|
24
28
|
end
|
25
29
|
end
|
@@ -11,6 +11,7 @@ module Gateway
|
|
11
11
|
TRANSPORT_TG = 'telegram' # transport telegram
|
12
12
|
TRANSPORT_SMS = 'modem' # transport modem
|
13
13
|
TRANSPORT_FACEBOOK = 'facebook' # transport facebook
|
14
|
+
TRANSPORT_EXTERNAL = 'external' # transport external
|
14
15
|
|
15
16
|
attr_accessor :phone, :devicePhone, :body, :image, :transport, :plannedDate
|
16
17
|
|
@@ -18,7 +19,7 @@ module Gateway
|
|
18
19
|
# Possible transports
|
19
20
|
#
|
20
21
|
def self.possible_transports
|
21
|
-
[TRANSPORT_WA, TRANSPORT_VIBER, TRANSPORT_TG, TRANSPORT_SMS, TRANSPORT_FACEBOOK]
|
22
|
+
[TRANSPORT_WA, TRANSPORT_VIBER, TRANSPORT_TG, TRANSPORT_SMS, TRANSPORT_FACEBOOK, TRANSPORT_EXTERNAL]
|
22
23
|
end
|
23
24
|
|
24
25
|
def transport=(transport)
|
data/lib/gateway/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gateway-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- atanych
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-07-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -89,7 +89,9 @@ files:
|
|
89
89
|
- lib/gateway/client.rb
|
90
90
|
- lib/gateway/config.yml
|
91
91
|
- lib/gateway/errors.rb
|
92
|
+
- lib/gateway/requests/client.rb
|
92
93
|
- lib/gateway/requests/common_request.rb
|
94
|
+
- lib/gateway/requests/inbox_message_request.rb
|
93
95
|
- lib/gateway/requests/send_message_request.rb
|
94
96
|
- lib/gateway/requests/set_profile_request.rb
|
95
97
|
- lib/gateway/version.rb
|