osc_ruby 0.0.5 → 0.0.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 942ee89662b0b209dd45a335444a2d111500bfd1
4
- data.tar.gz: dd643b88f840af731ebde064ef83c02ef563d702
3
+ metadata.gz: a19c4503e2a134adf3015c3d27f1aaf7a4928ba6
4
+ data.tar.gz: 8e5dc65d2b0acd9cc91a1029b8ae95784fdb1a7b
5
5
  SHA512:
6
- metadata.gz: 38a462edfb97c8d90517510f042922c91fdeba3e72eaabb119c75b861218107884f9d5837a5f4d1d22e9ab1dccce12d407b6e169c10f18759215a44d16892b1b
7
- data.tar.gz: 46de252b73802e45d236a4015c84bca4cf824a84be99e9cac87d342e3c258e710f7ca7f3676b17dce98ce7909dc3aceb641e1125894c5514fedc6ff2c0ee150e
6
+ metadata.gz: 4d581c99f828f1134e9a5d7615b9c738f868f2be9e0722a44a65774c18e21c378248b473259e53922d03607870ca31ac5535c084852d511b48f4030990b77f52
7
+ data.tar.gz: 9e4c10c0572672a729e083d5681115d91f3d6201b3bb3c61602b81f96c4a7fe47c72cd0a1a9a9f359ca9d955a3a0b5e3eb3d40913011afebca47752f2aceba92
@@ -1,5 +1,6 @@
1
1
  require 'net/http'
2
2
  require 'openssl'
3
+ require 'json'
3
4
 
4
5
  require 'osc_ruby/version'
5
6
  require 'osc_ruby/configuration'
@@ -31,26 +32,25 @@ module OSCRuby
31
32
  end
32
33
  end
33
34
 
34
- # def basic_auth(config)
35
- # uri = URI(service_cloud_interface(config))
36
- # end
35
+ def self.basic_auth_url
36
+ uri = URI.parse(self.service_cloud_interface)
37
+ end
37
38
 
38
- # def service_cloud_interface(config)
39
- # @url = 'https://' + config.interface + '/services/rest/connect/v1.3/'
40
- # end
39
+ def self.service_cloud_interface
40
+ url = 'https://' + config.interface + '.custhelp.com/services/rest/connect/v1.3/'
41
+ end
41
42
 
42
- # def connect(config,uri)
43
- # Net::HTTP.start(uri.host, uri.port,
44
- # :use_ssl => uri.scheme == 'https') do |http|
43
+ def self.connect(config,uri)
44
+ Net::HTTP.start(uri.host, uri.port,
45
+ :use_ssl => true) do |http|
45
46
 
46
- # request = Net::HTTP::Get.new uri.request_uri
47
- # request.basic_auth config.username, config.password
47
+ request = Net::HTTP::Get.new uri.request_uri
48
+ request.basic_auth config.username, config.password
48
49
 
49
- # response = http.request request # Net::HTTPResponse object
50
+ response = http.request request # Net::HTTPResponse object
50
51
 
51
- # puts response
52
- # puts response.body
53
- # end
54
- # end
52
+ json_response = JSON.parse(response.body)
53
+ end
54
+ end
55
55
  end
56
56
  end
@@ -1,3 +1,3 @@
1
1
  module OSCRuby
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -4,6 +4,7 @@ describe OSCRuby::Client do
4
4
  subject { client }
5
5
 
6
6
  context '#initialize' do
7
+
7
8
  it 'should require a block' do
8
9
  expect { OSCRuby::Client.new }.to raise_error(ArgumentError)
9
10
  end
@@ -54,4 +55,46 @@ describe OSCRuby::Client do
54
55
  end
55
56
  end
56
57
  end
58
+
59
+ context '#service_cloud_interface' do
60
+ it 'should produce a valid url string' do
61
+ expect do
62
+ client = OSCRuby::Client.new do |config|
63
+ config.interface = 'test'
64
+ config.username = 'test_username'
65
+ config.password = 'test_password'
66
+ end
67
+
68
+ client.service_cloud_interface.should eq('https://test.custhelp.com/services/rest/connect/v1.3/')
69
+ end
70
+ end
71
+ end
72
+
73
+ context '#basic_auth_url' do
74
+ it 'should produce a URI::HTTPS object' do
75
+ expect do
76
+ client = OSCRuby::Client.new do |config|
77
+ config.interface = 'test'
78
+ config.username = 'test_username'
79
+ config.password = 'test_password'
80
+ end
81
+
82
+ client.basic_auth_url.should_be a('URI::HTTPS')
83
+ end
84
+ end
85
+ end
86
+
87
+ context '#basic_auth_url' do
88
+ it 'should produce a JSON Response' do
89
+ expect do
90
+ client = OSCRuby::Client.new do |config|
91
+ config.interface = 'qsee--tst'
92
+ config.username = ENV['OSC_ADMIN']
93
+ config.password = ENV['OSC_PASSWORD']
94
+ end
95
+
96
+ client.connect.should_be a('String')
97
+ end
98
+ end
99
+ end
57
100
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: osc_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rajan Davis
@@ -71,7 +71,6 @@ files:
71
71
  - lib/osc_ruby/client.rb
72
72
  - lib/osc_ruby/configuration.rb
73
73
  - lib/osc_ruby/version.rb
74
- - osc_ruby-0.0.3.gem
75
74
  - osc_ruby.gemspec
76
75
  - spec/core/client_spec.rb
77
76
  - spec/core/configuration_spec.rb
data/osc_ruby-0.0.3.gem DELETED
Binary file