<commit_before>module StripeMock
  module RequestHandlers
    module Subscriptions

      def Subscriptions.included(klass)
        klass.add_handler 'get /v1/subscriptions', :retrieve_subscriptions
        klass.add_handler 'post /v1/subscriptions', :create_subscription
        klass.add_handler 'get /v1/subscriptions/(.*)', :retrieve_subscription
        klass.add_handler 'post /v1/subscriptions/(.*)', :update_subscription
        klass.add_handler 'delete /v1/subscriptions/(.*)', :cancel_subscription

        klass.add_handler 'post /v1/customers/(.*)/subscriptions', :create_customer_subscription
        klass.add_handler 'get /v1/customers/(.*)/subscriptions/(.*)', :retrieve_customer_subscription
        klass.add_handler 'get /v1/customers/(.*)/subscriptions', :retrieve_customer_subscriptions
      end

      def retrieve_customer_subscription(route, method_url, params, headers)
        route =~ method_url

        customer = :customer, $1, customers[$1]
        subscription = get_customer_subscription(customer, $2)

        assert_existence :subscription, $2, subscription
      end

      def retrieve_customer_subscriptions(route, method_url, params, headers)
        route =~ method_url

        customer = assert_existence :customer, $1, customers[$1]
        customer[:subscriptions]
      end

      def create_customer_subscription(route, method_url, params, headers)
        route =~ method_url

        plan_id = params[:plan].to_s
        plan = assert_existence :plan, plan_id, plans[plan_id]

        customer = assert_existence :customer, $1, customers[$1]<commit_msg>Fix TypeError on customer subscriptions retrieve<commit_after>module StripeMock
  module RequestHandlers
    module Subscriptions

      def Subscriptions.included(klass)
        klass.add_handler 'get /v1/subscriptions', :retrieve_subscriptions
        klass.add_handler 'post /v1/subscriptions', :create_subscription
        klass.add_handler 'get /v1/subscriptions/(.*)', :retrieve_subscription
        klass.add_handler 'post /v1/subscriptions/(.*)', :update_subscription
        klass.add_handler 'delete /v1/subscriptions/(.*)', :cancel_subscription

        klass.add_handler 'post /v1/customers/(.*)/subscriptions', :create_customer_subscription
        klass.add_handler 'get /v1/customers/(.*)/subscriptions/(.*)', :retrieve_customer_subscription
        klass.add_handler 'get /v1/customers/(.*)/subscriptions', :retrieve_customer_subscriptions
      end

      def retrieve_customer_subscription(route, method_url, params, headers)
        route =~ method_url

        customer = assert_existence :customer, $1, customers[$1]
        subscription = get_customer_subscription(customer, $2)

        assert_existence :subscription, $2, subscription
      end

      def retrieve_customer_subscriptions(route, method_url, params, headers)
        route =~ method_url

        customer = assert_existence :customer, $1, customers[$1]
        customer[:subscriptions]
      end

      def create_customer_subscription(route, method_url, params, headers)
        route =~ method_url

        plan_id = params[:plan].to_s
        plan = assert_existence :plan, plan_id, plans[plan_id]

        customer = assert_existence :customer, $1, customers[$1]
{'fraction_non_alphanumeric': 0.10313075506445672, 'fraction_numerical': 0.009821976672805401, 'mean_word_length': 3.558041958041958, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5706881', 'n_tokens_mistral': 925, 'n_tokens_neox': 925, 'n_words': 191}