amazon_flex_pay 0.9.3 → 0.9.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/amazon_flex_pay.rb +2 -2
- data/lib/amazon_flex_pay/model.rb +7 -8
- data/test/amazon_flex_pay_test.rb +3 -1
- metadata +3 -3
data/lib/amazon_flex_pay.rb
CHANGED
@@ -5,7 +5,7 @@ require 'openssl'
|
|
5
5
|
require 'rubygems'
|
6
6
|
require 'rest_client'
|
7
7
|
require 'multi_xml'
|
8
|
-
require 'active_support/
|
8
|
+
require 'active_support/inflector' # camelcase, underscore
|
9
9
|
|
10
10
|
require 'amazon_flex_pay/signing'
|
11
11
|
require 'amazon_flex_pay/model'
|
@@ -16,7 +16,7 @@ require 'amazon_flex_pay/api'
|
|
16
16
|
require 'amazon_flex_pay/pipelines'
|
17
17
|
|
18
18
|
module AmazonFlexPay
|
19
|
-
VERSION = '0.9.
|
19
|
+
VERSION = '0.9.4'
|
20
20
|
API_VERSION = '2010-08-28'
|
21
21
|
PIPELINE_VERSION = '2009-01-09'
|
22
22
|
|
@@ -96,20 +96,16 @@ module AmazonFlexPay
|
|
96
96
|
assign(hash)
|
97
97
|
end
|
98
98
|
|
99
|
-
protected
|
100
|
-
|
101
99
|
# Formats all attributes into a hash of parameters.
|
102
100
|
def to_hash
|
103
101
|
self.class.attribute_names.inject({}) do |hash, name|
|
104
|
-
val = send(name.underscore)
|
105
|
-
|
106
|
-
hash
|
107
|
-
else
|
108
|
-
hash.merge(format_key(name) => val.is_a?(AmazonFlexPay::Model) ? val.to_hash : format_value(val))
|
109
|
-
end
|
102
|
+
val = format_value(send(name.underscore))
|
103
|
+
val.empty? ? hash : hash.merge(format_key(name) => val)
|
110
104
|
end
|
111
105
|
end
|
112
106
|
|
107
|
+
protected
|
108
|
+
|
113
109
|
# By default all parameter keys are CamelCase.
|
114
110
|
def format_key(key)
|
115
111
|
key.camelcase
|
@@ -118,6 +114,9 @@ module AmazonFlexPay
|
|
118
114
|
# Formats times and booleans as Amazon desires them.
|
119
115
|
def format_value(val)
|
120
116
|
case val
|
117
|
+
when AmazonFlexPay::Model
|
118
|
+
val.to_hash
|
119
|
+
|
121
120
|
when Time
|
122
121
|
val.utc.strftime('%Y-%m-%dT%H:%M:%SZ')
|
123
122
|
|
@@ -48,11 +48,13 @@ class AmazonFlexPayTest < AmazonFlexPay::Test
|
|
48
48
|
|
49
49
|
class Response < AmazonFlexPay::API::Base::BaseResponse; end
|
50
50
|
end
|
51
|
-
|
51
|
+
|
52
52
|
should "respond with data structures even when models are empty" do
|
53
53
|
tr = TestRequest.new
|
54
54
|
assert tr.stuffs.is_a?(Array)
|
55
55
|
assert tr.amount.respond_to?(:value)
|
56
|
+
assert !tr.to_hash.has_key?('Stuffs')
|
57
|
+
assert !tr.to_hash.has_key?('Amount')
|
56
58
|
end
|
57
59
|
|
58
60
|
should "add necessary fields and sign api requests" do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: amazon_flex_pay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 51
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 9
|
9
|
-
-
|
10
|
-
version: 0.9.
|
9
|
+
- 4
|
10
|
+
version: 0.9.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Lance Ivy
|