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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 100077aae71b80b7c86682bc567c1c152422290a
4
- data.tar.gz: 6e843040eb4d758f3cd6b30b4b9b7a6d86603d20
3
+ metadata.gz: 271d52aa01027d75b3a88ac907c4a17b20863f29
4
+ data.tar.gz: cddfd9179c1c1a5cfe166eb26589cb9698467efd
5
5
  SHA512:
6
- metadata.gz: 6a1feb99abe733c262261776296396921b456a4413205fabb05e8ac2238a2eb44234bbbce195ccbdb837ad1a789f4a0cc16168cdf421beef74d262e0abf75bc1
7
- data.tar.gz: 6fe1aa17279a43c4c768c9120fc9f897b961b988a2a3b1db6d8844dcb650039ca2c7830c6834805ab6b76e9511af89fda7f0c4c73b21a7d683bd1b74b2c95d92
6
+ metadata.gz: 5faaebe1edb4a3fb492f4dfef8ce6ba5f9fede224a02ffb234d9216aea4e4a437339223127711a075042cfbdca2be6785b7b825987a4d66d62c06e2bb6edbbbb
7
+ data.tar.gz: 748ec05eaf9306d6c85da9b2c78992ff37e7cce655aeab109f12d8bc42a9b34acfe2ebd9fe54613b605bda4e45ca864e5b239f8c4b0c017689d426692091bfe0
data/.gitignore CHANGED
@@ -8,6 +8,7 @@
8
8
  /spec/reports/
9
9
  /tmp/
10
10
  *.bundle
11
+ *.gem
11
12
  *.so
12
13
  *.o
13
14
  *.a
data/README.md CHANGED
@@ -42,6 +42,10 @@ rcs.phone('0040F0CC8E43')
42
42
 
43
43
  rcs.register_phone_with_profile('0040F0CC8E43', 'tgp500')
44
44
 
45
+ # => true
46
+
47
+ rcs.unregister_phone('0040F0CC8E43')
48
+
45
49
  # => true
46
50
  ```
47
51
 
@@ -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
 
@@ -1,3 +1,3 @@
1
1
  module PanasonicRcs
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -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.0.1
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: 2015-10-30 00:00:00.000000000 Z
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.4.5
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