Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support optionally marking address as residential #36

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/ups/builders/address_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class AddressBuilder < BuilderBase
# @option opts [String] :state State
# @option opts [String] :postal_code Zip or Postal Code
# @option opts [String] :country Country
# @option opts [Boolean] :residential_address Whether destination is considered residential
# @raise [InvalidAttributeError] If the passed :state is nil or an
# empty string and the :country is IE
def initialize(opts = {})
Expand Down Expand Up @@ -132,6 +133,7 @@ def to_xml
address << state
address << postal_code
address << country
address << Element.new('ResidentialAddress') if opts[:residential_address]
end
end
end
Expand Down
14 changes: 14 additions & 0 deletions spec/ups/builders/address_builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,18 @@
end
end
end

describe 'residential address' do
it 'is not a residential address by default' do
address = UPS::Builders::AddressBuilder.new(address_line_1: 'Googleplex', city: 'Mountain View', state: 'California', postal_code: '94043', country: 'US')

expect(address.to_xml.locate('ResidentialAddress')).must_equal([])
end

it 'is indicates when specified as a residential address' do
address = UPS::Builders::AddressBuilder.new(address_line_1: 'Googleplex', city: 'Mountain View', state: 'California', postal_code: '94043', country: 'US', residential_address: true)

expect(address.to_xml.locate('ResidentialAddress')).wont_equal([])
end
end
end