Sha256: dd2482678386c751f1bc36c0fae9f530f0f8cb9263db7943ba56ffbca549abea

Contents?: true

Size: 1.38 KB

Versions: 38

Compression:

Stored size: 1.38 KB

Contents

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

            def index
              render_serialized_payload { serialize_collection(resource) }
            end

            def show
              render_serialized_payload { serialize_resource(resource) }
            end

            private

            def resource
              resource_finder.new.execute(scope: scope, params: params)
            end

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

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

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

            def serialize_collection(collection)
              collection_serializer.new(
                collection,
                include: resource_includes,
                fields: sparse_fields
              ).serializable_hash
            end

            def scope
              spree_current_user.credit_cards.accessible_by(current_ability, :show)
            end
          end
        end
      end
    end
  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
spree_api-4.0.9 app/controllers/spree/api/v2/storefront/account/credit_cards_controller.rb
spree_api-4.1.15 app/controllers/spree/api/v2/storefront/account/credit_cards_controller.rb
spree_api-4.1.14 app/controllers/spree/api/v2/storefront/account/credit_cards_controller.rb
spree_api-4.0.8 app/controllers/spree/api/v2/storefront/account/credit_cards_controller.rb
spree_api-4.1.13.1 app/controllers/spree/api/v2/storefront/account/credit_cards_controller.rb
spree_api-4.0.7.1 app/controllers/spree/api/v2/storefront/account/credit_cards_controller.rb
spree_api-4.0.7 app/controllers/spree/api/v2/storefront/account/credit_cards_controller.rb
spree_api-4.1.13 app/controllers/spree/api/v2/storefront/account/credit_cards_controller.rb
spree_api-4.0.6 app/controllers/spree/api/v2/storefront/account/credit_cards_controller.rb
spree_api-4.2.0.rc2 app/controllers/spree/api/v2/storefront/account/credit_cards_controller.rb
spree_api-4.0.5 app/controllers/spree/api/v2/storefront/account/credit_cards_controller.rb
spree_api-4.1.12 app/controllers/spree/api/v2/storefront/account/credit_cards_controller.rb
spree_api-4.2.0.rc1 app/controllers/spree/api/v2/storefront/account/credit_cards_controller.rb
spree_api-4.0.4 app/controllers/spree/api/v2/storefront/account/credit_cards_controller.rb
spree_api-4.1.11 app/controllers/spree/api/v2/storefront/account/credit_cards_controller.rb
spree_api-4.1.10 app/controllers/spree/api/v2/storefront/account/credit_cards_controller.rb
spree_api-4.2.0.beta app/controllers/spree/api/v2/storefront/account/credit_cards_controller.rb
spree_api-4.1.9 app/controllers/spree/api/v2/storefront/account/credit_cards_controller.rb
spree_api-4.1.8 app/controllers/spree/api/v2/storefront/account/credit_cards_controller.rb
spree_api-4.1.7 app/controllers/spree/api/v2/storefront/account/credit_cards_controller.rb