osc_ruby 0.4.0 → 0.5.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: f3699de5d5f0bfd43b0fa37ee16e2bbe47fed6ff
4
- data.tar.gz: 31b35ce287cc0d343afb32e399b052fa9becff64
3
+ metadata.gz: 577cfee3d6df8ff91d8b6a066f8f0f7a053d97f4
4
+ data.tar.gz: 6bd02a2717606ac0d830e8500f2436b593c42865
5
5
  SHA512:
6
- metadata.gz: 3027967797e07efaecc469545382d6b521170d51ce5c5eb4bb43f1c8a046d0d3f42c32ee241b59485f36d53015eae58fa40ece9d62124d3d971c09b9416ea475
7
- data.tar.gz: 760a5ce18c2dc9bcebe61b5fa31b8d4145228704d1bab14628dcea3e0bfb7abd89d805ca2160a49fdc67c94d436506809323c347de556ed1d0104993d5f21bcb
6
+ metadata.gz: 66505f1778ad733d0c19208c3167bbad6f14092eac4e080e98f2d2cd0732ab42daea9b898d9ab75f6e3eb6e0b2167d5c2a054b8c64374567a50c79bd96fffb17
7
+ data.tar.gz: affc28237a55753fc882e67ecf4c3201e811dde465bcde5d07da23baa0891ceb7fac7c4b4f530513517c77834f85cddf9f1d24cb3d30f8033bc859186042200c
data/README.md CHANGED
@@ -225,12 +225,18 @@ product_to_delete.destroy(rn_client)
225
225
 
226
226
  - [x] Make version default to 1.3 but an option to be set in the config class
227
227
 
228
+ - [ ] Follow with next Classes (Accounts,ServiceCategories, Answers, Incidents)
229
+
230
+ - [ ] Need to update QueryResults to split the queries
231
+
232
+ - [ ] Need to update QueryResults to be able to manipulate the results
233
+
234
+ - [ ] Need to finish up the Account object
235
+
228
236
  - [ ] Allow for the prefer:exclude-null-properties header => update config and connect class, update tests
229
237
 
230
238
  - [ ] Allow for Session Authorization => update config class and connect classes, update tests
231
239
 
232
240
  - [ ] Figure out how to do RDoc/Yardoc documentation or best in class documentation for using this Ruby ORM
233
241
 
234
- - [ ] Follow with next Classes (ServiceCategories, Answers, Incidents)
235
-
236
242
  - [ ] Release MVP
@@ -0,0 +1,75 @@
1
+ module OSCRuby
2
+
3
+ class Account < ServiceClass
4
+
5
+ attr_accessor :displayName,:login,:name,:nameFurigana,:attributes,:profile,:name,:staffGroup,:newPassword,:country,:emails
6
+
7
+ def initialize(attributes = nil)
8
+
9
+ @displayName = 'Display Name'
10
+ @login = 'Login'
11
+ @name = {}
12
+ @nameFurigana = {}
13
+ @attributes = {}
14
+ @profile = {}
15
+ @name = {}
16
+ @staffGroup = {}
17
+ @newPassword = 'default_password'
18
+ @country = {}
19
+ @emails = []
20
+
21
+ end
22
+
23
+ # Convenience Methods for making the CRUD operations nicer to use
24
+
25
+ def set_attributes(response_body)
26
+
27
+ self.id = response_body["id"]
28
+
29
+ self.name = response_body["lookupName"]
30
+
31
+ self.lookupName = response_body["lookupName"]
32
+
33
+ self.displayOrder = response_body["displayOrder"]
34
+
35
+ end
36
+
37
+ def update_attributes(updated_product)
38
+
39
+ self.lookupName = updated_product.lookupName
40
+
41
+ self.createdTime = updated_product.createdTime
42
+
43
+ self.updatedTime = updated_product.updatedTime
44
+
45
+ self.name = updated_product.name
46
+
47
+ self.parent = updated_product.parent
48
+
49
+ end
50
+
51
+ def self.check_self(obj,is_update = false)
52
+
53
+ class_name = self.to_s.split('::')[1]
54
+
55
+ obj_attrs = ValidationsModule::extract_attributes(obj)
56
+
57
+ # if is_update == true
58
+
59
+ # obj_attrs = remove_unused_new_attrs(obj_attrs)
60
+
61
+ # else
62
+
63
+ # obj_attrs = ValidationsModule::check_for_names(obj_attrs,class_name)
64
+
65
+ # obj_attrs = ValidationsModule::check_for_parents(obj_attrs)
66
+
67
+ # end
68
+
69
+ obj_attrs
70
+
71
+ end
72
+
73
+ end
74
+
75
+ end
@@ -20,7 +20,7 @@ module OSCRuby
20
20
 
21
21
  check_obj_for_errors(obj_to_find)
22
22
 
23
- normalize(obj_to_find)
23
+ normalize(obj_to_find,resource)
24
24
  else
25
25
 
26
26
  obj_to_find.body
@@ -47,7 +47,7 @@ module OSCRuby
47
47
 
48
48
  end
49
49
 
50
- def normalize(input)
50
+ def normalize(input,resource)
51
51
 
52
52
  if input.code.to_i == 404
53
53
 
@@ -59,15 +59,29 @@ module OSCRuby
59
59
 
60
60
  final_hash = []
61
61
 
62
- json_input['items'][0]['rows'].each do |row|
62
+ query_capture = URI.unescape(resource).split('=')[1]
63
63
 
64
- obj_hash = {}
65
-
66
- json_input['items'][0]['columnNames'].each_with_index do |column,i|
67
- obj_hash[column] = if !row[i].nil? && row[i].is_i? == true then row[i].to_i else row[i] end
68
- end
64
+ queries = query_capture.split(';')
65
+
66
+ json_input['items'].each do |item|
67
+
68
+ item['rows'].each_with_index do |row,row_i|
69
+
70
+ obj_hash = {}
71
+
72
+ item['columnNames'].each_with_index do |column,i|
73
+ obj_hash[column] = if !row[i].nil? && row[i].is_i? == true then row[i].to_i else row[i] end
74
+ end
75
+
76
+ final_hash.push(obj_hash)
69
77
 
70
- final_hash.push(obj_hash)
78
+ if json_input['items'].count > 1 && (item['rows'].count-1 == row_i)
79
+
80
+ final_hash.push("\n")
81
+
82
+ end
83
+
84
+ end
71
85
 
72
86
  end
73
87
 
@@ -23,8 +23,6 @@ module OSCRuby
23
23
 
24
24
  json_response = JSON.parse(response)
25
25
 
26
- puts "Results for '#{query}'"
27
- puts
28
26
  puts json_response
29
27
  puts
30
28
 
@@ -1,3 +1,3 @@
1
1
  module OSCRuby
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
data/lib/osc_ruby.rb CHANGED
@@ -7,4 +7,5 @@ require 'osc_ruby/product_category_shared'
7
7
  require 'osc_ruby/service_product'
8
8
  require 'osc_ruby/service_category'
9
9
  require 'osc_ruby/answer'
10
+ require 'osc_ruby/account'
10
11
  require 'osc_ruby/query_results'
@@ -0,0 +1,497 @@
1
+ require 'core/spec_helper'
2
+ require 'json'
3
+ require 'uri'
4
+
5
+ describe OSCRuby::Account do
6
+
7
+ let(:account){
8
+
9
+ OSCRuby::Account.new
10
+
11
+ }
12
+
13
+ context '#initialize' do
14
+
15
+ it 'should not throw an error when initialized' do
16
+
17
+ expect{account}.not_to raise_error
18
+
19
+ end
20
+
21
+ it 'should initialize with a displayName as a string, login as a string, name as a hash, nameFurigana as a hash, attributes as a hash, profile as a hash,staffGroup as a hash, newPassword as a string, country as a hash, emails as an array' do
22
+
23
+ expect(account.displayName).to be_a(String)
24
+ expect(account.login).to be_a(String)
25
+ expect(account.name).to be_a(Hash)
26
+ expect(account.nameFurigana).to be_a(Hash)
27
+ expect(account.attributes).to be_a(Hash)
28
+ expect(account.profile).to be_a(Hash)
29
+ expect(account.staffGroup).to be_a(Hash)
30
+ expect(account.newPassword).to be_a(String)
31
+ expect(account.country).to be_a(Hash)
32
+ expect(account.emails).to be_an(Array)
33
+
34
+ end
35
+
36
+ end
37
+
38
+ # let(:attributes){
39
+ #
40
+ #
41
+ # }
42
+
43
+ # context '#new_from_fetch' do
44
+
45
+ # it 'should accept an attributes as a hash' do
46
+
47
+ # expect do
48
+
49
+ # attributes = []
50
+
51
+ # OSCRuby::Account.new_from_fetch(attributes)
52
+
53
+ # end.to raise_error("Attributes must be a hash; please use the appropriate data structure")
54
+
55
+ # expect do
56
+
57
+ # OSCRuby::Account.new_from_fetch(attributes)
58
+
59
+ # end.not_to raise_error
60
+
61
+ # end
62
+
63
+ # it 'should instantiate an id, lookupName, createdTime, updatedTime, accessLevels, adminLastAccessTime, answerType, expiresDate, guidedAssistance, keywords, language, lastAccessTime, lastNotificationTime, name, nextNotificationTime, originalReferenceNumber, positionInList, publishOnDate, question, solution, summary, updatedByAccount, uRL with the correct values' do
64
+
65
+ # test = OSCRuby::Account.new_from_fetch(attributes)
66
+
67
+ # expect(test.id).to eq(2222)
68
+ # expect(test.lookupName).to eq(2222)
69
+ # expect(test.createdTime).to eq("2014-02-05T23:42:28Z")
70
+ # expect(test.updatedTime).to eq("2016-12-13T09:55:45Z")
71
+ # expect(test.accessLevels).to eq(3)
72
+ # expect(test.adminLastAccessTime).to eq("2016-11-23T22:54:26Z")
73
+ # expect(test.answerType).to eq(1)
74
+ # expect(test.expiresDate).to eq(nil)
75
+ # expect(test.guidedAssistance).to eq(nil)
76
+ # expect(test.keywords).to eq("AbCbEbAb")
77
+ # expect(test.language).to eq(1)
78
+ # expect(test.lastAccessTime).to eq("2016-12-10T07:27:37Z")
79
+ # expect(test.lastNotificationTime).to eq(nil)
80
+ # expect(test.name).to eq(2222)
81
+ # expect(test.nextNotificationTime).to eq(nil)
82
+ # expect(test.originalReferenceNumber).to eq(nil)
83
+ # expect(test.positionInList).to eq(1)
84
+ # expect(test.publishOnDate).to eq(nil)
85
+ # expect(test.question).to eq(nil)
86
+ # expect(test.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>")
87
+ # expect(test.summary).to eq("QT Series: (VIDEO) Scan 'N View Setup")
88
+ # expect(test.updatedByAccount).to eq(47)
89
+ # expect(test.uRL).to eq(nil)
90
+
91
+ # end
92
+
93
+ # end
94
+
95
+ let(:client) {
96
+
97
+ OSCRuby::Client.new do |config|
98
+
99
+ config.interface = ENV['OSC_TEST_SITE']
100
+
101
+ config.username = ENV['OSC_ADMIN']
102
+
103
+ config.password = ENV['OSC_PASSWORD']
104
+
105
+ end
106
+ }
107
+
108
+ # let(:new_answer){
109
+ # OSCRuby::Account.new
110
+ # }
111
+
112
+ # context '#create' do
113
+
114
+ # it 'should expect client is an instance of OSCRuby::Client class and raise an error if does not' do
115
+
116
+ # expect(client).to be_an(OSCRuby::Client)
117
+
118
+ # client = nil
119
+
120
+ # expect{new_answer.create(client)}.to raise_error('Client must have some configuration set; please create an instance of OSCRuby::Client with configuration settings')
121
+
122
+ # end
123
+
124
+ # it 'should check the object and make sure that it at least has a language, answerType, and summary set', :vcr do
125
+
126
+ # expect{new_answer.create(client)}.to raise_error('Answer should at least the language, answerType, and summary set (new_answer.language = {"id" => 1}; new_answer.answerType = {"id" => 1}}; new_answer.summary = "This is the Answer Title")')
127
+
128
+ # new_answer.language['id'] = 1
129
+
130
+ # expect{new_answer.create(client)}.to raise_error('Answer should at least the language, answerType, and summary set (new_answer.language = {"id" => 1}; new_answer.answerType = {"id" => 1}}; new_answer.summary = "This is the Answer Title")')
131
+
132
+ # new_answer.answerType['id'] = 1
133
+
134
+ # # the Answer summary is defaulted to "Answer summary text" so it should pass here
135
+
136
+ # expect{new_answer.create(client)}.to_not raise_error
137
+
138
+ # end
139
+
140
+ # it 'should expect the language as a hash with an id as a key with a value of a number' do
141
+
142
+ # new_answer.language['id'] = "new answer name"
143
+ # new_answer.answerType['id'] = 1
144
+
145
+ # expect{new_answer.create(client)}.to raise_error('Answer should at least the language, answerType, and summary set (new_answer.language = {"id" => 1}; new_answer.answerType = {"id" => 1}}; new_answer.summary = "This is the Answer Title")')
146
+
147
+ # end
148
+
149
+ # it 'should expect the answerType as a hash with an id as a key with a value of a number' do
150
+
151
+ # new_answer.language['id'] = 1
152
+ # new_answer.answerType['id'] = "new answer name"
153
+
154
+ # expect{new_answer.create(client)}.to raise_error('Answer should at least the language, answerType, and summary set (new_answer.language = {"id" => 1}; new_answer.answerType = {"id" => 1}}; new_answer.summary = "This is the Answer Title")')
155
+
156
+ # end
157
+
158
+ # it 'should expect the answerType as a hash with an lookupName as a key with a value of "HTML","URL", or "File Attachment"', :vcr do
159
+
160
+ # new_answer.language['id'] = 1
161
+ # new_answer.answerType['lookupName'] = "HTML"
162
+
163
+ # expect{new_answer.create(client)}.not_to raise_error
164
+
165
+ # end
166
+
167
+ # it 'should expect the categories to be an array' do
168
+
169
+ # expect(new_answer.categories).to be_an(Array)
170
+
171
+ # end
172
+
173
+ # it 'should expect that a hash with an id key for categories should create an answer without issue', :vcr do
174
+
175
+ # new_answer.language['id'] = 1
176
+ # new_answer.answerType['lookupName'] = "HTML"
177
+
178
+ # new_answer.categories[0] = {'id' => 6}
179
+
180
+ # new_answer.create(client)
181
+
182
+ # expect(new_answer).to be_a(OSCRuby::Account)
183
+
184
+ # end
185
+
186
+ # it 'should return an instance of an OSCRuby::Account if the json_response param is set to false (which it is by default)', :vcr do
187
+
188
+ # new_answer.language['id'] = 1
189
+ # new_answer.answerType['lookupName'] = "HTML"
190
+
191
+ # new_answer.create(client)
192
+
193
+ # expect(new_answer).to be_a(OSCRuby::Account)
194
+
195
+ # expect(new_answer.summary).to eq("Answer summary text")
196
+
197
+ # expect(new_answer.language).to eq({"id"=>1, "lookupName"=>"en_US"})
198
+
199
+ # end
200
+
201
+
202
+ # it 'should return the body object if the json_response param is set to true', :vcr do
203
+
204
+ # new_answer.language['id'] = 1
205
+ # new_answer.answerType['lookupName'] = "HTML"
206
+
207
+ # expect(new_answer.create(client,true)).to be_a(String)
208
+
209
+ # end
210
+
211
+ # end
212
+
213
+ # context '#find' do
214
+
215
+ # it 'should expect client is an instance of OSCRuby::Client class and raise an error if does not' do
216
+
217
+ # expect(client).to be_an(OSCRuby::Client)
218
+
219
+ # client = nil
220
+
221
+ # expect{OSCRuby::Account.find(client,100)}.to raise_error('Client must have some configuration set; please create an instance of OSCRuby::Client with configuration settings')
222
+
223
+ # end
224
+
225
+ # it 'should raise an error if ID is undefined' do
226
+
227
+ # expect{OSCRuby::Account.find(client)}.to raise_error('ID cannot be nil')
228
+
229
+ # end
230
+
231
+ # it 'should raise an error if ID is not an integer' do
232
+
233
+ # expect{OSCRuby::Account.find(client, 'a')}.to raise_error('ID must be an integer')
234
+
235
+ # end
236
+
237
+ # it 'should return a warning if empty/no instances of the object can be found', :vcr do
238
+
239
+ # expect{OSCRuby::Account.find(client, 100)}.to raise_error('There were no objects matching your query; please try again.')
240
+
241
+ # end
242
+
243
+
244
+ # it 'should return an instance of a new OSCRuby::Account object with at least a name and displayOrder', :vcr do
245
+
246
+ # known_working_answer = OSCRuby::Account.find(client, 2222)
247
+
248
+ # expect(known_working_answer).to be_an(OSCRuby::Account)
249
+ # expect(known_working_answer.id).to eq(2222)
250
+ # expect(known_working_answer.lookupName).to eq(2222)
251
+ # expect(known_working_answer.createdTime).to eq("2014-02-05T23:42:28Z")
252
+ # expect(known_working_answer.updatedTime).to eq("2016-12-13T09:55:45Z")
253
+ # expect(known_working_answer.accessLevels).to eq(3)
254
+ # expect(known_working_answer.adminLastAccessTime).to eq("2016-11-23T22:54:26Z")
255
+ # expect(known_working_answer.answerType).to eq(1)
256
+ # expect(known_working_answer.expiresDate).to eq(nil)
257
+ # expect(known_working_answer.guidedAssistance).to eq(nil)
258
+ # expect(known_working_answer.keywords).to eq("AbCbEbAb")
259
+ # expect(known_working_answer.language).to eq(1)
260
+ # expect(known_working_answer.lastAccessTime).to eq("2016-12-10T07:27:37Z")
261
+ # expect(known_working_answer.lastNotificationTime).to eq(nil)
262
+ # expect(known_working_answer.name).to eq(2222)
263
+ # expect(known_working_answer.nextNotificationTime).to eq(nil)
264
+ # expect(known_working_answer.originalReferenceNumber).to eq(nil)
265
+ # expect(known_working_answer.positionInList).to eq(1)
266
+ # expect(known_working_answer.publishOnDate).to eq(nil)
267
+ # expect(known_working_answer.question).to eq(nil)
268
+ # 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>")
269
+ # expect(known_working_answer.summary).to eq("QT Series: (VIDEO) Scan 'N View Setup")
270
+ # expect(known_working_answer.updatedByAccount).to eq(47)
271
+ # expect(known_working_answer.uRL).to eq(nil)
272
+
273
+ # end
274
+
275
+ # it 'should return the raw json response if the return_json parameter is set to true', :vcr do
276
+
277
+ # known_working_answer_in_json = OSCRuby::Account.find(client, 2222, true)
278
+
279
+ # expect(known_working_answer_in_json).to be_an(String)
280
+
281
+ # end
282
+
283
+ # end
284
+
285
+ # context '#all' do
286
+
287
+ # it 'should expect client is an instance of OSCRuby::Client class and raise an error if does not' do
288
+
289
+ # expect(client).to be_an(OSCRuby::Client)
290
+
291
+ # client = nil
292
+
293
+ # expect{OSCRuby::Account.all(client)}.to raise_error('Client must have some configuration set; please create an instance of OSCRuby::Client with configuration settings')
294
+
295
+ # end
296
+
297
+ # it 'should return multiple instances of OSCRuby::Account', :vcr do
298
+
299
+ # answers = OSCRuby::Account.all(client)
300
+
301
+ # expect(answers.size).to be > 0
302
+
303
+ # # puts "Checking if OSCRuby::Account.all produces multiple instances of answers"
304
+
305
+ # answers.each_with_index do |p,i|
306
+
307
+ # if i < 10
308
+
309
+ # expect(p).to be_an(OSCRuby::Account)
310
+
311
+ # # puts p.name
312
+
313
+ # end
314
+
315
+ # end
316
+
317
+ # end
318
+
319
+ # it 'should just return JSON if the return_json parameter is set to true', :vcr do
320
+
321
+ # expect(OSCRuby::Account.all(client,true)).to be_a(String)
322
+
323
+ # end
324
+
325
+ # end
326
+
327
+ # context '#where' do
328
+
329
+ # it 'should expect client is an instance of OSCRuby::Client class and raise an error if does not' do
330
+
331
+ # expect(client).to be_an(OSCRuby::Client)
332
+
333
+ # client = nil
334
+
335
+ # expect{OSCRuby::Account.where(client,'query')}.to raise_error('Client must have some configuration set; please create an instance of OSCRuby::Client with configuration settings')
336
+
337
+ # end
338
+
339
+ # it 'should raise an error if there is no query' do
340
+
341
+ # expect{OSCRuby::Account.where(client)}.to raise_error("A query must be specified when using the 'where' method")
342
+
343
+ # end
344
+
345
+ # it 'should take a query and return results', :vcr do
346
+
347
+ # answers_lvl_1 = OSCRuby::Account.where(client,"language.id = 11")
348
+
349
+ # expect(answers_lvl_1.count).to be > 0
350
+
351
+ # answers_lvl_1.each_with_index do |p,i|
352
+
353
+ # if i < 10
354
+
355
+ # expect(p).to be_an(OSCRuby::Account)
356
+
357
+ # # puts p.name
358
+
359
+ # end
360
+
361
+ # end
362
+
363
+ # end
364
+
365
+ # it 'should raise an error if the query returns 0 results', :vcr do
366
+
367
+ # expect{OSCRuby::Account.where(client,"id = 6546546546546")}.to raise_error('There were no objects matching your query; please try again.')
368
+
369
+ # end
370
+
371
+ # it 'should just return JSON if the return_json parameter is set to true', :vcr do
372
+
373
+ # parents = OSCRuby::Account.where(client,"parent is null and lookupname not like 'Unsure'",true)
374
+
375
+ # expect(parents).to be_a(String)
376
+
377
+ # # puts parents
378
+
379
+ # end
380
+
381
+ # end
382
+
383
+ # context '#update' do
384
+
385
+ # it 'should expect client is an instance of OSCRuby::Client class and raise an error if does not', :vcr do
386
+
387
+ # known_working_answer = OSCRuby::Account.find(client, 2222)
388
+
389
+ # expect(client).to be_an(OSCRuby::Client)
390
+
391
+ # client = nil
392
+
393
+ # expect{known_working_answer.update(client)}.to raise_error('Client must have some configuration set; please create an instance of OSCRuby::Client with configuration settings')
394
+
395
+ # end
396
+
397
+ # it 'should expect that the Answer is an instance of a OSCRuby::Account', :vcr do
398
+
399
+ # known_working_answer = OSCRuby::Account.find(client, 2222)
400
+
401
+ # expect(known_working_answer).to be_an(OSCRuby::Account)
402
+
403
+ # end
404
+
405
+ # it 'should expect that the answer has an ID and spit out an error if it does not', :vcr do
406
+
407
+ # known_working_answer = OSCRuby::Account.find(client, 2222)
408
+
409
+ # known_working_answer.id = nil
410
+
411
+ # expect{known_working_answer.update(client)}.to raise_error('OSCRuby::Account must have a valid ID set')
412
+
413
+ # end
414
+
415
+ # # it 'should update name when the names is updated', :vcr do
416
+
417
+ # # test_answers = OSCRuby::Account.where(client,"language.id = 11")
418
+ # # first_prod = test_answers[0]
419
+
420
+ # # first_prod.names[0] = {"labelText" => "TEST-answer-UPDATED", "language" => {"id" => 1}}
421
+
422
+ # # first_prod.update(client)
423
+
424
+ # # expect(first_prod.name).to eq('TEST-answer-UPDATED')
425
+
426
+ # # end
427
+
428
+ # it 'should just return JSON if the return_json parameter is set to true', :vcr do
429
+
430
+ # known_working_answer = OSCRuby::Account.find(client, 2222)
431
+
432
+ # test = known_working_answer.update(client,true)
433
+
434
+ # expect(test).to be_a(String)
435
+
436
+ # end
437
+
438
+ # end
439
+
440
+ # context '#destroy' do
441
+
442
+ # it 'should expect client is an instance of OSCRuby::Client class and raise an error if does not', :vcr do
443
+
444
+ # test_answers = OSCRuby::Account.where(client,"summary like '%Answer summary text%'")
445
+ # answer_to_delete = test_answers[0]
446
+
447
+ # expect(client).to be_an(OSCRuby::Client)
448
+
449
+ # client = nil
450
+
451
+ # expect{answer_to_delete.destroy(client)}.to raise_error('Client must have some configuration set; please create an instance of OSCRuby::Client with configuration settings')
452
+
453
+ # end
454
+
455
+ # it 'should expect that the Service answer is an instance of a OSCRuby::Account', :vcr do
456
+
457
+ # test_answers = OSCRuby::Account.where(client,"summary like '%Answer summary text%'")
458
+ # answer_to_delete = test_answers[0]
459
+
460
+ # expect(answer_to_delete).to be_an(OSCRuby::Account)
461
+
462
+ # end
463
+
464
+ # it 'should expect that the answer has an ID and spit out an error if it does not', :vcr do
465
+
466
+ # test_answers = OSCRuby::Account.where(client,"summary like '%Answer summary text%'")
467
+ # answer_to_delete = test_answers[0]
468
+
469
+ # answer_to_delete.id = nil
470
+
471
+ # expect{answer_to_delete.destroy(client)}.to raise_error('OSCRuby::Account must have a valid ID set')
472
+
473
+ # end
474
+
475
+ # it 'should delete the answer', :vcr do
476
+
477
+ # test_answers = OSCRuby::Account.where(client,"summary like '%Answer summary text%'")
478
+
479
+ # answer_to_delete = test_answers[0]
480
+
481
+ # id_to_find = answer_to_delete.id
482
+
483
+ # test_answers.each do |answer|
484
+
485
+ # puts answer.id
486
+
487
+ # answer.destroy(client)
488
+
489
+ # end
490
+
491
+ # expect{OSCRuby::Account.find(client, id_to_find)}.to raise_error('There were no objects matching your query; please try again.')
492
+
493
+ # end
494
+
495
+ # end
496
+
497
+ end
@@ -47,6 +47,8 @@ describe OSCRuby::QueryResults do
47
47
 
48
48
  expect(query_results.select(client,"describe answers")).to eq(nil)
49
49
 
50
+ expect(query_results.select(client,"describe answers;describe servicecategories")).to eq(nil)
51
+
50
52
  end
51
53
 
52
54
  end
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.4.0
4
+ version: 0.5.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-01-20 00:00:00.000000000 Z
11
+ date: 2017-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: simplecov
@@ -141,6 +141,7 @@ files:
141
141
  - Rakefile
142
142
  - lib/ext/string.rb
143
143
  - lib/osc_ruby.rb
144
+ - lib/osc_ruby/account.rb
144
145
  - lib/osc_ruby/answer.rb
145
146
  - lib/osc_ruby/class_factory_module.rb
146
147
  - lib/osc_ruby/client.rb
@@ -156,6 +157,7 @@ files:
156
157
  - lib/osc_ruby/validations_module.rb
157
158
  - lib/osc_ruby/version.rb
158
159
  - osc_ruby.gemspec
160
+ - spec/core/account_spec.rb
159
161
  - spec/core/answer_spec.rb
160
162
  - spec/core/client_spec.rb
161
163
  - spec/core/configuration_spec.rb
@@ -190,6 +192,7 @@ signing_key:
190
192
  specification_version: 4
191
193
  summary: Making the best of opensource and enterprise technology
192
194
  test_files:
195
+ - spec/core/account_spec.rb
193
196
  - spec/core/answer_spec.rb
194
197
  - spec/core/client_spec.rb
195
198
  - spec/core/configuration_spec.rb