You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: subscription_service.rb
    path of file: ./repos/limestone-accounts/app/services
    
    the code of the file until where you have to start completion: # frozen_string_literal: true

# Manages all calls to Stripe pertaining to subscriptions
class SubscriptionService
  def initialize(current_account, params = {})
    @account = current_account
    @params = params
  end

  # Subscriptions are created when users complete the registration form.
  def create_subscription
    subscription = nil
    stripe_call do
      local_plan = Plan.active.find(@params[:plan_id])
      return false if local_plan.nil?
      stripe_plan = Stripe::Plan.retrieve(local_plan.stripe_id)
      # If the plan has a trial time, it does not need a stripe token to create a subscription
      # We assume you have a trial time > 0. Otherwise there will be 2 customers created for
      # each subscribed customer. One at registration and another when subscribing.
      subscription = customer.subscriptions.create(
        source: @params[:stripeToken],
        plan: stripe_plan.id,
        quantity: @account.active_users_count
      )
    end
    return false if subscription.nil?

    account_attributes_to_update = {
      stripe_customer_id: customer.id,
      stripe_subscription_id: subscription.id
    }

    @account.update(account_attributes_t
    
  def create_subscription
    subscription = nil
    stripe_call do
      local_plan = Plan.active.find(@params[:plan_id])
      return false if local_plan.nil?
      stripe_plan = Stripe::Plan.retrieve(local_plan.stripe_id)
      # If the plan has a trial time, it does not need a stripe token to create a subscription
      # We assume you have a trial time > 0. Otherwise there will be 2 customers created for
      # each subscribed customer. One at registration and another when subscribing.
      subscription = customer.subscriptions.create(
        source: @params[:stripeToken],
        plan: stripe_plan.id,
        quantity: @account.active_users_count
      )
    end
    return false if subscription.nil?

    account_attributes_to_update = {
      stripe_customer_id: customer.id,
      stripe_subscription_id: subscription.id
    }

    @account.update(account_attributes_to_update)
  end

  # Fires when users subscribe (/subscribe), update their card (/billing) and switch plans.
  def update_subscription
    success = stripe_call do
      # Don't need this when I have the customer method
      # customer = Stripe::Customer.retrieve(@account.stripe_customer_id)
      subscription = customer.subscriptions.retrieve(@account.stripe_subscription_id)
      subscription.source = @params[:stripeToken] if @params[:stripeToken]
      # Update plan if one is provided, otherwise use user's existing plan
      plan_stripe_id = if @params[:plan_id]
                         Plan.find(@params[:plan_id]).stripe_id
                       else
                         @account.plan.stripe_id
                       end
      subscription.items = [{
        id: subscription.items.data[0].id,
        plan: plan_stripe_id,
        quantity: @account.active_users_count
      }]
      subscription.save
    end
    return false unless success
    account_attributes_to_update = {}
    # This is updated by the stripe webhook customer.updated
    # But we can update it here for a faster optimistic 'response'
    if @params[:card_last4] && @params[:stripeToken]
      account_attributes_to_update.merge!(
        card_last4: @params[:card_last4],
        card_exp_month: @params[:card_exp_month],
        card_exp_year: @params[:card_exp_year],
        card_type: @params[:card_brand]
      )
    end