osc_ruby 0.1.8 → 0.1.9

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: 9479c24f1242d139221ddebe5f651f9daa9a2352
4
- data.tar.gz: 693034d0a473d3069c2072800991f7342ea0e793
3
+ metadata.gz: 147fb6cc739484cf85fab9b8b43f6ab197eeb240
4
+ data.tar.gz: afd7a03fc798c644d2d275a6e285528a32c01746
5
5
  SHA512:
6
- metadata.gz: 7f53b5e08cb805f9c511128746d6b1a96e4abc79a5c7690b77e0284c1972505be4764ecf5cdf2d51be11629999f6983f2f41145bb4ebc94735ec06554ff79a06
7
- data.tar.gz: fa8ce0a80ee596922beeb91242e0e9b819fa91badb58aad140d716806cdeeacba4fd41c9e66c495835fd2ec168f9472310e969cd1dab476a828819d9692ab99a
6
+ metadata.gz: 632fa408fe9ac6b9e7eac7521caceeed202b594f5f0d06607dbebf7c62b688eb98f4fb98b3351d38f583d52dc8773b77b4e63a3ab58bb57aba3c07fd8d4a331f
7
+ data.tar.gz: 2906a3b6b5a8208ed770aa9e4e3e010304226605058f7c3f2e6429f760a48a8e52a6701b74b81ff545a2feea5f99c7d806cb4855a88f050c396c7cfcf604b311
data/README.md CHANGED
@@ -9,86 +9,86 @@ An (under development) Ruby ORM for using Oracle Service Cloud influenced by the
9
9
  # Configuration is as simple as requiring the gem
10
10
  # and adding a config block (Completed 12/2016)
11
11
 
12
- require 'osc_ruby'
12
+ require 'osc_ruby'
13
13
 
14
- rn_client = OSCRuby::Client.new do |config|
15
- config.username = ENV['OSC_ADMIN']
16
- config.password = ENV['OSC_PASSWORD']
17
- config.interface = ENV['OSC_TEST_SITE']
18
- end
14
+ rn_client = OSCRuby::Client.new do |config|
15
+ config.username = ENV['OSC_ADMIN']
16
+ config.password = ENV['OSC_PASSWORD']
17
+ config.interface = ENV['OSC_TEST_SITE']
18
+ end
19
19
 
20
20
 
21
21
  # ServiceProduct Creation example (Completed 12/30/2016)
22
22
 
23
- new_product = OSCRuby::ServiceProduct.new
23
+ new_product = OSCRuby::ServiceProduct.new
24
24
 
25
- # use Ruby hashes to set field information
25
+ # use Ruby hashes to set field information
26
26
 
27
- new_product.names[0] = {'labelText' => 'QTH45-test', 'language' => {'id' => 1}}
28
- new_product.names[1] = {'labelText' => 'QTH45-test', 'language' => {'id' => 11}}
27
+ new_product.names[0] = {'labelText' => 'QTH45-test', 'language' => {'id' => 1}}
28
+ new_product.names[1] = {'labelText' => 'QTH45-test', 'language' => {'id' => 11}}
29
29
 
30
- new_product.parent = {'id' => 102}
30
+ new_product.parent = {'id' => 102}
31
31
 
32
- new_product.displayOrder = 4
32
+ new_product.displayOrder = 4
33
33
 
34
- new_product.adminVisibleInterfaces[0] = {'id' => 1}
34
+ new_product.adminVisibleInterfaces[0] = {'id' => 1}
35
35
 
36
- new_product.endUserVisibleInterfaces[0] = {'id' => 1}
36
+ new_product.endUserVisibleInterfaces[0] = {'id' => 1}
37
37
 
38
- new_product.create(rn_client)
38
+ new_product.create(rn_client)
39
39
 
40
- # callback with JSON details
40
+ # callback with JSON details
41
41
 
42
42
 
43
43
  # ServiceProduct fetch example (Completed 12/28/2016)
44
44
 
45
- product = OSCRuby::ServiceProduct.find(rn_client,100)
45
+ product = OSCRuby::ServiceProduct.find(rn_client,100)
46
46
 
47
- puts product
48
- # => #<ServiceProduct:0x007fd0fa87e588>
47
+ puts product
48
+ # => #<ServiceProduct:0x007fd0fa87e588>
49
49
 
50
- puts product.name
51
- # => QR404
50
+ puts product.name
51
+ # => QR404
52
52
 
53
- puts product.displayOrder
54
- # => 3
53
+ puts product.displayOrder
54
+ # => 3
55
55
 
56
56
  # ServiceProduct fetch all example
57
57
 
58
- products = OSCRuby::ServiceProduct.all(rn_client)
58
+ products = OSCRuby::ServiceProduct.all(rn_client)
59
59
 
60
- products.each do |p|
60
+ products.each do |p|
61
61
 
62
- puts p.name
62
+ puts p.name
63
63
 
64
- end
64
+ end
65
65
 
66
- # => Unsure
67
- # => DVR/NVR
68
- # => QC Series
69
- # => QR Series
70
- # => QR404
71
- # => QS Series
72
- # => QT Series
66
+ # => Unsure
67
+ # => DVR/NVR
68
+ # => QC Series
69
+ # => QR Series
70
+ # => QR404
71
+ # => QS Series
72
+ # => QT Series
73
73
 
74
74
  # ServiceProduct update example
75
75
 
76
- product_to_update = OSCRuby::ServiceProduct.find(rn_client,100)
76
+ product_to_update = OSCRuby::ServiceProduct.find(rn_client,100)
77
77
 
78
- product_to_update.names[0] = {'labelText' => 'name-updated', 'language' => {'id' => 1}}
78
+ product_to_update.names[0] = {'labelText' => 'name-updated', 'language' => {'id' => 1}}
79
79
 
80
- product_to_update.update(rn_client)
80
+ product_to_update.update(rn_client)
81
81
 
82
- # ServiceProduct updated
82
+ # ServiceProduct updated
83
83
 
84
84
 
85
85
  # ServiceProduct destroy example
86
86
 
87
- product_to_delete = OSCRuby::ServiceProduct.find(rn_client,100)
87
+ product_to_delete = OSCRuby::ServiceProduct.find(rn_client,100)
88
88
 
89
- product_to_delete.destroy(rn_client)
89
+ product_to_delete.destroy(rn_client)
90
90
 
91
- # ServiceProduct destroyed
91
+ # ServiceProduct destroyed
92
92
  ```
93
93
 
94
94
  ## To do list
@@ -139,7 +139,7 @@ An (under development) Ruby ORM for using Oracle Service Cloud influenced by the
139
139
 
140
140
  - [ ] Also add the following remaining CRUD Functionality:
141
141
 
142
- - [ ] create
142
+ - [x] create
143
143
 
144
144
  - [ ] update
145
145
 
@@ -147,7 +147,7 @@ An (under development) Ruby ORM for using Oracle Service Cloud influenced by the
147
147
 
148
148
  - [x] QueryModule converts JSON response into a Ruby Hash => new instance of the object being queried
149
149
 
150
- - [ ] Create some validations for creating a ServiceProduct object
150
+ - [x] Create some validations for creating a ServiceProduct object
151
151
 
152
152
  - [ ] Make OpenSSL::SSL::VERIFY_PEER the default with OpenSSL::SSL::VERIFY_NONE option set in the config class
153
153
 
@@ -59,19 +59,25 @@ module OSCRuby
59
59
 
60
60
  response_body = JSON.parse(response.body)
61
61
 
62
- puts response_body
63
-
64
62
  if response.code.to_i == 201 && return_json == false
65
63
 
66
64
  self.id = response_body['id'].to_i
67
65
 
68
- self.name = response_body['name']
66
+ self.name = response_body["lookupName"]
69
67
 
70
68
  self.lookupName = response_body["lookupName"]
71
69
 
72
70
  self.displayOrder = response_body["displayOrder"]
73
71
 
74
- self.parent = response_body["parent"]
72
+ if !response_body["parent"].nil?
73
+
74
+ self.parent = response_body["parent"]["links"][0]["href"].split('/').pop.to_i
75
+
76
+ else
77
+
78
+ self.parent = nil
79
+
80
+ end
75
81
 
76
82
  elsif return_json == true
77
83
 
@@ -125,11 +131,9 @@ module OSCRuby
125
131
 
126
132
  empty_arr = []
127
133
 
128
- json_content = {}
134
+ empty_arr[0] = {}
129
135
 
130
- obj.instance_variables.each {|var| json_content[var.to_s.delete("@")] = obj.instance_variable_get(var)}
131
-
132
- empty_arr[0] = json_content
136
+ obj.instance_variables.each {|var| empty_arr[0][var.to_s.delete("@")] = obj.instance_variable_get(var)}
133
137
 
134
138
  if empty_arr[0]['names'].count == 0 || empty_arr[0]['names'][0]['labelText'].nil? || empty_arr[0]['names'][0]['language'].nil?
135
139
  raise ArgumentError, 'ServiceProduct should at least have one name set (new_service_product.names[0] = {"labelText" => "QTH45-test", "language" => {"id" => 1}} )'
@@ -143,7 +147,7 @@ module OSCRuby
143
147
  empty_arr[0].delete('endUserVisibleInterfaces')
144
148
  end
145
149
 
146
- if !empty_arr[0]['parent'].key?('id') && !empty_arr[0]['parent'].key?('name')
150
+ if !empty_arr[0]['parent'].key?('id') && !empty_arr[0]['parent'].key?('lookupName')
147
151
  empty_arr[0].delete('parent')
148
152
  end
149
153
 
@@ -1,3 +1,3 @@
1
1
  module OSCRuby
2
- VERSION = "0.1.8"
2
+ VERSION = "0.1.9"
3
3
  end
@@ -143,8 +143,8 @@ describe OSCRuby::ServiceProduct do
143
143
 
144
144
  it 'should return an instance of an OSCRuby::ServiceProduct if the json_response param is set to false (which it is by default)' do
145
145
 
146
- new_service_product.names[0] = {"labelText" => "QTH45-test", "language" => {"id" => 1}}
147
- new_service_product.names[1] = {'labelText' => 'QTH45-test', 'language' => {'id' => 11}}
146
+ new_service_product.names[0] = {"labelText" => "QTH45", "language" => {"id" => 1}}
147
+ new_service_product.names[1] = {"labelText" => "QTH45", "language" => {"id" => 11}}
148
148
 
149
149
  new_service_product.parent = {'id' => 102}
150
150
 
@@ -154,13 +154,13 @@ describe OSCRuby::ServiceProduct do
154
154
 
155
155
  expect(new_service_product).to be_a(OSCRuby::ServiceProduct)
156
156
 
157
- expect(new_service_product.name).to eq("QTH45-test")
157
+ expect(new_service_product.name).to eq("QTH45")
158
158
 
159
- expect(new_service_product.lookupName).to eq("QTH45-test")
159
+ expect(new_service_product.lookupName).to eq("QTH45")
160
160
 
161
161
  expect(new_service_product.displayOrder).to eq(4)
162
162
 
163
- # expect(new_service_product.parent).to eq(102)
163
+ expect(new_service_product.parent).to eq(102)
164
164
 
165
165
  end
166
166
 
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.1.8
4
+ version: 0.1.9
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-05 00:00:00.000000000 Z
11
+ date: 2017-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler