osc_ruby 0.6.0 → 0.7.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fcd220980ce2649919596ac53c856ab62f7b99e0
4
- data.tar.gz: 311d5a6749cf7e471413b393dda6415fb4826536
3
+ metadata.gz: 2829268a23dea86d4974cc5462737e1553b424cd
4
+ data.tar.gz: 5e6d1763a191dbdb338a93455506bc8b13e296a1
5
5
  SHA512:
6
- metadata.gz: 8382c574776ac272cbf0c92d2dff5c128dd7405341433e875df5e9923922acdb30f6b991d7c69612ceeb3ad2a356768e405b7d46c4ca7c694d0f4d9f969f6936
7
- data.tar.gz: e27f0bd63323b296b7a974692827a265f4f15395d80c292f115642592e9fa71133d983a3bf25a4e6f551a30971c23f9e8b0931bdc4999313f8d224084115d6b6
6
+ metadata.gz: c3df42fdc806d43f143160e5cf451481ca4a96826347cb4f4f74c21b6c240dff35b67cfc1d1060b46489c077a72b8170b3b4944d836fadf6d3561ca1ac4a3967
7
+ data.tar.gz: f0d928e74dc96d32c91d28fe405bc1decfb60574aa48d1f89d6241b7b9cee85919a6918201f207d4e28942dfadc6df84784de3528cf6dc837d732a8b9c621f9c
data/.travis.yml CHANGED
@@ -1,7 +1,6 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 2.2.0
4
- - jruby
5
4
  addons:
6
5
  code_climate:
7
6
  repo_token:
@@ -13,10 +13,12 @@ module OSCRuby
13
13
  if attributes.nil?
14
14
 
15
15
  @answerType = {}
16
+ @accessLevels = []
16
17
  @summary = "Answer summary text"
17
18
  @language = {}
18
19
  @question = nil
19
20
  @categories = []
21
+ @id = 0
20
22
 
21
23
  else
22
24
 
@@ -51,30 +53,30 @@ module OSCRuby
51
53
 
52
54
  # Convenience Methods for making the CRUD operations nicer to use
53
55
 
54
- def set_attributes(response_body)
55
- self.id = response_body['id'].to_i
56
- self.lookupName = response_body['lookupName'].to_i
57
- self.createdTime = response_body['createdTime']
58
- self.updatedTime = response_body['updatedTime']
59
- self.accessLevels = response_body['accessLevels']
60
- self.adminLastAccessTime = response_body['adminLastAccessTime']
61
- self.answerType = response_body['answerType']
62
- self.expiresDate = response_body['expiresDate']
63
- self.guidedAssistance = response_body['guidedAssistance']
64
- self.keywords = response_body['keywords']
65
- self.language = response_body['language']
66
- self.lastAccessTime = response_body['lastAccessTime']
67
- self.lastNotificationTime = response_body['lastNotificationTime']
68
- self.name = response_body['name'].to_i
69
- self.nextNotificationTime = response_body['nextNotificationTime']
70
- self.originalReferenceNumber = response_body['originalReferenceNumber']
71
- self.positionInList = response_body['positionInList']
72
- self.publishOnDate = response_body['publishOnDate']
73
- self.question = response_body['question']
74
- self.solution = response_body['solution']
75
- self.summary = response_body['summary']
76
- self.updatedByAccount = response_body['updatedByAccount']
77
- self.uRL = response_body['uRL']
56
+ def self.set_attributes(response_body)
57
+ id = response_body['id'].to_i
58
+ lookupName = response_body['lookupName'].to_i
59
+ createdTime = response_body['createdTime']
60
+ updatedTime = response_body['updatedTime']
61
+ accessLevels = response_body['accessLevels']
62
+ adminLastAccessTime = response_body['adminLastAccessTime']
63
+ answerType = response_body['answerType']
64
+ expiresDate = response_body['expiresDate']
65
+ guidedAssistance = response_body['guidedAssistance']
66
+ keywords = response_body['keywords']
67
+ language = response_body['language']
68
+ lastAccessTime = response_body['lastAccessTime']
69
+ lastNotificationTime = response_body['lastNotificationTime']
70
+ name = response_body['name'].to_i
71
+ nextNotificationTime = response_body['nextNotificationTime']
72
+ originalReferenceNumber = response_body['originalReferenceNumber']
73
+ positionInList = response_body['positionInList']
74
+ publishOnDate = response_body['publishOnDate']
75
+ question = response_body['question']
76
+ solution = response_body['solution']
77
+ summary = response_body['summary']
78
+ updatedByAccount = response_body['updatedByAccount']
79
+ uRL = response_body['uRL']
78
80
  end
79
81
 
80
82
  def self.check_self(obj,is_update = false)
@@ -3,11 +3,12 @@ module OSCRuby
3
3
  class Configuration
4
4
  # A holder class that holds the configuration information for the OSCRuby::Client block
5
5
 
6
- attr_accessor :interface,:username,:password,:no_ssl_verify,:version
6
+ attr_accessor :interface,:username,:password,:no_ssl_verify,:version,:suppress_rules
7
7
 
8
8
  def initialize
9
9
  @no_ssl_verify = false
10
10
  @version = 'v1.3'
11
+ @suppress_rules = 'No'
11
12
  end
12
13
  end
13
14
  end
@@ -26,6 +26,9 @@ module OSCRuby
26
26
  request = Net::HTTP::Get.new @uri.request_uri
27
27
 
28
28
  request.add_field('Content-Type', 'application/x-www-form-urlencoded')
29
+ if @final_config['suppress_rules'] == true
30
+ request.add_field 'OSvC-CREST-Suppress-All',true
31
+ end
29
32
 
30
33
  request.basic_auth @username, @password
31
34
 
@@ -53,6 +56,9 @@ module OSCRuby
53
56
  if @final_config['patch_request'] == true
54
57
  request.add_field 'X-HTTP-Method-Override','PATCH'
55
58
  end
59
+ if @final_config['suppress_rules'] == true
60
+ request.add_field 'OSvC-CREST-Suppress-All',true
61
+ end
56
62
  request.body = JSON.dump(json_content)
57
63
 
58
64
  http.request request # Net::HTTPResponse object
@@ -93,15 +99,9 @@ module OSCRuby
93
99
 
94
100
  @version = @config.version
95
101
 
96
- if @config.no_ssl_verify == true
102
+ @ssl_verification = ssl_check(@config)
97
103
 
98
- @ssl_verification = OpenSSL::SSL::VERIFY_NONE
99
-
100
- else
101
-
102
- @ssl_verification = OpenSSL::SSL::VERIFY_PEER
103
-
104
- end
104
+ @rule_suppression = rule_suppress_check(@config)
105
105
 
106
106
  @url = "https://" + @config.interface + ".custhelp.com/services/rest/connect/#{@version}/#{resource_url}"
107
107
 
@@ -109,7 +109,41 @@ module OSCRuby
109
109
 
110
110
  @patch_request = patch_request == true ? true : false
111
111
 
112
- @final_config = {'site_url' => @final_uri, 'username' => @config.username, 'password' => @config.password, 'patch_request' => @patch_request, 'ssl' => @ssl_verification}
112
+ @final_config = {'site_url' => @final_uri,
113
+ 'username' => @config.username,
114
+ 'password' => @config.password,
115
+ 'patch_request' => @patch_request,
116
+ 'ssl' => @ssl_verification,
117
+ 'suppress_rules' => @rule_suppression
118
+ }
119
+
120
+ end
121
+
122
+ def self.rule_suppress_check(config)
123
+
124
+ if config.suppress_rules == true || config.suppress_rules == "Yes"
125
+
126
+ true
127
+
128
+ else
129
+
130
+ false
131
+
132
+ end
133
+
134
+ end
135
+
136
+ def self.ssl_check(config)
137
+
138
+ if config.no_ssl_verify == true
139
+
140
+ OpenSSL::SSL::VERIFY_NONE
141
+
142
+ else
143
+
144
+ OpenSSL::SSL::VERIFY_PEER
145
+
146
+ end
113
147
 
114
148
  end
115
149
 
@@ -28,16 +28,18 @@ module OSCRuby
28
28
 
29
29
  response_body = JSON.parse(response.body)
30
30
 
31
- if response.code.to_i == 201 && return_json == false
32
-
33
- obj.set_attributes(response_body)
34
-
35
- elsif return_json == true
31
+ if return_json == true
36
32
 
37
- response.body
33
+ puts response.body
38
34
 
39
35
  end
40
36
 
37
+ if obj.class.respond_to? :set_attributes
38
+ obj.class.new(response_body)
39
+ else
40
+ obj.set_attributes(response_body)
41
+ end
42
+
41
43
  end
42
44
 
43
45
  def find(client,id,obj_query,return_json,class_name,custom_or_nested = nil)
@@ -15,11 +15,18 @@ module OSCRuby
15
15
 
16
16
  obj_vars.each do |var|
17
17
 
18
- obj_attr = var.to_s.delete("@")
18
+ # Make sure to get rid of the empty ID
19
+ # otherwise everything gets all screwed up
19
20
 
20
- obj_attr_val = obj.instance_variable_get(var)
21
+ if var.to_s != '@id'
21
22
 
22
- empty_arr[0][obj_attr] = obj_attr_val
23
+ obj_attr = var.to_s.delete("@")
24
+
25
+ obj_attr_val = obj.instance_variable_get(var)
26
+
27
+ empty_arr[0][obj_attr] = obj_attr_val
28
+
29
+ end
23
30
 
24
31
  end
25
32
 
@@ -1,3 +1,3 @@
1
1
  module OSCRuby
2
- VERSION = "0.6.0"
2
+ VERSION = "0.7.0"
3
3
  end
@@ -206,13 +206,15 @@ describe OSCRuby::Answer do
206
206
  new_answer.language['id'] = 1
207
207
  new_answer.answerType['lookupName'] = "HTML"
208
208
 
209
- new_answer.create(client)
209
+ 10.times do |test|
210
+ new_answer.create(client)
211
+ end
210
212
 
211
213
  expect(new_answer).to be_a(OSCRuby::Answer)
212
214
 
213
215
  expect(new_answer.summary).to eq("Answer summary text")
214
216
 
215
- expect(new_answer.language).to eq({"id"=>1, "lookupName"=>"en_US"})
217
+ expect(new_answer.language).to eq({"id"=>1})
216
218
 
217
219
  end
218
220
 
@@ -228,12 +230,28 @@ describe OSCRuby::Answer do
228
230
  # end
229
231
 
230
232
 
231
- it 'should return the body object if the json_response param is set to true', :vcr do
233
+ it 'should print the body object if the json_response param is set to true', :vcr do
234
+
235
+ new_answer.language['id'] = 1
236
+ new_answer.answerType['lookupName'] = "HTML"
237
+
238
+ expect(new_answer.create(client,true)).to be_a(OSCRuby::Answer)
239
+
240
+ 10.times do |test|
241
+ new_answer.create(client,true)
242
+ end
243
+
244
+ end
245
+
246
+
247
+ it 'should return the answer attrs and assign them to the answer object', :vcr do
232
248
 
233
249
  new_answer.language['id'] = 1
234
250
  new_answer.answerType['lookupName'] = "HTML"
235
251
 
236
- expect(new_answer.create(client,true)).to be_a(String)
252
+ new_answer.create(client,true)
253
+
254
+ expect(new_answer.id).to_not be(nil)
237
255
 
238
256
  end
239
257
 
@@ -278,15 +296,12 @@ describe OSCRuby::Answer do
278
296
  expect(known_working_answer.id).to eq(2222)
279
297
  expect(known_working_answer.lookupName).to eq(2222)
280
298
  expect(known_working_answer.createdTime).to eq("2014-02-05T23:42:28Z")
281
- expect(known_working_answer.updatedTime).to eq("2016-12-13T09:55:45Z")
282
299
  expect(known_working_answer.accessLevels).to eq(3)
283
- expect(known_working_answer.adminLastAccessTime).to eq("2016-11-23T22:54:26Z")
284
300
  expect(known_working_answer.answerType).to eq(1)
285
301
  expect(known_working_answer.expiresDate).to eq(nil)
286
302
  expect(known_working_answer.guidedAssistance).to eq(nil)
287
303
  expect(known_working_answer.keywords).to eq("AbCbEbAb")
288
304
  expect(known_working_answer.language).to eq(1)
289
- expect(known_working_answer.lastAccessTime).to eq("2016-12-10T07:27:37Z")
290
305
  expect(known_working_answer.lastNotificationTime).to eq(nil)
291
306
  expect(known_working_answer.name).to eq(2222)
292
307
  expect(known_working_answer.nextNotificationTime).to eq(nil)
@@ -294,10 +309,14 @@ describe OSCRuby::Answer do
294
309
  expect(known_working_answer.positionInList).to eq(1)
295
310
  expect(known_working_answer.publishOnDate).to eq(nil)
296
311
  expect(known_working_answer.question).to eq(nil)
297
- expect(known_working_answer.solution).to eq("<p ></iframe></p>\n<ol>\n<li>\n<div class=\"MsoNormal\" >The following video will show you how to view your DVR using the QT view app or through a Browser using the Q-See Scan n View P2P technology.</div>\n<p align=\"center\"><img border=\"0\" alt=\"Image\" src=\"//q-see.s3.amazonaws.com/content/files/HowToFiles/p2pimages/Step1.png\" /></p>\n</li>\n<li>\n<div class=\"MsoNormal\" >P2P equals Peer to Peer. This concept has been around for a long time.</div>\n<p align=\"center\"><img border=\"0\" alt=\"Image\" src=\"//q-see.s3.amazonaws.com/content/files/HowToFiles/p2pimages/Step2.png\" /></p>\n</li>\n<li>\n<div class=\"MsoNormal\" >P2P equals Peer to Peer. In a peer to peer network, tasks (such as searching for files or streaming audio/video) are shared amongst multiple interconnected peers who each make a portion of their resources (such as processing power, Disk Storage or network bandwidth) directly available to other Network participants, without the need for centralized coordination by servers.</div>\n<p align=\"center\"><img border=\"0\" alt=\"Image\" src=\"//q-see.s3.amazonaws.com/content/files/HowToFiles/p2pimages/Step3.png\" /></p>\n</li>\n<li>\n<div class=\"MsoNormal\" >Q-See's application is to take the Port Forwarding process out of the hands of the End User.</div>\n<p align=\"center\"><img border=\"0\" alt=\"Image\" src=\"//q-see.s3.amazonaws.com/content/files/HowToFiles/p2pimages/Step4.png\" /></p>\n</li>\n<li>\n<div class=\"MsoNormal\" >Next, you will need to install your QT View app via the Apple App Store or the Google Play Store.</div>\n<p align=\"center\"><img border=\"0\" alt=\"Image\" src=\"//q-see.s3.amazonaws.com/content/files/HowToFiles/p2pimages/Step5.png\" /></p>\n</li>\n<li>\n<div class=\"MsoNormal\" >Once the DVR is connected and is powered up, you will go through the wizard.</div>\n<p align=\"center\"><img border=\"0\" alt=\"Image\" src=\"//q-see.s3.amazonaws.com/content/files/HowToFiles/p2pimages/Step6.png\" /></p>\n<div class=\"MsoNormal\" ></div>\n<p align=\"center\"><img border=\"0\" alt=\"Image\" src=\"//q-see.s3.amazonaws.com/content/files/HowToFiles/p2pimages/Step6a.png\" /></p>\n<div class=\"MsoNormal\" ></div>\n<p align=\"center\"><img border=\"0\" alt=\"Image\" src=\"//q-see.s3.amazonaws.com/content/files/HowToFiles/p2pimages/Step6b.png\" /></p>\n<div class=\"MsoNormal\" ></div>\n<p align=\"center\"><img border=\"0\" alt=\"Image\" src=\"//q-see.s3.amazonaws.com/content/files/HowToFiles/p2pimages/Step6c.png\" /></p>\n</li>\n<li>\n<div class=\"MsoNormal\" >While going through the wizard you will need to select your device to fit the the QR Code.</div>\n<p align=\"center\"><img border=\"0\" alt=\"Image\" src=\"//q-see.s3.amazonaws.com/content/files/HowToFiles/p2pimages/Step6d.png\" /></p>\n<div class=\"MsoNormal\" ></div>\n<p align=\"center\"><img border=\"0\" alt=\"Image\" src=\"//q-see.s3.amazonaws.com/content/files/HowToFiles/p2pimages/Step6e.png\" /></p>\n</li>\n<li>\n<div class=\"MsoNormal\" >Then go to your QT View and tap on the QR code image.</div>\n<p align=\"center\"><img border=\"0\" alt=\"Image\" src=\"//q-see.s3.amazonaws.com/content/files/HowToFiles/p2pimages/Step7.png\" /></p>\n</li>\n<li>\n<div class=\"MsoNormal\" >Now, your scanner will come up, then scan the QR code.</div>\n<p align=\"center\"><img border=\"0\" alt=\"Image\" src=\"//q-see.s3.amazonaws.com/content/files/HowToFiles/p2pimages/Step8.png\" /></p>\n</li>\n<li>\n<div class=\"MsoNormal\" >The MAC address will appear, then enter the DVR's user name and password.</div>\n<p align=\"center\"><img border=\"0\" alt=\"Image\" src=\"//q-see.s3.amazonaws.com/content/files/HowToFiles/p2pimages/Step9.png\" /></p>\n</li>\n<li>\n<div class=\"MsoNormal\" >Then Tap Login.</div>\n<p align=\"center\"><img border=\"0\" alt=\"Image\" src=\"//q-see.s3.amazonaws.com/content/files/HowToFiles/p2pimages/Step10.png\" /></p>\n</li>\n<li>\n<div class=\"MsoNormal\" >After a few moments you will then be able to see the cameras without having to access the router.</div>\n<p align=\"center\"><img border=\"0\" alt=\"Image\" src=\"//q-see.s3.amazonaws.com/content/files/HowToFiles/p2pimages/Step11.png\" /></p>\n</li>\n<li>\n<div class=\"MsoNormal\" >How to access it for PC/MAC.</div>\n<p align=\"center\"><img border=\"0\" alt=\"Image\" src=\"//q-see.s3.amazonaws.com/content/files/HowToFiles/p2pimages/Step12.png\" /></p>\n</li>\n<li>\n<div class=\"MsoNormal\" >Open Browser. Enter qtview.com, Push enter. NOTE: YOU WILL STILL NEED TO ADD IN THE ACTIVE X OR IE PLUG IN FOR YOUR BROWSER.</div>\n<p align=\"center\"><img border=\"0\" alt=\"Image\" src=\"//q-see.s3.amazonaws.com/content/files/HowToFiles/p2pimages/Step13.png\" /></p>\n</li>\n<li>\n<div class=\"MsoNormal\" >Enter the MAC address, User name, and Password, then click LOGIN.</div>\n<p align=\"center\"><img border=\"0\" alt=\"Image\" src=\"//q-see.s3.amazonaws.com/content/files/HowToFiles/p2pimages/Step14.png\" /></p>\n</li>\n<li>\n<div class=\"MsoNormal\" >Then you will be able to see your system.</div>\n<p align=\"center\"><img border=\"0\" alt=\"Image\" src=\"//q-see.s3.amazonaws.com/content/files/HowToFiles/p2pimages/Step15.png\" /></p>\n</li>\n<li>\n<div class=\"MsoNormal\" >Q-See Scan n View.</div>\n<p align=\"center\"><img border=\"0\" alt=\"Image\" src=\"//q-see.s3.amazonaws.com/content/files/HowToFiles/p2pimages/Step16.png\" /></p>\n</li>\n</ol>")
298
312
  expect(known_working_answer.summary).to eq("QT Series: (VIDEO) Scan 'N View Setup")
299
- expect(known_working_answer.updatedByAccount).to eq(47)
300
313
  expect(known_working_answer.uRL).to eq(nil)
314
+
315
+ # not a very reliable metrics.....
316
+ # expect(known_working_answer.updatedByAccount).to eq(47)
317
+ # expect(known_working_answer.updatedTime).to eq("2016-12-13T09:55:45Z")
318
+ # expect(known_working_answer.adminLastAccessTime).to eq("2016-11-23T22:54:26Z")
319
+ # expect(known_working_answer.lastAccessTime).to eq("2016-12-10T07:27:37Z")
301
320
 
302
321
  end
303
322
 
@@ -15,6 +15,8 @@ describe OSCRuby::Connect do
15
15
  config.username = ENV['OSC_ADMIN']
16
16
 
17
17
  config.password = ENV['OSC_PASSWORD']
18
+
19
+ config.suppress_rules = true
18
20
 
19
21
  end
20
22
  }
@@ -160,10 +160,12 @@ describe OSCRuby::ServiceCategory do
160
160
 
161
161
  expect(new_service_category.displayOrder).to eq(1)
162
162
 
163
+ expect(new_service_category.id).to_not eq(nil)
164
+
163
165
  end
164
166
 
165
167
 
166
- it 'should return the body object if the json_response param is set to true', :vcr do
168
+ it 'should print the body object if the json_response param is set to true', :vcr do
167
169
 
168
170
  new_service_category.displayOrder = 11
169
171
 
@@ -172,7 +174,9 @@ describe OSCRuby::ServiceCategory do
172
174
  new_service_category.names[0] = {"labelText" => "TEST-CATEGORY", "language" => {"id" => 1}}
173
175
  new_service_category.names[1] = {'labelText' => 'TEST-CATEGORY', 'language' => {'id' => 11}}
174
176
 
175
- expect(new_service_category.create(client,true)).to be_a(String)
177
+ new_service_category.create(client,true)
178
+
179
+ expect(new_service_category).to be_a(OSCRuby::ServiceCategory)
176
180
 
177
181
  end
178
182
 
@@ -215,9 +219,9 @@ describe OSCRuby::ServiceCategory do
215
219
 
216
220
  expect(known_working_category).to be_an(OSCRuby::ServiceCategory)
217
221
 
218
- expect(known_working_category.name).to eq('Manuals & Guides')
222
+ expect(known_working_category.name).to eq('Manuals and Guides')
219
223
 
220
- expect(known_working_category.displayOrder).to eq(2)
224
+ expect(known_working_category.displayOrder).to eq(1)
221
225
 
222
226
  end
223
227
 
@@ -162,15 +162,19 @@ describe OSCRuby::ServiceProduct do
162
162
 
163
163
  expect(new_service_product.parent).to eq(102)
164
164
 
165
+ expect(new_service_product.id).to_not eq(nil)
166
+
165
167
  end
166
168
 
167
169
 
168
- it 'should return the body object if the json_response param is set to true', :vcr do
170
+ it 'should print the body object if the json_response param is set to true', :vcr do
169
171
 
170
172
  new_service_product.names[0] = {"labelText" => "TEST-PRODUCT", "language" => {"id" => 1}}
171
173
  new_service_product.names[1] = {'labelText' => 'TEST-PRODUCT', 'language' => {'id' => 11}}
172
174
 
173
- expect(new_service_product.create(client,true)).to be_a(String)
175
+ new_service_product.create(client,true)
176
+
177
+ expect(new_service_product).to be_a(OSCRuby::ServiceProduct)
174
178
 
175
179
  end
176
180
 
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.6.0
4
+ version: 0.7.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-02-17 00:00:00.000000000 Z
11
+ date: 2017-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: simplecov