spree_api 4.1.9 → 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/helpers/spree/api/api_helpers.rb +3 -2
- data/app/serializers/spree/v2/storefront/product_serializer.rb +2 -2
- data/app/serializers/spree/v2/storefront/variant_serializer.rb +2 -2
- data/app/views/spree/api/v1/products/show.rabl +4 -0
- data/docs/v2/storefront/index.yaml +82 -13
- data/lib/spree/api/controller_setup.rb +0 -1
- data/spree_api.gemspec +1 -1
- metadata +12 -12
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
|
@@ -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]
|
@@ -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'
|
@@ -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: >-
|
@@ -2003,10 +2084,6 @@ components:
|
|
2003
2084
|
VariantAttributes:
|
2004
2085
|
type: object
|
2005
2086
|
properties:
|
2006
|
-
name:
|
2007
|
-
type: string
|
2008
|
-
example: 'Example product'
|
2009
|
-
description: 'Product name'
|
2010
2087
|
sku:
|
2011
2088
|
type: string
|
2012
2089
|
example: 'SKU-1001'
|
@@ -2038,14 +2115,6 @@ components:
|
|
2038
2115
|
options_text:
|
2039
2116
|
type: string
|
2040
2117
|
example: 'Size: small, Color: red'
|
2041
|
-
slug:
|
2042
|
-
type: string
|
2043
|
-
example: 'example-product'
|
2044
|
-
description: 'Product slug'
|
2045
|
-
description:
|
2046
|
-
type: string
|
2047
|
-
example: 'Example description'
|
2048
|
-
description: 'Product description'
|
2049
2118
|
purchasable:
|
2050
2119
|
type: boolean
|
2051
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__))
|
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
|
@@ -297,15 +297,15 @@ files:
|
|
297
297
|
- script/rails
|
298
298
|
- spec/fixtures/thinking-cat.jpg
|
299
299
|
- spree_api.gemspec
|
300
|
-
homepage:
|
300
|
+
homepage: https://spreecommerce.org
|
301
301
|
licenses:
|
302
302
|
- BSD-3-Clause
|
303
303
|
metadata:
|
304
304
|
bug_tracker_uri: https://github.com/spree/spree/issues
|
305
|
-
changelog_uri: https://github.com/spree/spree/releases/tag/v4.
|
305
|
+
changelog_uri: https://github.com/spree/spree/releases/tag/v4.2.0.beta
|
306
306
|
documentation_uri: https://guides.spreecommerce.org/
|
307
|
-
source_code_uri: https://github.com/spree/spree/tree/v4.
|
308
|
-
post_install_message:
|
307
|
+
source_code_uri: https://github.com/spree/spree/tree/v4.2.0.beta
|
308
|
+
post_install_message:
|
309
309
|
rdoc_options: []
|
310
310
|
require_paths:
|
311
311
|
- lib
|
@@ -316,12 +316,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
316
316
|
version: 2.5.0
|
317
317
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
318
318
|
requirements:
|
319
|
-
- - "
|
319
|
+
- - ">"
|
320
320
|
- !ruby/object:Gem::Version
|
321
|
-
version:
|
321
|
+
version: 1.3.1
|
322
322
|
requirements: []
|
323
323
|
rubygems_version: 3.1.2
|
324
|
-
signing_key:
|
324
|
+
signing_key:
|
325
325
|
specification_version: 4
|
326
326
|
summary: Spree's API
|
327
327
|
test_files: []
|