osc_ruby 1.1.0 → 1.2.0
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/README.md +429 -42
- data/lib/osc_ruby/classes/query_results.rb +0 -1
- data/lib/osc_ruby/connect.rb +8 -0
- data/lib/osc_ruby/modules/query_module.rb +4 -0
- data/lib/osc_ruby/version.rb +1 -1
- data/lib/osc_ruby.rb +28 -1
- data/spec/core/connect_spec.rb +99 -7
- data/spec/core/query_results_set_spec.rb +0 -2
- data/spec/core/query_results_spec.rb +0 -31
- metadata +2 -3
- data/osc_ruby-1.0.2.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '092bf8f94c945604c55401ccc25290289a330bb5'
|
4
|
+
data.tar.gz: b93990c2ad72a2b09aa350ad49eaf842e70088d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 155dc9b479a66e823ad6aedbb563021ca2a875184623d3af3a7b69a243a31c0fa34d06717a9a4f9e892ae211c853d865cb96b24131868a64d5926a2d192a0b11
|
7
|
+
data.tar.gz: 2433bff4ab9edbf81e37d7f3bde8c413a397152737e7d75854e551b6f4442faf887d284694babcaa909521aac4415cc35ea64c2566dc5db5461879eda557bf6a
|
data/README.md
CHANGED
@@ -8,11 +8,21 @@ An (under development) Ruby ORM for using Oracle Service Cloud influenced by the
|
|
8
8
|
## Compatibility
|
9
9
|
|
10
10
|
This gem was tested against Oracle Service Cloud November 2016 using Ruby version 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]. Additionally,
|
11
|
-
[TravisCI](https://travis-ci.org/rajangdavis/osc_ruby) tests against Ruby version 2.2.0
|
11
|
+
[TravisCI](https://travis-ci.org/rajangdavis/osc_ruby) tests against Ruby version 2.2.0
|
12
12
|
|
13
|
-
|
13
|
+
All of the HTTP methods should work on any version of Oracle Service Cloud since version May 2015; however, there maybe some issues with querying items on any version before May 2016. This is because ROQL queries were not exposed via the REST API until May 2016.
|
14
|
+
|
15
|
+
You can use this Ruby API for:
|
16
|
+
|
17
|
+
1. Running ROQL queries either 1 at a time or multiple queries in a set
|
18
|
+
2. Running Reports with filters
|
19
|
+
3. Convenience methods for Analytics filters and setting dates
|
20
|
+
4. Basic CRUD Operations via HTTP Methods
|
21
|
+
a. Create => Post
|
22
|
+
b. Read => Get
|
23
|
+
c. Update => Patch
|
24
|
+
d. Destroy => Delete
|
14
25
|
|
15
|
-
There is only support for except for ROQL Queries. There is still the capacity to create, read, update, and destroy a Service Cloud object; more on this below.
|
16
26
|
|
17
27
|
## Installation
|
18
28
|
|
@@ -31,65 +41,442 @@ Or install it yourself as:
|
|
31
41
|
$ gem install osc_ruby
|
32
42
|
|
33
43
|
|
34
|
-
## ServiceProduct Example
|
35
|
-
```ruby
|
36
44
|
|
37
|
-
# Configuration is as simple as requiring the gem
|
38
45
|
|
39
|
-
require 'osc_ruby'
|
40
46
|
|
41
|
-
rn_client = OSCRuby::Client.new do |config|
|
42
|
-
config.username = ENV['OSC_ADMIN']
|
43
|
-
config.password = ENV['OSC_PASSWORD']
|
44
|
-
config.interface = ENV['OSC_SITE']
|
45
|
-
end
|
46
47
|
|
47
|
-
|
48
|
+
## Basic Examples
|
49
|
+
```ruby
|
50
|
+
|
51
|
+
# Configuration is as simple as requiring the gem
|
52
|
+
# and writing a Ruby block
|
48
53
|
|
49
|
-
|
50
|
-
new_product['names'] = []
|
51
|
-
new_product['names'][0] = {'labelText' => 'NEW_PRODUCT', 'language' => {'id' => 1}}
|
52
|
-
new_product['displayOrder'] = 4
|
54
|
+
require 'osc_ruby'
|
53
55
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
56
|
+
rn_client = OSCRuby::Client.new do |c|
|
57
|
+
c.username = ENV['OSC_ADMIN'] # => These are interface credentials
|
58
|
+
c.password = ENV['OSC_PASSWORD'] # => store these in environmental
|
59
|
+
c.interface = ENV['OSC_SITE'] # => variables in your .bash_profile
|
58
60
|
|
59
|
-
|
61
|
+
### optional configuration
|
62
|
+
c.no_ssl_verify = true # => Defaults to false. Turns off SSL verification; don't use in production
|
63
|
+
c.version = 'v1.4' # => Defaults to 'v1.3'. Sets the version of the REST API to use
|
64
|
+
c.suppress_rules = true # => Defaults to false. Let's you supress business rules
|
65
|
+
c.demo_site = true # => Defaults to false. Use 'rightnowdemo' namespace instead of 'custhelp'
|
60
66
|
|
61
|
-
|
67
|
+
end
|
62
68
|
|
63
|
-
puts res.body # => JSON body
|
64
69
|
|
65
|
-
# callback with JSON details
|
66
70
|
|
67
71
|
|
68
72
|
|
69
73
|
|
70
74
|
# QueryResults example
|
71
|
-
# NOTE: Make sure to put your queries wrapped in doublequotes("")
|
72
|
-
# this is because when Ruby converts the queries into a URI
|
73
|
-
# the REST API does not like it when the queries are wrapped in single quotes ('')
|
74
|
-
# with strings escaped by double quotes
|
75
75
|
|
76
|
-
|
77
|
-
|
78
|
-
#
|
79
|
-
#
|
76
|
+
q = OSCRuby::QueryResults.new
|
77
|
+
|
78
|
+
# NOTE: Make sure to put your queries WRAPPED in doublequotes("")
|
79
|
+
# this is because when Ruby converts the queries into a URI
|
80
|
+
# the REST API does not like it when the queries are WRAPPED in single quotes ('')
|
81
|
+
|
82
|
+
# For example
|
83
|
+
# "parent is null and lookupName!='Unsure'" => great!
|
84
|
+
# 'parent is null and lookupName!="Unsure"' => don't do this
|
85
|
+
# it will spit back an error from the REST API!
|
86
|
+
|
87
|
+
|
88
|
+
query = "select * from answers where ID = 1557"
|
89
|
+
results = q.query(rn_client,query) # => will return an array of results
|
90
|
+
|
91
|
+
puts results[0] # => "{'id':1557,'name':...}"
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
# QueryResultsSet example
|
102
|
+
|
103
|
+
mq = OSCRuby::QueryResultsSet.new
|
104
|
+
|
105
|
+
# NOTE: Make sure to put your queries WRAPPED in doublequotes("")
|
106
|
+
# Pass in each query into a hash
|
107
|
+
# set query: to the query you want to execute
|
108
|
+
# set key: to the value you want the results to of the query to be referenced to
|
109
|
+
|
110
|
+
r = mq.query_set(rn_client,
|
111
|
+
{query:"DESCRIBE ANSWERS", key: "answerSchema"},
|
112
|
+
{query:"SELECT * FROM ANSWERS LIMIT 1", key: "answers"},
|
113
|
+
{query:"DESCRIBE SERVICECATEGORIES", key: "categoriesSchema"},
|
114
|
+
{query:"SELECT * FROM SERVICECATEGORIES", key:"categories"},
|
115
|
+
{query:"DESCRIBE SERVICEPRODUCTS", key: "productsSchema"},
|
116
|
+
{query:"SELECT * FROM SERVICEPRODUCTS", key:"products"})
|
117
|
+
|
118
|
+
puts JSON.pretty_generate(r.answerSchema)
|
119
|
+
|
120
|
+
# [
|
121
|
+
# {
|
122
|
+
# "Name": "id",
|
123
|
+
# "Type": "Integer",
|
124
|
+
# "Path": ""
|
125
|
+
# },
|
126
|
+
# {
|
127
|
+
# "Name": "lookupName",
|
128
|
+
# "Type": "String",
|
129
|
+
# "Path": ""
|
130
|
+
# },
|
131
|
+
# {
|
132
|
+
# "Name": "createdTime",
|
133
|
+
# "Type": "String",
|
134
|
+
# "Path": ""
|
135
|
+
# }
|
136
|
+
# ... everything else including customfields and objects...
|
137
|
+
# ]
|
138
|
+
|
139
|
+
puts JSON.pretty_generate(r.answers)
|
140
|
+
|
141
|
+
#[
|
142
|
+
# {
|
143
|
+
# "id": 1,
|
144
|
+
# "lookupName": 1,
|
145
|
+
# "createdTime": "2016-03-04T18:25:50Z",
|
146
|
+
# "updatedTime": "2016-09-12T17:12:14Z",
|
147
|
+
# "accessLevels": 1,
|
148
|
+
# "adminLastAccessTime": "2016-03-04T18:25:50Z",
|
149
|
+
# "answerType": 1,
|
150
|
+
# "expiresDate": null,
|
151
|
+
# "guidedAssistance": null,
|
152
|
+
# "keywords": null,
|
153
|
+
# "language": 1,
|
154
|
+
# "lastAccessTime": "2016-03-04T18:25:50Z",
|
155
|
+
# "lastNotificationTime": null,
|
156
|
+
# "name": 1,
|
157
|
+
# "nextNotificationTime": null,
|
158
|
+
# "originalReferenceNumber": null,
|
159
|
+
# "positionInList": 1,
|
160
|
+
# "publishOnDate": null,
|
161
|
+
# "question": null,
|
162
|
+
# "solution": "<HTML SOLUTION WITH INLINE CSS>",
|
163
|
+
# "summary": "SPRING IS ALMOST HERE!",
|
164
|
+
# "updatedByAccount": 16,
|
165
|
+
# "uRL": null
|
166
|
+
# }
|
167
|
+
#]
|
168
|
+
|
169
|
+
puts JSON.pretty_generate(r.categoriesSchema)
|
170
|
+
|
171
|
+
[
|
172
|
+
... skipping the first few ...
|
173
|
+
{
|
174
|
+
"Name": "adminVisibleInterfaces",
|
175
|
+
"Type": "SubTable",
|
176
|
+
"Path": "serviceCategories.adminVisibleInterfaces"
|
177
|
+
},
|
178
|
+
{
|
179
|
+
"Name": "descriptions",
|
180
|
+
"Type": "SubTable",
|
181
|
+
"Path": "serviceCategories.descriptions"
|
182
|
+
},
|
183
|
+
{
|
184
|
+
"Name": "displayOrder",
|
185
|
+
"Type": "Integer",
|
186
|
+
"Path": ""
|
187
|
+
},
|
188
|
+
{
|
189
|
+
"Name": "endUserVisibleInterfaces",
|
190
|
+
"Type": "SubTable",
|
191
|
+
"Path": "serviceCategories.endUserVisibleInterfaces"
|
192
|
+
},
|
193
|
+
... everything else include parents and children ...
|
194
|
+
]
|
195
|
+
|
196
|
+
puts JSON.pretty_generate(r.categories)
|
197
|
+
|
198
|
+
[
|
199
|
+
{
|
200
|
+
"id": 3,
|
201
|
+
"lookupName": "Manuals",
|
202
|
+
"createdTime": null,
|
203
|
+
"updatedTime": null,
|
204
|
+
"displayOrder": 3,
|
205
|
+
"name": "Manuals",
|
206
|
+
"parent": 60
|
207
|
+
},
|
208
|
+
{
|
209
|
+
"id": 4,
|
210
|
+
"lookupName": "Installations",
|
211
|
+
"createdTime": null,
|
212
|
+
"updatedTime": null,
|
213
|
+
"displayOrder": 4,
|
214
|
+
"name": "Installations",
|
215
|
+
"parent": 60
|
216
|
+
},
|
217
|
+
{
|
218
|
+
"id": 5,
|
219
|
+
"lookupName": "Downloads",
|
220
|
+
"createdTime": null,
|
221
|
+
"updatedTime": null,
|
222
|
+
"displayOrder": 2,
|
223
|
+
"name": "Downloads",
|
224
|
+
"parent": 60
|
225
|
+
},
|
226
|
+
... you should get the idea by now ...
|
227
|
+
]
|
228
|
+
|
229
|
+
### Both of these are similar to the above
|
230
|
+
puts JSON.pretty_generate(r.productsSchema)
|
231
|
+
puts JSON.pretty_generate(r.products)
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
# AnalyticsReportsResults
|
240
|
+
|
241
|
+
last_updated = OSCRuby::AnalyticsReportResults.new(lookupName: "Last Updated By Status")
|
242
|
+
|
243
|
+
# You can create a new instance either by the report id or lookupName
|
244
|
+
|
245
|
+
report_results = last_updated.run(rn_client)
|
246
|
+
|
247
|
+
# More on filters and datetime methods below
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
|
258
|
+
# Convenience Methods
|
259
|
+
|
260
|
+
# 'arrf' => stands for 'analytics_report_results_filter'
|
261
|
+
|
262
|
+
# arrf lets you set filters for an OSCRuby::AnalyticsReportsResults Object
|
263
|
+
|
264
|
+
answers_search = OSCRuby::AnalyticsReportResults.new(id: 176)
|
265
|
+
|
266
|
+
keywords = arrf(name: "search_ex", values: "Maestro")
|
267
|
+
answers_search.filters << keywords
|
268
|
+
|
269
|
+
answers = answers_search.run(rn_client)
|
270
|
+
|
271
|
+
answers.each do |answer|
|
272
|
+
puts answer['Summary']
|
273
|
+
end
|
274
|
+
|
275
|
+
# How do I get started with the Maestro Smart Thermostat App?
|
276
|
+
|
277
|
+
# Is my Wi-Fi router compatible with the Maestro Smart Thermostat?
|
278
|
+
|
279
|
+
# Will the Maestro Smart Thermostat work with my HVAC system?
|
280
|
+
|
281
|
+
# Maestro Smart Thermostat App
|
282
|
+
|
283
|
+
# Maestro Smart Thermostat Installation Guide
|
284
|
+
|
285
|
+
# Maestro Product Warranty
|
286
|
+
|
287
|
+
# ... and so on and so forth
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
|
292
|
+
|
293
|
+
|
294
|
+
|
295
|
+
|
296
|
+
# 'dti' => stands for 'date_to_iso8601'
|
297
|
+
|
298
|
+
# dti lets you type in a date and get it in ISO8601 format
|
299
|
+
# explicit => better
|
300
|
+
|
301
|
+
dti("January 1st, 2014") # => 2014-01-01T00:00:00-08:00 # => 1200 AM, January First of 2014
|
302
|
+
|
303
|
+
dti("January 1st, 2014 11:59PM MDT") # => 2014-01-01T23:59:00-06:00 # => 11:59 PM Mountain Time, January First of 2014
|
304
|
+
|
305
|
+
dti("January 1st, 2014 23:59 PDT") # => 2014-01-01T23:59:00-07:00 # => 11:59 PM Pacific Time, January First of 2014
|
306
|
+
|
307
|
+
dti("January 1st") # => 2017-01-01T00:00:00-08:00 # => 12:00 AM, January First of this Year
|
308
|
+
|
309
|
+
# But you should be careful!
|
310
|
+
# Sometimes the dates will not be what you expect
|
311
|
+
# So try to write code as explicitly/predictably as possible
|
312
|
+
# Full dates should be formatted as
|
313
|
+
# %d/%m/%y %h:%m tt
|
314
|
+
|
315
|
+
dti("01/02/14") # => 2001-02-14T00:00:00-08:00 # => 12:00 AM, February 14th, 2001
|
316
|
+
|
317
|
+
dti("01/02/2014") # => 2014-02-01T00:00:00-08:00 # => 12:00 AM, February 14th, 2014
|
318
|
+
|
319
|
+
dti("Jan-02-14") # => 2014-01-02T00:00:00-08:00 # => 12:00 AM, January 2nd, 2014
|
320
|
+
|
321
|
+
dti("11:59PM January 1st, 2014 GMT") #=> 2017-08-01T23:59:00-07:00 #=> 11:59 PM, August 1st, 2017 Pacific Time (?)
|
322
|
+
|
323
|
+
|
324
|
+
|
325
|
+
|
326
|
+
|
327
|
+
|
328
|
+
|
329
|
+
|
330
|
+
|
331
|
+
|
332
|
+
|
333
|
+
# Basic CRUD operations
|
334
|
+
|
335
|
+
# CREATE
|
336
|
+
#
|
337
|
+
# OSCRuby::Connect.post( <client>, <url>, <json_data> )
|
338
|
+
|
339
|
+
# Here's how you could create a new ServiceProduct object
|
340
|
+
# using Ruby variables, hashes(sort of like JSON), and arrays to set field information
|
341
|
+
|
342
|
+
new_product = {}
|
343
|
+
new_product['names'] = []
|
344
|
+
new_product['names'][0] = {'labelText' => 'NEW_PRODUCT', 'language' => {'id' => 1}}
|
345
|
+
new_product['displayOrder'] = 4
|
346
|
+
|
347
|
+
new_product['adminVisibleInterfaces'] = []
|
348
|
+
new_product['adminVisibleInterfaces'][0] = {'id' => 1}
|
349
|
+
new_product['endUserVisibleInterfaces'] = []
|
350
|
+
new_product['endUserVisibleInterfaces'][0] = {'id' => 1}
|
351
|
+
|
352
|
+
res = OSCRuby::Connect.post(rn_client,'/serviceProducts',new_product)
|
353
|
+
|
354
|
+
puts res.code # => 201
|
355
|
+
|
356
|
+
puts res.body # => JSON body
|
357
|
+
|
358
|
+
# callback with JSON details
|
359
|
+
|
360
|
+
|
361
|
+
|
362
|
+
|
363
|
+
|
364
|
+
|
365
|
+
|
366
|
+
|
367
|
+
|
368
|
+
# READ
|
369
|
+
#
|
370
|
+
# OSCRuby::Connect.get( <client>, optional (<url>/<id>/...<params>) )
|
371
|
+
|
372
|
+
# Here's how you could get a list of ServiceProducts
|
373
|
+
# using Ruby variables, hashes(sort of like JSON), and arrays to set field information
|
374
|
+
|
375
|
+
res = OSCRuby::Connect.get(rn_client,'/serviceProducts?limit=3')
|
376
|
+
|
377
|
+
puts JSON.pretty_generate(res.body)
|
378
|
+
|
379
|
+
#{
|
380
|
+
# "items": [
|
381
|
+
# {
|
382
|
+
# "id": 2,
|
383
|
+
# "lookupName": "Maestro Smart Thermostat",
|
384
|
+
# "links": [
|
385
|
+
# {
|
386
|
+
# "rel": "canonical",
|
387
|
+
# "href": "https://<OSC_SITE>.rightnowdemo.com/services/rest/connect/v1.3/serviceProducts/2"
|
388
|
+
# }
|
389
|
+
# ]
|
390
|
+
# },
|
391
|
+
# {
|
392
|
+
# "id": 6,
|
393
|
+
# "lookupName": "Home Security",
|
394
|
+
# "links": [
|
395
|
+
# {
|
396
|
+
# "rel": "canonical",
|
397
|
+
# "href": "https://<OSC_SITE>.rightnowdemo.com/services/rest/connect/v1.3/serviceProducts/6"
|
398
|
+
# }
|
399
|
+
# ]
|
400
|
+
# },
|
401
|
+
# {
|
402
|
+
# "id": 7,
|
403
|
+
# "lookupName": "Hubs",
|
404
|
+
# "links": [
|
405
|
+
# {
|
406
|
+
# "rel": "canonical",
|
407
|
+
# "href": "https://<OSC_SITE>.rightnowdemo.com/services/rest/connect/v1.3/serviceProducts/7"
|
408
|
+
# }
|
409
|
+
# ]
|
410
|
+
# }
|
411
|
+
# ],
|
412
|
+
# "hasMore": true,
|
413
|
+
#
|
414
|
+
# ... and everything else ...
|
415
|
+
#
|
416
|
+
#}
|
417
|
+
|
418
|
+
|
419
|
+
|
420
|
+
|
421
|
+
|
422
|
+
|
423
|
+
|
424
|
+
# UPDATE
|
425
|
+
#
|
426
|
+
# OSCRuby::Connect.patch( <client>, <url>, <json_data> )
|
427
|
+
|
428
|
+
# Here's how you could update the previously created ServiceProduct object
|
429
|
+
# using Ruby variables, arrays, hashes,
|
430
|
+
# and symbols (read only string values, eg :example)
|
431
|
+
# to set field information
|
432
|
+
|
433
|
+
names = []
|
434
|
+
|
435
|
+
names[0] = {:labelText => 'PRODUCT-TEST-updated', :language => {:id => 1}}
|
436
|
+
displayOrder = {:id => 4}
|
437
|
+
|
438
|
+
admin_user_visible_interfaces = []
|
439
|
+
admin_user_visible_interfaces[0] = {:id => 1}
|
440
|
+
|
441
|
+
end_user_visible_interfaces = []
|
442
|
+
end_user_visible_interfaces[0] = {:id => 1}
|
443
|
+
|
444
|
+
prod_info_to_change = []
|
445
|
+
prod_info_to_change[0] = {:names => names,
|
446
|
+
:adminVisibleInterfaces => admin_user_visible_interfaces,
|
447
|
+
:endUserVisibleInterfaces => end_user_visible_interfaces}
|
448
|
+
|
449
|
+
updated_product = OSCRuby::Connect.patch(rn_client,"serviceProducts/56",prod_info_to_change[0])
|
450
|
+
|
451
|
+
puts updated_product.code # => "200"
|
452
|
+
|
453
|
+
puts updated_product.body # => "" if successful...
|
454
|
+
|
455
|
+
|
456
|
+
|
457
|
+
|
458
|
+
|
459
|
+
|
460
|
+
# DELETE
|
461
|
+
#
|
462
|
+
# OSCRuby::Connect.delete( <client>, <url> )
|
463
|
+
|
464
|
+
# Here's how you could delete the previously updated ServiceProduct object
|
465
|
+
# using the OSCRuby::QueryResults
|
466
|
+
# and OSCRuby::Connect classes
|
467
|
+
|
468
|
+
q = OSCRuby::QueryResults.new
|
469
|
+
query = "select id from serviceproducts where lookupname = 'PRODUCT-TEST-updated';"
|
470
|
+
|
471
|
+
product_test_updated = q.query(rn_client,resource) # => returns array of results
|
472
|
+
|
473
|
+
test = OSCRuby::Connect.delete(rn_client,"serviceProducts/#{product_test_updated[0]['id']}")
|
80
474
|
|
81
|
-
|
82
|
-
config.username = ENV['OSC_ADMIN']
|
83
|
-
config.password = ENV['OSC_PASSWORD']
|
84
|
-
config.interface = ENV['OSC_SITE']
|
85
|
-
end
|
475
|
+
puts updated_product.code # => "200"
|
86
476
|
|
87
|
-
|
477
|
+
puts updated_product.body # => "" if successful...
|
88
478
|
|
89
|
-
query = "select * from answers where ID = 1557"
|
90
479
|
|
91
|
-
results = q.query(rn_client,query) # => will return an array of results
|
92
480
|
|
93
|
-
puts results[0] => "{'id':1557,'name':...}"
|
94
481
|
|
95
482
|
```
|
data/lib/osc_ruby/connect.rb
CHANGED
@@ -66,6 +66,14 @@ module OSCRuby
|
|
66
66
|
|
67
67
|
end
|
68
68
|
|
69
|
+
def self.post(client,resource_url = nil, json_content = nil)
|
70
|
+
self.post_or_patch(client,resource_url, json_content)
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.patch(client,resource_url = nil, json_content = nil)
|
74
|
+
self.post_or_patch(client,resource_url, json_content,true)
|
75
|
+
end
|
76
|
+
|
69
77
|
def self.delete(client,resource_url = nil)
|
70
78
|
|
71
79
|
@final_config = delete_check(client,resource_url)
|
@@ -22,6 +22,8 @@ module OSCRuby
|
|
22
22
|
NormalizeModule::normalize(obj_to_find,resource)
|
23
23
|
else
|
24
24
|
|
25
|
+
puts obj_to_find.body
|
26
|
+
|
25
27
|
obj_to_find.body
|
26
28
|
|
27
29
|
end
|
@@ -39,6 +41,8 @@ module OSCRuby
|
|
39
41
|
NormalizeModule::nested_normalize(obj_to_find,resource)
|
40
42
|
else
|
41
43
|
|
44
|
+
puts obj_to_find.body
|
45
|
+
|
42
46
|
obj_to_find.body
|
43
47
|
|
44
48
|
end
|
data/lib/osc_ruby/version.rb
CHANGED
data/lib/osc_ruby.rb
CHANGED
@@ -1,6 +1,33 @@
|
|
1
|
+
require 'time'
|
2
|
+
|
1
3
|
module OSCRuby; end
|
2
4
|
|
5
|
+
# Add this in eventually...
|
6
|
+
$time_zone = ''
|
7
|
+
|
8
|
+
def dti(date)
|
9
|
+
begin
|
10
|
+
Time.parse(date +' '+$time_zone).iso8601
|
11
|
+
rescue Exception => e
|
12
|
+
e.message
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def arrf(**args)
|
17
|
+
filter_attrs = [:attributes,:dataType,:name,:operator,:prompt,:values]
|
18
|
+
filter_hash = {}
|
19
|
+
|
20
|
+
filter_attrs.each do |attr|
|
21
|
+
|
22
|
+
filter_hash[attr] = args[attr] unless args[attr].nil?
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
filter_hash
|
27
|
+
end
|
28
|
+
|
3
29
|
require 'osc_ruby/client'
|
4
30
|
require 'osc_ruby/connect'
|
5
31
|
require 'osc_ruby/classes/query_results'
|
6
|
-
require 'osc_ruby/classes/query_results_set'
|
32
|
+
require 'osc_ruby/classes/query_results_set'
|
33
|
+
require 'osc_ruby/classes/analytics_report_results'
|
data/spec/core/connect_spec.rb
CHANGED
@@ -221,8 +221,94 @@ describe OSCRuby::Connect do
|
|
221
221
|
|
222
222
|
end
|
223
223
|
|
224
|
+
end
|
225
|
+
|
226
|
+
context '#post' do
|
227
|
+
|
228
|
+
it 'should produce a Net::HTTPResponse, should produce a 201 response code, and should produce a JSON Response form the response body', :vcr do
|
229
|
+
|
230
|
+
names = []
|
231
|
+
|
232
|
+
names[0] = {:labelText => 'PRODUCT-TEST', :language => {:id => 1}}
|
233
|
+
# names[1] = {:labelText => 'PRODUCT-TEST', :language => {:id => 11}}
|
234
|
+
|
235
|
+
# parent = {:id => 102}
|
236
|
+
|
237
|
+
displayOrder = {:id => 4}
|
238
|
+
|
239
|
+
admin_user_visible_interfaces = []
|
240
|
+
admin_user_visible_interfaces[0] = {:id => 1}
|
241
|
+
|
242
|
+
end_user_visible_interfaces = []
|
243
|
+
end_user_visible_interfaces[0] = {:id => 1}
|
244
|
+
|
245
|
+
new_prod = []
|
246
|
+
new_prod[0] = {:names => names,
|
247
|
+
:adminVisibleInterfaces => admin_user_visible_interfaces,
|
248
|
+
:endUserVisibleInterfaces => end_user_visible_interfaces}
|
249
|
+
|
250
|
+
test = OSCRuby::Connect.post(client,'serviceProducts',new_prod[0])
|
251
|
+
|
252
|
+
expect(test).to be_an(Net::HTTPResponse)
|
253
|
+
|
254
|
+
expect(test.code).to eq("201")
|
255
|
+
|
256
|
+
expect(test.body).to be_an(String)
|
257
|
+
|
258
|
+
expect{JSON.parse(test.body)}.not_to raise_error
|
259
|
+
|
260
|
+
end
|
261
|
+
|
224
262
|
end
|
225
263
|
|
264
|
+
context '#patch' do
|
265
|
+
|
266
|
+
it 'should make a patch request', :vcr do
|
267
|
+
|
268
|
+
resource = URI.escape("queryResults/?query=select id from serviceproducts where lookupname = 'PRODUCT-TEST';")
|
269
|
+
|
270
|
+
product_test = OSCRuby::Connect.get(client,resource)
|
271
|
+
|
272
|
+
prod_json = JSON.parse(product_test.body).to_hash
|
273
|
+
|
274
|
+
product_test_id = prod_json['items'][0]['rows'][0][0].to_i
|
275
|
+
|
276
|
+
names = []
|
277
|
+
|
278
|
+
names[0] = {:labelText => 'PRODUCT-TEST-updated', :language => {:id => 1}}
|
279
|
+
# names[1] = {:labelText => 'PRODUCT-TEST-updated', :language => {:id => 11}}
|
280
|
+
|
281
|
+
# parent = {:id => 102}
|
282
|
+
|
283
|
+
displayOrder = {:id => 4}
|
284
|
+
|
285
|
+
admin_user_visible_interfaces = []
|
286
|
+
admin_user_visible_interfaces[0] = {:id => 1}
|
287
|
+
|
288
|
+
end_user_visible_interfaces = []
|
289
|
+
end_user_visible_interfaces[0] = {:id => 1}
|
290
|
+
|
291
|
+
new_prod = []
|
292
|
+
new_prod[0] = {:names => names,
|
293
|
+
# :parent => parent,
|
294
|
+
:adminVisibleInterfaces => admin_user_visible_interfaces,
|
295
|
+
:endUserVisibleInterfaces => end_user_visible_interfaces}
|
296
|
+
|
297
|
+
test = OSCRuby::Connect.patch(client,"serviceProducts/#{product_test_id}",new_prod[0])
|
298
|
+
|
299
|
+
expect(test).to be_an(Net::HTTPResponse)
|
300
|
+
|
301
|
+
expect(test.body).to eq("")
|
302
|
+
|
303
|
+
expect(test.code).to eq("200")
|
304
|
+
|
305
|
+
end
|
306
|
+
|
307
|
+
end
|
308
|
+
|
309
|
+
|
310
|
+
|
311
|
+
|
226
312
|
context '#get' do
|
227
313
|
|
228
314
|
it 'should take at least a config parameter that is an instance of an OSCRuby::Client', :vcr do
|
@@ -274,6 +360,12 @@ describe OSCRuby::Connect do
|
|
274
360
|
expect{JSON.parse(test.body)}.not_to raise_error
|
275
361
|
end
|
276
362
|
|
363
|
+
it 'should bring back a list of service products when specified',:vcr do
|
364
|
+
res = OSCRuby::Connect.get(client,'/serviceProducts?limit=3')
|
365
|
+
|
366
|
+
expect(res.body).to be_an(String)
|
367
|
+
end
|
368
|
+
|
277
369
|
end
|
278
370
|
|
279
371
|
|
@@ -317,6 +409,7 @@ describe OSCRuby::Connect do
|
|
317
409
|
expect(test.body).to eq("")
|
318
410
|
|
319
411
|
expect(test.code).to eq("200")
|
412
|
+
|
320
413
|
|
321
414
|
end
|
322
415
|
|
@@ -348,15 +441,12 @@ describe OSCRuby::Connect do
|
|
348
441
|
|
349
442
|
it 'it should produce a Net::HTTPResponse, should produce a 200 code', :vcr do
|
350
443
|
|
351
|
-
|
352
|
-
|
353
|
-
product_test_updated = OSCRuby::Connect.get(client,resource)
|
354
|
-
|
355
|
-
prod_json = JSON.parse(product_test_updated.body).to_hash
|
444
|
+
q = OSCRuby::QueryResults.new
|
445
|
+
query = "select id from serviceproducts where lookupname = 'PRODUCT-TEST-updated';"
|
356
446
|
|
357
|
-
|
447
|
+
product_test_updated = q.query(client,query)
|
358
448
|
|
359
|
-
test = OSCRuby::Connect.delete(client,"serviceProducts/#{
|
449
|
+
test = OSCRuby::Connect.delete(client,"serviceProducts/#{product_test_updated[0]['id']}")
|
360
450
|
|
361
451
|
expect(test).to be_an(Net::HTTPResponse)
|
362
452
|
|
@@ -366,6 +456,8 @@ describe OSCRuby::Connect do
|
|
366
456
|
|
367
457
|
end
|
368
458
|
|
459
|
+
|
460
|
+
|
369
461
|
end
|
370
462
|
|
371
463
|
end
|
@@ -24,37 +24,6 @@ describe OSCRuby::QueryResults do
|
|
24
24
|
}
|
25
25
|
|
26
26
|
|
27
|
-
|
28
|
-
let(:table){ "answers" }
|
29
|
-
let(:nested_attributes){
|
30
|
-
[ "*",
|
31
|
-
"accessLevels.namedIDList.*",
|
32
|
-
"answerType.*",
|
33
|
-
"assignedTo.account.*",
|
34
|
-
"assignedTo.staffGroup.*",
|
35
|
-
"banner.*",
|
36
|
-
"banner.importanceFlag.*",
|
37
|
-
"banner.updatedByAccount.*",
|
38
|
-
"categories.categoriesList.*",
|
39
|
-
"commonAttachments.fileAttachmentList.*",
|
40
|
-
"commonAttachments.fileAttachmentList.names.labelList.labelText",
|
41
|
-
"commonAttachments.fileAttachmentList.names.labelList.language.*",
|
42
|
-
"fileAttachments.fileAttachmentList.*",
|
43
|
-
"guidedAssistance.*",
|
44
|
-
"language.*",
|
45
|
-
"notes.noteList.*",
|
46
|
-
"positionInList.*",
|
47
|
-
"products.productsList.*",
|
48
|
-
"relatedAnswers.answerRelatedAnswerList.*",
|
49
|
-
"relatedAnswers.answerRelatedAnswerList.toAnswer.*",
|
50
|
-
"siblingAnswers.*",
|
51
|
-
"statusWithType.statusType.*",
|
52
|
-
"updatedByAccount.*",
|
53
|
-
"customFields.c.*"
|
54
|
-
]
|
55
|
-
}
|
56
|
-
|
57
|
-
|
58
27
|
context "#query" do
|
59
28
|
|
60
29
|
it 'should expect client is an instance of OSCRuby::Client class and raise an error if does not' do
|
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: 1.
|
4
|
+
version: 1.2.0
|
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-08-
|
11
|
+
date: 2017-08-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: simplecov
|
@@ -168,7 +168,6 @@ files:
|
|
168
168
|
- lib/osc_ruby/modules/query_module.rb
|
169
169
|
- lib/osc_ruby/modules/validations_module.rb
|
170
170
|
- lib/osc_ruby/version.rb
|
171
|
-
- osc_ruby-1.0.2.gem
|
172
171
|
- osc_ruby.gemspec
|
173
172
|
- spec/core/client_spec.rb
|
174
173
|
- spec/core/configuration_spec.rb
|
data/osc_ruby-1.0.2.gem
DELETED
Binary file
|