Sha256: 13328ee7fd5c4674db4cda9ef514858f6aad103a7cfb68927200189caba02408

Contents?: true

Size: 1.33 KB

Versions: 7

Compression:

Stored size: 1.33 KB

Contents

module Spree
  module Api
    module V2
      module Storefront
        module Account
          class CreditCardsController < ::Spree::Api::V2::ResourceController
            before_action :require_spree_current_user

            def destroy
              spree_authorize! :destroy, resource, resource

              destroy_service.call(card: resource)
            end

            private

            def resource
              params[:id].eql?('default') ? scope.default.first! : scope.find(params[:id])
            end

            def model_class
              Spree::CreditCard
            end

            def scope
              super.where(user: spree_current_user, payment_method: current_store.payment_methods.available_on_front_end)
            end

            def collection_serializer
              Spree::Api::Dependencies.storefront_credit_card_serializer.constantize
            end

            def collection_finder
              Spree::Api::Dependencies.storefront_credit_card_finder.constantize
            end

            def resource_serializer
              Spree::Api::Dependencies.storefront_credit_card_serializer.constantize
            end

            def destroy_service
              Spree::Api::Dependencies.storefront_credit_cards_destroy_service.constantize
            end
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
spree_api-4.3.3 app/controllers/spree/api/v2/storefront/account/credit_cards_controller.rb
spree_api-4.3.2 app/controllers/spree/api/v2/storefront/account/credit_cards_controller.rb
spree_api-4.3.1 app/controllers/spree/api/v2/storefront/account/credit_cards_controller.rb
spree_api-4.3.0 app/controllers/spree/api/v2/storefront/account/credit_cards_controller.rb
spree_api-4.3.0.rc3 app/controllers/spree/api/v2/storefront/account/credit_cards_controller.rb
spree_api-4.3.0.rc2 app/controllers/spree/api/v2/storefront/account/credit_cards_controller.rb
spree_api-4.3.0.rc1 app/controllers/spree/api/v2/storefront/account/credit_cards_controller.rb