osc_ruby 0.1.1 → 0.1.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.
- checksums.yaml +4 -4
- data/README.md +62 -33
- data/lib/osc_ruby/query_module.rb +6 -6
- data/lib/osc_ruby/service_product.rb +35 -14
- data/lib/osc_ruby/version.rb +1 -1
- data/spec/core/service_product_spec.rb +32 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e14e902577a5de33e8df4bfd1d69c10f57200397
|
4
|
+
data.tar.gz: f518a4aeb02c0a170fa80427aae13b8b7e43796e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 338ffa1f9a35271bb9d0039e4e7f02193ac37c593032f46d6c14edc700ec1b8b35df0dc321e17116b10a32349c03b2ca76bc64b100ab1b2a787c305e66e5a980
|
7
|
+
data.tar.gz: 09810e30982cde2bb3edc2a67d1145d6acc1f1bd302d0662c43124f0c9e1fc43eedd2154fdb620c98db413fe5beaab53dac7e4412d97cfbb6efa148b075ccb80
|
data/README.md
CHANGED
@@ -4,27 +4,51 @@
|
|
4
4
|
|
5
5
|
[](https://codeclimate.com/github/rajangdavis/osc_ruby/coverage)
|
6
6
|
|
7
|
+
[](https://travis-ci.org/rajangdavis/osc_ruby)
|
7
8
|
|
9
|
+
[](https://badge.fury.io/rb/osc_ruby)
|
8
10
|
|
9
|
-
An (under development) Ruby ORM for using Oracle Service Cloud influenced by the ConnectPHP API and ActiveRecord Gem
|
11
|
+
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
|
10
12
|
|
11
13
|
## Example (still coding this out, but trying to get this pretty simple)
|
12
14
|
|
13
15
|
# Configuration is as simple as requiring the gem
|
14
16
|
# and adding a config block (Completed 12/2016)
|
15
17
|
|
16
|
-
|
18
|
+
require 'osc_ruby'
|
17
19
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
rn_client = OSCRuby::Client.new do |config|
|
21
|
+
config.username = ENV['OSC_ADMIN']
|
22
|
+
config.password = ENV['OSC_PASSWORD']
|
23
|
+
config.interface = ENV['OSC_TEST_SITE']
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
# ServiceProduct Creation example (Completed 12/30/2016)
|
28
|
+
|
29
|
+
new_product = OSCRuby::ServiceProduct.new
|
30
|
+
|
31
|
+
# use Ruby hashes to set field information
|
32
|
+
|
33
|
+
new_product.names[0] = {'labelText' => 'QTH45-test', 'language' => {'id' => 1}}
|
34
|
+
new_product.names[1] = {'labelText' => 'QTH45-test', 'language' => {'id' => 11}}
|
35
|
+
|
36
|
+
new_product.parent = {'id' => 102}
|
37
|
+
|
38
|
+
new_product.displayOrder = 4
|
39
|
+
|
40
|
+
new_product.adminVisibleInterfaces[0] = {'id' => 1}
|
41
|
+
|
42
|
+
new_product.endUserVisibleInterfaces[0] = {'id' => 1}
|
43
|
+
|
44
|
+
new_product.create(rn_client)
|
45
|
+
|
46
|
+
# callback with JSON details
|
23
47
|
|
24
48
|
|
25
49
|
# ServiceProduct fetch example (Completed 12/28/2016)
|
26
50
|
|
27
|
-
product = ServiceProduct.find(rn_client,100)
|
51
|
+
product = OSCRuby::ServiceProduct.find(rn_client,100)
|
28
52
|
|
29
53
|
puts product
|
30
54
|
# => #<ServiceProduct:0x007fd0fa87e588>
|
@@ -53,27 +77,24 @@ An (under development) Ruby ORM for using Oracle Service Cloud influenced by the
|
|
53
77
|
# => QS Series
|
54
78
|
# => QT Series
|
55
79
|
|
56
|
-
#
|
80
|
+
# ServiceProduct update example
|
57
81
|
|
58
|
-
|
82
|
+
product_to_update = OSCRuby::ServiceProduct.find(rn_client,100)
|
59
83
|
|
60
|
-
|
84
|
+
product_to_update.names[0] = {'labelText' => 'name-updated', 'language' => {'id' => 1}}
|
61
85
|
|
62
|
-
|
63
|
-
new_product.names[1] = {'labelText' => 'QTH45-test', 'language' => {'id' => 11}}
|
64
|
-
|
65
|
-
new_product.parent = {'id' => 102}
|
86
|
+
product_to_update.update(rn_client)
|
66
87
|
|
67
|
-
|
88
|
+
# ServiceProduct updated
|
68
89
|
|
69
|
-
new_product.adminVisibleInterfaces[0] = {'id' => 1}
|
70
90
|
|
71
|
-
|
91
|
+
# ServiceProduct destroy example
|
72
92
|
|
73
|
-
|
93
|
+
product_to_delete = OSCRuby::ServiceProduct.find(rn_client,100)
|
74
94
|
|
75
|
-
|
95
|
+
product_to_delete.destroy(rn_client)
|
76
96
|
|
97
|
+
# ServiceProduct destroyed
|
77
98
|
|
78
99
|
## To do list
|
79
100
|
|
@@ -111,35 +132,43 @@ An (under development) Ruby ORM for using Oracle Service Cloud influenced by the
|
|
111
132
|
|
112
133
|
- [x] Create a OSCRuby::ServiceProduct class
|
113
134
|
|
114
|
-
- [x] Build a QueryModule Module with the following query methods to be shared between all classes:
|
135
|
+
- [x] Build a QueryModule Module with the following query methods to be shared between most if not all classes:
|
115
136
|
|
116
137
|
- [x] find
|
117
138
|
|
118
|
-
- [ ] take
|
119
|
-
|
120
|
-
- [ ] first
|
121
|
-
|
122
|
-
- [ ] last
|
123
|
-
|
124
|
-
- [ ] order
|
125
|
-
|
126
139
|
- [ ] find_by
|
127
140
|
|
128
141
|
- [ ] where
|
129
142
|
|
130
143
|
- [ ] all
|
131
144
|
|
132
|
-
- [
|
145
|
+
- [ ] Also add the following remaining CRUD Functionality:
|
146
|
+
|
147
|
+
- [ ] create
|
148
|
+
|
149
|
+
- [ ] update
|
150
|
+
|
151
|
+
- [ ] destroy
|
152
|
+
|
153
|
+
- [x] QueryModule converts JSON response into a Ruby Hash => new instance of the object being queried
|
154
|
+
|
155
|
+
- [ ] Create some validations for creating a ServiceProduct object
|
156
|
+
|
157
|
+
- [ ] Make OpenSSL::SSL::VERIFY_PEER the default with OpenSSL::SSL::VERIFY_NONE option set in the config class
|
158
|
+
|
159
|
+
- [ ] Make version default to 1.3 but an option to be set in the config class
|
160
|
+
|
161
|
+
- [ ] Allow for Session Authorization => update config class and connect classes, update tests
|
133
162
|
|
134
|
-
- [ ] Figure out how to do RDoc/Yardoc documentation or best in class documentation for using this Ruby
|
163
|
+
- [ ] Figure out how to do RDoc/Yardoc documentation or best in class documentation for using this Ruby ORM
|
135
164
|
|
136
165
|
- [ ] Add in VCR and WebMock as dependencies
|
137
166
|
|
138
167
|
- [ ] Figure out how to record and stub responses for a good response and bad response
|
139
168
|
|
140
|
-
- [ ] Simulate these responses
|
169
|
+
- [ ] Simulate these responses for ALL Connect HTTP methods
|
141
170
|
|
142
|
-
- [ ] Follow with next Classes (ServiceCategories, Answers,
|
171
|
+
- [ ] Follow with next Classes (ServiceCategories, Answers, Incidents)
|
143
172
|
|
144
173
|
- [ ] Release MVP
|
145
174
|
|
@@ -13,7 +13,7 @@ module OSCRuby
|
|
13
13
|
|
14
14
|
check_obj_for_errors(obj_to_find)
|
15
15
|
|
16
|
-
|
16
|
+
normalize(obj_to_find)
|
17
17
|
|
18
18
|
end
|
19
19
|
|
@@ -33,15 +33,15 @@ module OSCRuby
|
|
33
33
|
|
34
34
|
else
|
35
35
|
|
36
|
-
|
36
|
+
json_input = JSON.parse(input.body)
|
37
37
|
|
38
38
|
final_hash = []
|
39
39
|
|
40
|
-
|
40
|
+
json_input['items'][0]['rows'].each do |row|
|
41
41
|
|
42
42
|
obj_hash = {}
|
43
43
|
|
44
|
-
|
44
|
+
json_input['items'][0]['columnNames'].each_with_index do |column,i|
|
45
45
|
obj_hash[column] = if !row[i].nil? && row[i].is_i? == true then row[i].to_i else row[i] end
|
46
46
|
end
|
47
47
|
|
@@ -57,9 +57,9 @@ module OSCRuby
|
|
57
57
|
|
58
58
|
def self.check_obj_for_errors(obj_to_check)
|
59
59
|
|
60
|
-
|
60
|
+
json_obj = JSON.parse(obj_to_check.body)
|
61
61
|
|
62
|
-
if
|
62
|
+
if json_obj['items'][0]['rows'].count == 0
|
63
63
|
|
64
64
|
raise ArgumentError, 'There were no objects matching your query; please try again.'
|
65
65
|
|
@@ -15,7 +15,7 @@ module OSCRuby
|
|
15
15
|
|
16
16
|
def initialize(attributes = nil)
|
17
17
|
|
18
|
-
|
18
|
+
if attributes.nil?
|
19
19
|
|
20
20
|
@names = []
|
21
21
|
|
@@ -47,6 +47,20 @@ module OSCRuby
|
|
47
47
|
|
48
48
|
end
|
49
49
|
|
50
|
+
def create(client)
|
51
|
+
|
52
|
+
self.class.check_client(client)
|
53
|
+
|
54
|
+
new_product = self
|
55
|
+
|
56
|
+
final_json = self.class.check_self_for_create_method(new_product)
|
57
|
+
|
58
|
+
resource = URI.escape("/serviceProducts")
|
59
|
+
|
60
|
+
QueryModule::create(client,resource,final_json)
|
61
|
+
|
62
|
+
end
|
63
|
+
|
50
64
|
def self.find(client,id = nil)
|
51
65
|
|
52
66
|
check_client(client)
|
@@ -79,31 +93,38 @@ module OSCRuby
|
|
79
93
|
|
80
94
|
# end
|
81
95
|
|
82
|
-
# def create(client)
|
83
96
|
|
84
|
-
|
97
|
+
def self.new_from_fetch(attributes)
|
85
98
|
|
86
|
-
|
99
|
+
check_attributes(attributes)
|
87
100
|
|
88
|
-
|
101
|
+
OSCRuby::ServiceProduct.new(attributes)
|
89
102
|
|
90
|
-
|
103
|
+
end
|
91
104
|
|
92
|
-
|
105
|
+
def self.check_self_for_create_method(obj)
|
93
106
|
|
94
|
-
|
107
|
+
empty_arr = []
|
95
108
|
|
96
|
-
|
109
|
+
json_content = {}
|
97
110
|
|
98
|
-
|
111
|
+
obj.instance_variables.each {|var| json_content[var.to_s.delete("@")] = obj.instance_variable_get(var)}
|
112
|
+
|
113
|
+
empty_arr[0] = json_content
|
99
114
|
|
100
|
-
|
115
|
+
if empty_arr[0]['names'].count == 0
|
116
|
+
raise ArgumentError, 'ServiceProduct should at least have one name set (new_service_product.names[0] = "new product name" )'
|
117
|
+
end
|
101
118
|
|
102
|
-
|
119
|
+
if empty_arr[0]['adminVisibleInterfaces'].empty?
|
120
|
+
empty_arr[0].delete('adminVisibleInterfaces')
|
121
|
+
end
|
103
122
|
|
104
|
-
|
123
|
+
if empty_arr[0]['endUserVisibleInterfaces'].empty?
|
124
|
+
empty_arr[0].delete('endUserVisibleInterfaces')
|
125
|
+
end
|
105
126
|
|
106
|
-
|
127
|
+
empty_arr
|
107
128
|
|
108
129
|
end
|
109
130
|
|
data/lib/osc_ruby/version.rb
CHANGED
@@ -103,6 +103,38 @@ describe OSCRuby::ServiceProduct do
|
|
103
103
|
end
|
104
104
|
}
|
105
105
|
|
106
|
+
let(:new_service_product){
|
107
|
+
OSCRuby::ServiceProduct.new
|
108
|
+
}
|
109
|
+
|
110
|
+
context '#create' do
|
111
|
+
|
112
|
+
it 'should expect client is an instance of OSCRuby::Client class and raise an error if does not' do
|
113
|
+
|
114
|
+
expect(client).to be_an(OSCRuby::Client)
|
115
|
+
|
116
|
+
client = nil
|
117
|
+
|
118
|
+
expect{new_service_product.create(client)}.to raise_error('Client must have some configuration set; please create an instance of OSCRuby::Client with configuration settings')
|
119
|
+
|
120
|
+
end
|
121
|
+
|
122
|
+
it 'should check the object and make sure that it at least has a name set' do
|
123
|
+
|
124
|
+
expect{new_service_product.create(client)}.to raise_error('ServiceProduct should at least have one name set (new_service_product.names[0] = "new product name" )')
|
125
|
+
|
126
|
+
end
|
127
|
+
|
128
|
+
it 'should return the body object if it was created or not' do
|
129
|
+
|
130
|
+
new_service_product.names[0] = "new product name"
|
131
|
+
|
132
|
+
expect(new_service_product.create(client)).to be_a(String)
|
133
|
+
|
134
|
+
end
|
135
|
+
|
136
|
+
end
|
137
|
+
|
106
138
|
context '#find' do
|
107
139
|
|
108
140
|
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: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rajan Davis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-12-
|
11
|
+
date: 2016-12-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|