spree_api 4.1.11 → 4.2.0.beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/controllers/concerns/spree/api/v2/storefront/order_concern.rb +4 -0
- data/app/controllers/spree/api/base_controller.rb +1 -3
- data/app/controllers/spree/api/errors_controller.rb +1 -1
- data/app/controllers/spree/api/v1/taxons_controller.rb +6 -1
- data/app/controllers/spree/api/v1/users_controller.rb +35 -9
- data/app/controllers/spree/api/v2/base_controller.rb +1 -6
- data/app/controllers/spree/api/v2/storefront/checkout_controller.rb +2 -1
- data/app/helpers/spree/api/api_helpers.rb +3 -2
- data/app/models/spree/api_dependencies.rb +1 -10
- data/app/serializers/spree/v2/storefront/cart_serializer.rb +1 -2
- data/app/serializers/spree/v2/storefront/line_item_serializer.rb +1 -2
- data/app/serializers/spree/v2/storefront/product_serializer.rb +2 -2
- data/app/serializers/spree/v2/storefront/shipment_serializer.rb +1 -3
- data/app/serializers/spree/v2/storefront/variant_serializer.rb +2 -2
- data/app/views/spree/api/v1/products/show.rabl +4 -0
- data/config/routes.rb +0 -2
- data/docs/v2/storefront/index.yaml +82 -39
- data/lib/spree/api/controller_setup.rb +0 -1
- data/lib/spree/api/testing_support/v2/base.rb +1 -1
- data/lib/spree/api/testing_support/v2/current_order.rb +0 -4
- data/spree_api.gemspec +1 -1
- metadata +12 -16
- data/app/controllers/spree/api/v2/storefront/account/addresses_controller.rb +0 -77
- data/app/controllers/spree/api/v2/storefront/stores_controller.rb +0 -27
- data/app/serializers/spree/v2/storefront/stock_location_serializer.rb +0 -11
- data/app/serializers/spree/v2/storefront/store_serializer.rb +0 -13
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 3d7a31de48e37ea579244e2c62fb47e2891f5663b095aa8f49de99ecc24abc1e
         | 
| 4 | 
            +
              data.tar.gz: 6d5470cb5181210801f5210f46b1e0fc7a3d704b8cd930f372a0544b5861713b
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 0b79cb583334e0813cde900718b6062a3601761aba2093159846a383c684219735ebf6861056a24376701d072e766eb74b2a280ef9dacf0f4993f67237dc6c01
         | 
| 7 | 
            +
              data.tar.gz: 2429b6091f2e256743136cef85b42a65cfd53f9daadc6b1a5f3945c0fba1b9a1f882491edc85f0cf8a22cd7a7ee8dbed30c174f53e3d139b7d62eda8fe91c4a4
         | 
| @@ -34,6 +34,10 @@ module Spree | |
| 34 34 | 
             
                        )
         | 
| 35 35 | 
             
                      end
         | 
| 36 36 |  | 
| 37 | 
            +
                      def supported_currencies
         | 
| 38 | 
            +
                        current_store.supported_currencies_list
         | 
| 39 | 
            +
                      end
         | 
| 40 | 
            +
             | 
| 37 41 | 
             
                      def serialize_order(order)
         | 
| 38 42 | 
             
                        resource_serializer.new(order.reload, include: resource_includes, fields: sparse_fields).serializable_hash
         | 
| 39 43 | 
             
                      end
         | 
| @@ -2,9 +2,7 @@ require_dependency 'spree/api/controller_setup' | |
| 2 2 |  | 
| 3 3 | 
             
            module Spree
         | 
| 4 4 | 
             
              module Api
         | 
| 5 | 
            -
                class BaseController < ActionController:: | 
| 6 | 
            -
                  protect_from_forgery unless: -> { request.format.json? || request.format.xml? }
         | 
| 7 | 
            -
             | 
| 5 | 
            +
                class BaseController < ActionController::API
         | 
| 8 6 | 
             
                  include Spree::Api::ControllerSetup
         | 
| 9 7 | 
             
                  include Spree::Core::ControllerHelpers::Store
         | 
| 10 8 | 
             
                  include Spree::Core::ControllerHelpers::StrongParameters
         | 
| @@ -74,7 +74,12 @@ module Spree | |
| 74 74 |  | 
| 75 75 | 
             
                    def taxonomy
         | 
| 76 76 | 
             
                      if params[:taxonomy_id].present?
         | 
| 77 | 
            -
                        @taxonomy ||= | 
| 77 | 
            +
                        @taxonomy ||=
         | 
| 78 | 
            +
                          if defined?(SpreeGlobalize)
         | 
| 79 | 
            +
                            Spree::Taxonomy.includes(:translations, taxons: [:translations]).accessible_by(current_ability, :show).find(params[:taxonomy_id])
         | 
| 80 | 
            +
                          else
         | 
| 81 | 
            +
                            Spree::Taxonomy.accessible_by(current_ability, :show).find(params[:taxonomy_id])
         | 
| 82 | 
            +
                          end
         | 
| 78 83 | 
             
                      end
         | 
| 79 84 | 
             
                    end
         | 
| 80 85 |  | 
| @@ -5,22 +5,48 @@ module Spree | |
| 5 5 | 
             
                    rescue_from Spree::Core::DestroyWithOrdersError, with: :error_during_processing
         | 
| 6 6 |  | 
| 7 7 | 
             
                    def index
         | 
| 8 | 
            -
                       | 
| 8 | 
            +
                      users
         | 
| 9 9 |  | 
| 10 10 | 
             
                      if params[:ids]
         | 
| 11 | 
            -
                         | 
| 12 | 
            -
                      elsif params | 
| 13 | 
            -
                         | 
| 14 | 
            -
             | 
| 15 | 
            -
             | 
| 16 | 
            -
                        users_with_addresses_ids = (users_with_ship_address.ids + users_with_bill_address.ids).compact.uniq
         | 
| 17 | 
            -
                        @users = @users.with_email_or_addresses_ids(params[:q][:email_start], users_with_addresses_ids)
         | 
| 11 | 
            +
                        load_users_by_ids
         | 
| 12 | 
            +
                      elsif params.dig(:q, :ship_address_firstname_start)
         | 
| 13 | 
            +
                        load_users_by_address
         | 
| 14 | 
            +
                      elsif params.dig(:q, :email_start)
         | 
| 15 | 
            +
                        load_users_by_email
         | 
| 18 16 | 
             
                      end
         | 
| 19 17 |  | 
| 18 | 
            +
                      prepare_index_response
         | 
| 19 | 
            +
                      respond_with(@users)
         | 
| 20 | 
            +
                    end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                    def users
         | 
| 23 | 
            +
                      @users ||= Spree.user_class.accessible_by(current_ability, :show)
         | 
| 24 | 
            +
                    end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                    def load_users_by_ids
         | 
| 27 | 
            +
                      @users = @users.where(id: params[:ids])
         | 
| 28 | 
            +
                    end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                    def load_users_by_address
         | 
| 31 | 
            +
                      address_params = params[:q][:ship_address_firstname_start] ||
         | 
| 32 | 
            +
                        params[:q][:ship_address_lastname_start] ||
         | 
| 33 | 
            +
                        params[:q][:bill_address_firstname_start] ||
         | 
| 34 | 
            +
                        params[:q][:bill_address_lastname_start]
         | 
| 35 | 
            +
                      @users = @users.with_email_or_address(params[:q][:email_start], address_params)
         | 
| 36 | 
            +
                    end
         | 
| 37 | 
            +
             | 
| 38 | 
            +
                    def load_users_by_email
         | 
| 39 | 
            +
                      @users = @users.with_email(params[:q][:email_start])
         | 
| 40 | 
            +
                    end
         | 
| 41 | 
            +
             | 
| 42 | 
            +
                    def paginate_users
         | 
| 20 43 | 
             
                      @users = @users.page(params[:page]).per(params[:per_page])
         | 
| 44 | 
            +
                    end
         | 
| 45 | 
            +
             | 
| 46 | 
            +
                    def prepare_index_response
         | 
| 47 | 
            +
                      paginate_users
         | 
| 21 48 | 
             
                      expires_in 15.minutes, public: true
         | 
| 22 49 | 
             
                      headers['Surrogate-Control'] = "max-age=#{15.minutes}"
         | 
| 23 | 
            -
                      respond_with(@users)
         | 
| 24 50 | 
             
                    end
         | 
| 25 51 |  | 
| 26 52 | 
             
                    def show
         | 
| @@ -53,12 +53,7 @@ module Spree | |
| 53 53 | 
             
                    end
         | 
| 54 54 |  | 
| 55 55 | 
             
                    def spree_current_user
         | 
| 56 | 
            -
                       | 
| 57 | 
            -
                      return @spree_current_user if @spree_current_user
         | 
| 58 | 
            -
             | 
| 59 | 
            -
                      doorkeeper_authorize!
         | 
| 60 | 
            -
             | 
| 61 | 
            -
                      @spree_current_user ||= Spree.user_class.find_by(id: doorkeeper_token.resource_owner_id)
         | 
| 56 | 
            +
                      @spree_current_user ||= Spree.user_class.find_by(id: doorkeeper_token.resource_owner_id) if doorkeeper_token
         | 
| 62 57 | 
             
                    end
         | 
| 63 58 |  | 
| 64 59 | 
             
                    def spree_authorize!(action, subject, *args)
         | 
| @@ -125,7 +125,8 @@ module Spree | |
| 125 125 | 
             
                      def serialize_shipping_rates(shipments)
         | 
| 126 126 | 
             
                        shipping_rates_serializer.new(
         | 
| 127 127 | 
             
                          shipments,
         | 
| 128 | 
            -
                          include: [:shipping_rates, | 
| 128 | 
            +
                          include: [:shipping_rates],
         | 
| 129 | 
            +
                          params: { show_rates: true }
         | 
| 129 130 | 
             
                        ).serializable_hash
         | 
| 130 131 | 
             
                      end
         | 
| 131 132 | 
             
                    end
         | 
| @@ -161,8 +161,9 @@ module Spree | |
| 161 161 |  | 
| 162 162 | 
             
                  @@store_attributes = [
         | 
| 163 163 | 
             
                    :id, :name, :url, :meta_description, :meta_keywords, :seo_title,
         | 
| 164 | 
            -
                    :mail_from_address, : | 
| 165 | 
            -
                    :facebook, :twitter, :instagram
         | 
| 164 | 
            +
                    :mail_from_address, :customer_support_email, :default_currency,
         | 
| 165 | 
            +
                    :code, :default, :facebook, :twitter, :instagram,
         | 
| 166 | 
            +
                    :supported_currencies
         | 
| 166 167 | 
             
                  ]
         | 
| 167 168 |  | 
| 168 169 | 
             
                  @@tag_attributes = [:id, :name]
         | 
| @@ -13,9 +13,7 @@ module Spree | |
| 13 13 | 
             
                  :storefront_country_serializer, :storefront_current_order_finder, :storefront_completed_order_finder, :storefront_order_sorter,
         | 
| 14 14 | 
             
                  :storefront_collection_paginator, :storefront_user_serializer, :storefront_products_sorter, :storefront_products_finder,
         | 
| 15 15 | 
             
                  :storefront_product_serializer, :storefront_taxon_serializer, :storefront_taxon_finder, :storefront_find_by_variant_finder,
         | 
| 16 | 
            -
                  :storefront_cart_update_service, :storefront_cart_estimate_shipping_rates_service, :storefront_estimated_shipment_serializer | 
| 17 | 
            -
                  :storefront_store_serializer, :storefront_address_serializer,
         | 
| 18 | 
            -
                  :storefront_account_create_address_service, :storefront_account_update_address_service, :storefront_address_finder
         | 
| 16 | 
            +
                  :storefront_cart_update_service, :storefront_cart_estimate_shipping_rates_service, :storefront_estimated_shipment_serializer
         | 
| 19 17 | 
             
                ].freeze
         | 
| 20 18 |  | 
| 21 19 | 
             
                attr_accessor *INJECTION_POINTS
         | 
| @@ -50,12 +48,7 @@ module Spree | |
| 50 48 | 
             
                  @storefront_checkout_remove_store_credit_service = Spree::Dependencies.checkout_remove_store_credit_service
         | 
| 51 49 | 
             
                  @storefront_checkout_get_shipping_rates_service = Spree::Dependencies.checkout_get_shipping_rates_service
         | 
| 52 50 |  | 
| 53 | 
            -
                  # account services
         | 
| 54 | 
            -
                  @storefront_account_create_address_service = Spree::Dependencies.account_create_address_service
         | 
| 55 | 
            -
                  @storefront_account_update_address_service = Spree::Dependencies.account_update_address_service
         | 
| 56 | 
            -
             | 
| 57 51 | 
             
                  # serializers
         | 
| 58 | 
            -
                  @storefront_address_serializer = 'Spree::V2::Storefront::AddressSerializer'
         | 
| 59 52 | 
             
                  @storefront_cart_serializer = 'Spree::V2::Storefront::CartSerializer'
         | 
| 60 53 | 
             
                  @storefront_credit_card_serializer = 'Spree::V2::Storefront::CreditCardSerializer'
         | 
| 61 54 | 
             
                  @storefront_country_serializer = 'Spree::V2::Storefront::CountrySerializer'
         | 
| @@ -65,7 +58,6 @@ module Spree | |
| 65 58 | 
             
                  @storefront_payment_method_serializer = 'Spree::V2::Storefront::PaymentMethodSerializer'
         | 
| 66 59 | 
             
                  @storefront_product_serializer = 'Spree::V2::Storefront::ProductSerializer'
         | 
| 67 60 | 
             
                  @storefront_estimated_shipment_serializer = 'Spree::V2::Storefront::EstimatedShippingRateSerializer'
         | 
| 68 | 
            -
                  @storefront_store_serializer = 'Spree::V2::Storefront::StoreSerializer'
         | 
| 69 61 |  | 
| 70 62 | 
             
                  # sorters
         | 
| 71 63 | 
             
                  @storefront_order_sorter = Spree::Dependencies.order_sorter
         | 
| @@ -75,7 +67,6 @@ module Spree | |
| 75 67 | 
             
                  @storefront_collection_paginator = Spree::Dependencies.collection_paginator
         | 
| 76 68 |  | 
| 77 69 | 
             
                  # finders
         | 
| 78 | 
            -
                  @storefront_address_finder = Spree::Dependencies.address_finder
         | 
| 79 70 | 
             
                  @storefront_country_finder = Spree::Dependencies.country_finder
         | 
| 80 71 | 
             
                  @storefront_current_order_finder = Spree::Dependencies.current_order_finder
         | 
| 81 72 | 
             
                  @storefront_completed_order_finder = Spree::Dependencies.completed_order_finder
         | 
| @@ -8,8 +8,7 @@ module Spree | |
| 8 8 | 
             
                               :updated_at, :completed_at, :included_tax_total, :additional_tax_total, :display_additional_tax_total,
         | 
| 9 9 | 
             
                               :display_included_tax_total, :tax_total, :currency, :state, :token, :email,
         | 
| 10 10 | 
             
                               :display_item_total, :display_ship_total, :display_adjustment_total, :display_tax_total,
         | 
| 11 | 
            -
                               :promo_total, :display_promo_total, :item_count, :special_instructions, :display_total | 
| 12 | 
            -
                               :pre_tax_item_amount, :display_pre_tax_item_amount, :pre_tax_total, :display_pre_tax_total
         | 
| 11 | 
            +
                               :promo_total, :display_promo_total, :item_count, :special_instructions, :display_total
         | 
| 13 12 |  | 
| 14 13 | 
             
                    has_many   :line_items
         | 
| 15 14 | 
             
                    has_many   :variants
         | 
| @@ -9,8 +9,7 @@ module Spree | |
| 9 9 | 
             
                               :display_adjustment_total, :additional_tax_total,
         | 
| 10 10 | 
             
                               :discounted_amount, :display_discounted_amount,
         | 
| 11 11 | 
             
                               :display_additional_tax_total, :promo_total, :display_promo_total,
         | 
| 12 | 
            -
                               :included_tax_total, :display_included_tax_total | 
| 13 | 
            -
                               :pre_tax_amount, :display_pre_tax_amount
         | 
| 12 | 
            +
                               :included_tax_total, :display_included_tax_total
         | 
| 14 13 |  | 
| 15 14 | 
             
                    belongs_to :variant
         | 
| 16 15 | 
             
                  end
         | 
| @@ -5,8 +5,8 @@ module Spree | |
| 5 5 | 
             
                    set_type :product
         | 
| 6 6 |  | 
| 7 7 | 
             
                    attributes :name, :description, :price, :currency, :display_price,
         | 
| 8 | 
            -
                               : | 
| 9 | 
            -
                               :updated_at
         | 
| 8 | 
            +
                               :compare_at_price, :display_compare_at_price, :available_on,
         | 
| 9 | 
            +
                               :slug, :meta_description, :meta_keywords, :updated_at
         | 
| 10 10 |  | 
| 11 11 | 
             
                    attribute :purchasable,   &:purchasable?
         | 
| 12 12 | 
             
                    attribute :in_stock,      &:in_stock?
         | 
| @@ -4,8 +4,8 @@ module Spree | |
| 4 4 | 
             
                  class VariantSerializer < BaseSerializer
         | 
| 5 5 | 
             
                    set_type :variant
         | 
| 6 6 |  | 
| 7 | 
            -
                    attributes : | 
| 8 | 
            -
                               :width, :depth, :is_master, :options_text | 
| 7 | 
            +
                    attributes :sku, :price, :currency, :display_price, :weight, :height,
         | 
| 8 | 
            +
                               :width, :depth, :is_master, :options_text
         | 
| 9 9 |  | 
| 10 10 | 
             
                    attribute :purchasable,   &:purchasable?
         | 
| 11 11 | 
             
                    attribute :in_stock,      &:in_stock?
         | 
| @@ -6,6 +6,10 @@ attributes *product_attributes | |
| 6 6 | 
             
            node(:display_price) { |p| p.display_price.to_s }
         | 
| 7 7 | 
             
            node(:has_variants, &:has_variants?)
         | 
| 8 8 | 
             
            node(:taxon_ids, &:taxon_ids)
         | 
| 9 | 
            +
            node(:display_current_currency_price) do |product|
         | 
| 10 | 
            +
              price = product.price_in(current_currency)
         | 
| 11 | 
            +
              Spree::Money.new(price.amount, currency: current_currency).to_s
         | 
| 12 | 
            +
            end
         | 
| 9 13 |  | 
| 10 14 | 
             
            child master: :master do
         | 
| 11 15 | 
             
              extends 'spree/api/v1/variants/small'
         | 
    
        data/config/routes.rb
    CHANGED
    
    | @@ -152,7 +152,6 @@ Spree::Core::Engine.add_routes do | |
| 152 152 | 
             
                    resource :account, controller: :account, only: %i[show]
         | 
| 153 153 |  | 
| 154 154 | 
             
                    namespace :account do
         | 
| 155 | 
            -
                      resources :addresses, controller: :addresses, only: %i[index create update]
         | 
| 156 155 | 
             
                      resources :credit_cards, controller: :credit_cards, only: %i[index show]
         | 
| 157 156 | 
             
                      resources :orders, controller: :orders, only: %i[index show]
         | 
| 158 157 | 
             
                    end
         | 
| @@ -162,7 +161,6 @@ Spree::Core::Engine.add_routes do | |
| 162 161 | 
             
                    get '/order_status/:number', to: 'order_status#show', as: :order_status
         | 
| 163 162 | 
             
                    resources :products, only: %i[index show]
         | 
| 164 163 | 
             
                    resources :taxons,   only: %i[index show], id: /.+/
         | 
| 165 | 
            -
                    get '/stores/:code', to: 'stores#show', as: :store
         | 
| 166 164 | 
             
                  end
         | 
| 167 165 | 
             
                end
         | 
| 168 166 |  | 
| @@ -49,7 +49,88 @@ paths: | |
| 49 49 | 
             
                      $ref: '#/components/responses/403Forbidden'
         | 
| 50 50 | 
             
                  security:
         | 
| 51 51 | 
             
                    - bearerAuth: []
         | 
| 52 | 
            -
             | 
| 52 | 
            +
                post:
         | 
| 53 | 
            +
                  description: >-
         | 
| 54 | 
            +
                    Creates a new account
         | 
| 55 | 
            +
                    
         | 
| 56 | 
            +
                    This endpoint requires [Spree Auth Devise](https://github.com/spree/spree_auth_devise) gem installed
         | 
| 57 | 
            +
                  tags:
         | 
| 58 | 
            +
                    - Account
         | 
| 59 | 
            +
                  operationId: 'Account Creation'
         | 
| 60 | 
            +
                  requestBody:
         | 
| 61 | 
            +
                    required: true
         | 
| 62 | 
            +
                    content:
         | 
| 63 | 
            +
                      application/vnd.api+json:
         | 
| 64 | 
            +
                        schema:
         | 
| 65 | 
            +
                          type: object
         | 
| 66 | 
            +
                          properties:
         | 
| 67 | 
            +
                            user:
         | 
| 68 | 
            +
                              type: object
         | 
| 69 | 
            +
                              properties:
         | 
| 70 | 
            +
                                email:
         | 
| 71 | 
            +
                                  type: string
         | 
| 72 | 
            +
                                  example: 'john@snow.org'
         | 
| 73 | 
            +
                                password:
         | 
| 74 | 
            +
                                  type: string
         | 
| 75 | 
            +
                                  example: 'spree123'
         | 
| 76 | 
            +
                                password_confirmation:
         | 
| 77 | 
            +
                                  type: string
         | 
| 78 | 
            +
                                  example: 'spree123'
         | 
| 79 | 
            +
                  responses:
         | 
| 80 | 
            +
                    '200':
         | 
| 81 | 
            +
                      description: ok
         | 
| 82 | 
            +
                      content:
         | 
| 83 | 
            +
                        application/vnd.api+json:
         | 
| 84 | 
            +
                          schema:
         | 
| 85 | 
            +
                            $ref: '#/components/schemas/Account'
         | 
| 86 | 
            +
                    '422':
         | 
| 87 | 
            +
                      description: Validation errors
         | 
| 88 | 
            +
                      content:
         | 
| 89 | 
            +
                        application/vnd.api+json:
         | 
| 90 | 
            +
                          schema:
         | 
| 91 | 
            +
                            $ref: '#/components/schemas/Error'
         | 
| 92 | 
            +
                patch:
         | 
| 93 | 
            +
                  description: >-
         | 
| 94 | 
            +
                    Updates user account
         | 
| 95 | 
            +
                    
         | 
| 96 | 
            +
                    This endpoint requires [Spree Auth Devise](https://github.com/spree/spree_auth_devise) gem installed
         | 
| 97 | 
            +
                  tags:
         | 
| 98 | 
            +
                    - Account
         | 
| 99 | 
            +
                  operationId: 'Account Updates'
         | 
| 100 | 
            +
                  requestBody:
         | 
| 101 | 
            +
                    required: true
         | 
| 102 | 
            +
                    content:
         | 
| 103 | 
            +
                      application/vnd.api+json:
         | 
| 104 | 
            +
                        schema:
         | 
| 105 | 
            +
                          type: object
         | 
| 106 | 
            +
                          properties:
         | 
| 107 | 
            +
                            user:
         | 
| 108 | 
            +
                              type: object
         | 
| 109 | 
            +
                              properties:
         | 
| 110 | 
            +
                                email:
         | 
| 111 | 
            +
                                  type: string
         | 
| 112 | 
            +
                                  example: 'john@snow.org'
         | 
| 113 | 
            +
                                password:
         | 
| 114 | 
            +
                                  type: string
         | 
| 115 | 
            +
                                  example: 'spree123'
         | 
| 116 | 
            +
                                password_confirmation:
         | 
| 117 | 
            +
                                  type: string
         | 
| 118 | 
            +
                                  example: 'spree123'
         | 
| 119 | 
            +
                  responses:
         | 
| 120 | 
            +
                    '200':
         | 
| 121 | 
            +
                      description: ok
         | 
| 122 | 
            +
                      content:
         | 
| 123 | 
            +
                        application/vnd.api+json:
         | 
| 124 | 
            +
                          schema:
         | 
| 125 | 
            +
                            $ref: '#/components/schemas/Account'
         | 
| 126 | 
            +
                    '422':
         | 
| 127 | 
            +
                      description: Validation errors
         | 
| 128 | 
            +
                      content:
         | 
| 129 | 
            +
                        application/vnd.api+json:
         | 
| 130 | 
            +
                          schema:
         | 
| 131 | 
            +
                            $ref: '#/components/schemas/Error'
         | 
| 132 | 
            +
                  security:
         | 
| 133 | 
            +
                    - bearerAuth: []
         | 
| 53 134 | 
             
              '/account/credit_cards':
         | 
| 54 135 | 
             
                get:
         | 
| 55 136 | 
             
                  description: >-
         | 
| @@ -1125,14 +1206,6 @@ components: | |
| 1125 1206 | 
             
                        company:
         | 
| 1126 1207 | 
             
                          type: string
         | 
| 1127 1208 | 
             
                          example: 'Google Inc.'
         | 
| 1128 | 
            -
                AddressList:
         | 
| 1129 | 
            -
                  required:
         | 
| 1130 | 
            -
                    - data
         | 
| 1131 | 
            -
                  properties:
         | 
| 1132 | 
            -
                    data:
         | 
| 1133 | 
            -
                      type: array
         | 
| 1134 | 
            -
                      items:
         | 
| 1135 | 
            -
                        $ref: '#/components/schemas/Address'
         | 
| 1136 1209 | 
             
                Cart:
         | 
| 1137 1210 | 
             
                  required:
         | 
| 1138 1211 | 
             
                    - data
         | 
| @@ -1299,18 +1372,6 @@ components: | |
| 1299 1372 | 
             
                    display_tax_total:
         | 
| 1300 1373 | 
             
                      type: string
         | 
| 1301 1374 | 
             
                      example: '$10.00'
         | 
| 1302 | 
            -
                    pre_tax_item_amount:
         | 
| 1303 | 
            -
                      type: string
         | 
| 1304 | 
            -
                      example: '17.00'
         | 
| 1305 | 
            -
                    display_pre_tax_item_amount:
         | 
| 1306 | 
            -
                      type: string
         | 
| 1307 | 
            -
                      example: '$17.00'
         | 
| 1308 | 
            -
                    pre_tax_total:
         | 
| 1309 | 
            -
                      type: string
         | 
| 1310 | 
            -
                      example: '20.00'
         | 
| 1311 | 
            -
                    display_pre_tax_total:
         | 
| 1312 | 
            -
                      type: string
         | 
| 1313 | 
            -
                      example: '$20.00'
         | 
| 1314 1375 | 
             
                    item_count:
         | 
| 1315 1376 | 
             
                      type: number
         | 
| 1316 1377 | 
             
                      example: 2
         | 
| @@ -1523,12 +1584,6 @@ components: | |
| 1523 1584 | 
             
                        display_discounted_amount:
         | 
| 1524 1585 | 
             
                          type: string
         | 
| 1525 1586 | 
             
                          example: '$125.00'
         | 
| 1526 | 
            -
                        pre_tax_amount:
         | 
| 1527 | 
            -
                          type: string
         | 
| 1528 | 
            -
                          example: '125.0'
         | 
| 1529 | 
            -
                        display_pre_tax_amount:
         | 
| 1530 | 
            -
                          type: string
         | 
| 1531 | 
            -
                          example: '$125.00'
         | 
| 1532 1587 | 
             
                        promo_total:
         | 
| 1533 1588 | 
             
                          type: string
         | 
| 1534 1589 | 
             
                          example: '-5.0'
         | 
| @@ -2029,10 +2084,6 @@ components: | |
| 2029 2084 | 
             
                VariantAttributes:
         | 
| 2030 2085 | 
             
                  type: object
         | 
| 2031 2086 | 
             
                  properties:
         | 
| 2032 | 
            -
                    name:
         | 
| 2033 | 
            -
                      type: string
         | 
| 2034 | 
            -
                      example: 'Example product'
         | 
| 2035 | 
            -
                      description: 'Product name'
         | 
| 2036 2087 | 
             
                    sku:
         | 
| 2037 2088 | 
             
                      type: string
         | 
| 2038 2089 | 
             
                      example: 'SKU-1001'
         | 
| @@ -2064,14 +2115,6 @@ components: | |
| 2064 2115 | 
             
                    options_text:
         | 
| 2065 2116 | 
             
                      type: string
         | 
| 2066 2117 | 
             
                      example: 'Size: small, Color: red'
         | 
| 2067 | 
            -
                    slug:
         | 
| 2068 | 
            -
                      type: string
         | 
| 2069 | 
            -
                      example: 'example-product'
         | 
| 2070 | 
            -
                      description: 'Product slug'
         | 
| 2071 | 
            -
                    description:
         | 
| 2072 | 
            -
                      type: string
         | 
| 2073 | 
            -
                      example: 'Example description'
         | 
| 2074 | 
            -
                      description: 'Product description'
         | 
| 2075 2118 | 
             
                    purchasable:
         | 
| 2076 2119 | 
             
                      type: boolean
         | 
| 2077 2120 | 
             
                      example: true
         | 
| @@ -6,7 +6,6 @@ module Spree | |
| 6 6 | 
             
                  def self.included(klass)
         | 
| 7 7 | 
             
                    klass.class_eval do
         | 
| 8 8 | 
             
                      include CanCan::ControllerAdditions
         | 
| 9 | 
            -
                      include Spree::Core::ControllerHelpers::Auth
         | 
| 10 9 |  | 
| 11 10 | 
             
                      prepend_view_path Rails.root + 'app/views'
         | 
| 12 11 | 
             
                      append_view_path File.expand_path('../../../app/views', File.dirname(__FILE__))
         | 
| @@ -4,7 +4,7 @@ shared_context 'API v2 tokens' do | |
| 4 4 | 
             
              let(:headers_order_token) { { 'X-Spree-Order-Token' => order.token } }
         | 
| 5 5 | 
             
            end
         | 
| 6 6 |  | 
| 7 | 
            -
            [200, 201, 400,  | 
| 7 | 
            +
            [200, 201, 400, 404, 403, 422].each do |status_code|
         | 
| 8 8 | 
             
              shared_examples "returns #{status_code} HTTP status" do
         | 
| 9 9 | 
             
                it "returns #{status_code}" do
         | 
| 10 10 | 
             
                  expect(response.status).to eq(status_code)
         | 
| @@ -48,10 +48,6 @@ shared_examples 'returns valid cart JSON' do | |
| 48 48 | 
             
                expect(json_response['data']).to have_attribute(:promo_total).with_value(order.promo_total.to_s)
         | 
| 49 49 | 
             
                expect(json_response['data']).to have_attribute(:display_promo_total).with_value(order.display_promo_total.to_s)
         | 
| 50 50 | 
             
                expect(json_response['data']).to have_attribute(:display_total).with_value(order.display_total.to_s)
         | 
| 51 | 
            -
                expect(json_response['data']).to have_attribute(:pre_tax_item_amount).with_value(order.pre_tax_item_amount.to_s)
         | 
| 52 | 
            -
                expect(json_response['data']).to have_attribute(:display_pre_tax_item_amount).with_value(order.display_pre_tax_item_amount.to_s)
         | 
| 53 | 
            -
                expect(json_response['data']).to have_attribute(:pre_tax_total).with_value(order.pre_tax_total.to_s)
         | 
| 54 | 
            -
                expect(json_response['data']).to have_attribute(:display_pre_tax_total).with_value(order.display_pre_tax_total.to_s)
         | 
| 55 51 | 
             
                expect(json_response['data']).to have_relationships(:user, :line_items, :variants, :billing_address, :shipping_address, :payments, :shipments, :promotions)
         | 
| 56 52 | 
             
              end
         | 
| 57 53 | 
             
            end
         | 
    
        data/spree_api.gemspec
    CHANGED
    
    | @@ -8,7 +8,7 @@ Gem::Specification.new do |s| | |
| 8 8 | 
             
              s.email         = ["ryan@spreecommerce.com"]
         | 
| 9 9 | 
             
              s.summary       = %q{Spree's API}
         | 
| 10 10 | 
             
              s.description   = %q{Spree's API}
         | 
| 11 | 
            -
              s.homepage      = ' | 
| 11 | 
            +
              s.homepage      = 'https://spreecommerce.org'
         | 
| 12 12 | 
             
              s.license       = 'BSD-3-Clause'
         | 
| 13 13 |  | 
| 14 14 | 
             
              s.metadata = {
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: spree_api
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 4. | 
| 4 | 
            +
              version: 4.2.0.beta
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Ryan Bigg
         | 
| 8 | 
            -
            autorequire:
         | 
| 8 | 
            +
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2020- | 
| 11 | 
            +
            date: 2020-09-07 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: jsonapi-rspec
         | 
| @@ -30,14 +30,14 @@ dependencies: | |
| 30 30 | 
             
                requirements:
         | 
| 31 31 | 
             
                - - '='
         | 
| 32 32 | 
             
                  - !ruby/object:Gem::Version
         | 
| 33 | 
            -
                    version: 4. | 
| 33 | 
            +
                    version: 4.2.0.beta
         | 
| 34 34 | 
             
              type: :runtime
         | 
| 35 35 | 
             
              prerelease: false
         | 
| 36 36 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 37 37 | 
             
                requirements:
         | 
| 38 38 | 
             
                - - '='
         | 
| 39 39 | 
             
                  - !ruby/object:Gem::Version
         | 
| 40 | 
            -
                    version: 4. | 
| 40 | 
            +
                    version: 4.2.0.beta
         | 
| 41 41 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 42 42 | 
             
              name: rabl
         | 
| 43 43 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -133,7 +133,6 @@ files: | |
| 133 133 | 
             
            - app/controllers/spree/api/v1/variants_controller.rb
         | 
| 134 134 | 
             
            - app/controllers/spree/api/v1/zones_controller.rb
         | 
| 135 135 | 
             
            - app/controllers/spree/api/v2/base_controller.rb
         | 
| 136 | 
            -
            - app/controllers/spree/api/v2/storefront/account/addresses_controller.rb
         | 
| 137 136 | 
             
            - app/controllers/spree/api/v2/storefront/account/credit_cards_controller.rb
         | 
| 138 137 | 
             
            - app/controllers/spree/api/v2/storefront/account/orders_controller.rb
         | 
| 139 138 | 
             
            - app/controllers/spree/api/v2/storefront/account_controller.rb
         | 
| @@ -142,7 +141,6 @@ files: | |
| 142 141 | 
             
            - app/controllers/spree/api/v2/storefront/countries_controller.rb
         | 
| 143 142 | 
             
            - app/controllers/spree/api/v2/storefront/order_status_controller.rb
         | 
| 144 143 | 
             
            - app/controllers/spree/api/v2/storefront/products_controller.rb
         | 
| 145 | 
            -
            - app/controllers/spree/api/v2/storefront/stores_controller.rb
         | 
| 146 144 | 
             
            - app/controllers/spree/api/v2/storefront/taxons_controller.rb
         | 
| 147 145 | 
             
            - app/helpers/spree/api/api_helpers.rb
         | 
| 148 146 | 
             
            - app/helpers/spree/api/v2/collection_options_helpers.rb
         | 
| @@ -168,11 +166,9 @@ files: | |
| 168 166 | 
             
            - app/serializers/spree/v2/storefront/shipment_serializer.rb
         | 
| 169 167 | 
             
            - app/serializers/spree/v2/storefront/shipping_rate_serializer.rb
         | 
| 170 168 | 
             
            - app/serializers/spree/v2/storefront/state_serializer.rb
         | 
| 171 | 
            -
            - app/serializers/spree/v2/storefront/stock_location_serializer.rb
         | 
| 172 169 | 
             
            - app/serializers/spree/v2/storefront/store_credit_event_serializer.rb
         | 
| 173 170 | 
             
            - app/serializers/spree/v2/storefront/store_credit_serializer.rb
         | 
| 174 171 | 
             
            - app/serializers/spree/v2/storefront/store_credit_type_serializer.rb
         | 
| 175 | 
            -
            - app/serializers/spree/v2/storefront/store_serializer.rb
         | 
| 176 172 | 
             
            - app/serializers/spree/v2/storefront/taxon_image_serializer.rb
         | 
| 177 173 | 
             
            - app/serializers/spree/v2/storefront/taxon_serializer.rb
         | 
| 178 174 | 
             
            - app/serializers/spree/v2/storefront/taxonomy_serializer.rb
         | 
| @@ -301,15 +297,15 @@ files: | |
| 301 297 | 
             
            - script/rails
         | 
| 302 298 | 
             
            - spec/fixtures/thinking-cat.jpg
         | 
| 303 299 | 
             
            - spree_api.gemspec
         | 
| 304 | 
            -
            homepage:  | 
| 300 | 
            +
            homepage: https://spreecommerce.org
         | 
| 305 301 | 
             
            licenses:
         | 
| 306 302 | 
             
            - BSD-3-Clause
         | 
| 307 303 | 
             
            metadata:
         | 
| 308 304 | 
             
              bug_tracker_uri: https://github.com/spree/spree/issues
         | 
| 309 | 
            -
              changelog_uri: https://github.com/spree/spree/releases/tag/v4. | 
| 305 | 
            +
              changelog_uri: https://github.com/spree/spree/releases/tag/v4.2.0.beta
         | 
| 310 306 | 
             
              documentation_uri: https://guides.spreecommerce.org/
         | 
| 311 | 
            -
              source_code_uri: https://github.com/spree/spree/tree/v4. | 
| 312 | 
            -
            post_install_message:
         | 
| 307 | 
            +
              source_code_uri: https://github.com/spree/spree/tree/v4.2.0.beta
         | 
| 308 | 
            +
            post_install_message: 
         | 
| 313 309 | 
             
            rdoc_options: []
         | 
| 314 310 | 
             
            require_paths:
         | 
| 315 311 | 
             
            - lib
         | 
| @@ -320,12 +316,12 @@ required_ruby_version: !ruby/object:Gem::Requirement | |
| 320 316 | 
             
                  version: 2.5.0
         | 
| 321 317 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 322 318 | 
             
              requirements:
         | 
| 323 | 
            -
              - - " | 
| 319 | 
            +
              - - ">"
         | 
| 324 320 | 
             
                - !ruby/object:Gem::Version
         | 
| 325 | 
            -
                  version:  | 
| 321 | 
            +
                  version: 1.3.1
         | 
| 326 322 | 
             
            requirements: []
         | 
| 327 323 | 
             
            rubygems_version: 3.1.2
         | 
| 328 | 
            -
            signing_key:
         | 
| 324 | 
            +
            signing_key: 
         | 
| 329 325 | 
             
            specification_version: 4
         | 
| 330 326 | 
             
            summary: Spree's API
         | 
| 331 327 | 
             
            test_files: []
         | 
| @@ -1,77 +0,0 @@ | |
| 1 | 
            -
            module Spree
         | 
| 2 | 
            -
              module Api
         | 
| 3 | 
            -
                module V2
         | 
| 4 | 
            -
                  module Storefront
         | 
| 5 | 
            -
                    module Account
         | 
| 6 | 
            -
                      class AddressesController < ::Spree::Api::V2::BaseController
         | 
| 7 | 
            -
                        before_action :require_spree_current_user
         | 
| 8 | 
            -
             | 
| 9 | 
            -
                        def index
         | 
| 10 | 
            -
                          render_serialized_payload { serialize_collection(collection) }
         | 
| 11 | 
            -
                        end
         | 
| 12 | 
            -
             | 
| 13 | 
            -
                        def create
         | 
| 14 | 
            -
                          result = create_service.call(user: spree_current_user, address_params: address_params)
         | 
| 15 | 
            -
                          render_result(result)
         | 
| 16 | 
            -
                        end
         | 
| 17 | 
            -
             | 
| 18 | 
            -
                        def update
         | 
| 19 | 
            -
                          result = update_service.call(address: resource, address_params: address_params)
         | 
| 20 | 
            -
                          render_result(result)
         | 
| 21 | 
            -
                        end
         | 
| 22 | 
            -
             | 
| 23 | 
            -
                        private
         | 
| 24 | 
            -
             | 
| 25 | 
            -
                        def collection
         | 
| 26 | 
            -
                          collection_finder.new(scope: scope, params: params).execute
         | 
| 27 | 
            -
                        end
         | 
| 28 | 
            -
             | 
| 29 | 
            -
                        def resource
         | 
| 30 | 
            -
                          @resource ||= scope.find(params[:id])
         | 
| 31 | 
            -
                        end
         | 
| 32 | 
            -
             | 
| 33 | 
            -
                        def scope
         | 
| 34 | 
            -
                          spree_current_user.addresses
         | 
| 35 | 
            -
                        end
         | 
| 36 | 
            -
             | 
| 37 | 
            -
                        def collection_finder
         | 
| 38 | 
            -
                          Spree::Api::Dependencies.storefront_address_finder.constantize
         | 
| 39 | 
            -
                        end
         | 
| 40 | 
            -
             | 
| 41 | 
            -
                        def collection_serializer
         | 
| 42 | 
            -
                          Spree::Api::Dependencies.storefront_address_serializer.constantize
         | 
| 43 | 
            -
                        end
         | 
| 44 | 
            -
             | 
| 45 | 
            -
                        def resource_serializer
         | 
| 46 | 
            -
                          Spree::Api::Dependencies.storefront_address_serializer.constantize
         | 
| 47 | 
            -
                        end
         | 
| 48 | 
            -
             | 
| 49 | 
            -
                        def serialize_collection(collection)
         | 
| 50 | 
            -
                          collection_serializer.new(collection).serializable_hash
         | 
| 51 | 
            -
                        end
         | 
| 52 | 
            -
             | 
| 53 | 
            -
                        def create_service
         | 
| 54 | 
            -
                          Spree::Api::Dependencies.storefront_account_create_address_service.constantize
         | 
| 55 | 
            -
                        end
         | 
| 56 | 
            -
             | 
| 57 | 
            -
                        def update_service
         | 
| 58 | 
            -
                          Spree::Api::Dependencies.storefront_account_update_address_service.constantize
         | 
| 59 | 
            -
                        end
         | 
| 60 | 
            -
             | 
| 61 | 
            -
                        def address_params
         | 
| 62 | 
            -
                          params.require(:address).permit(permitted_address_attributes)
         | 
| 63 | 
            -
                        end
         | 
| 64 | 
            -
             | 
| 65 | 
            -
                        def render_result(result)
         | 
| 66 | 
            -
                          if result.success?
         | 
| 67 | 
            -
                            render_serialized_payload { serialize_resource(result.value) }
         | 
| 68 | 
            -
                          else
         | 
| 69 | 
            -
                            render_error_payload(result.error)
         | 
| 70 | 
            -
                          end
         | 
| 71 | 
            -
                        end
         | 
| 72 | 
            -
                      end
         | 
| 73 | 
            -
                    end
         | 
| 74 | 
            -
                  end
         | 
| 75 | 
            -
                end
         | 
| 76 | 
            -
              end
         | 
| 77 | 
            -
            end
         | 
| @@ -1,27 +0,0 @@ | |
| 1 | 
            -
            module Spree
         | 
| 2 | 
            -
              module Api
         | 
| 3 | 
            -
                module V2
         | 
| 4 | 
            -
                  module Storefront
         | 
| 5 | 
            -
                    class StoresController < ::Spree::Api::V2::BaseController
         | 
| 6 | 
            -
                      def show
         | 
| 7 | 
            -
                        render_serialized_payload { serialize_resource(resource) }
         | 
| 8 | 
            -
                      end
         | 
| 9 | 
            -
             | 
| 10 | 
            -
                      private
         | 
| 11 | 
            -
             | 
| 12 | 
            -
                      def scope
         | 
| 13 | 
            -
                        Spree::Store
         | 
| 14 | 
            -
                      end
         | 
| 15 | 
            -
             | 
| 16 | 
            -
                      def resource
         | 
| 17 | 
            -
                        scope.find_by!(code: params[:code])
         | 
| 18 | 
            -
                      end
         | 
| 19 | 
            -
             | 
| 20 | 
            -
                      def resource_serializer
         | 
| 21 | 
            -
                        Spree::Api::Dependencies.storefront_store_serializer.constantize
         | 
| 22 | 
            -
                      end
         | 
| 23 | 
            -
                    end
         | 
| 24 | 
            -
                  end
         | 
| 25 | 
            -
                end
         | 
| 26 | 
            -
              end
         | 
| 27 | 
            -
            end
         | 
| @@ -1,13 +0,0 @@ | |
| 1 | 
            -
            module Spree
         | 
| 2 | 
            -
              module V2
         | 
| 3 | 
            -
                module Storefront
         | 
| 4 | 
            -
                  class StoreSerializer < BaseSerializer
         | 
| 5 | 
            -
                    set_type :store
         | 
| 6 | 
            -
             | 
| 7 | 
            -
                    attributes :name, :url, :meta_description, :meta_keywords, :seo_title, :default_currency, :default, :supported_currencies, :facebook,
         | 
| 8 | 
            -
                               :twitter, :instagram, :default_locale, :customer_support_email, :default_country_id, :description,
         | 
| 9 | 
            -
                               :address, :contact_phone, :contact_email
         | 
| 10 | 
            -
                  end
         | 
| 11 | 
            -
                end
         | 
| 12 | 
            -
              end
         | 
| 13 | 
            -
            end
         |