class JeraPayment::Services::Iugu::Subscriptions::Create

Public Instance Methods

call() click to toggle source
# File lib/jera_payment/services/iugu/subscriptions/create.rb, line 6
def call
  iugu_subscription = JeraPayment::Api::Iugu::Subscription.create(@attributes.merge({customer_id: @resource.customer.api_id}),
                                                                  @resource&.customer&.sub_account&.api_token)

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

  @resource.errors.blank?
end

Private Instance Methods

set_api_attributes(attributes) click to toggle source
# File lib/jera_payment/services/iugu/subscriptions/create.rb, line 20
def set_api_attributes(attributes)
  @resource.assign_attributes(api_id: attributes[:id], active: attributes[:active],
                              suspended: attributes[:suspended], credits: attributes[:credits],
                              price_cents: attributes[:price_cents])
end