class Afterpay::Address

Attributes

area_1[RW]
area_2[RW]
country[RW]
line_1[RW]
line_2[RW]
name[RW]
phone[RW]
postcode[RW]
region[RW]

Public Class Methods

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

  new(
    name: response[:name],
    line_1: response[:line1],
    line_2: response[:line2],
    area_1: response[:area1],
    area_2: response[:area2],
    region: response[:region],
    postcode: response[:postcode],
    country: response[:countryCode],
    phone: response[:phoneNumber]
  )
end
new(attributes = {}) click to toggle source
# File lib/afterpay/address.rb, line 7
def initialize(attributes = {})
  @name = attributes[:name]
  @line_1 = attributes[:line_1] || ""
  @line_2 = attributes[:line_2] || ""
  @area_1 = attributes[:area_1] || ""
  @area_2 = attributes[:area_2] || ""
  @region = attributes[:region] || ""
  @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 19
def to_hash
  {
    name: name,
    line1: line_1,
    line2: line_2,
    area_1: area_1,
    area_2: area_2,
    region: region,
    postcode: postcode.to_s,
    countryCode: country,
    phoneNumber: phone.to_s
  }
end