conduit 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/conduit/blueprints/generators/action.tt +0 -1
- data/lib/conduit/blueprints/generators/blueprints/action.tt +0 -2
- data/lib/conduit/blueprints/parsers/base.tt +17 -34
- data/lib/conduit/cli.rb +1 -1
- data/lib/conduit/core/action.rb +2 -2
- data/lib/conduit/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3bb1b8f51e94f9a01e34b93b204ddcc665f0fa97
|
4
|
+
data.tar.gz: 83f0645c72bea202ad14ee8feda10aeb2a343847
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 017b4f44d22ef1b74dd5d032ca1a8f52978e4e27abf59e730144d6a818891425613433b3a8e360174d7e06dbd4c4dfed0568b92a0a4fa7ce479136f474d47835
|
7
|
+
data.tar.gz: 41918d02a479a3fc530ca6061dc54d2982543f37cf7ac43b79ea4e43f5fdc64f48eb8fd9ad5f375f92dc70d6883c10480fe739742fa9849a6372345d7119cb3a
|
@@ -2,8 +2,6 @@ require_relative "base"
|
|
2
2
|
|
3
3
|
module Conduit::Driver::<%= classified_name %>
|
4
4
|
class <%%= classified_name %> < Conduit::Driver::<%= classified_name %>::Base
|
5
|
-
operation :<%%= underscored_name %>
|
6
|
-
|
7
5
|
# Required attributes go here
|
8
6
|
# required_attributes :required_attribute_name
|
9
7
|
|
@@ -18,7 +18,7 @@ module Conduit::Driver::<%= classified_name %>
|
|
18
18
|
# Extracts the camelized attribute from the xml response
|
19
19
|
def self.attribute(attr_name, &block)
|
20
20
|
block ||= lambda do
|
21
|
-
content_for "//#{
|
21
|
+
content_for "//#{inflector_method(attr_name)}"
|
22
22
|
end
|
23
23
|
super(attr_name, &block)
|
24
24
|
end
|
@@ -57,12 +57,8 @@ module Conduit::Driver::<%= classified_name %>
|
|
57
57
|
# Returns normalized request errors if present.
|
58
58
|
def response_errors
|
59
59
|
if response_content?
|
60
|
-
if
|
61
|
-
|
62
|
-
else
|
63
|
-
# Returns empty array if no errors
|
64
|
-
normalized_errors
|
65
|
-
end
|
60
|
+
# Returns empty array if no errors
|
61
|
+
normalized_errors
|
66
62
|
else
|
67
63
|
[Conduit::Error.new(message: "Unexpected response from server.")]
|
68
64
|
end
|
@@ -76,42 +72,29 @@ module Conduit::Driver::<%= classified_name %>
|
|
76
72
|
|
77
73
|
private
|
78
74
|
|
75
|
+
# Camelize `attr_name` while keeping first character lower case
|
76
|
+
def inflector_method attr_name
|
77
|
+
ActiveSupport::Inflector.camelize(attr_name, false)
|
78
|
+
end
|
79
|
+
|
79
80
|
# Indicates if a request is in progress. Used for async requests.
|
80
81
|
# Should be overwritten in the action's parser in case true.
|
81
82
|
def in_progress?
|
82
83
|
false
|
83
84
|
end
|
84
85
|
|
85
|
-
# Returns
|
86
|
-
# and
|
87
|
-
def normalized_fault
|
88
|
-
# TODO: replace this if error message and code not present in the
|
89
|
-
# below paths
|
90
|
-
Conduit::Error.new({
|
91
|
-
message: content_for("//Fault//Text"),
|
92
|
-
code: content_for("//Fault//Code//Value")
|
93
|
-
})
|
94
|
-
end
|
95
|
-
|
96
|
-
# Extracts the error from either `errorMessage` or `errorText`
|
97
|
-
def error_response
|
98
|
-
# TODO: replace this if error response not present in any of the following
|
99
|
-
# paths.
|
100
|
-
content_for("//errorMessage") || content_for("//errorText")
|
101
|
-
end
|
102
|
-
|
103
|
-
# Returns a new `Conduit::Error` instance containing the error message and
|
104
|
-
# its code.
|
86
|
+
# Returns an array of `Conduit::Error` instances containing the error
|
87
|
+
# messages and codes.
|
105
88
|
def normalized_errors
|
106
|
-
# TODO: replace this if error not present in `
|
107
|
-
#
|
108
|
-
if
|
109
|
-
|
89
|
+
# TODO: replace this if error not present in `error` node or `code` and
|
90
|
+
# `message` paths different.
|
91
|
+
if content_for("//error")
|
92
|
+
root.xpath("//error").map do |error|
|
110
93
|
Conduit::Error.new({
|
111
|
-
message:
|
112
|
-
code: content_for("
|
94
|
+
message: content_for("message", error),
|
95
|
+
code: content_for("code", error)
|
113
96
|
})
|
114
|
-
|
97
|
+
end
|
115
98
|
else
|
116
99
|
[]
|
117
100
|
end
|
data/lib/conduit/cli.rb
CHANGED
@@ -113,7 +113,7 @@ module Conduit
|
|
113
113
|
# add gemspec dependencies
|
114
114
|
str = " # Dependencies\n"\
|
115
115
|
" #\n"\
|
116
|
-
" spec.add_dependency \"conduit\", \"~> 1.0.
|
116
|
+
" spec.add_dependency \"conduit\", \"~> 1.0.4\"\n"\
|
117
117
|
" # xml parser\n"\
|
118
118
|
" spec.add_dependency \"nokogiri\"\n"\
|
119
119
|
" # to get string inflectors\n"\
|
data/lib/conduit/core/action.rb
CHANGED
@@ -136,7 +136,7 @@ module Conduit
|
|
136
136
|
#
|
137
137
|
def perform_request
|
138
138
|
response = request(body: view, method: :post)
|
139
|
-
parser_instance =
|
139
|
+
parser_instance = parser_class.new(response.body)
|
140
140
|
|
141
141
|
Conduit::ApiResponse.new(raw_response: response, parser: parser_instance)
|
142
142
|
end
|
@@ -189,7 +189,7 @@ module Conduit
|
|
189
189
|
# Returns the parser for this action subclasses responsible for providing
|
190
190
|
# the response_body and response_status.
|
191
191
|
#
|
192
|
-
def
|
192
|
+
def parser_class
|
193
193
|
self.class.const_get(:Parser)
|
194
194
|
end
|
195
195
|
|
data/lib/conduit/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: conduit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Kelley
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -237,7 +237,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
237
237
|
version: '0'
|
238
238
|
requirements: []
|
239
239
|
rubyforge_project:
|
240
|
-
rubygems_version: 2.
|
240
|
+
rubygems_version: 2.2.2
|
241
241
|
signing_key:
|
242
242
|
specification_version: 4
|
243
243
|
summary: Conduit is an interface for debit platforms.
|