paypal-sdk-rest 1.6.1 → 1.7.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 96c5110387c529214199709d42f2583c1c9ec8bf
4
- data.tar.gz: 8c258a28b2716cba02248cc8f9a822a207c35b6c
3
+ metadata.gz: d165dec1b67f8e996a1d4fe9a406bc3b388428c4
4
+ data.tar.gz: bfab6906d27219ecb60cb74af6afacec35e316e9
5
5
  SHA512:
6
- metadata.gz: c4da04b7606a4ce1fe30a0600aa2ef8521f696d7411c1158d0e0fc23553017d0325aa86a26e95a61fabe6692bca0fa303c3185be4a5c6486e0326fd0ffffecaa
7
- data.tar.gz: d420deb8a02247e67d3648f502c246abb81fcde5eb5a7d7d3776c1e862b8b48cfeb336297870135c322d57714ae62dab044b9038f0d0e5a9b8e0172c4b0eb81d
6
+ metadata.gz: 6678cc8c36716ab8a898612c97ed8aa214f3349cbe2c23e154c4012657d17e10c053c468d835ef2ecd30a4902a01850bf8346d8bf6eec550b8c5248e93002603
7
+ data.tar.gz: 584469eaffaae16b69cce489b15635644c03970b02471e1cea4a0671612521f5d7c1a39faea627e947dbdfef770724aee13e9f4db03c9b546992f797c18fd147
@@ -365,7 +365,7 @@ module PayPal::SDK
365
365
  raise_on_api_error :create, :update, :delete
366
366
  end
367
367
 
368
- class Address < Base
368
+ class BaseAddress < Base
369
369
  def self.load_members
370
370
  object_of :line1, String
371
371
  object_of :line2, String
@@ -373,13 +373,24 @@ module PayPal::SDK
373
373
  object_of :country_code, String
374
374
  object_of :postal_code, String
375
375
  object_of :state, String
376
- object_of :phone, String
377
376
  object_of :normalization_status, String
378
377
  object_of :status, String
379
378
  object_of :type, String
380
379
  end
381
380
  end
382
381
 
382
+ class Address < BaseAddress
383
+ def self.load_members
384
+ object_of :phone, String
385
+ end
386
+ end
387
+
388
+ class InvoiceAddress < BaseAddress
389
+ def self.load_members
390
+ object_of :phone, Phone
391
+ end
392
+ end
393
+
383
394
  class OneOf < Base
384
395
  def self.load_members
385
396
  object_of :phone, Phone
@@ -1811,11 +1822,37 @@ module PayPal::SDK
1811
1822
  object_of :first_name, String
1812
1823
  object_of :last_name, String
1813
1824
  object_of :business_name, String
1814
- object_of :address, Address
1825
+ object_of :address, InvoiceAddress
1815
1826
  object_of :language, String
1816
1827
  object_of :additional_info, String
1817
1828
  object_of :notification_channel, String
1818
1829
  object_of :phone, Phone
1830
+
1831
+ define_method "address=" do |value|
1832
+ if value.is_a?(Address)
1833
+ value = value.to_hash
1834
+ end
1835
+ object = convert_object(value, InvoiceAddress)
1836
+ instance_variable_set("@address", object)
1837
+ end
1838
+
1839
+ define_method "address" do |&block|
1840
+ default_value = PayPal::SDK::Core::Util::OrderedHash.new
1841
+ value = instance_variable_get("@address") || ( default_value && (send("address=", default_value)))
1842
+ value = convert_object(value.to_hash, Address)
1843
+ value
1844
+ end
1845
+
1846
+ define_method "invoice_address=" do |value|
1847
+ object = convert_object(value, InvoiceAddress)
1848
+ instance_variable_set("@address", object)
1849
+ end
1850
+
1851
+ define_method "invoice_address" do |&block|
1852
+ default_value = PayPal::SDK::Core::Util::OrderedHash.new
1853
+ value = instance_variable_get("@address") || ( default_value && (send("address=", default_value)))
1854
+ value
1855
+ end
1819
1856
  end
1820
1857
  end
1821
1858
 
@@ -1824,8 +1861,34 @@ module PayPal::SDK
1824
1861
  object_of :first_name, String
1825
1862
  object_of :last_name, String
1826
1863
  object_of :business_name, String
1827
- object_of :address, Address
1864
+ object_of :address, InvoiceAddress
1828
1865
  object_of :email, String
1866
+
1867
+ define_method "address=" do |value|
1868
+ if value.is_a?(Address)
1869
+ value = value.to_hash
1870
+ end
1871
+ object = convert_object(value, InvoiceAddress)
1872
+ instance_variable_set("@address", object)
1873
+ end
1874
+
1875
+ define_method "address" do |&block|
1876
+ default_value = PayPal::SDK::Core::Util::OrderedHash.new
1877
+ value = instance_variable_get("@address") || ( default_value && (send("address=", default_value)))
1878
+ value = convert_object(value.to_hash, Address)
1879
+ value
1880
+ end
1881
+
1882
+ define_method "invoice_address=" do |value|
1883
+ object = convert_object(value, InvoiceAddress)
1884
+ instance_variable_set("@address", object)
1885
+ end
1886
+
1887
+ define_method "invoice_address" do |&block|
1888
+ default_value = PayPal::SDK::Core::Util::OrderedHash.new
1889
+ value = instance_variable_get("@address") || ( default_value && (send("address=", default_value)))
1890
+ value
1891
+ end
1829
1892
  end
1830
1893
  end
1831
1894
 
@@ -2110,7 +2173,7 @@ module PayPal::SDK
2110
2173
  object_of :rel, String
2111
2174
  object_of :targetSchema, HyperSchema
2112
2175
  object_of :method, String
2113
- object_of :enctype, String
2176
+ object_of :encType, String
2114
2177
  object_of :schema, HyperSchema
2115
2178
  end
2116
2179
  end
@@ -1,7 +1,7 @@
1
1
  module PayPal
2
2
  module SDK
3
3
  module REST
4
- VERSION = "1.6.1"
4
+ VERSION = "1.7.0"
5
5
  end
6
6
  end
7
7
  end
@@ -56,6 +56,106 @@ describe PayPal::SDK::Core::API::DataTypes::Base do
56
56
  expect(test_type.fromCurrency.amount).to eql "50.0"
57
57
  end
58
58
 
59
+ it "invoice address loads all members of default address object" do
60
+ invoice_address = InvoiceAddress.new(:line1 => "line1", :line2 => "line2", :phone => { :country_code => "123", :national_number => "1231231234", :extension => "123" }, :status => "status" )
61
+ expect(invoice_address).to be_a InvoiceAddress
62
+ expect(invoice_address.phone).to be_a Phone
63
+ expect(invoice_address.line1).to eql "line1"
64
+ expect(invoice_address.line2).to eql "line2"
65
+ expect(invoice_address.status).to eql "status"
66
+ expect(invoice_address.phone.country_code).to eql "123"
67
+ expect(invoice_address.phone.national_number).to eql "1231231234"
68
+ expect(invoice_address.phone.extension).to eql "123"
69
+ end
70
+
71
+ it "billing info converts an address to invoiceaddress automatically" do
72
+ address = Address.new(:line1 => "line1", :line2 => "line2", :status => "status" )
73
+ billing_info = BillingInfo.new({
74
+ :first_name => "Sally",
75
+ :last_name => "Patient",
76
+ :business_name => "Not applicable",
77
+ })
78
+ billing_info.address = address
79
+ expect(billing_info.address).to be_a Address
80
+ expect(billing_info.invoice_address).to be_a InvoiceAddress
81
+ end
82
+
83
+ it "shipping info returns an Address even if set to InvoiceAddress for backwards compatibility" do
84
+ address = InvoiceAddress.new(:line1 => "line1", :line2 => "line2", :status => "status", :phone => { :national_number => "1234567890" } )
85
+ billing_info = BillingInfo.new({
86
+ :first_name => "Sally",
87
+ :last_name => "Patient",
88
+ :business_name => "Not applicable",
89
+ })
90
+ billing_info.address = address
91
+ expect(billing_info.address).to be_a Address
92
+ expect(billing_info.invoice_address).to be_a InvoiceAddress
93
+ expect(billing_info.invoice_address.phone.national_number).to eql "1234567890"
94
+ end
95
+
96
+ it "returns the address and invoice address types in the billing info" do
97
+ billing_info = BillingInfo.new({
98
+ "first_name" => "Sally",
99
+ "last_name" => "Patient",
100
+ "business_name" => "Not applicable",
101
+ "address" => {
102
+ "line1" => "line1Value",
103
+ "phone" => { "country_code" => "123", "national_number" => "1234567890", "extension" => "456" },
104
+ },
105
+ })
106
+ expect(billing_info.address).to be_a Address
107
+ expect(billing_info.address.line1).to eql "line1Value"
108
+ expect(billing_info.invoice_address).to be_a InvoiceAddress
109
+ expect(billing_info.invoice_address.line1).to eql "line1Value"
110
+ expect(billing_info.invoice_address.phone.country_code).to eql "123"
111
+ expect(billing_info.invoice_address.phone.national_number).to eql "1234567890"
112
+ expect(billing_info.invoice_address.phone.extension).to eql "456"
113
+ end
114
+
115
+ it "shipping info converts an address to invoiceaddress automatically" do
116
+ address = Address.new(:line1 => "line1", :line2 => "line2", :status => "status" )
117
+ shipping_info = ShippingInfo.new({
118
+ "first_name" => "Sally",
119
+ "last_name" => "Patient",
120
+ "business_name" => "Not applicable",
121
+ })
122
+ shipping_info.address = address
123
+ expect(shipping_info.address).to be_a Address
124
+ expect(shipping_info.invoice_address).to be_a InvoiceAddress
125
+ end
126
+
127
+ it "shipping info returns an Address even if set to InvoiceAddress for backwards compatibility" do
128
+ address = InvoiceAddress.new(:line1 => "line1", :line2 => "line2", :status => "status", :phone => { :national_number => "1234567890" } )
129
+ shipping_info = ShippingInfo.new({
130
+ "first_name" => "Sally",
131
+ "last_name" => "Patient",
132
+ "business_name" => "Not applicable",
133
+ })
134
+ shipping_info.address = address
135
+ expect(shipping_info.address).to be_a Address
136
+ expect(shipping_info.invoice_address).to be_a InvoiceAddress
137
+ expect(shipping_info.invoice_address.phone.national_number).to eql "1234567890"
138
+ end
139
+
140
+ it "returns the address and invoice address types in the shipping info" do
141
+ shipping_info = ShippingInfo.new({
142
+ "first_name" => "Sally",
143
+ "last_name" => "Patient",
144
+ "business_name" => "Not applicable",
145
+ "address" => {
146
+ "line1" => "line1Value",
147
+ "phone" => { "country_code" => "123", "national_number" => "1234567890", "extension" => "456" },
148
+ },
149
+ })
150
+ expect(shipping_info.address).to be_a Address
151
+ expect(shipping_info.address.line1).to eql "line1Value"
152
+ expect(shipping_info.invoice_address).to be_a InvoiceAddress
153
+ expect(shipping_info.invoice_address.line1).to eql "line1Value"
154
+ expect(shipping_info.invoice_address.phone.country_code).to eql "123"
155
+ expect(shipping_info.invoice_address.phone.national_number).to eql "1234567890"
156
+ expect(shipping_info.invoice_address.phone.extension).to eql "456"
157
+ end
158
+
59
159
  it "should allow block with initializer" do
60
160
  test_type = TestType.new do
61
161
  fromCurrency do
@@ -76,10 +76,11 @@ describe PayPal::SDK::Core::API::REST do
76
76
  }.to raise_error PayPal::SDK::Core::Exceptions::UnauthorizedAccess
77
77
  end
78
78
 
79
- xit "Should handle expired token" do
79
+ it "Should handle expired token" do
80
80
  old_token = @api.token
81
81
  @api.token_hash[:expires_in] = 0
82
- expect(@api.token).not_to eql old_token
82
+ new_token = @api.token
83
+ expect(@api.token_hash[:expires_in]).not_to eql 0
83
84
  end
84
85
 
85
86
  it "Get token" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paypal-sdk-rest
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.1
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - PayPal
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-25 00:00:00.000000000 Z
11
+ date: 2017-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: coveralls