osc_ruby 0.0.8 → 0.0.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 +4 -4
- data/.travis.yml +7 -0
- data/Gemfile +4 -0
- data/README.md +90 -0
- data/example.rb +1 -1
- data/lib/osc_ruby/client.rb +0 -22
- data/lib/osc_ruby/connect.rb +62 -0
- data/lib/osc_ruby/version.rb +1 -1
- data/lib/osc_ruby.rb +2 -1
- data/osc_ruby.gemspec +1 -1
- data/spec/core/client_spec.rb +0 -14
- data/spec/core/connect_spec.rb +120 -0
- metadata +10 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b82a5d228fa182fe5a73df7f71b36b23e92ad59
|
4
|
+
data.tar.gz: bb5d960406ed2bf3fbddce9da64c32813ae83d38
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aedf18269daa81d4236bbe809efe35ea007abdd6561d93256968f11db9cfb03cd390d06bfd13d2ba3d41af95162903e15e78a6808d28567b1480edaae3b9c6e7
|
7
|
+
data.tar.gz: ae20c909f4d475ffa2b164a8b9dc861fa0e029b3327fa1c94fa9e4bece0691111c6b173fec6260bed8815abd9207f310267ad6d041edb1e58385223342b400d2
|
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -6,6 +6,96 @@ The basic idea is to be able to do something simple like import a csv of informa
|
|
6
6
|
|
7
7
|
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
8
|
|
9
|
+
# Example (still coding this out, but trying to get this pretty simple)
|
10
|
+
|
11
|
+
# // Product Fetch example
|
12
|
+
|
13
|
+
client = OSCRuby::Client.new do |config|
|
14
|
+
config.interface = ENV['OSC_TEST_SITE']
|
15
|
+
config.username = ENV['OSC_ADMIN']
|
16
|
+
config.password = ENV['OSC_PASSWORD']
|
17
|
+
end
|
18
|
+
|
19
|
+
product = OSCRuby::ServiceProduct.fetch(1)
|
20
|
+
|
21
|
+
puts product.name
|
22
|
+
|
23
|
+
// puts 'Product Lookup Name'
|
24
|
+
|
25
|
+
# // Product Creation example
|
26
|
+
|
27
|
+
names = []
|
28
|
+
|
29
|
+
names[0] = {:labelText => 'QTH45', :language => {:id => 1}}
|
30
|
+
names[1] = {:labelText => 'QTH45', :language => {:id => 11}}
|
31
|
+
|
32
|
+
parent = {:id => 102}
|
33
|
+
|
34
|
+
displayOrder = {:id => 4}
|
35
|
+
|
36
|
+
admin_user_visible_interfaces = []
|
37
|
+
admin_user_visible_interfaces[0] = {:id => 1}
|
38
|
+
|
39
|
+
end_user_visible_interfaces = []
|
40
|
+
end_user_visible_interfaces[0] = {:id => 1}
|
41
|
+
|
42
|
+
new_prod = []
|
43
|
+
new_prod[0] = {:names => names,
|
44
|
+
:parent => parent,
|
45
|
+
:adminVisibleInterfaces => admin_user_visible_interfaces,
|
46
|
+
:endUserVisibleInterfaces => end_user_visible_interfaces}
|
47
|
+
|
48
|
+
OSCRuby::ServiceProduct.save(client, new_prod)
|
49
|
+
|
50
|
+
// callback with JSON details
|
51
|
+
|
52
|
+
# TODO
|
53
|
+
|
54
|
+
<!-- Create a URL generator method into the Connect Class -->
|
55
|
+
<!-- Move tests for the get method into the URL generator method -->
|
56
|
+
|
57
|
+
<!-- Move check_config method into the URL generator method so that tests pass -->
|
58
|
+
|
59
|
+
<!-- Create more tests to validate the generated URL -->
|
60
|
+
|
61
|
+
Put the URL generator method into the get class
|
62
|
+
|
63
|
+
Have the get method make a get request using the Net::HTTP class
|
64
|
+
|
65
|
+
Need to add tests for passing resources, query/id/other param into the URL generator class
|
66
|
+
|
67
|
+
Need to figure out how to pass resources and some sort of query/id/other param into the URL generator class
|
68
|
+
|
69
|
+
Add in tests for Post requests
|
70
|
+
|
71
|
+
Make a Post method
|
72
|
+
|
73
|
+
Add in tests for update requests
|
74
|
+
|
75
|
+
Make a update method
|
76
|
+
|
77
|
+
Add in tests for delete requests
|
78
|
+
|
79
|
+
Make a delete method
|
80
|
+
|
81
|
+
Create a OSCRuby::ServiceProduct class
|
82
|
+
|
83
|
+
Figure out how to do RDoc/Yardoc documentation or best in class documentation for using this Ruby Wrapper
|
84
|
+
|
85
|
+
Add in VCR and WebMock as dependencies
|
86
|
+
|
87
|
+
Figure out how to record and stub responses for a good response and bad response
|
88
|
+
|
89
|
+
Simulate these responses
|
90
|
+
|
91
|
+
Add in TravisCI into workflow to run tests and push and publish gem
|
92
|
+
|
93
|
+
Add in Code Climate? or something to show the percentage of covered methods for testing
|
94
|
+
|
95
|
+
Follow with next Classes (ServiceCategories, Answers, Interfaces)
|
96
|
+
|
97
|
+
Release MVP
|
98
|
+
|
9
99
|
## Installation
|
10
100
|
|
11
101
|
Add this line to your application's Gemfile:
|
data/example.rb
CHANGED
data/lib/osc_ruby/client.rb
CHANGED
@@ -1,7 +1,3 @@
|
|
1
|
-
require 'net/http'
|
2
|
-
require 'openssl'
|
3
|
-
require 'json'
|
4
|
-
|
5
1
|
require 'osc_ruby/version'
|
6
2
|
require 'osc_ruby/configuration'
|
7
3
|
|
@@ -33,23 +29,5 @@ module OSCRuby
|
|
33
29
|
|
34
30
|
true
|
35
31
|
end
|
36
|
-
|
37
|
-
# def connect
|
38
|
-
|
39
|
-
# url = 'https://' + config.interface + '.custhelp.com/services/rest/connect/v1.3/'
|
40
|
-
# uri = URI.parse(url)
|
41
|
-
|
42
|
-
# Net::HTTP.start(uri.host, uri.port,
|
43
|
-
# :use_ssl => true,
|
44
|
-
# :verify_mode => OpenSSL::SSL::VERIFY_NONE) do |http|
|
45
|
-
|
46
|
-
# request = Net::HTTP::Get.new uri.request_uri
|
47
|
-
# request.basic_auth config.username, config.password
|
48
|
-
|
49
|
-
# response = http.request request # Net::HTTPResponse object
|
50
|
-
|
51
|
-
# json_response = JSON.parse(response.body)
|
52
|
-
# end
|
53
|
-
# end
|
54
32
|
end
|
55
33
|
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'osc_ruby/client'
|
2
|
+
|
3
|
+
require 'net/http'
|
4
|
+
require 'openssl'
|
5
|
+
require 'json'
|
6
|
+
require 'uri'
|
7
|
+
|
8
|
+
module OSCRuby
|
9
|
+
|
10
|
+
class Connect
|
11
|
+
|
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
|
+
|
17
|
+
# request = Net::HTTP::Get.new uri.request_uri
|
18
|
+
# request.basic_auth config.username, config.password
|
19
|
+
|
20
|
+
# response = http.request request # Net::HTTPResponse object
|
21
|
+
|
22
|
+
# json_response = JSON.parse(response.body)
|
23
|
+
# end
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def self.generate_url_and_config(client,resource_url = nil)
|
29
|
+
|
30
|
+
check_client_config(client)
|
31
|
+
|
32
|
+
@config = client.config
|
33
|
+
|
34
|
+
@url = "https://" + @config.interface + ".custhelp.com/services/rest/connect/v1.3/#{resource_url}"
|
35
|
+
@final_uri = URI(@url)
|
36
|
+
|
37
|
+
@final_config = {'site_url' => @final_uri, 'username' => @config.username, 'password' => @config.password}
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.check_client_config(client)
|
42
|
+
|
43
|
+
if client.nil?
|
44
|
+
raise ArgumentError, "Client must have some configuration set; please create an instance of OSCRuby::Client with configuration settings"
|
45
|
+
else
|
46
|
+
@config = client.config
|
47
|
+
end
|
48
|
+
|
49
|
+
if @config.nil?
|
50
|
+
raise ArgumentError, "Client configuration cannot be nil or blank"
|
51
|
+
elsif @config.interface.nil?
|
52
|
+
raise ArgumentError, "The configured client interface cannot be nil or blank"
|
53
|
+
elsif @config.username.nil?
|
54
|
+
raise ArgumentError, "The configured client username cannot be nil or blank"
|
55
|
+
elsif @config.password.nil?
|
56
|
+
raise ArgumentError, "The configured client password cannot be nil or blank"
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
data/lib/osc_ruby/version.rb
CHANGED
data/lib/osc_ruby.rb
CHANGED
data/osc_ruby.gemspec
CHANGED
data/spec/core/client_spec.rb
CHANGED
@@ -55,18 +55,4 @@ describe OSCRuby::Client do
|
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end
|
58
|
-
|
59
|
-
# context '#connect' do
|
60
|
-
# it 'should produce a JSON Response' do
|
61
|
-
# expect do
|
62
|
-
# client = OSCRuby::Client.new do |config|
|
63
|
-
# config.interface = 'qsee--tst'
|
64
|
-
# config.username = ENV['OSC_ADMIN']
|
65
|
-
# config.password = ENV['OSC_PASSWORD']
|
66
|
-
# end
|
67
|
-
|
68
|
-
# client.connect.should_be a('String')
|
69
|
-
# end
|
70
|
-
# end
|
71
|
-
# end
|
72
58
|
end
|
@@ -0,0 +1,120 @@
|
|
1
|
+
require 'core/spec_helper'
|
2
|
+
|
3
|
+
describe OSCRuby::Connect do
|
4
|
+
|
5
|
+
subject { connect }
|
6
|
+
|
7
|
+
let(:client) {
|
8
|
+
|
9
|
+
OSCRuby::Client.new do |config|
|
10
|
+
|
11
|
+
config.interface = ENV['OSC_TEST_SITE']
|
12
|
+
|
13
|
+
config.username = ENV['OSC_ADMIN']
|
14
|
+
|
15
|
+
config.password = ENV['OSC_PASSWORD']
|
16
|
+
|
17
|
+
end
|
18
|
+
}
|
19
|
+
|
20
|
+
context '#generate_url_and_config' do
|
21
|
+
|
22
|
+
it 'should take at least a config parameter that is an instance of an OSCRuby::Client' do
|
23
|
+
|
24
|
+
expect(client).to be_an(OSCRuby::Client)
|
25
|
+
|
26
|
+
expect do
|
27
|
+
|
28
|
+
OSCRuby::Connect.generate_url_and_config(client)
|
29
|
+
|
30
|
+
end.not_to raise_error
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should raise an error if client is nil' do
|
34
|
+
|
35
|
+
expect do
|
36
|
+
|
37
|
+
client = nil
|
38
|
+
|
39
|
+
OSCRuby::Connect.generate_url_and_config(client)
|
40
|
+
|
41
|
+
end.to raise_error("Client must have some configuration set; please create an instance of OSCRuby::Client with configuration settings")
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should raise an error if client.config is nil' do
|
46
|
+
|
47
|
+
expect do
|
48
|
+
|
49
|
+
client.config = nil
|
50
|
+
|
51
|
+
OSCRuby::Connect.generate_url_and_config(client)
|
52
|
+
|
53
|
+
end.to raise_error("Client configuration cannot be nil or blank")
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'should raise an error if client interface is absent' do
|
58
|
+
|
59
|
+
expect do
|
60
|
+
|
61
|
+
client.config.interface = nil
|
62
|
+
|
63
|
+
OSCRuby::Connect.generate_url_and_config(client)
|
64
|
+
|
65
|
+
end.to raise_error("The configured client interface cannot be nil or blank")
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'should raise an error if client username is absent' do
|
70
|
+
|
71
|
+
expect do
|
72
|
+
|
73
|
+
client.config.username = nil
|
74
|
+
|
75
|
+
OSCRuby::Connect.generate_url_and_config(client)
|
76
|
+
|
77
|
+
end.to raise_error("The configured client username cannot be nil or blank")
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'should raise an error if client password is absent' do
|
82
|
+
|
83
|
+
expect do
|
84
|
+
|
85
|
+
client.config.password = nil
|
86
|
+
|
87
|
+
OSCRuby::Connect.generate_url_and_config(client)
|
88
|
+
|
89
|
+
end.to raise_error("The configured client password cannot be nil or blank")
|
90
|
+
|
91
|
+
end
|
92
|
+
|
93
|
+
|
94
|
+
it 'should create an Hash object with a site_url, username, password properties' do
|
95
|
+
|
96
|
+
final_config = OSCRuby::Connect.generate_url_and_config(client)
|
97
|
+
|
98
|
+
expect(final_config).to be_an(Hash)
|
99
|
+
|
100
|
+
expect(final_config['site_url']).to be_an(URI::HTTPS)
|
101
|
+
|
102
|
+
expect(final_config['username']).to eq(ENV['OSC_ADMIN'])
|
103
|
+
|
104
|
+
expect(final_config['password']).to eq(ENV['OSC_PASSWORD'])
|
105
|
+
|
106
|
+
end
|
107
|
+
|
108
|
+
end
|
109
|
+
|
110
|
+
context '#get' do
|
111
|
+
|
112
|
+
# it 'should produce a JSON Response' do
|
113
|
+
# expect do
|
114
|
+
|
115
|
+
|
116
|
+
# client.connect.should_be a('String')
|
117
|
+
# end
|
118
|
+
# end
|
119
|
+
end
|
120
|
+
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.0.
|
4
|
+
version: 0.0.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: 2016-12-
|
11
|
+
date: 2016-12-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -42,16 +42,16 @@ dependencies:
|
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 3.2.0
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 3.2.0
|
55
55
|
description: An unofficial Ruby wrapper for the Oracle Cloud Services (fka RightNow
|
56
56
|
Technologies) REST API
|
57
57
|
email:
|
@@ -62,6 +62,7 @@ extra_rdoc_files: []
|
|
62
62
|
files:
|
63
63
|
- ".gitignore"
|
64
64
|
- ".rspec"
|
65
|
+
- ".travis.yml"
|
65
66
|
- Gemfile
|
66
67
|
- LICENSE.txt
|
67
68
|
- README.md
|
@@ -70,10 +71,12 @@ files:
|
|
70
71
|
- lib/osc_ruby.rb
|
71
72
|
- lib/osc_ruby/client.rb
|
72
73
|
- lib/osc_ruby/configuration.rb
|
74
|
+
- lib/osc_ruby/connect.rb
|
73
75
|
- lib/osc_ruby/version.rb
|
74
76
|
- osc_ruby.gemspec
|
75
77
|
- spec/core/client_spec.rb
|
76
78
|
- spec/core/configuration_spec.rb
|
79
|
+
- spec/core/connect_spec.rb
|
77
80
|
- spec/core/spec_helper.rb
|
78
81
|
- tasks/rspec.rake
|
79
82
|
homepage: https://github.com/rajangdavis/osc_ruby
|
@@ -103,4 +106,5 @@ summary: Making the best of opensource and enterprise technology
|
|
103
106
|
test_files:
|
104
107
|
- spec/core/client_spec.rb
|
105
108
|
- spec/core/configuration_spec.rb
|
109
|
+
- spec/core/connect_spec.rb
|
106
110
|
- spec/core/spec_helper.rb
|