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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fa0b858de02b3d93f7394e6b2b2b86de5bd544c7
4
- data.tar.gz: de7c1bc1b95797567c9789ee960af85b7b498cc2
3
+ metadata.gz: e492a8204ba370b3a1cb5ad2557d393b7c89ab57
4
+ data.tar.gz: 9f4cac8333e5a1d241b50c4948cf062f70265656
5
5
  SHA512:
6
- metadata.gz: 6b8441e9c2d9edfef640a416d84dfa10a52fba29417361652e53376f275fad4a121cc54ac3347bd769b1707a8cd263dcaf9d3c2bb683dd9a52fa7de28c0f962b
7
- data.tar.gz: 9fb7c71a6538567f39e6f9a5acc986c535b481e82920a994fb1c460a7164968b426b661e865528918049d75baedc12a383a87455b68bf5f5414d0a1aa01d2a43
6
+ metadata.gz: 8f8cb1924e2736aab95decd6f42ad5df06fe58ab9df48065af300706d3de7dffa81dd8f759ab772394481a37a3228f90c3bdf059a32fe1a38eef41552b23940c
7
+ data.tar.gz: bda56c6357a89945c27c20c8f158ea91838dac242d0b0aae3167413185a40e985082ab662fc6d3342992b3387b7ee0609ffe1fd592e7e3425ed71247552533a0
data/CHANGELOG.md CHANGED
@@ -10,6 +10,11 @@
10
10
 
11
11
  * [Fixed]
12
12
 
13
+ ## 0.3.1 / 2015-08-28
14
+
15
+ * [Fixed]
16
+ * Amount xml generation
17
+
13
18
  ## 0.3.0 / 2015-08-25
14
19
 
15
20
  * [Added]
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
- - order reference - original transaction reference you want to refund. Required for Refund. Not required for CFT Refund.
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.
@@ -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['__content__']
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'] = 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 && attrs_hash.stringify_keys
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
- XmlDoc.elements(xml_tag_name => @attributes_hash).first
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
@@ -33,7 +33,7 @@ module Securetrading
33
33
  end
34
34
 
35
35
  def billing
36
- Billing.new(amount: @amount).ox_xml
36
+ Billing.new(amount: { content: @amount }).ox_xml
37
37
  end
38
38
 
39
39
  def merchant
@@ -1,3 +1,3 @@
1
1
  module Securetrading
2
- VERSION = '0.3.0'
2
+ VERSION = '0.3.1'
3
3
  end
@@ -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.0
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-25 00:00:00.000000000 Z
11
+ date: 2015-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty