From bfe5b3c0541e10418040e0ea4e13167176415df7 Mon Sep 17 00:00:00 2001 From: Jack wu Date: Mon, 13 May 2019 14:58:02 -0400 Subject: [PATCH 1/5] added residential address indicator at address builder --- lib/ups/builders/address_builder.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/ups/builders/address_builder.rb b/lib/ups/builders/address_builder.rb index 6ee3533..7120c19 100644 --- a/lib/ups/builders/address_builder.rb +++ b/lib/ups/builders/address_builder.rb @@ -15,6 +15,7 @@ class AddressBuilder < BuilderBase # Initializes a new {AddressBuilder} object # # @param [Hash] opts The Address Parts + # @option opts [Bool] :residential Residential Address Indicator # @option opts [String] :address_line_1 Address Line 1 # @option opts [String] :city City # @option opts [String] :state State @@ -120,11 +121,24 @@ def email_address element_with_value('EmailAddress', opts[:email_address][0..49]) end + # Residential address indicator + # Only add to XML request iff indicator is true, skip otherwise + # + # @return [Ox::Element] XML representation of the residential address indicator + def residential_address + if opts[:residential] + element_with_value('ResidentialAddressIndicator', '1') + else + '' + end + end + # Returns an XML representation of a UPS Address # # @return [Ox::Element] XML representation of the current object def to_xml Element.new('Address').tap do |address| + address << residential_address address << address_line_1 address << address_line_2 address << email_address if opts[:email_address] From 1c56cbdceb156afdc27a569eda5908182df038fc Mon Sep 17 00:00:00 2001 From: Jack wu Date: Tue, 14 May 2019 13:48:08 -0400 Subject: [PATCH 2/5] changed to empty tag instead --- lib/ups/builders/address_builder.rb | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/lib/ups/builders/address_builder.rb b/lib/ups/builders/address_builder.rb index 7120c19..cbb2659 100644 --- a/lib/ups/builders/address_builder.rb +++ b/lib/ups/builders/address_builder.rb @@ -121,24 +121,15 @@ def email_address element_with_value('EmailAddress', opts[:email_address][0..49]) end - # Residential address indicator - # Only add to XML request iff indicator is true, skip otherwise - # - # @return [Ox::Element] XML representation of the residential address indicator - def residential_address - if opts[:residential] - element_with_value('ResidentialAddressIndicator', '1') - else - '' - end - end - # Returns an XML representation of a UPS Address # # @return [Ox::Element] XML representation of the current object def to_xml Element.new('Address').tap do |address| - address << residential_address + # By setting the residential address indicator tag. + # We can trigger UPS to check for any surcharge related to that area + # and apply the charge automically. + address << element_with_value('ResidentialAddressIndicator', '') address << address_line_1 address << address_line_2 address << email_address if opts[:email_address] From 0462645792d7517f556d0a6df052bcf1b801fb67 Mon Sep 17 00:00:00 2001 From: Jack wu Date: Tue, 14 May 2019 13:51:13 -0400 Subject: [PATCH 3/5] remove unused comment --- lib/ups/builders/address_builder.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/ups/builders/address_builder.rb b/lib/ups/builders/address_builder.rb index cbb2659..45c47bb 100644 --- a/lib/ups/builders/address_builder.rb +++ b/lib/ups/builders/address_builder.rb @@ -15,7 +15,6 @@ class AddressBuilder < BuilderBase # Initializes a new {AddressBuilder} object # # @param [Hash] opts The Address Parts - # @option opts [Bool] :residential Residential Address Indicator # @option opts [String] :address_line_1 Address Line 1 # @option opts [String] :city City # @option opts [String] :state State From ddd4a5bc622e27abf0a0ec15cd9685f0787d8b2c Mon Sep 17 00:00:00 2001 From: Jack wu Date: Tue, 14 May 2019 14:08:39 -0400 Subject: [PATCH 4/5] added warning message on unoffical API usages --- lib/ups/builders/address_builder.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/ups/builders/address_builder.rb b/lib/ups/builders/address_builder.rb index 45c47bb..f63b965 100644 --- a/lib/ups/builders/address_builder.rb +++ b/lib/ups/builders/address_builder.rb @@ -128,6 +128,7 @@ def to_xml # By setting the residential address indicator tag. # We can trigger UPS to check for any surcharge related to that area # and apply the charge automically. + # ** WARNING: The usage of an empty flag is not inlcuded in UPS's documentation, subject to future changes. address << element_with_value('ResidentialAddressIndicator', '') address << address_line_1 address << address_line_2 From 9beb84b357d6b325412163d16f1135df31baa2d3 Mon Sep 17 00:00:00 2001 From: Jack wu Date: Wed, 15 May 2019 09:25:57 -0400 Subject: [PATCH 5/5] remove warning since it is included in UPS API doc --- lib/ups/builders/address_builder.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/ups/builders/address_builder.rb b/lib/ups/builders/address_builder.rb index f63b965..45c47bb 100644 --- a/lib/ups/builders/address_builder.rb +++ b/lib/ups/builders/address_builder.rb @@ -128,7 +128,6 @@ def to_xml # By setting the residential address indicator tag. # We can trigger UPS to check for any surcharge related to that area # and apply the charge automically. - # ** WARNING: The usage of an empty flag is not inlcuded in UPS's documentation, subject to future changes. address << element_with_value('ResidentialAddressIndicator', '') address << address_line_1 address << address_line_2