soap_adapters_fork 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/CHANGELOG.md +12 -0
- data/Gemfile +6 -0
- data/LICENSE.md +7 -0
- data/LICENSE.txt +22 -0
- data/README.md +59 -0
- data/Rakefile +2 -0
- data/lib/soap_adapters.rb +5 -0
- data/lib/soap_adapters/savon.rb +37 -0
- data/lib/soap_adapters/version.rb +3 -0
- data/soap_adapters.gemspec +27 -0
- data/spec/lib/soap_adapters/savon_spec.rb +81 -0
- data/spec/spec_helper.rb +4 -0
- metadata +146 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a88f7871c5da2cf37ef027bfa90c3e196839290f
|
4
|
+
data.tar.gz: 66c7c7694250de457c4da823491a6ded4ff3ece7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 877257be00bbecdd6f83f06a2863d9929f7e6c1d4ac385286c5f5a8b3c7af9ef07c8862d5e8db19e0d7d7da4a8b8b4eb029b3dd45b9804a5262d1d9663d686d7
|
7
|
+
data.tar.gz: 42292d3165023ea6417b583ef0343d14fca059b419d1781bf1a1d9448f0fbd13ede108e9857b28d37327cf7a8c5e9728f0b0de6ba57e3535a6e80d8455baed23
|
data/.gitignore
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# v0.1.0
|
2
|
+
|
3
|
+
- Adds support for open and read timeouts
|
4
|
+
|
5
|
+
# v0.0.2
|
6
|
+
|
7
|
+
- Fix bug where `:ssl_version` is a string when it should be a symbol
|
8
|
+
- Fix bug where attributes with nil values are passed into `Savon.client` (like a nil logger)
|
9
|
+
|
10
|
+
# v0.0.1
|
11
|
+
|
12
|
+
Initial version
|
data/Gemfile
ADDED
data/LICENSE.md
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
Copyright 2015 G5
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
4
|
+
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
6
|
+
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Ramon Tayag
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# SoapAdapters
|
2
|
+
|
3
|
+
Defines a way to interact with different SOAP gems.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'savon' # Currently, only Savon is supported. In the future, you will install the gem you need.
|
11
|
+
gem 'soap_adapters'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install soap_adapters
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
require "soap_adapters/savon"
|
26
|
+
|
27
|
+
adapter = SoapAdapters::Savon.new(
|
28
|
+
wsdl: "https://myservice.com?WSDL",
|
29
|
+
logger: MyLogger.new,
|
30
|
+
log: false,
|
31
|
+
ssl_version: :TLSv1, # optional; defaults to :TLSv1,
|
32
|
+
open_timeout: 30,
|
33
|
+
read_timeout: 10
|
34
|
+
)
|
35
|
+
|
36
|
+
response = adapter.call(:make_reservation, message: {username: "abc"})
|
37
|
+
|
38
|
+
adapter.last_xml_request # Returns the XML of the last request
|
39
|
+
|
40
|
+
response.xml # Returns the XML of the response
|
41
|
+
```
|
42
|
+
|
43
|
+
## Contributing
|
44
|
+
|
45
|
+
1. Fork it ( https://github.com/[my-github-username]/soap_adapters/fork )
|
46
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
47
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
48
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
49
|
+
5. Create a new Pull Request
|
50
|
+
|
51
|
+
## License
|
52
|
+
|
53
|
+
Copyright 2015 G5
|
54
|
+
|
55
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
56
|
+
|
57
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
58
|
+
|
59
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
module SoapAdapters
|
2
|
+
class Savon
|
3
|
+
|
4
|
+
include Virtus.model
|
5
|
+
CLIENT_ATTRS = %i[wsdl logger log ssl_version open_timeout read_timeout]
|
6
|
+
|
7
|
+
attribute :wsdl, String
|
8
|
+
attribute :logger
|
9
|
+
attribute :log, Boolean, default: true
|
10
|
+
attribute :ssl_version, Symbol, default: :TLSv1
|
11
|
+
attribute :last_request, String
|
12
|
+
attribute :open_timeout, Integer
|
13
|
+
attribute :read_timeout, Integer
|
14
|
+
|
15
|
+
def ssl_version
|
16
|
+
@ssl_version || :TLSv1
|
17
|
+
end
|
18
|
+
|
19
|
+
def call(*args)
|
20
|
+
result = client.call(*args)
|
21
|
+
self.last_request = client.build_request(*args).body
|
22
|
+
result
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def client
|
28
|
+
args = CLIENT_ATTRS.reduce({}) do |hash, attr|
|
29
|
+
val = self.attributes.fetch(attr)
|
30
|
+
hash[attr] = val unless val.nil?
|
31
|
+
hash
|
32
|
+
end
|
33
|
+
::Savon.client(args)
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'soap_adapters/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "soap_adapters_fork"
|
8
|
+
spec.version = SoapAdapters::VERSION
|
9
|
+
spec.authors = ["G5", "Ramon Tayag", "Michael Mitchell"]
|
10
|
+
spec.email = ["ramon.tayag@gmail.com", "lateam@getg5.com"]
|
11
|
+
spec.summary = %q{Common interface to soap clients}
|
12
|
+
spec.description = %q{Common interface to soap clients}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "virtus"
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
25
|
+
spec.add_development_dependency "virtus-matchers"
|
26
|
+
spec.add_development_dependency "savon"
|
27
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require "savon"
|
3
|
+
require "soap_adapters/savon"
|
4
|
+
|
5
|
+
describe SoapAdapters::Savon do
|
6
|
+
|
7
|
+
describe "attributes" do
|
8
|
+
subject { described_class }
|
9
|
+
it { is_expected.to have_attribute(:wsdl, String) }
|
10
|
+
it { is_expected.to have_attribute(:logger) }
|
11
|
+
it { is_expected.to have_attribute(:log).with_default(true) }
|
12
|
+
it do
|
13
|
+
is_expected.to have_attribute(:ssl_version, Symbol).with_default(:TLSv1)
|
14
|
+
end
|
15
|
+
it { is_expected.to have_attribute(:last_request, String) }
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "#call" do
|
19
|
+
let(:client_args) do
|
20
|
+
[
|
21
|
+
:action,
|
22
|
+
message: {
|
23
|
+
unit_id: "unit_id",
|
24
|
+
}
|
25
|
+
]
|
26
|
+
end
|
27
|
+
let(:client) { double(Savon::Client) }
|
28
|
+
let(:built_request) { double(body: "request_xml") }
|
29
|
+
let(:response) { double(to_s: "response_xml", xml: "response_xml") }
|
30
|
+
let(:logger) { double }
|
31
|
+
|
32
|
+
before do
|
33
|
+
allow(::Savon).to receive(:client).with(hash_including(
|
34
|
+
wsdl: "wsdl",
|
35
|
+
logger: logger,
|
36
|
+
log: true,
|
37
|
+
)).and_return(client)
|
38
|
+
allow(client).to receive(:build_request).with(*client_args).
|
39
|
+
and_return(built_request)
|
40
|
+
allow(client).to receive(:call).with(*client_args).
|
41
|
+
and_return(response)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "makes a soap call and sets the last request and response" do
|
45
|
+
adapter = described_class.new(wsdl: "wsdl", logger: logger, log: true)
|
46
|
+
r = adapter.call(*client_args)
|
47
|
+
expect(adapter.last_request).to eq "request_xml"
|
48
|
+
expect(r.to_s).to eq "response_xml"
|
49
|
+
expect(r.xml).to eq "response_xml"
|
50
|
+
end
|
51
|
+
|
52
|
+
it "instantiates a Savon client passing only arguments that are present" do
|
53
|
+
allow(::Savon).to receive(:client).with(
|
54
|
+
wsdl: "wsdl",
|
55
|
+
log: false,
|
56
|
+
ssl_version: :TLSv1,
|
57
|
+
).and_return(client)
|
58
|
+
adapter = described_class.new(wsdl: "wsdl", log: false)
|
59
|
+
r = adapter.call(*client_args)
|
60
|
+
expect(adapter.last_request).to eq "request_xml"
|
61
|
+
expect(r.to_s).to eq "response_xml"
|
62
|
+
expect(r.xml).to eq "response_xml"
|
63
|
+
end
|
64
|
+
|
65
|
+
it "sets the open_timeout and read_timeout if declared" do
|
66
|
+
allow(::Savon).to receive(:client).with(
|
67
|
+
wsdl: "wsdl",
|
68
|
+
log: false,
|
69
|
+
ssl_version: :TLSv1,
|
70
|
+
open_timeout: 30,
|
71
|
+
read_timeout: 10
|
72
|
+
).and_return(client)
|
73
|
+
adapter = described_class.new(wsdl: "wsdl", log: false, open_timeout: 30, read_timeout: 10)
|
74
|
+
r = adapter.call(*client_args)
|
75
|
+
expect(adapter.last_request).to eq "request_xml"
|
76
|
+
expect(r.to_s).to eq "response_xml"
|
77
|
+
expect(r.xml).to eq "response_xml"
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,146 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: soap_adapters_fork
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- G5
|
8
|
+
- Ramon Tayag
|
9
|
+
- Michael Mitchell
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2016-10-28 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: virtus
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - ">="
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: '0'
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: bundler
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - "~>"
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '1.7'
|
36
|
+
type: :development
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - "~>"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '1.7'
|
43
|
+
- !ruby/object:Gem::Dependency
|
44
|
+
name: rake
|
45
|
+
requirement: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '10.0'
|
50
|
+
type: :development
|
51
|
+
prerelease: false
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - "~>"
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '10.0'
|
57
|
+
- !ruby/object:Gem::Dependency
|
58
|
+
name: rspec
|
59
|
+
requirement: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - "~>"
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '3.0'
|
64
|
+
type: :development
|
65
|
+
prerelease: false
|
66
|
+
version_requirements: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - "~>"
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '3.0'
|
71
|
+
- !ruby/object:Gem::Dependency
|
72
|
+
name: virtus-matchers
|
73
|
+
requirement: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
type: :development
|
79
|
+
prerelease: false
|
80
|
+
version_requirements: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
- !ruby/object:Gem::Dependency
|
86
|
+
name: savon
|
87
|
+
requirement: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
type: :development
|
93
|
+
prerelease: false
|
94
|
+
version_requirements: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
description: Common interface to soap clients
|
100
|
+
email:
|
101
|
+
- ramon.tayag@gmail.com
|
102
|
+
- lateam@getg5.com
|
103
|
+
executables: []
|
104
|
+
extensions: []
|
105
|
+
extra_rdoc_files: []
|
106
|
+
files:
|
107
|
+
- ".gitignore"
|
108
|
+
- CHANGELOG.md
|
109
|
+
- Gemfile
|
110
|
+
- LICENSE.md
|
111
|
+
- LICENSE.txt
|
112
|
+
- README.md
|
113
|
+
- Rakefile
|
114
|
+
- lib/soap_adapters.rb
|
115
|
+
- lib/soap_adapters/savon.rb
|
116
|
+
- lib/soap_adapters/version.rb
|
117
|
+
- soap_adapters.gemspec
|
118
|
+
- spec/lib/soap_adapters/savon_spec.rb
|
119
|
+
- spec/spec_helper.rb
|
120
|
+
homepage: ''
|
121
|
+
licenses:
|
122
|
+
- MIT
|
123
|
+
metadata: {}
|
124
|
+
post_install_message:
|
125
|
+
rdoc_options: []
|
126
|
+
require_paths:
|
127
|
+
- lib
|
128
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0'
|
133
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - ">="
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '0'
|
138
|
+
requirements: []
|
139
|
+
rubyforge_project:
|
140
|
+
rubygems_version: 2.5.1
|
141
|
+
signing_key:
|
142
|
+
specification_version: 4
|
143
|
+
summary: Common interface to soap clients
|
144
|
+
test_files:
|
145
|
+
- spec/lib/soap_adapters/savon_spec.rb
|
146
|
+
- spec/spec_helper.rb
|