cloud_connect 2.0.1 → 2.0.2
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.
- data/HISTORY.md +4 -0
- data/cloud_connect.gemspec +1 -2
- data/lib/cloud_connect.rb +1 -0
- data/lib/cloud_connect/client.rb +8 -4
- data/lib/cloud_connect/client/messages.rb +9 -2
- data/lib/cloud_connect/version.rb +1 -1
- metadata +2 -2
data/HISTORY.md
CHANGED
data/cloud_connect.gemspec
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
1
|
require File.expand_path("../lib/cloud_connect/version", __FILE__)
|
3
2
|
|
4
3
|
Gem::Specification.new do |s|
|
@@ -10,7 +9,7 @@ Gem::Specification.new do |s|
|
|
10
9
|
s.homepage = "http://rubygems.org/gems/cloud_connect"
|
11
10
|
s.summary = "Wrapper for Cloud Connect"
|
12
11
|
s.description = "Ruby Wrapper for the Mobile Devices Cloud Connect API"
|
13
|
-
s.version = '2.0.
|
12
|
+
s.version = '2.0.2'
|
14
13
|
|
15
14
|
s.required_rubygems_version = ">= 1.3.6"
|
16
15
|
|
data/lib/cloud_connect.rb
CHANGED
data/lib/cloud_connect/client.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module CloudConnect
|
2
2
|
class Client
|
3
|
-
attr_reader :username, :password, :account, :env, :cookie
|
3
|
+
attr_reader :username, :password, :account, :env, :cookie, :version
|
4
4
|
attr_writer :cookie
|
5
5
|
|
6
6
|
def initialize(options={})
|
@@ -8,6 +8,7 @@ module CloudConnect
|
|
8
8
|
@password = options[:password] || CloudConnect.password
|
9
9
|
@account = options[:account] || CloudConnect.account
|
10
10
|
@env = options[:env] || CloudConnect.env || "prod"
|
11
|
+
@version = options[:version] || "v2"
|
11
12
|
end
|
12
13
|
|
13
14
|
# Raw HTTP connection, either Faraday::Connection
|
@@ -34,13 +35,16 @@ module CloudConnect
|
|
34
35
|
if env == "preprod"
|
35
36
|
"http://srv/api/v2"
|
36
37
|
else
|
37
|
-
"http://#{env}.g8teway.com/api
|
38
|
+
"http://#{env}.g8teway.com/api/#{version}"
|
38
39
|
end
|
39
40
|
end
|
40
41
|
|
41
|
-
|
42
42
|
def login
|
43
|
-
|
43
|
+
if version == "v1.5"
|
44
|
+
req = connection.post('ws?login', "username=#{username}&password=#{password}&client=#{account}")
|
45
|
+
else
|
46
|
+
req = connection.post('sessions', {:login => username, :password => password, :client => account})
|
47
|
+
end
|
44
48
|
end
|
45
49
|
|
46
50
|
private
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module CloudConnect
|
2
2
|
module Messages
|
3
3
|
|
4
|
+
require 'open-uri'
|
5
|
+
|
4
6
|
# Returns all messages that match parameters provided in +opts+ list
|
5
7
|
# (if +opts+ is provided)
|
6
8
|
#
|
@@ -40,8 +42,13 @@ module CloudConnect
|
|
40
42
|
# TODO: rename #message_create ?
|
41
43
|
opts.merge! :channelid => channel, :unitid => unit, :content => content
|
42
44
|
response = connection.post do |req|
|
43
|
-
|
44
|
-
|
45
|
+
if version == "v1.5"
|
46
|
+
req.url 'ws?messagesend'
|
47
|
+
req.body = "unit=#{unit}&channel=#{channel}&content=#{URI::encode(content)}"
|
48
|
+
else
|
49
|
+
req.url 'messages'
|
50
|
+
req.body = {:message => opts}
|
51
|
+
end
|
45
52
|
end
|
46
53
|
response.body.values.first
|
47
54
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloud_connect
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-08-
|
12
|
+
date: 2014-08-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|