pp-adaptive 0.0.6 → 1.0.0

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: f0a9349a12a78ad24953831058c1a14dc60771ae
4
- data.tar.gz: 9bb8f0de539e9bcb33306b5abd87fb9efe07687f
3
+ metadata.gz: 25264e4f7b4b30721e9025b888007bdb6301e8e1
4
+ data.tar.gz: 3ecf88f709c167305f46d96fa96860224823063f
5
5
  SHA512:
6
- metadata.gz: 3da9fe529d691e3c2176a449f73cccfbd9faae4125a56cbb1b63daa3b6b13db7b38ac861c98e4ce0d2bea2f8e7865815b79362c4b3f83678dcfa48bdcc0b872b
7
- data.tar.gz: 5c2244c0a5fe57b2dd10664e99ed3bee452b508c22b113145eee1b2e0237a085411f9b411ce0b8b3a347d3f6ac168d7ff1b0105349882d44b6b6a20dbb3cbd56
6
+ metadata.gz: 124f719f40dccfb65d0146030e9b5dbd0ceebddac07fc5e775682bbcdd902256baef3ea5027f1dc9c1d87ea2f9ef494c77d041d5c33c0c33084f69ab74e7fb70
7
+ data.tar.gz: 91b67a77bf6eef2c25f9c913edcbe590649f8fd4ef8e2d62aee9a3c8dee59d10c722e9d8c5374d26f8db37f386fa7ba533ba45cd7ba9d857ac4b074b1228e851
data/README.md CHANGED
@@ -248,6 +248,11 @@ https://www.paypalobjects.com/webstatic/en_US/developer/docs/pdf/pp_adaptivepaym
248
248
  Just ruby-ize the fields (i.e. underscores, not camel case) and open up the
249
249
  request/response classes in this repository to get a feel for how this all works.
250
250
 
251
+ ## Contributors
252
+
253
+ * [d11wtq](https://github.com/d11wtq)
254
+ * [Maxim-Filimonov](https://github.com/Maxim-Filimonov)
255
+
251
256
  ## License & Copyright
252
257
 
253
258
  Copyright © Flippa.com Pty Ltd. Licensed under the MIT license. See the
@@ -4,7 +4,7 @@ require "virtus"
4
4
  module AdaptivePayments
5
5
  # The principle hub through which all requests and responses are passed.
6
6
  class Client
7
- include Virtus
7
+ include Virtus.model
8
8
 
9
9
  attribute :user_id, String, :header => "X-PAYPAL-SECURITY-USERID"
10
10
  attribute :password, String, :header => "X-PAYPAL-SECURITY-PASSWORD"
@@ -1,15 +1,17 @@
1
1
  module AdaptivePayments
2
2
  # Array that coerces all input values to a JsonModel of the given type
3
3
  class CoercedArray < Array
4
+ attr_accessor :type
4
5
  # Initialize the CoercedArray for the given type
5
6
  #
6
7
  # @param [Class<JsonModel>] type
7
8
  # the JsonModel descendant to coerce to
8
- def initialize(type)
9
+ def self.for_type(type)
9
10
  raise ArgumentError, "The type in a CoercedArray must be a JsonModel" unless type <= JsonModel
10
11
 
11
- super()
12
- @type = type
12
+ arr = CoercedArray.new
13
+ arr.type = type
14
+ arr
13
15
  end
14
16
 
15
17
  # Append the given value to the Array
@@ -34,8 +36,10 @@ module AdaptivePayments
34
36
  #
35
37
  # @return CoercedArray
36
38
  def +(other)
37
- raise ArgumentError, "Cannot union #{other.class} with #{self.class}<#{@type}>" unless other.kind_of?(Array)
38
- super(CoercedArray.new(@type).concat(other))
39
+ raise ArgumentError, "Cannot union #{other.class} with #{self.class}<#{type}>" unless other.kind_of?(Array)
40
+ result = CoercedArray.new(super(CoercedArray.for_type(type).concat(other)))
41
+ result.type = type
42
+ result
39
43
  end
40
44
 
41
45
  # Concatenate another Array with this one and modify the Array in place
@@ -45,8 +49,10 @@ module AdaptivePayments
45
49
  #
46
50
  # @return CoercedArray
47
51
  def concat(other)
48
- raise ArgumentError, "Cannot append #{other.class} to #{self.class}<#{@type}>" unless other.kind_of?(Array)
49
- super(other.inject(CoercedArray.new(@type)) { |ary, v| ary.push(v) })
52
+ raise ArgumentError, "Cannot append #{other.class} to #{self.class}<#{type}>" unless other.kind_of?(Array)
53
+ result = CoercedArray.new(super(other.inject(CoercedArray.for_type(type)) { |ary, v| ary.push(v) }))
54
+ result.type = type
55
+ result
50
56
  end
51
57
  end
52
58
  end
@@ -39,7 +39,7 @@ module AdaptivePayments
39
39
  # feel more ruby-esque, pp-adaptive define aliases where it seems logical to do so. The fully qualified paths will always
40
40
  # work, however.
41
41
  class JsonModel
42
- include Virtus
42
+ include Virtus.model
43
43
  extend Aliases
44
44
 
45
45
  # Methods used for building a JsonModel given a JSON string.
@@ -12,7 +12,7 @@ module AdaptivePayments
12
12
  #
13
13
  # Assigning a Hash directly to the attribute will store an object of the boxed type, based on the elements
14
14
  # in the Hash.
15
- class Node < Virtus::Attribute::Object
15
+ class Node < Virtus::Attribute
16
16
  # Provide access to the boxed type
17
17
  attr_reader :type
18
18
 
@@ -30,6 +30,7 @@ module AdaptivePayments
30
30
  @generated_class_map ||= {}
31
31
  @generated_class_map[type] ||= Class.new(self) do
32
32
  default lambda { |m, a| type.new }
33
+ lazy true
33
34
 
34
35
  define_method :type do
35
36
  type
@@ -11,8 +11,7 @@ module AdaptivePayments
11
11
  # in the Array will be coerced to the boxed type. If an Array is assigned directly to the attribute,
12
12
  # all items inside it will be coerced to the boxed type. If a Hash is pushed onto the existing
13
13
  # Array, it will be coerced to the boxed type.
14
- class NodeList < Virtus::Attribute::Object
15
- primitive ::Array
14
+ class NodeList < Virtus::Attribute
16
15
 
17
16
  # Allow access to the boxed type
18
17
  attr_reader :type
@@ -29,14 +28,14 @@ module AdaptivePayments
29
28
  raise ArgumentError, "Lists may only be created from JsonModel classes" unless type <= JsonModel
30
29
 
31
30
  Class.new(self) do
32
- default lambda { |m, a| CoercedArray.new(type) }
31
+ default lambda { |m, a| arr = CoercedArray.for_type(type) }
33
32
 
34
33
  define_method :type do
35
34
  type
36
35
  end
37
36
 
38
37
  define_method :coerce do |value|
39
- CoercedArray.new(type) + Array(value)
38
+ CoercedArray.for_type(type) + Array.new(value)
40
39
  end
41
40
  end
42
41
  end
@@ -1,3 +1,3 @@
1
1
  module AdaptivePayments
2
- VERSION = "0.0.6"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
19
19
  s.require_paths = ["lib"]
20
20
 
21
21
  s.add_runtime_dependency "rest-client"
22
- s.add_runtime_dependency "virtus", "~> 0.5.5"
22
+ s.add_runtime_dependency "virtus", "~> 1.0.0"
23
23
  s.add_runtime_dependency "json"
24
24
  s.add_development_dependency "rspec", ">= 2.10"
25
25
  end
@@ -4,10 +4,10 @@ require "virtus"
4
4
  describe AdaptivePayments::JsonModel do
5
5
  let(:model) do
6
6
  Class.new(AdaptivePayments::JsonModel) do
7
- attribute :an_example, Virtus::Attribute::String, :param => "anExample"
8
- attribute :simple, Virtus::Attribute::String
9
- attribute :numeric, Virtus::Attribute::Decimal
10
- attribute :optional, Virtus::Attribute::String, :default => "test"
7
+ attribute :an_example, String, :param => "anExample"
8
+ attribute :simple, String
9
+ attribute :numeric, BigDecimal
10
+ attribute :optional, String, :default => "test"
11
11
  end
12
12
  end
13
13
 
metadata CHANGED
@@ -1,69 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pp-adaptive
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - d11wtq
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-14 00:00:00.000000000 Z
11
+ date: 2014-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: virtus
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.5.5
33
+ version: 1.0.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.5.5
40
+ version: 1.0.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: json
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '2.10'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '2.10'
69
69
  description: Provides complete access to PayPal's Adaptive Payments API
@@ -73,8 +73,8 @@ executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
- - .gitignore
77
- - .rspec
76
+ - ".gitignore"
77
+ - ".rspec"
78
78
  - Gemfile
79
79
  - README.md
80
80
  - Rakefile
@@ -189,18 +189,47 @@ require_paths:
189
189
  - lib
190
190
  required_ruby_version: !ruby/object:Gem::Requirement
191
191
  requirements:
192
- - - '>='
192
+ - - ">="
193
193
  - !ruby/object:Gem::Version
194
194
  version: '0'
195
195
  required_rubygems_version: !ruby/object:Gem::Requirement
196
196
  requirements:
197
- - - '>='
197
+ - - ">="
198
198
  - !ruby/object:Gem::Version
199
199
  version: '0'
200
200
  requirements: []
201
201
  rubyforge_project: pp-adaptive
202
- rubygems_version: 2.0.3
202
+ rubygems_version: 2.1.8
203
203
  signing_key:
204
204
  specification_version: 4
205
205
  summary: Rubygem for working with PayPal's Adaptive Payments API
206
- test_files: []
206
+ test_files:
207
+ - spec/public/cancel_preapproval_request_spec.rb
208
+ - spec/public/cancel_preapproval_response_spec.rb
209
+ - spec/public/client_spec.rb
210
+ - spec/public/convert_currency_request_spec.rb
211
+ - spec/public/convert_currency_response_spec.rb
212
+ - spec/public/execute_payment_request_spec.rb
213
+ - spec/public/execute_payment_response_spec.rb
214
+ - spec/public/get_payment_options_request_spec.rb
215
+ - spec/public/get_payment_options_response_spec.rb
216
+ - spec/public/json_model_spec.rb
217
+ - spec/public/node_list_spec.rb
218
+ - spec/public/node_spec.rb
219
+ - spec/public/pay_request_spec.rb
220
+ - spec/public/pay_response_spec.rb
221
+ - spec/public/payment_details_request_spec.rb
222
+ - spec/public/payment_details_response_spec.rb
223
+ - spec/public/preapproval_details_request_spec.rb
224
+ - spec/public/preapproval_details_response_spec.rb
225
+ - spec/public/preapproval_request_spec.rb
226
+ - spec/public/preapproval_response_spec.rb
227
+ - spec/public/refund_request_spec.rb
228
+ - spec/public/refund_response_spec.rb
229
+ - spec/public/set_payment_options_request_spec.rb
230
+ - spec/public/set_payment_options_response_spec.rb
231
+ - spec/shared/a_fault_message.rb
232
+ - spec/shared/a_request_envelope.rb
233
+ - spec/shared/a_response_envelope.rb
234
+ - spec/spec_helper.rb
235
+ has_rdoc: