osc_ruby 0.7.1 → 1.0.2

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.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +25 -25
  3. data/.gitignore +15 -15
  4. data/.rspec +1 -1
  5. data/.rubocop.yml +1156 -1156
  6. data/.travis.yml +9 -9
  7. data/Gemfile +3 -3
  8. data/License.txt +21 -0
  9. data/README.md +95 -242
  10. data/Rakefile +2 -2
  11. data/lib/ext/string.rb +18 -18
  12. data/lib/osc_ruby/classes/query_results.rb +40 -60
  13. data/lib/osc_ruby/client.rb +40 -40
  14. data/lib/osc_ruby/configuration.rb +14 -13
  15. data/lib/osc_ruby/connect.rb +218 -209
  16. data/lib/osc_ruby/modules/normalize_module.rb +121 -121
  17. data/lib/osc_ruby/modules/query_module.rb +69 -69
  18. data/lib/osc_ruby/modules/validations_module.rb +168 -168
  19. data/lib/osc_ruby/version.rb +2 -2
  20. data/lib/osc_ruby.rb +4 -10
  21. data/osc_ruby.gemspec +28 -29
  22. data/spec/core/client_spec.rb +96 -96
  23. data/spec/core/configuration_spec.rb +4 -4
  24. data/spec/core/connect_spec.rb +366 -364
  25. data/spec/core/query_results_spec.rb +107 -133
  26. data/spec/core/spec_helper.rb +25 -25
  27. data/tasks/rspec.rake +2 -2
  28. metadata +23 -22
  29. data/LICENSE.txt +0 -22
  30. data/lib/osc_ruby/classes/account.rb +0 -75
  31. data/lib/osc_ruby/classes/answer.rb +0 -117
  32. data/lib/osc_ruby/classes/incident.rb +0 -13
  33. data/lib/osc_ruby/classes/product_category_shared.rb +0 -118
  34. data/lib/osc_ruby/classes/service_category.rb +0 -6
  35. data/lib/osc_ruby/classes/service_class.rb +0 -66
  36. data/lib/osc_ruby/classes/service_product.rb +0 -6
  37. data/lib/osc_ruby/modules/class_factory_module.rb +0 -165
  38. data/lib/osc_ruby/modules/nested_resource_module.rb +0 -10
  39. data/spec/core/account_spec.rb +0 -497
  40. data/spec/core/answer_spec.rb +0 -545
  41. data/spec/core/service_category_spec.rb +0 -445
  42. data/spec/core/service_product_spec.rb +0 -443
data/.travis.yml CHANGED
@@ -1,10 +1,10 @@
1
- language: ruby
2
- rvm:
3
- - 2.2.0
4
- addons:
5
- code_climate:
6
- repo_token:
7
- secure: jhiFV5qK92z9GNZNgifvOmzoYmghcTFcuHYn21B5pkcIFmUJRYL03FK4QHqinFQ4BvjHnKlGTEgRPvglivvPBtIwpGMwuDF0oX0JHeTNLXuAXk8Dd6SAap+udSc2fOZYBg7H8PNmhSVpP97fYu23JsLmhRN8lnoO/yYyFUn/xUZIufOhpPj5RBMtR/XmxXiqS1tnsuHpSs7P+Kp/h6sr8QUOw1pJALEAqHGw2WmdxGrI76GQc0bylLFGMITkCbAiTxVQA3QnjLKFYCHq8zo1U0QZiW78+ubbV22oZS1EVATAb4SyqlqFd2bJA9wYjL2J4tYl1I+RvgVSspMsksHs72uIYHDTNSsEuQTnMCxtkq7WJLbYjRW3Tzbqn124ize/NmJqHcJ70Bc8Tzc3CkgEuJNF/cK266r0UkNTu+m65OTElyic14y+wCzeU8r/aDfX9vQKPBpOFpvHuoWMC54iiGIPjLVZb0AYvI2i3weK2dcCh7ZFD+FsFoMAzyaFFFJP4ANH7R08ewVpTjdud4O8WiQBJOW08dXE9inOF+4hqUho2FdrTWQLvMbanVXOmQXsODeEy7zxFUi1I1wVcX1AktEACmcX2ruose8UiScRu7Tr2R6mhgPa4UAf1YhhBClYafeqtCBi1rRrHkgOkaofhKbU3hHHF5cQwDP2v2jUYEI=
8
- script: bundle exec rake spec
9
- after_success:
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.0
4
+ addons:
5
+ code_climate:
6
+ repo_token:
7
+ secure: jhiFV5qK92z9GNZNgifvOmzoYmghcTFcuHYn21B5pkcIFmUJRYL03FK4QHqinFQ4BvjHnKlGTEgRPvglivvPBtIwpGMwuDF0oX0JHeTNLXuAXk8Dd6SAap+udSc2fOZYBg7H8PNmhSVpP97fYu23JsLmhRN8lnoO/yYyFUn/xUZIufOhpPj5RBMtR/XmxXiqS1tnsuHpSs7P+Kp/h6sr8QUOw1pJALEAqHGw2WmdxGrI76GQc0bylLFGMITkCbAiTxVQA3QnjLKFYCHq8zo1U0QZiW78+ubbV22oZS1EVATAb4SyqlqFd2bJA9wYjL2J4tYl1I+RvgVSspMsksHs72uIYHDTNSsEuQTnMCxtkq7WJLbYjRW3Tzbqn124ize/NmJqHcJ70Bc8Tzc3CkgEuJNF/cK266r0UkNTu+m65OTElyic14y+wCzeU8r/aDfX9vQKPBpOFpvHuoWMC54iiGIPjLVZb0AYvI2i3weK2dcCh7ZFD+FsFoMAzyaFFFJP4ANH7R08ewVpTjdud4O8WiQBJOW08dXE9inOF+4hqUho2FdrTWQLvMbanVXOmQXsODeEy7zxFUi1I1wVcX1AktEACmcX2ruose8UiScRu7Tr2R6mhgPa4UAf1YhhBClYafeqtCBi1rRrHkgOkaofhKbU3hHHF5cQwDP2v2jUYEI=
8
+ script: bundle exec rake spec
9
+ after_success:
10
10
  - bundle exec codeclimate-test-reporter
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in osc_ruby.gemspec
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in osc_ruby.gemspec
4
4
  gemspec
data/License.txt ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017 rajangdavis
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -1,242 +1,95 @@
1
- # OSCRuby
2
-
3
- [![Code Climate](https://codeclimate.com/github/rajangdavis/osc_ruby/badges/gpa.svg)](https://codeclimate.com/github/rajangdavis/osc_ruby) [![Test Coverage](https://codeclimate.com/github/rajangdavis/osc_ruby/badges/coverage.svg)](https://codeclimate.com/github/rajangdavis/osc_ruby/coverage) [![Build Status](https://travis-ci.org/rajangdavis/osc_ruby.svg?branch=master)](https://travis-ci.org/rajangdavis/osc_ruby) [![Gem Version](https://badge.fury.io/rb/osc_ruby.svg)](https://badge.fury.io/rb/osc_ruby)
4
-
5
- An (under development) Ruby ORM for using Oracle Service Cloud influenced by the [ConnectPHP API](http://documentation.custhelp.com/euf/assets/devdocs/november2016/Connect_PHP/Default.htm) and ActiveRecord Gem
6
-
7
-
8
- ## Compatibility
9
-
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 as well as jruby version 1.7.19
12
-
13
- The create, update, and destroy 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 November 2016. This is because I am using the ROQL queries to generate values for Common Objects
14
-
15
- Currently supporting the following objects from the REST API:
16
-
17
- ServiceProduct
18
-
19
- ServiceCategory
20
-
21
- Answer
22
-
23
- QueryResults (does not support CRUD)
24
-
25
- At this time, subclasses such as ServiceProduct.CategoryLinks are not currently supported.
26
-
27
- I am trying to build a few more classes and have a pretty solid testing suite and codebase before implementing this functionality.
28
-
29
- ## Installation
30
-
31
- Add this line to your application's Gemfile:
32
-
33
- ```ruby
34
- gem 'osc_ruby'
35
- ```
36
-
37
- And then execute:
38
-
39
- $ bundle
40
-
41
- Or install it yourself as:
42
-
43
- $ gem install osc_ruby
44
-
45
-
46
- ## ServiceProduct Example
47
- ```ruby
48
-
49
- # Configuration is as simple as requiring the gem
50
- # and adding a config block (Completed 12/2016)
51
-
52
- require 'osc_ruby'
53
-
54
- rn_client = OSCRuby::Client.new do |config|
55
- config.username = ENV['OSC_ADMIN']
56
- config.password = ENV['OSC_PASSWORD']
57
- config.interface = ENV['OSC_TEST1_SITE']
58
- end
59
-
60
-
61
- # ServiceProduct Creation example (Completed 12/30/2016)
62
-
63
- new_product = OSCRuby::ServiceProduct.new
64
-
65
- # use Ruby hashes to set field information
66
-
67
- new_product.names[0] = {'labelText' => 'QTH45-test', 'language' => {'id' => 1}}
68
- new_product.names[1] = {'labelText' => 'QTH45-test', 'language' => {'id' => 11}}
69
-
70
- new_product.parent = {'id' => 102}
71
-
72
- new_product.displayOrder = 4
73
-
74
- new_product.adminVisibleInterfaces[0] = {'id' => 1}
75
-
76
- new_product.endUserVisibleInterfaces[0] = {'id' => 1}
77
-
78
- new_product.create(rn_client)
79
-
80
- # callback with JSON details
81
-
82
-
83
-
84
-
85
- # NOTE: Make sure that in a production environment
86
- # that the following methods are wrapped in a begin/rescue block.
87
-
88
- # If a null set is returned by your query
89
- # an exception will be raised
90
- # this is to ensure that you
91
- # handle your errors explicitly
92
- # when writing scripts
93
-
94
-
95
- # ServiceProduct fetch example (Completed 12/28/2016)
96
-
97
- product = OSCRuby::ServiceProduct.find(rn_client,100)
98
-
99
- puts product
100
- # => #<ServiceProduct:0x007fd0fa87e588>
101
-
102
- puts product.name
103
- # => QR404
104
-
105
- puts product.displayOrder
106
- # => 3
107
-
108
- # ServiceProduct fetch all example (Completed 01/05/2017)
109
-
110
- products = OSCRuby::ServiceProduct.all(rn_client)
111
-
112
- products.each do |p|
113
-
114
- puts p.name
115
-
116
- end
117
-
118
- # => Unsure
119
- # => DVR/NVR
120
- # => QC Series
121
- # => QR Series
122
- # => QR404
123
- # => QS Series
124
- # => QT Series
125
-
126
-
127
- # ServiceProduct where example (Completed 01/05/2017)
128
-
129
- # NOTE: Make sure to put your queries wrapped in doublequotes("")
130
- # this is because when Ruby converts the queries into a URI
131
- # the REST API does not like it when the queries are wrapped in single quotes ('')
132
- # with strings escaped by double quotes
133
-
134
- # For example
135
- # "parent is null and lookupName!='Unsure'" => great!
136
- # 'parent is null and lookupName!="Unsure"' => don't do this
137
- # it will spit back an error from the REST API!
138
-
139
- products_lvl_1 = OSCRuby::ServiceProduct.where(rn_client,"parent is null and lookupName!='Unsure'")
140
-
141
- products_lvl_1.each do |p|
142
-
143
- puts p.name
144
-
145
- end
146
-
147
- # => DVR/NVR
148
- # => Cameras
149
- # => Accessories
150
-
151
-
152
- # ServiceProduct update example (Completed 01/05/2017)
153
-
154
- product_to_update = OSCRuby::ServiceProduct.find(rn_client,100)
155
-
156
- product_to_update.names[0] = {'labelText' => 'name-updated', 'language' => {'id' => 1}}
157
-
158
- product_to_update.update(rn_client)
159
-
160
- # ServiceProduct updated
161
-
162
-
163
-
164
-
165
- # ServiceProduct destroy example (Completed 01/06/2017)
166
-
167
- product_to_delete = OSCRuby::ServiceProduct.find(rn_client,100)
168
-
169
- product_to_delete.destroy(rn_client)
170
-
171
- # ServiceProduct destroyed
172
- ```
173
-
174
- ## To do list
175
-
176
- - [x] Create a URL generator method into the Connect Class
177
-
178
- - [x] Move tests for the get method into the URL generator method
179
-
180
- - [x] Move check_config method into the URL generator method so that tests pass
181
-
182
- - [x] Create more tests to validate the generated URL
183
-
184
- - [x] Add in TravisCI into workflow to run tests and push and publish gem
185
-
186
- - [x] Add in Code Climate or something to show the percentage of covered methods for testing
187
-
188
- - [x] Put the URL generator method into the get class
189
-
190
- - [x] Have the get method make a get request using the Net::HTTP class
191
-
192
- - [x] Need to add tests for passing resources, query/id/other param into the URL generator class
193
-
194
- - [x] Need to figure out how to pass resources and some sort of query/id/other param into the URL generator class
195
-
196
- - [x] Add in tests for Post requests
197
-
198
- - [x] Make a Post method
199
-
200
- - [x] Add in tests for patch requests
201
-
202
- - [x] Make a patch method
203
-
204
- - [x] Add in tests for delete requests
205
-
206
- - [x] Make a delete method
207
-
208
- - [x] Create a OSCRuby::ServiceProduct class
209
-
210
- - [x] Build a QueryModule Module with the following query methods to be shared between most if not all classes:
211
-
212
- - [x] create, find, where, all, update, destroy
213
-
214
- - [x] QueryModule converts JSON response into a Ruby Hash => new instance of the object being queried
215
-
216
- - [x] Create some validations for creating a ServiceProduct object
217
-
218
- - [x] Add in VCR and WebMock as dependencies
219
-
220
- - [x] Figure out how to record and stub responses for a good response and bad response
221
-
222
- - [x] Simulate these responses for ALL Connect HTTP methods
223
-
224
- - [x] Make OpenSSL::SSL::VERIFY_PEER the default with OpenSSL::SSL::VERIFY_NONE option set in the config class
225
-
226
- - [x] Make version default to 1.3 but an option to be set in the config class
227
-
228
- - [x] Need to update QueryResults to split the queries
229
-
230
- - [x] Need to update QueryResults to be able to manipulate the results
231
-
232
- - [ ] Figure out subclasses
233
-
234
- - [ ] Follow with next Classes (Accounts,ServiceCategories, Incidents)
235
-
236
- - [ ] Allow for the prefer:exclude-null-properties header => update config and connect class, update tests
237
-
238
- - [ ] Allow for Session Authorization => update config class and connect classes, update tests
239
-
240
- - [ ] Figure out how to do RDoc/Yardoc documentation or best in class documentation for using this Ruby ORM
241
-
242
- - [ ] Release MVP
1
+ # OSCRuby
2
+
3
+ [![Code Climate](https://codeclimate.com/github/rajangdavis/osc_ruby/badges/gpa.svg)](https://codeclimate.com/github/rajangdavis/osc_ruby) [![Test Coverage](https://codeclimate.com/github/rajangdavis/osc_ruby/badges/coverage.svg)](https://codeclimate.com/github/rajangdavis/osc_ruby/coverage) [![Build Status](https://travis-ci.org/rajangdavis/osc_ruby.svg?branch=master)](https://travis-ci.org/rajangdavis/osc_ruby) [![Gem Version](https://badge.fury.io/rb/osc_ruby.svg)](https://badge.fury.io/rb/osc_ruby)
4
+
5
+ An (under development) Ruby ORM for using Oracle Service Cloud influenced by the [ConnectPHP API](http://documentation.custhelp.com/euf/assets/devdocs/november2016/Connect_PHP/Default.htm) and ActiveRecord Gem
6
+
7
+
8
+ ## Compatibility
9
+
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 as well as jruby version 1.7.19
12
+
13
+ The create, update, and destroy 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
+ 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
+
17
+ ## Installation
18
+
19
+ Add this line to your application's Gemfile:
20
+
21
+ ```ruby
22
+ gem 'osc_ruby'
23
+ ```
24
+
25
+ And then execute:
26
+
27
+ $ bundle
28
+
29
+ Or install it yourself as:
30
+
31
+ $ gem install osc_ruby
32
+
33
+
34
+ ## ServiceProduct Example
35
+ ```ruby
36
+
37
+ # Configuration is as simple as requiring the gem
38
+
39
+ require 'osc_ruby'
40
+
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
+ # use Ruby hashes and arrays to set field information
48
+
49
+ new_product = {}
50
+ new_product['names'] = []
51
+ new_product['names'][0] = {'labelText' => 'NEW_PRODUCT', 'language' => {'id' => 1}}
52
+ new_product['displayOrder'] = 4
53
+
54
+ new_product['adminVisibleInterfaces'] = []
55
+ new_product['adminVisibleInterfaces'][0] = {'id' => 1}
56
+ new_product['endUserVisibleInterfaces'] = []
57
+ new_product['endUserVisibleInterfaces'][0] = {'id' => 1}
58
+
59
+ res = OSCRuby::Connect.post_or_patch(rn_client,'/serviceProducts',new_product)
60
+
61
+ puts res.code # => 201
62
+
63
+ puts res.body # => JSON body
64
+
65
+ # callback with JSON details
66
+
67
+
68
+
69
+
70
+ # 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
+
76
+ # For example
77
+ # "parent is null and lookupName!='Unsure'" => great!
78
+ # 'parent is null and lookupName!="Unsure"' => don't do this
79
+ # it will spit back an error from the REST API!
80
+
81
+ rn_client = OSCRuby::Client.new do |config|
82
+ config.username = ENV['OSC_ADMIN']
83
+ config.password = ENV['OSC_PASSWORD']
84
+ config.interface = ENV['OSC_SITE']
85
+ end
86
+
87
+ q = OSCRuby::QueryResults.new
88
+
89
+ query = "select * from answers where ID = 1557"
90
+
91
+ results = q.query(rn_client,query) # => will return an array of results
92
+
93
+ puts results[0] => "{'id':1557,'name':...}"
94
+
95
+ ```
data/Rakefile CHANGED
@@ -1,3 +1,3 @@
1
- require "bundler/gem_tasks"
2
-
1
+ require "bundler/gem_tasks"
2
+
3
3
  Dir.glob('tasks/**/*.rake').each(&method(:import))
data/lib/ext/string.rb CHANGED
@@ -1,19 +1,19 @@
1
- class String
2
- def is_i?
3
- /\A[-+]?\d+\z/ === self
4
- end
5
-
6
- def camel_case_lower
7
- @class_to_array = self.split('')
8
- @class_name_length = @class_to_array.length - 1
9
- @output = @class_to_array.each_with_index do |letter,i|
10
- if i ==0
11
- letter.downcase!
12
- elsif i == @class_name_length
13
- letter.gsub!(/y/,'ie')
14
- end
15
- end.join
16
-
17
- @output + 's'
18
- end
1
+ class String
2
+ def is_i?
3
+ /\A[-+]?\d+\z/ === self
4
+ end
5
+
6
+ def camel_case_lower
7
+ @class_to_array = self.split('')
8
+ @class_name_length = @class_to_array.length - 1
9
+ @output = @class_to_array.each_with_index do |letter,i|
10
+ if i ==0
11
+ letter.downcase!
12
+ elsif i == @class_name_length
13
+ letter.gsub!(/y/,'ie')
14
+ end
15
+ end.join
16
+
17
+ @output + 's'
18
+ end
19
19
  end
@@ -1,61 +1,41 @@
1
- require 'osc_ruby/connect'
2
- require 'osc_ruby/modules/validations_module'
3
- require 'osc_ruby/modules/normalize_module'
4
- require 'json'
5
-
6
- module OSCRuby
7
-
8
- class QueryResults
9
-
10
- include QueryModule
11
- include ValidationsModule
12
-
13
- def initialize; end
14
-
15
- def query(client,query,return_json = false)
16
-
17
- ValidationsModule::check_client(client)
18
-
19
- ValidationsModule::check_query(query,"query")
20
-
21
- @query = URI.escape("queryResults/?query=#{query}")
22
-
23
- response = QueryModule::find(client,@query)
24
-
25
- json_response = JSON.parse(response)
26
-
27
- json_response.unshift("\n")
28
-
29
- if return_json == true
30
- json_response_final = NormalizeModule::query_injection(query,json_response)
31
- puts json_response_final
32
- end
33
-
34
- NormalizeModule::remove_new_lines(json_response)
35
-
36
- end
37
-
38
- def nested_query(client,query,return_json = false)
39
-
40
- ValidationsModule::check_client(client)
41
-
42
- ValidationsModule::check_query(query,"query")
43
-
44
- @query = URI.escape("queryResults/?query=#{query}")
45
-
46
- response = QueryModule::nested_find(client,@query)
47
-
48
- json_response = JSON.parse(response)
49
-
50
- if return_json == true
51
- json_response_final = NormalizeModule::query_injection(query,json_response)
52
- puts json_response_final
53
- end
54
-
55
- NormalizeModule::remove_new_lines(json_response)
56
-
57
- end
58
-
59
- end
60
-
1
+ require 'osc_ruby/connect'
2
+ require 'osc_ruby/modules/validations_module'
3
+ require 'osc_ruby/modules/normalize_module'
4
+ require 'osc_ruby/modules/query_module'
5
+ require 'json'
6
+
7
+ module OSCRuby
8
+
9
+ class QueryResults
10
+
11
+ include QueryModule
12
+ include ValidationsModule
13
+
14
+ def initialize; end
15
+
16
+ def query(client,query,return_json = false)
17
+
18
+ ValidationsModule::check_client(client)
19
+
20
+ ValidationsModule::check_query(query,"query")
21
+
22
+ @query = URI.escape("queryResults/?query=#{query}")
23
+
24
+ response = QueryModule::find(client,@query)
25
+
26
+ json_response = JSON.parse(response)
27
+
28
+ json_response.unshift("\n")
29
+
30
+ if return_json == true
31
+ json_response_final = NormalizeModule::query_injection(query,json_response)
32
+ puts json_response_final
33
+ end
34
+
35
+ NormalizeModule::remove_new_lines(json_response)
36
+
37
+ end
38
+
39
+ end
40
+
61
41
  end
@@ -1,41 +1,41 @@
1
- require 'osc_ruby/version'
2
- require 'osc_ruby/configuration'
3
-
4
-
5
- module OSCRuby
6
-
7
- class Client
8
- # The top-level class that handles configuration and connection to the Oracle Service Cloud REST API.
9
-
10
- attr_accessor :config
11
-
12
- def initialize
13
- raise ArgumentError, "block not given" unless block_given?
14
- self.config ||= OSCRuby::Configuration.new
15
- yield(config)
16
-
17
- check_config
18
- optional_check
19
- end
20
-
21
- def check_config
22
- if config.interface ==''
23
- raise ArgumentError, "Interface cannot be nil or blank"
24
- elsif config.username ==''
25
- raise ArgumentError, "Username cannot be nil or blank"
26
- elsif config.password ==''
27
- raise ArgumentError, "Password cannot be nil or blank"
28
- end
29
-
30
- true
31
- end
32
-
33
- def optional_check
34
- if config.no_ssl_verify.class != FalseClass && config.no_ssl_verify.class != TrueClass
35
- raise ArgumentError, "The no SSL verification setting must be set to true or false"
36
- elsif config.version.nil?
37
- raise ArgumentError, "Connect version cannot be null"
38
- end
39
- end
40
- end
1
+ require 'osc_ruby/version'
2
+ require 'osc_ruby/configuration'
3
+
4
+
5
+ module OSCRuby
6
+
7
+ class Client
8
+ # The top-level class that handles configuration and connection to the Oracle Service Cloud REST API.
9
+
10
+ attr_accessor :config
11
+
12
+ def initialize
13
+ raise ArgumentError, "block not given" unless block_given?
14
+ self.config ||= OSCRuby::Configuration.new
15
+ yield(config)
16
+
17
+ check_config
18
+ optional_check
19
+ end
20
+
21
+ def check_config
22
+ if config.interface ==''
23
+ raise ArgumentError, "Interface cannot be nil or blank"
24
+ elsif config.username ==''
25
+ raise ArgumentError, "Username cannot be nil or blank"
26
+ elsif config.password ==''
27
+ raise ArgumentError, "Password cannot be nil or blank"
28
+ end
29
+
30
+ true
31
+ end
32
+
33
+ def optional_check
34
+ if config.no_ssl_verify.class != FalseClass && config.no_ssl_verify.class != TrueClass
35
+ raise ArgumentError, "The no SSL verification setting must be set to true or false"
36
+ elsif config.version.nil?
37
+ raise ArgumentError, "Connect version cannot be null"
38
+ end
39
+ end
40
+ end
41
41
  end
@@ -1,14 +1,15 @@
1
- module OSCRuby
2
-
3
- class Configuration
4
- # A holder class that holds the configuration information for the OSCRuby::Client block
5
-
6
- attr_accessor :interface,:username,:password,:no_ssl_verify,:version,:suppress_rules
7
-
8
- def initialize
9
- @no_ssl_verify = false
10
- @version = 'v1.3'
11
- @suppress_rules = 'No'
12
- end
13
- end
1
+ module OSCRuby
2
+
3
+ class Configuration
4
+ # A holder class that holds the configuration information for the OSCRuby::Client block
5
+
6
+ attr_accessor :interface,:username,:password,:no_ssl_verify,:version,:suppress_rules,:demo_site
7
+
8
+ def initialize
9
+ @no_ssl_verify = false
10
+ @version = 'v1.3'
11
+ @suppress_rules = false
12
+ @demo_site = false
13
+ end
14
+ end
14
15
  end