soap_adapters 0.0.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/Gemfile +6 -0
- data/LICENSE.md +7 -0
- data/LICENSE.txt +22 -0
- data/README.md +57 -0
- data/Rakefile +2 -0
- data/lib/soap_adapters.rb +5 -0
- data/lib/soap_adapters/savon.rb +34 -0
- data/lib/soap_adapters/version.rb +3 -0
- data/soap_adapters.gemspec +27 -0
- data/spec/lib/soap_adapters/savon_spec.rb +53 -0
- data/spec/spec_helper.rb +4 -0
- metadata +144 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2d6dbef0b4e53fcddce347f22e0b380d4dce45cc
|
4
|
+
data.tar.gz: bc80a049c96f79b9b19332ddfaa17add4e46393f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6034c0105099ebfa33131795c142133ed8027dacbef2e32dfa9ac4608feee5602eaa458f37e3665c939bbf08b163f7b08d544017fb39f6e97be54dd561359ef8
|
7
|
+
data.tar.gz: 350557fe24622988b175018ce216fb309e8b8db4bdf88aa868c205e148704b69f4c6334f14a23df218dcdb076ad5302322aff2ea5d71c032714f29c19ec668e3
|
data/.gitignore
ADDED
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,57 @@
|
|
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
|
+
)
|
33
|
+
|
34
|
+
response = adapter.call(:make_reservation, message: {username: "abc"})
|
35
|
+
|
36
|
+
adapter.last_xml_request # Returns the XML of the last request
|
37
|
+
|
38
|
+
response.xml # Returns the XML of the response
|
39
|
+
```
|
40
|
+
|
41
|
+
## Contributing
|
42
|
+
|
43
|
+
1. Fork it ( https://github.com/[my-github-username]/soap_adapters/fork )
|
44
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
45
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
46
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
47
|
+
5. Create a new Pull Request
|
48
|
+
|
49
|
+
## License
|
50
|
+
|
51
|
+
Copyright 2015 G5
|
52
|
+
|
53
|
+
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:
|
54
|
+
|
55
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
56
|
+
|
57
|
+
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,34 @@
|
|
1
|
+
module SoapAdapters
|
2
|
+
class Savon
|
3
|
+
|
4
|
+
include Virtus.model
|
5
|
+
CLIENT_ATTRS = %i[wsdl logger log ssl_version]
|
6
|
+
|
7
|
+
attribute :wsdl, String
|
8
|
+
attribute :logger
|
9
|
+
attribute :log, Boolean, default: true
|
10
|
+
attribute :ssl_version, String, default: :TLSv1
|
11
|
+
attribute :last_request, String
|
12
|
+
|
13
|
+
def ssl_version
|
14
|
+
@ssl_version || :TLSv1
|
15
|
+
end
|
16
|
+
|
17
|
+
def call(*args)
|
18
|
+
result = client.call(*args)
|
19
|
+
self.last_request = client.build_request(*args).body
|
20
|
+
result
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def client
|
26
|
+
args = CLIENT_ATTRS.reduce({}) do |hash, attr|
|
27
|
+
hash[attr] = self.attributes.fetch(attr)
|
28
|
+
hash
|
29
|
+
end
|
30
|
+
::Savon.client(args)
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
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"
|
8
|
+
spec.version = SoapAdapters::VERSION
|
9
|
+
spec.authors = ["Ramon Tayag"]
|
10
|
+
spec.email = ["G5", "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,53 @@
|
|
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, String).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
|
+
end
|
52
|
+
|
53
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,144 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: soap_adapters
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ramon Tayag
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: virtus
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.7'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.7'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: virtus-matchers
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: savon
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: Common interface to soap clients
|
98
|
+
email:
|
99
|
+
- G5
|
100
|
+
- ramon.tayag@gmail.com
|
101
|
+
- lateam@getg5.com
|
102
|
+
executables: []
|
103
|
+
extensions: []
|
104
|
+
extra_rdoc_files: []
|
105
|
+
files:
|
106
|
+
- ".gitignore"
|
107
|
+
- Gemfile
|
108
|
+
- LICENSE.md
|
109
|
+
- LICENSE.txt
|
110
|
+
- README.md
|
111
|
+
- Rakefile
|
112
|
+
- lib/soap_adapters.rb
|
113
|
+
- lib/soap_adapters/savon.rb
|
114
|
+
- lib/soap_adapters/version.rb
|
115
|
+
- soap_adapters.gemspec
|
116
|
+
- spec/lib/soap_adapters/savon_spec.rb
|
117
|
+
- spec/spec_helper.rb
|
118
|
+
homepage: ''
|
119
|
+
licenses:
|
120
|
+
- MIT
|
121
|
+
metadata: {}
|
122
|
+
post_install_message:
|
123
|
+
rdoc_options: []
|
124
|
+
require_paths:
|
125
|
+
- lib
|
126
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '0'
|
131
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
132
|
+
requirements:
|
133
|
+
- - ">="
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
version: '0'
|
136
|
+
requirements: []
|
137
|
+
rubyforge_project:
|
138
|
+
rubygems_version: 2.4.3
|
139
|
+
signing_key:
|
140
|
+
specification_version: 4
|
141
|
+
summary: Common interface to soap clients
|
142
|
+
test_files:
|
143
|
+
- spec/lib/soap_adapters/savon_spec.rb
|
144
|
+
- spec/spec_helper.rb
|