Class: JeraPayment::Services::Iugu::Subscriptions::ChangePlan
- Defined in:
- lib/jera_payment/services/iugu/subscriptions/change_plan.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(resource, plan_identifier, simulation = nil) ⇒ ChangePlan
constructor
A new instance of ChangePlan.
Constructor Details
#initialize(resource, plan_identifier, simulation = nil) ⇒ ChangePlan
Returns a new instance of ChangePlan.
6 7 8 9 10 |
# File 'lib/jera_payment/services/iugu/subscriptions/change_plan.rb', line 6 def initialize(resource, plan_identifier, simulation = nil) @resource = resource @plan_identifier = plan_identifier @simulation = simulation end |
Instance Method Details
#call ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/jera_payment/services/iugu/subscriptions/change_plan.rb', line 12 def call begin ApplicationRecord.transaction do iugu_change_subscription_plan = eval("JeraPayment::Api::Iugu::Subscription.change_plan#{@simulation.to_s}(@resource.api_id, @plan_identifier, @resource&.customer&.sub_account&.api_token)") raise(StandardError, iugu_change_subscription_plan[:errors]) if iugu_change_subscription_plan[:errors].present? if @simulation.present? @resource = iugu_change_subscription_plan else set_api_attributes(iugu_change_subscription_plan) end end rescue Exception => error add_error(error.) end @resource end |