class PagSeguro::Shipping

Constants

InvalidShippingTypeError

Define the error class for invalid type assignment.

TYPE

Set the available shipping type.

Attributes

address[R]

Get the address object.

cost[RW]

Set the shipping cost.

type_id[R]

Define the shipping type id.

type_name[R]

Get the shipping type name.

Public Instance Methods

address=(address) click to toggle source

Set the shipping address info.

# File lib/pagseguro/shipping.rb, line 29
def address=(address)
  @address = ensure_type(Address, address)
end
type_id=(id) click to toggle source

Set the shipping type id. It raises the PagSeguro::Shipping::InvalidShippingTypeError exception when trying to assign an invalid type id.

# File lib/pagseguro/shipping.rb, line 47
def type_id=(id)
  type_id = id.to_i

  raise InvalidShippingTypeError,
    "invalid #{id.inspect} type id" unless TYPE.value?(type_id)

  @type_id = type_id
  @type_name = TYPE.key(type_id)
end
type_name=(type_name) click to toggle source

Set the shipping type. It raises the PagSeguro::Shipping::InvalidShippingTypeError exception when trying to assign an invalid type name.

# File lib/pagseguro/shipping.rb, line 36
def type_name=(type_name)
  type_name = type_name.to_sym
  @type_id = TYPE.fetch(type_name) {
    raise InvalidShippingTypeError, "invalid #{type_name.inspect} type name"
  }
  @type_name = type_name
end