osc_ruby 0.1.9 → 0.1.10
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/service_product.rb +25 -9
- data/lib/osc_ruby/version.rb +1 -1
- data/spec/core/service_product_spec.rb +43 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca63de8b887f3fd7a4f053fa2169013a9ec0121a
|
4
|
+
data.tar.gz: d51fe8fd736021ed2bcd74cf68b758e92ba0f25e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c907042c7cbad989ae25e304bfc85182b92295fd55c07eeb3159ff1af9695f93577383c68c27dd0a693bfb28b609e388b60efd805aaab044100d627fa50d7f41
|
7
|
+
data.tar.gz: e6340ed3dc8cf652e92cbfcac44abc7b184ef42c509e22c2f39c19144e6d358f04ebba1d8e6815348aca1a285313db841e54e0bdfa254b97e036c27501ebe757
|
@@ -87,7 +87,7 @@ module OSCRuby
|
|
87
87
|
|
88
88
|
end
|
89
89
|
|
90
|
-
def self.find(client,id = nil)
|
90
|
+
def self.find(client,id = nil,return_json = false)
|
91
91
|
|
92
92
|
check_client(client)
|
93
93
|
|
@@ -101,23 +101,39 @@ module OSCRuby
|
|
101
101
|
|
102
102
|
service_product_json = QueryModule::find(client,resource)
|
103
103
|
|
104
|
-
|
104
|
+
if return_json == true
|
105
105
|
|
106
|
-
|
106
|
+
service_product_json
|
107
|
+
|
108
|
+
else
|
109
|
+
|
110
|
+
service_product_json_final = JSON.parse(service_product_json)
|
111
|
+
|
112
|
+
new_from_fetch(service_product_json_final[0])
|
113
|
+
|
114
|
+
end
|
107
115
|
|
108
116
|
end
|
109
117
|
|
110
|
-
|
118
|
+
def self.all(client, return_json = false)
|
111
119
|
|
112
|
-
|
120
|
+
resource = URI.escape("queryResults/?query=select * from serviceproducts")
|
113
121
|
|
114
|
-
|
122
|
+
service_product_json = QueryModule::find(client,resource)
|
115
123
|
|
116
|
-
|
124
|
+
if return_json == true
|
117
125
|
|
118
|
-
|
126
|
+
service_product_json
|
119
127
|
|
120
|
-
|
128
|
+
else
|
129
|
+
|
130
|
+
service_product_json_final = JSON.parse(service_product_json)
|
131
|
+
|
132
|
+
service_product_json_final.map { |attributes| new_from_fetch(attributes) }
|
133
|
+
|
134
|
+
end
|
135
|
+
|
136
|
+
end
|
121
137
|
|
122
138
|
def self.new_from_fetch(attributes)
|
123
139
|
|
data/lib/osc_ruby/version.rb
CHANGED
@@ -210,7 +210,7 @@ describe OSCRuby::ServiceProduct do
|
|
210
210
|
OSCRuby::ServiceProduct.find(client, 100)
|
211
211
|
}
|
212
212
|
|
213
|
-
it 'should return an instance of a new
|
213
|
+
it 'should return an instance of a new OSCRuby::ServiceProduct object with at least a name and displayOrder' do
|
214
214
|
|
215
215
|
expect(known_working_product).to be_an(OSCRuby::ServiceProduct)
|
216
216
|
|
@@ -220,6 +220,48 @@ describe OSCRuby::ServiceProduct do
|
|
220
220
|
|
221
221
|
end
|
222
222
|
|
223
|
+
it 'should return the raw json response if the return_json parameter is set to true' do
|
224
|
+
|
225
|
+
known_working_product_in_json = OSCRuby::ServiceProduct.find(client, 100, true)
|
226
|
+
|
227
|
+
expect(known_working_product_in_json).to be_an(String)
|
228
|
+
|
229
|
+
end
|
230
|
+
|
231
|
+
end
|
232
|
+
|
233
|
+
context '#all' do
|
234
|
+
|
235
|
+
it 'should return multiple instances of OSCRuby::ServiceProduct' do
|
236
|
+
|
237
|
+
products = OSCRuby::ServiceProduct.all(client)
|
238
|
+
|
239
|
+
expect(products.size).to be > 0
|
240
|
+
|
241
|
+
puts "Checking if OSCRuby::ServiceProduct.all produces multiple instances of products"
|
242
|
+
|
243
|
+
products.each_with_index do |p,i|
|
244
|
+
|
245
|
+
if i < 10
|
246
|
+
|
247
|
+
expect(p).to be_an(OSCRuby::ServiceProduct)
|
248
|
+
|
249
|
+
end
|
250
|
+
|
251
|
+
end
|
252
|
+
|
253
|
+
end
|
254
|
+
|
255
|
+
it 'should just return JSON if the return_json parameter is set to true' do
|
256
|
+
|
257
|
+
expect(OSCRuby::ServiceProduct.all(client,true)).to be_a(String)
|
258
|
+
|
259
|
+
end
|
260
|
+
|
261
|
+
end
|
262
|
+
|
263
|
+
contect '#where' do
|
264
|
+
|
223
265
|
end
|
224
266
|
|
225
267
|
end
|