osc_ruby 0.0.9 → 0.0.10
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/.codeclimate.yml +25 -0
- data/.rubocop.yml +1156 -0
- data/.travis.yml +9 -5
- data/Gemfile +2 -0
- data/README.md +36 -29
- data/lib/osc_ruby/connect.rb +23 -8
- data/lib/osc_ruby/version.rb +1 -1
- data/spec/core/connect_spec.rb +23 -0
- data/spec/core/spec_helper.rb +3 -1
- metadata +4 -2
data/.travis.yml
CHANGED
@@ -1,7 +1,11 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
- 2.2.0
|
4
|
+
- jruby
|
5
|
+
addons:
|
6
|
+
code_climate:
|
7
|
+
repo_token:
|
8
|
+
secure: jhiFV5qK92z9GNZNgifvOmzoYmghcTFcuHYn21B5pkcIFmUJRYL03FK4QHqinFQ4BvjHnKlGTEgRPvglivvPBtIwpGMwuDF0oX0JHeTNLXuAXk8Dd6SAap+udSc2fOZYBg7H8PNmhSVpP97fYu23JsLmhRN8lnoO/yYyFUn/xUZIufOhpPj5RBMtR/XmxXiqS1tnsuHpSs7P+Kp/h6sr8QUOw1pJALEAqHGw2WmdxGrI76GQc0bylLFGMITkCbAiTxVQA3QnjLKFYCHq8zo1U0QZiW78+ubbV22oZS1EVATAb4SyqlqFd2bJA9wYjL2J4tYl1I+RvgVSspMsksHs72uIYHDTNSsEuQTnMCxtkq7WJLbYjRW3Tzbqn124ize/NmJqHcJ70Bc8Tzc3CkgEuJNF/cK266r0UkNTu+m65OTElyic14y+wCzeU8r/aDfX9vQKPBpOFpvHuoWMC54iiGIPjLVZb0AYvI2i3weK2dcCh7ZFD+FsFoMAzyaFFFJP4ANH7R08ewVpTjdud4O8WiQBJOW08dXE9inOF+4hqUho2FdrTWQLvMbanVXOmQXsODeEy7zxFUi1I1wVcX1AktEACmcX2ruose8UiScRu7Tr2R6mhgPa4UAf1YhhBClYafeqtCBi1rRrHkgOkaofhKbU3hHHF5cQwDP2v2jUYEI=
|
9
|
+
script: bundle exec rake spec
|
10
|
+
after_success:
|
11
|
+
- bundle exec codeclimate-test-reporter
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,14 +1,18 @@
|
|
1
1
|
# OSCRuby
|
2
2
|
|
3
|
+
[](https://codeclimate.com/github/rajangdavis/osc_ruby)
|
4
|
+
|
5
|
+
[](https://codeclimate.com/github/rajangdavis/osc_ruby/coverage)
|
6
|
+
|
3
7
|
Still developing this; will let ya know when this happens.
|
4
8
|
|
5
9
|
The basic idea is to be able to do something simple like import a csv of information and post it into an Oracle Service Cloud site.
|
6
10
|
|
7
11
|
The ultimate goal is to use this gem to make a Rails app for advanced administration/development that cannot be done with Oracle Service Cloud alone
|
8
12
|
|
9
|
-
|
13
|
+
## Example (still coding this out, but trying to get this pretty simple)
|
10
14
|
|
11
|
-
#
|
15
|
+
# Product Fetch example
|
12
16
|
|
13
17
|
client = OSCRuby::Client.new do |config|
|
14
18
|
config.interface = ENV['OSC_TEST_SITE']
|
@@ -20,9 +24,9 @@ The ultimate goal is to use this gem to make a Rails app for advanced administra
|
|
20
24
|
|
21
25
|
puts product.name
|
22
26
|
|
23
|
-
|
27
|
+
# puts 'Product Lookup Name'
|
24
28
|
|
25
|
-
#
|
29
|
+
# Product Creation example
|
26
30
|
|
27
31
|
names = []
|
28
32
|
|
@@ -47,54 +51,57 @@ The ultimate goal is to use this gem to make a Rails app for advanced administra
|
|
47
51
|
|
48
52
|
OSCRuby::ServiceProduct.save(client, new_prod)
|
49
53
|
|
50
|
-
|
54
|
+
# callback with JSON details
|
55
|
+
|
56
|
+
## TODO
|
57
|
+
|
58
|
+
- [x] Create a URL generator method into the Connect Class
|
51
59
|
|
52
|
-
|
60
|
+
- [x] Move tests for the get method into the URL generator method
|
53
61
|
|
54
|
-
|
55
|
-
<!-- Move tests for the get method into the URL generator method -->
|
62
|
+
- [x] Move check_config method into the URL generator method so that tests pass
|
56
63
|
|
57
|
-
|
64
|
+
- [x] Create more tests to validate the generated URL
|
58
65
|
|
59
|
-
|
66
|
+
- [x] Add in TravisCI into workflow to run tests and push and publish gem
|
60
67
|
|
61
|
-
|
68
|
+
- [x] Add in Code Climate or something to show the percentage of covered methods for testing
|
62
69
|
|
63
|
-
|
70
|
+
- [ ] Put the URL generator method into the get class
|
64
71
|
|
65
|
-
|
72
|
+
- [ ] Have the get method make a get request using the Net::HTTP class
|
66
73
|
|
67
|
-
|
74
|
+
- [ ] Need to add tests for passing resources, query/id/other param into the URL generator class
|
68
75
|
|
69
|
-
|
76
|
+
- [ ] Need to figure out how to pass resources and some sort of query/id/other param into the URL generator class
|
70
77
|
|
71
|
-
|
78
|
+
- [ ] Add in tests for Post requests
|
72
79
|
|
73
|
-
|
80
|
+
- [ ] Make a Post method
|
74
81
|
|
75
|
-
|
82
|
+
- [ ] Add in tests for update requests
|
76
83
|
|
77
|
-
|
84
|
+
- [ ] Make a update method
|
78
85
|
|
79
|
-
|
86
|
+
- [ ] Add in tests for delete requests
|
80
87
|
|
81
|
-
|
88
|
+
- [ ] Make a delete method
|
82
89
|
|
83
|
-
|
90
|
+
- [ ] I might need to do a transformation class that converts JSON response into a Ruby Hash
|
84
91
|
|
85
|
-
|
92
|
+
- [ ] Create a OSCRuby::ServiceProduct class
|
86
93
|
|
87
|
-
Figure out how to
|
94
|
+
- [ ] Figure out how to do RDoc/Yardoc documentation or best in class documentation for using this Ruby Wrapper
|
88
95
|
|
89
|
-
|
96
|
+
- [ ] Add in VCR and WebMock as dependencies
|
90
97
|
|
91
|
-
|
98
|
+
- [ ] Figure out how to record and stub responses for a good response and bad response
|
92
99
|
|
93
|
-
|
100
|
+
- [ ] Simulate these responses
|
94
101
|
|
95
|
-
Follow with next Classes (ServiceCategories, Answers, Interfaces)
|
102
|
+
- [ ] Follow with next Classes (ServiceCategories, Answers, Interfaces)
|
96
103
|
|
97
|
-
Release MVP
|
104
|
+
- [ ] Release MVP
|
98
105
|
|
99
106
|
## Installation
|
100
107
|
|
data/lib/osc_ruby/connect.rb
CHANGED
@@ -10,17 +10,31 @@ module OSCRuby
|
|
10
10
|
class Connect
|
11
11
|
|
12
12
|
def self.get(client,resource_url = nil)
|
13
|
-
# Net::HTTP.start(uri.host, uri.port,
|
14
|
-
# :use_ssl => true,
|
15
|
-
# :verify_mode => OpenSSL::SSL::VERIFY_NONE) do |http|
|
16
13
|
|
17
|
-
|
18
|
-
|
14
|
+
if client.nil?
|
15
|
+
raise ArgumentError, "Client must have some configuration set; please create an instance of OSCRuby::Client with configuration settings"
|
16
|
+
else
|
17
|
+
@final_config = generate_url_and_config(client)
|
18
|
+
end
|
19
|
+
|
20
|
+
@uri = @final_config['site_url']
|
21
|
+
@username = @final_config['username']
|
22
|
+
@password = @final_config['password']
|
19
23
|
|
20
|
-
|
24
|
+
Net::HTTP.start(@uri.host, @uri.port,
|
25
|
+
:use_ssl => true,
|
26
|
+
:verify_mode => OpenSSL::SSL::VERIFY_NONE) do |http|
|
21
27
|
|
22
|
-
|
23
|
-
|
28
|
+
request = Net::HTTP::Get.new @uri.request_uri
|
29
|
+
request.basic_auth @username, @password
|
30
|
+
|
31
|
+
response = http.request request # Net::HTTPResponse object
|
32
|
+
|
33
|
+
json_response = JSON.parse(response.body)
|
34
|
+
|
35
|
+
puts json_response
|
36
|
+
end
|
37
|
+
|
24
38
|
end
|
25
39
|
|
26
40
|
private
|
@@ -32,6 +46,7 @@ module OSCRuby
|
|
32
46
|
@config = client.config
|
33
47
|
|
34
48
|
@url = "https://" + @config.interface + ".custhelp.com/services/rest/connect/v1.3/#{resource_url}"
|
49
|
+
|
35
50
|
@final_uri = URI(@url)
|
36
51
|
|
37
52
|
@final_config = {'site_url' => @final_uri, 'username' => @config.username, 'password' => @config.password}
|
data/lib/osc_ruby/version.rb
CHANGED
data/spec/core/connect_spec.rb
CHANGED
@@ -109,6 +109,29 @@ describe OSCRuby::Connect do
|
|
109
109
|
|
110
110
|
context '#get' do
|
111
111
|
|
112
|
+
it 'should take at least a config parameter that is an instance of an OSCRuby::Client' do
|
113
|
+
|
114
|
+
expect(client).to be_an(OSCRuby::Client)
|
115
|
+
|
116
|
+
expect do
|
117
|
+
|
118
|
+
OSCRuby::Connect.get(client)
|
119
|
+
|
120
|
+
end.not_to raise_error
|
121
|
+
end
|
122
|
+
|
123
|
+
it 'should raise an error if client is nil' do
|
124
|
+
|
125
|
+
expect do
|
126
|
+
|
127
|
+
client = nil
|
128
|
+
|
129
|
+
OSCRuby::Connect.get(client)
|
130
|
+
|
131
|
+
end.to raise_error("Client must have some configuration set; please create an instance of OSCRuby::Client with configuration settings")
|
132
|
+
|
133
|
+
end
|
134
|
+
|
112
135
|
# it 'should produce a JSON Response' do
|
113
136
|
# expect do
|
114
137
|
|
data/spec/core/spec_helper.rb
CHANGED
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.0.
|
4
|
+
version: 0.0.10
|
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-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -60,8 +60,10 @@ executables: []
|
|
60
60
|
extensions: []
|
61
61
|
extra_rdoc_files: []
|
62
62
|
files:
|
63
|
+
- ".codeclimate.yml"
|
63
64
|
- ".gitignore"
|
64
65
|
- ".rspec"
|
66
|
+
- ".rubocop.yml"
|
65
67
|
- ".travis.yml"
|
66
68
|
- Gemfile
|
67
69
|
- LICENSE.txt
|