Class: DiscoApp::SubscriptionService
- Inherits:
-
Object
- Object
- DiscoApp::SubscriptionService
- Defined in:
- app/services/disco_app/subscription_service.rb
Instance Attribute Summary collapse
-
#plan ⇒ Object
readonly
Returns the value of attribute plan.
-
#plan_code ⇒ Object
readonly
Returns the value of attribute plan_code.
-
#shop ⇒ Object
readonly
Returns the value of attribute shop.
-
#source_name ⇒ Object
readonly
Returns the value of attribute source_name.
Class Method Summary collapse
-
.subscribe(shop, plan, plan_code = nil, source_name = nil) ⇒ Object
Subscribe the given shop to the given plan, optionally using the given plan code and optionally tracking the subscription source.
Instance Method Summary collapse
-
#initialize(shop, plan, plan_code = nil, source_name = nil) ⇒ SubscriptionService
constructor
A new instance of SubscriptionService.
- #subscribe ⇒ Object
Constructor Details
#initialize(shop, plan, plan_code = nil, source_name = nil) ⇒ SubscriptionService
Returns a new instance of SubscriptionService.
11 12 13 14 15 16 |
# File 'app/services/disco_app/subscription_service.rb', line 11 def initialize(shop, plan, plan_code = nil, source_name = nil) @shop = shop @plan = plan @plan_code = plan_code @source_name = source_name end |
Instance Attribute Details
#plan ⇒ Object (readonly)
Returns the value of attribute plan.
9 10 11 |
# File 'app/services/disco_app/subscription_service.rb', line 9 def plan @plan end |
#plan_code ⇒ Object (readonly)
Returns the value of attribute plan_code.
9 10 11 |
# File 'app/services/disco_app/subscription_service.rb', line 9 def plan_code @plan_code end |
#shop ⇒ Object (readonly)
Returns the value of attribute shop.
9 10 11 |
# File 'app/services/disco_app/subscription_service.rb', line 9 def shop @shop end |
#source_name ⇒ Object (readonly)
Returns the value of attribute source_name.
9 10 11 |
# File 'app/services/disco_app/subscription_service.rb', line 9 def source_name @source_name end |
Class Method Details
.subscribe(shop, plan, plan_code = nil, source_name = nil) ⇒ Object
Subscribe the given shop to the given plan, optionally using the given plan code and optionally tracking the subscription source.
5 6 7 |
# File 'app/services/disco_app/subscription_service.rb', line 5 def self.subscribe(shop, plan, plan_code = nil, source_name = nil) new(shop, plan, plan_code, source_name).subscribe end |
Instance Method Details
#subscribe ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/services/disco_app/subscription_service.rb', line 18 def subscribe cancel_existing_subscriptions # Create the new subscription. new_subscription = create_new_subscription # Enqueue the subscription changed background job. DiscoApp::SubscriptionChangedJob.perform_later(shop, new_subscription) # Return the new subscription. new_subscription end |