class Afterpay::Address

Attributes

country[RW]
line_1[RW]
line_2[RW]
name[RW]
phone[RW]
postcode[RW]
state[RW]
suburb[RW]

Public Class Methods

from_response(response) click to toggle source
# File lib/afterpay/address.rb, line 42
def self.from_response(response)
  return nil if response.nil?

  new(
    name: response[:name],
    line_1: response[:line1],
    line_2: response[:line2],
    suburb: response[:suburb],
    state: response[:state],
    postcode: response[:postcode],
    country: response[:countryCode],
    phone: response[:phoneNumber]
  )
end
new(attributes = {}) click to toggle source

Initializes an Order object

@overload initialize(total:, items:, consumer:, success_url:, cancel_url:, payment_type:)

@param name [String] The name
@param line_1 [String] Address line 1
@param line_2 [String] optional Address line 2
@param suburb [String] optional Suburb
@param state [String] State
@param postcode [String] Postal code
@param country [String] optional country Code
@param phone [String|Number] The phone number
# File lib/afterpay/address.rb, line 18
def initialize(attributes = {})
  @name = attributes[:name]
  @line_1 = attributes[:line_1] || ""
  @line_2 = attributes[:line_2] || ""
  @suburb = attributes[:suburb] || ""
  @state = attributes[:state] || ""
  @postcode = attributes[:postcode]
  @country = attributes[:country] || "AU"
  @phone = attributes[:phone]
end

Public Instance Methods

to_hash() click to toggle source
# File lib/afterpay/address.rb, line 29
def to_hash
  {
    name: name,
    line1: line_1,
    line2: line_2,
    suburb: suburb,
    state: state,
    postcode: postcode.to_s,
    countryCode: country,
    phoneNumber: phone.to_s
  }
end