panasonic_rcs 0.0.1 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +4 -0
- data/lib/panasonic_rcs/rcs.rb +13 -0
- data/lib/panasonic_rcs/version.rb +1 -1
- data/spec/lib/panasonic_rcs/rcs_spec.rb +12 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 271d52aa01027d75b3a88ac907c4a17b20863f29
|
4
|
+
data.tar.gz: cddfd9179c1c1a5cfe166eb26589cb9698467efd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5faaebe1edb4a3fb492f4dfef8ce6ba5f9fede224a02ffb234d9216aea4e4a437339223127711a075042cfbdca2be6785b7b825987a4d66d62c06e2bb6edbbbb
|
7
|
+
data.tar.gz: 748ec05eaf9306d6c85da9b2c78992ff37e7cce655aeab109f12d8bc42a9b34acfe2ebd9fe54613b605bda4e45ca864e5b239f8c4b0c017689d426692091bfe0
|
data/.gitignore
CHANGED
data/README.md
CHANGED
data/lib/panasonic_rcs/rcs.rb
CHANGED
@@ -46,6 +46,19 @@ module PanasonicRcs
|
|
46
46
|
body['params']['param']['value']['boolean'] == "1"
|
47
47
|
end
|
48
48
|
|
49
|
+
def unregister_phone(raw_mac_addr)
|
50
|
+
mac_addr = raw_mac_addr.gsub(/[^[:alnum:]]/, '')
|
51
|
+
body = "<?xml version=\"1.0\"?><methodCall><methodName>ipredirect.unregisterPhone</methodName><params><param><value><string>#{mac_addr}</string></value></param></params></methodCall>"
|
52
|
+
@response = connection.post(body)
|
53
|
+
fail RcsError.new "System responded with a #{@response.status} status." if @response.status != 200
|
54
|
+
|
55
|
+
body = @response.body['methodResponse']
|
56
|
+
if fault = body['fault']
|
57
|
+
fault_string = fault['value']['struct']['member'][1]['value']['string']
|
58
|
+
fail RcsError.new fault_string
|
59
|
+
end
|
60
|
+
body['params']['param']['value']['boolean'] == "1"
|
61
|
+
end
|
49
62
|
|
50
63
|
private
|
51
64
|
|
@@ -8,6 +8,8 @@ describe PanasonicRcs::Rcs do
|
|
8
8
|
let(:register_error){'<?xml version="1.0" encoding="UTF-8"?> <methodResponse> <fault> <value><struct> <member> <name>faultCode</name> <value><int>201</int></value> </member> <member> <name>faultString</name> <value><string>08F0C0123456:Invalid MAC address</string></value> </member> </struct></value> </fault> </methodResponse>'}
|
9
9
|
let(:getphone_success) {'<?xml version="1.0" encoding="UTF-8"?> <methodResponse><params> <param> <value> <struct> <member> <name>mac</name> <value><string>08F0C0123456</string></value> </member> <member> <name>url</name> <value><string>http://xxx/xxxxxx/xxx?xxx={MAC}</string></value> </member> <member> <name>register_date</name> <value><dateTime.iso8601>2011-07-12T05:32:12Z</dateTime.iso8601></value> </member> <member> <name>access_date</name> <value><dateTime.iso8601>2011-07-12T06:08:35Z</dateTime.iso8601></value> </member> <member> <name>note</name> <value><string>For test</string></value> </member> <member> <name>model</name> <value><string>KX-TGP550T01</string></value> </member> <member> <name>version</name> <value><string>1.00</string></value> </member> <member> <name>profile</name> <value><string> for KX-TGP500</string></value> </member> </struct> </value></param></params></methodResponse>'}
|
10
10
|
let(:getphone_error) {'<?xml version="1.0" encoding="UTF-8"?> <methodResponse> <fault> <value><struct> <member> <name>faultCode</name> <value><int>203</int></value> </member> <member> <name>faultString</name> <value><string>08F0C0123456: You are not owner of the phone.</string></value> </member> </struct></value></fault></methodResponse>'}
|
11
|
+
let(:unregister_success){'<?xml version="1.0" encoding="UTF-8"?> <methodResponse> <params> <param> <value><boolean>1</boolean></value> </param> </params> </methodResponse>'}
|
12
|
+
let(:unregister_error){'<?xml version="1.0" encoding="UTF-8"?> <methodResponse> <fault> <value><struct> <member> <name>faultCode</name> <value><int>201</int></value> </member> <member> <name>faultString</name> <value><string>08F0C0123456:Invalid MAC address</string></value> </member> </struct></value> </fault> </methodResponse>'}
|
11
13
|
|
12
14
|
let(:test_adapter) { Faraday::Adapter::Test::Stubs.new }
|
13
15
|
let(:connection) {PanasonicRcs::Connection.new(adapter: [:test, test_adapter])}
|
@@ -47,4 +49,14 @@ describe PanasonicRcs::Rcs do
|
|
47
49
|
test_adapter.post('/redirect/xmlrpc') {[200, {'Content-Type' => 'application/xml'}, getphone_error]}
|
48
50
|
expect{subject.phone('123456789123')}.to raise_error RcsError, /You are not owner/
|
49
51
|
end
|
52
|
+
|
53
|
+
it 'unregisters a phone successfully' do
|
54
|
+
test_adapter.post('/redirect/xmlrpc') {[200, {'Content-Type' => 'application/xml'}, unregister_success]}
|
55
|
+
expect(subject.unregister_phone('123456789123')).to eq true
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'fails to register a phone and reports the error' do
|
59
|
+
test_adapter.post('/redirect/xmlrpc') {[200, {'Content-Type' => 'application/xml'}, unregister_error]}
|
60
|
+
expect{subject.unregister_phone('123456789123')}.to raise_error RcsError, /Invalid MAC address/
|
61
|
+
end
|
50
62
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: panasonic_rcs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Emery A. Miller
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -178,7 +178,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
178
178
|
version: '0'
|
179
179
|
requirements: []
|
180
180
|
rubyforge_project:
|
181
|
-
rubygems_version: 2.
|
181
|
+
rubygems_version: 2.5.1
|
182
182
|
signing_key:
|
183
183
|
specification_version: 4
|
184
184
|
summary: A component to make XMLRPC calls to Panasonic's RCS service
|