securetrading 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/Guardfile +7 -0
- data/README.md +1 -1
- data/lib/securetrading/amount.rb +6 -2
- data/lib/securetrading/base_model.rb +14 -2
- data/lib/securetrading/refund.rb +1 -1
- data/lib/securetrading/version.rb +1 -1
- data/lib/securetrading/xml_doc.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e492a8204ba370b3a1cb5ad2557d393b7c89ab57
|
4
|
+
data.tar.gz: 9f4cac8333e5a1d241b50c4948cf062f70265656
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f8cb1924e2736aab95decd6f42ad5df06fe58ab9df48065af300706d3de7dffa81dd8f759ab772394481a37a3228f90c3bdf059a32fe1a38eef41552b23940c
|
7
|
+
data.tar.gz: bda56c6357a89945c27c20c8f158ea91838dac242d0b0aae3167413185a40e985082ab662fc6d3342992b3387b7ee0609ffe1fd592e7e3425ed71247552533a0
|
data/CHANGELOG.md
CHANGED
data/Guardfile
CHANGED
@@ -18,6 +18,13 @@ group :red_green_refactor, halt_on_fail: true do
|
|
18
18
|
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
|
19
19
|
Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance'
|
20
20
|
end
|
21
|
+
|
22
|
+
# BaseModel subclasses
|
23
|
+
watch('lib/securetrading/base_model.rb') do
|
24
|
+
%w(amount billing record response).map do |name|
|
25
|
+
"spec/securetrading/#{name}_spec.rb"
|
26
|
+
end
|
27
|
+
end
|
21
28
|
end
|
22
29
|
|
23
30
|
guard :rubocop, all_on_start: false, cli: ['--rails', '--auto-correct'] do
|
data/README.md
CHANGED
@@ -44,7 +44,7 @@ Currently supported methods:
|
|
44
44
|
|
45
45
|
Parameters:
|
46
46
|
- amount - refunded amount in cents
|
47
|
-
-
|
47
|
+
- parent_transaction - original transaction reference you want to refund.
|
48
48
|
- options - Hash of options.
|
49
49
|
- merchant - Check XML specification for merchant xml tags.
|
50
50
|
- account_type - default to ECOM. If you want to set different ```accounttypedescription``` xml tag you should set this option.
|
data/lib/securetrading/amount.rb
CHANGED
@@ -1,12 +1,16 @@
|
|
1
1
|
module Securetrading
|
2
2
|
class Amount < BaseModel
|
3
|
+
def currency_code
|
4
|
+
attributes_hash['currencycode']
|
5
|
+
end
|
6
|
+
|
3
7
|
def value
|
4
|
-
attributes_hash['
|
8
|
+
attributes_hash['content']
|
5
9
|
end
|
6
10
|
|
7
11
|
def ox_xml
|
8
12
|
el = XmlDoc.new_element(xml_tag_name)
|
9
|
-
el['currencycode'] =
|
13
|
+
el['currencycode'] = currency_code if currency_code.present?
|
10
14
|
el << value.to_s
|
11
15
|
end
|
12
16
|
end
|
@@ -1,15 +1,27 @@
|
|
1
1
|
module Securetrading
|
2
2
|
class BaseModel
|
3
3
|
def initialize(attrs_hash = {})
|
4
|
-
@attributes_hash = attrs_hash.presence &&
|
4
|
+
@attributes_hash = attrs_hash.presence &&
|
5
|
+
attrs_hash.transform_keys! { |k| k.to_s.tr('__', '') }
|
5
6
|
end
|
6
7
|
|
7
8
|
def ox_xml
|
8
|
-
|
9
|
+
ox = ox_from_values
|
10
|
+
sub_classes.each do |sub_class_name|
|
11
|
+
next unless attributes_hash.key?(sub_class_name)
|
12
|
+
ox << send(sub_class_name).ox_xml
|
13
|
+
end
|
14
|
+
ox
|
9
15
|
end
|
10
16
|
|
11
17
|
private
|
12
18
|
|
19
|
+
def ox_from_values
|
20
|
+
XmlDoc
|
21
|
+
.elements(xml_tag_name => @attributes_hash.except(*sub_classes))
|
22
|
+
.first
|
23
|
+
end
|
24
|
+
|
13
25
|
def xml_tag_name
|
14
26
|
self.class.name.demodulize.downcase
|
15
27
|
end
|
data/lib/securetrading/refund.rb
CHANGED
@@ -16,7 +16,7 @@ module Securetrading
|
|
16
16
|
|
17
17
|
# rubocop:disable Metrics/MethodLength
|
18
18
|
def self.elements(hash)
|
19
|
-
return '' unless hash.present?
|
19
|
+
return [''] unless hash.present?
|
20
20
|
hash.flat_map do |k, v|
|
21
21
|
return v.flat_map { |e| elements(k => e) } if v.is_a?(Array)
|
22
22
|
el = new_element(k.to_s)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: securetrading
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bitgamelabs
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|