Braintree.Address (Braintree v0.15.0)

You can create an address for a customer only although the structure is also used for a merchant account.

For additional reference see: https://developers.braintreepayments.com/reference/request/address/create/ruby

Summary

Functions

Create an address record, or return an error response after failed validation.

You can delete an address using its customer ID and address ID.

If you want to look up a single address for a customer using the customer ID and the address ID, use the find method.

Convert a map into a Address struct.

To update an address, use a customer's ID with an address's ID along with new attributes. The same validations apply as when creating an address. Any attribute not passed will remain unchanged.

Types

t()

@type t() :: %Braintree.Address{
  company: String.t(),
  country_code_alpha2: String.t(),
  country_code_alpha3: String.t(),
  country_code_numeric: String.t(),
  country_name: String.t(),
  created_at: String.t(),
  customer_id: String.t(),
  extended_address: String.t(),
  first_name: String.t(),
  id: String.t(),
  last_name: String.t(),
  locality: String.t(),
  postal_code: String.t(),
  region: String.t(),
  street_address: String.t(),
  updated_at: String.t()
}

Functions

create(customer_id, params \\ %{}, opts \\ [])

@spec create(binary(), map(), Keyword.t()) :: {:ok, t()} | Braintree.HTTP.error()

Create an address record, or return an error response after failed validation.

Example

= Braintree.Address.create("customer_id", %{

first_name: "Jenna"

})

address.company # Braintree

delete(customer_id, id, opts \\ [])

@spec delete(binary(), binary(), Keyword.t()) :: :ok | Braintree.HTTP.error()

You can delete an address using its customer ID and address ID.

Example

:ok = Braintree.Address.delete("customer_id", "address_id")

find(customer_id, id, opts \\ [])

@spec find(binary(), binary(), Keyword.t()) :: {:ok, t()} | Braintree.HTTP.error()

If you want to look up a single address for a customer using the customer ID and the address ID, use the find method.

Example

address = Braintree.Address.find("customer_id", "address_id")

new(params)

Convert a map into a Address struct.

Example

address = Braintree.Address.new(%{"company" => "Braintree"})

update(customer_id, id, params, opts \\ [])

@spec update(binary(), binary(), map(), Keyword.t()) ::
  {:ok, t()} | Braintree.HTTP.error()

To update an address, use a customer's ID with an address's ID along with new attributes. The same validations apply as when creating an address. Any attribute not passed will remain unchanged.

Example

{:ok, address} = Braintree.Address.update("customer_id", "address_id", %{
  company: "New Company Name"
})

address.company # "New Company Name"