osc_ruby 0.1.4 → 0.1.5
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 +4 -4
- data/lib/osc_ruby/query_module.rb +1 -3
- data/lib/osc_ruby/service_product.rb +20 -7
- data/lib/osc_ruby/version.rb +1 -1
- data/spec/core/service_product_spec.rb +31 -3
- metadata +2 -3
- data/example.rb +0 -42
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8d284a7e12fb44a4449480d36377dfa3e479f75
|
4
|
+
data.tar.gz: e4e486c461fb682b4712818716fa9fdde154e873
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40bdbcbfa817333418177cbd4ba8febf261640658762af2a8d429a95568a0b388c1d961326fde976dd3cd5bb77fb2b22652df01a5ff34ea7776f26b756d19ead
|
7
|
+
data.tar.gz: e77a12902ff14c5a6289a12817c408e317fbc88dc0803ac71873dde7fce843e587c5de694021fcfb1e85cf7b3fd262e48c1db244056606f15f8a6bef45b42093
|
@@ -19,9 +19,7 @@ module OSCRuby
|
|
19
19
|
|
20
20
|
def self.create(rn_client,resource,json_content)
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
obj_to_find.body
|
22
|
+
OSCRuby::Connect.post_or_patch(rn_client,resource,json_content)
|
25
23
|
|
26
24
|
end
|
27
25
|
|
@@ -47,7 +47,7 @@ module OSCRuby
|
|
47
47
|
|
48
48
|
end
|
49
49
|
|
50
|
-
def create(client)
|
50
|
+
def create(client,return_json = false)
|
51
51
|
|
52
52
|
self.class.check_client(client)
|
53
53
|
|
@@ -57,7 +57,23 @@ module OSCRuby
|
|
57
57
|
|
58
58
|
resource = URI.escape("/serviceProducts")
|
59
59
|
|
60
|
-
QueryModule::create(client,resource,final_json)
|
60
|
+
response = QueryModule::create(client,resource,final_json)
|
61
|
+
|
62
|
+
if response.code == 200 && return_json == false
|
63
|
+
|
64
|
+
prod_json = JSON.parse(response.body)
|
65
|
+
|
66
|
+
final_prod = new_from_fetch(service_product_json_final[0])
|
67
|
+
|
68
|
+
puts "New product ${final_prod.name} was created"
|
69
|
+
|
70
|
+
final_prod
|
71
|
+
|
72
|
+
elsif return_json == true
|
73
|
+
|
74
|
+
response.body
|
75
|
+
|
76
|
+
end
|
61
77
|
|
62
78
|
end
|
63
79
|
|
@@ -93,9 +109,6 @@ module OSCRuby
|
|
93
109
|
|
94
110
|
# end
|
95
111
|
|
96
|
-
|
97
|
-
protected
|
98
|
-
|
99
112
|
def self.new_from_fetch(attributes)
|
100
113
|
|
101
114
|
check_attributes(attributes)
|
@@ -114,8 +127,8 @@ module OSCRuby
|
|
114
127
|
|
115
128
|
empty_arr[0] = json_content
|
116
129
|
|
117
|
-
if empty_arr[0]['names'].count == 0
|
118
|
-
raise ArgumentError, 'ServiceProduct should at least have one name set (new_service_product.names[0] = "
|
130
|
+
if empty_arr[0]['names'].count == 0 || empty_arr[0]['names'][0]['labelText'].nil? || empty_arr[0]['names'][0]['language'].nil?
|
131
|
+
raise ArgumentError, 'ServiceProduct should at least have one name set (new_service_product.names[0] = {"labelText" => "QTH45-test", "language" => {"id" => 1}} )'
|
119
132
|
end
|
120
133
|
|
121
134
|
if empty_arr[0]['adminVisibleInterfaces'].empty?
|
data/lib/osc_ruby/version.rb
CHANGED
@@ -121,15 +121,43 @@ describe OSCRuby::ServiceProduct do
|
|
121
121
|
|
122
122
|
it 'should check the object and make sure that it at least has a name set' do
|
123
123
|
|
124
|
-
expect{new_service_product.create(client)}.to raise_error('ServiceProduct should at least have one name set (new_service_product.names[0] = "
|
124
|
+
expect{new_service_product.create(client)}.to raise_error('ServiceProduct should at least have one name set (new_service_product.names[0] = {"labelText" => "QTH45-test", "language" => {"id" => 1}} )')
|
125
125
|
|
126
126
|
end
|
127
127
|
|
128
|
-
it 'should
|
128
|
+
it 'should expect the name in a hash as the value of the labelText key' do
|
129
129
|
|
130
130
|
new_service_product.names[0] = "new product name"
|
131
131
|
|
132
|
-
expect
|
132
|
+
expect{new_service_product.create(client)}.to raise_error('ServiceProduct should at least have one name set (new_service_product.names[0] = {"labelText" => "QTH45-test", "language" => {"id" => 1}} )')
|
133
|
+
|
134
|
+
end
|
135
|
+
|
136
|
+
it 'should expect a language => id key pair within the hash' do
|
137
|
+
|
138
|
+
new_service_product.names[0] = {"labelText" => "QTH45-test"}
|
139
|
+
|
140
|
+
expect{new_service_product.create(client)}.to raise_error('ServiceProduct should at least have one name set (new_service_product.names[0] = {"labelText" => "QTH45-test", "language" => {"id" => 1}} )')
|
141
|
+
|
142
|
+
end
|
143
|
+
|
144
|
+
it 'should return an instance of an OSCRuby::ServiceProduct if the json_response param is set to false (which it is by default)' do
|
145
|
+
|
146
|
+
new_service_product.names[0] = {"labelText" => "QTH45-test", "language" => {"id" => 1}}
|
147
|
+
new_service_product.names[1] = {'labelText' => 'QTH45-test', 'language' => {'id' => 11}}
|
148
|
+
|
149
|
+
new_service_product.create(client)
|
150
|
+
|
151
|
+
expect(new_service_product).to be_a(OSCRuby::ServiceProduct)
|
152
|
+
|
153
|
+
end
|
154
|
+
|
155
|
+
|
156
|
+
it 'should return the body object if the json_response param is set to true' do
|
157
|
+
|
158
|
+
new_service_product.names[0] = {"labelText" => "QTH45-test", "language" => {"id" => 1}}
|
159
|
+
|
160
|
+
expect(new_service_product.create(client,true)).to be_a(String)
|
133
161
|
|
134
162
|
end
|
135
163
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: osc_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rajan Davis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -69,7 +69,6 @@ files:
|
|
69
69
|
- LICENSE.txt
|
70
70
|
- README.md
|
71
71
|
- Rakefile
|
72
|
-
- example.rb
|
73
72
|
- lib/ext/string.rb
|
74
73
|
- lib/osc_ruby.rb
|
75
74
|
- lib/osc_ruby/client.rb
|
data/example.rb
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
require 'osc_ruby'
|
2
|
-
|
3
|
-
rn_client = OSCRuby::Client.new do |config|
|
4
|
-
config.username = ENV['OSC_ADMIN']
|
5
|
-
config.password = ENV['OSC_PASSWORD']
|
6
|
-
config.interface = ENV['OSC_TEST_SITE']
|
7
|
-
end
|
8
|
-
|
9
|
-
|
10
|
-
# ServiceProduct fetch example
|
11
|
-
|
12
|
-
product = ServiceProduct.find(rn_client,100)
|
13
|
-
|
14
|
-
puts product
|
15
|
-
|
16
|
-
# => #<ServiceProduct:0x007fd0fa87e588>
|
17
|
-
|
18
|
-
puts product.name
|
19
|
-
|
20
|
-
# => QR404
|
21
|
-
|
22
|
-
puts product.displayOrder
|
23
|
-
|
24
|
-
# => 3
|
25
|
-
|
26
|
-
# ServiceProduct fetch all example
|
27
|
-
|
28
|
-
products = OSCRuby::ServiceProduct.all(rn_client)
|
29
|
-
|
30
|
-
products.each do |p|
|
31
|
-
|
32
|
-
puts p.name
|
33
|
-
|
34
|
-
end
|
35
|
-
|
36
|
-
# => Unsure
|
37
|
-
# => DVR/NVR
|
38
|
-
# => QC Series
|
39
|
-
# => QR Series
|
40
|
-
# => QR404
|
41
|
-
# => QS Series
|
42
|
-
# => QT Series
|