class JeraPayment::Services::Iugu::Customers::Update

Public Instance Methods

call() click to toggle source
# File lib/jera_payment/services/iugu/customers/update.rb, line 6
def call
  iugu_customer = JeraPayment::Api::Iugu::Customer.update(
    @resource.api_id,
    @attributes,
    @resource&.sub_account&.api_token
  )

  if iugu_customer[:errors].present?
    add_error(iugu_customer[:errors])
  else
    set_api_attributes(iugu_customer)
  end

  @resource.errors.blank?
end

Private Instance Methods

set_api_attributes(attributes) click to toggle source
# File lib/jera_payment/services/iugu/customers/update.rb, line 23
def set_api_attributes(attributes)
  @resource.assign_attributes(attributes.slice(:email, :name, :phone, :cpf_cpnj))
end