debitech_soap 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ 0.0.3
2
+
3
+ Added support for Java style method names.
4
+
1
5
  0.0.2
2
6
 
3
7
  Removed activesupport dependency.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- debitech_soap (0.0.1)
4
+ debitech_soap (0.0.2)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
data/lib/debitech_soap.rb CHANGED
@@ -8,20 +8,24 @@ module DebitechSoap
8
8
 
9
9
  RETURN_DATA = %w{aCSUrl acquirerAddress acquirerAuthCode acquirerAuthResponseCode acquirerCity acquirerConsumerLimit acquirerErrorDescription acquirerFirstName acquirerLastName acquirerMerchantLimit acquirerZipCode amount errorMsg infoCode infoDescription pAReqMsg resultCode resultText verifyID}
10
10
 
11
- PARAMS = { "settle" => ["verifyID", "transID", "amount", "extra"],
12
- "subscribe_and_settle" => ["verifyID", "transID", "data", "ip", "extra"],
13
- "authorize" => ["billingFirstName", "billingLastName", "billingAddress", "billingCity",
14
- "billingCountry", "cc", "expM", "expY", "eMail", "ip", "data", "currency", "transID", "extra"],
15
- "authorizeAndSettle3DS" => ["verifyID", "paRes", "extra"],
16
- "refund" => ["verifyID", "transID", "amount", "extra"],
17
- "askIf3DSEnrolled" => ["billingFirstName", "billingLastName", "billingAddress", "billingCity",
18
- "billingCountry", "cc", "expM", "expY", "eMail", "ip", "data", "currency", "transID",
19
- "httpAcceptHeader", "httpUserAgentHeader", "method", "referenceNo", "extra"],
20
- "auth_reversal" => ["verifyID", "amount", "transID", "extra"],
21
- "authorize3DS" => ["verifyID", "paRes", "extra"],
22
- "subscribe" => ["verifyID", "transID", "data", "ip", "extra"],
23
- "authorize_and_settle" => ["billingFirstName", "billingLastName", "billingAddress", "billingCity", "billingCountry",
24
- "cc", "expM", "expY", "eMail", "ip", "data", "currency", "transID", "extra"] }
11
+ PARAMS = { %w(settle) => ["verifyID", "transID", "amount", "extra"],
12
+ %w(subscribeAndSettle subscribe_and_settle) \
13
+ => ["verifyID", "transID", "data", "ip", "extra"],
14
+ %w(authorize) => ["billingFirstName", "billingLastName", "billingAddress", "billingCity",
15
+ "billingCountry", "cc", "expM", "expY", "eMail", "ip", "data", "currency", "transID", "extra"],
16
+ %w(authorizeAndSettle3DS authorize_and_settle_3ds) \
17
+ => ["verifyID", "paRes", "extra"],
18
+ %w(refund) => ["verifyID", "transID", "amount", "extra"],
19
+ %w(askIf3DSEnrolled ask_if_3ds_enrolled) \
20
+ => ["billingFirstName", "billingLastName", "billingAddress", "billingCity",
21
+ "billingCountry", "cc", "expM", "expY", "eMail", "ip", "data", "currency", "transID",
22
+ "httpAcceptHeader", "httpUserAgentHeader", "method", "referenceNo", "extra"],
23
+ %w(authReversal auth_reversal) => ["verifyID", "amount", "transID", "extra"],
24
+ %w(authorize3DS authorize_3ds) => ["verifyID", "paRes", "extra"],
25
+ %w(subscribe) => ["verifyID", "transID", "data", "ip", "extra"],
26
+ %w(authorizeAndSettle authorize_and_settle) \
27
+ => ["billingFirstName", "billingLastName", "billingAddress", "billingCity", "billingCountry",
28
+ "cc", "expM", "expY", "eMail", "ip", "data", "currency", "transID", "extra"] }
25
29
 
26
30
  def initialize(opts = {})
27
31
  @api_credentials = {}
@@ -45,7 +49,7 @@ module DebitechSoap
45
49
  private
46
50
 
47
51
  def define_java_wrapper_methods!
48
- PARAMS.keys.each { |method|
52
+ PARAMS.keys.flatten.each { |method|
49
53
  (class << self; self; end).class_eval do # Doc:
50
54
  define_method(method) do |*args| # def refund(*args)
51
55
  attributes = @api_credentials.clone
@@ -53,13 +57,13 @@ module DebitechSoap
53
57
  if args.first.is_a?(Hash)
54
58
  attributes.merge!(args.first)
55
59
  else
56
- parameter_order = PARAMS[method.to_s]
60
+ parameter_order = api_signature(method).last
57
61
  args.each_with_index { |argument, i|
58
62
  attributes[parameter_order[i].to_sym] = argument
59
63
  }
60
64
  end
61
65
 
62
- return_data @client.send(method, attributes).return
66
+ return_data @client.send(api_signature(method).first.first, attributes).return
63
67
  end # end
64
68
  end
65
69
  }
@@ -95,5 +99,9 @@ module DebitechSoap
95
99
  end
96
100
  end
97
101
 
102
+ def api_signature(method)
103
+ PARAMS.find {|key,value| key.include?(method.to_s) }
104
+ end
105
+
98
106
  end
99
107
  end
@@ -18,7 +18,7 @@ module DebitechSoap
18
18
  if first_letter_in_uppercase
19
19
  self.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
20
20
  else
21
- self.to_s[0].chr.downcase + camelize(lower_case_and_underscored_word)[1..1]
21
+ self.to_s[0].chr.downcase + self.camelcase[1..-1]
22
22
  end
23
23
  end
24
24
  end
@@ -1,3 +1,3 @@
1
1
  module DebitechSoap
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -50,7 +50,15 @@ describe DebitechSoap::API, "calling a method with java-style arguments" do
50
50
  and_return(MockSoapResult.new)
51
51
  api.refund(1234567, 23456, 100, "extra")
52
52
  end
53
-
53
+
54
+ it "should camel case method names" do
55
+ api = DebitechSoap::API.new(:merchant => "merchant_name", :username => "api_user_name", :password => "api_user_password")
56
+ @client.should_receive("authorize3DS").with(:verifyID => 1234567, :paRes => "RES", :extra => "extra",
57
+ :shopName => "merchant_name", :userName => "api_user_name", :password => "api_user_password").
58
+ and_return(MockSoapResult.new)
59
+ api.authorize_3ds(1234567, "RES", "extra")
60
+ end
61
+
54
62
  it "should not keep old attributes when making subsequent api calls" do
55
63
  api = DebitechSoap::API.new(:merchant => "merchant_name", :username => "api_user_name", :password => "api_user_password")
56
64
  @client.should_receive("refund").with(:verifyID => 1234567, :transID => 23456, :amount => 100, :extra => "extra",
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: debitech_soap
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - "Joakim Kolsj\xC3\xB6"