Class: StripeMock::TestStrategies::Mock

Inherits:
Base
  • Object
show all
Defined in:
lib/stripe_mock/test_strategies/mock.rb

Instance Method Summary collapse

Methods inherited from Base

#complete_checkout_session, #create_checkout_session, #create_checkout_session_params, #create_coupon, #create_coupon_params, #create_coupon_percent_of_params, #create_plan, #create_plan_params, #create_price, #create_price_params, #create_product, #create_product_params, #delete_all_coupons, #generate_bank_token, #generate_card_token, #list_plans, #list_products, #list_subscriptions, #prepare_card_error, #retrieve_product

Instance Method Details

#delete_plan(plan_id) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/stripe_mock/test_strategies/mock.rb', line 13

def delete_plan(plan_id)
  if StripeMock.state == 'remote'
    StripeMock.client.destroy_resource('plans', plan_id)
  elsif StripeMock.state == 'local'
    StripeMock.instance.plans.delete(plan_id)
  end
end

#delete_product(product_id) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/stripe_mock/test_strategies/mock.rb', line 5

def delete_product(product_id)
  if StripeMock.state == 'remote'
    StripeMock.client.destroy_resource('products', product_id)
  elsif StripeMock.state == 'local'
    StripeMock.instance.products.delete(product_id)
  end
end

#upsert_stripe_object(object, attributes = {}) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/stripe_mock/test_strategies/mock.rb', line 21

def upsert_stripe_object(object, attributes = {})
  if StripeMock.state == 'remote'
    StripeMock.client.upsert_stripe_object(object, attributes)
  elsif StripeMock.state == 'local'
    StripeMock.instance.upsert_stripe_object(object, attributes)
  end
end