def create(attributes)
Util.verify_keys(AddressGateway._create_signature, attributes)
unless attributes[:customer_id]
raise ArgumentError, "Expected hash to contain a :customer_id"
end
unless attributes[:customer_id] =~ /\A[0-9A-Za-z_-]+\z/
raise ArgumentError, ":customer_id contains invalid characters"
end
response = @config.http.post "/customers/#{attributes.delete(:customer_id)}/addresses", :address => attributes
if response[:address]
SuccessfulResult.new(:address => Address._new(@gateway, response[:address]))
elsif response[:api_error_response]
ErrorResult.new(@gateway, response[:api_error_response])
else
raise UnexpectedError, "expected :address or :api_error_response"
end
end