workarea-api-admin 4.4.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/README.md +82 -0
- data/Rakefile +10 -0
- data/app/assets/images/workarea/api/admin/icons/api.svg +1 -0
- data/app/controllers/workarea/api/admin/application_controller.rb +73 -0
- data/app/controllers/workarea/api/admin/categories_controller.rb +305 -0
- data/app/controllers/workarea/api/admin/category_product_rules_controller.rb +232 -0
- data/app/controllers/workarea/api/admin/content_assets_controller.rb +299 -0
- data/app/controllers/workarea/api/admin/content_controller.rb +268 -0
- data/app/controllers/workarea/api/admin/discounts_controller.rb +271 -0
- data/app/controllers/workarea/api/admin/email_signups_controller.rb +108 -0
- data/app/controllers/workarea/api/admin/fulfillments_controller.rb +268 -0
- data/app/controllers/workarea/api/admin/inventory_skus_controller.rb +305 -0
- data/app/controllers/workarea/api/admin/navigation_menus_controller.rb +267 -0
- data/app/controllers/workarea/api/admin/navigation_taxons_controller.rb +305 -0
- data/app/controllers/workarea/api/admin/orders_controller.rb +160 -0
- data/app/controllers/workarea/api/admin/pages_controller.rb +305 -0
- data/app/controllers/workarea/api/admin/payment_profiles_controller.rb +305 -0
- data/app/controllers/workarea/api/admin/payment_transactions_controller.rb +108 -0
- data/app/controllers/workarea/api/admin/payments_controller.rb +115 -0
- data/app/controllers/workarea/api/admin/prices_controller.rb +232 -0
- data/app/controllers/workarea/api/admin/pricing_skus_controller.rb +305 -0
- data/app/controllers/workarea/api/admin/product_images_controller.rb +232 -0
- data/app/controllers/workarea/api/admin/products_controller.rb +305 -0
- data/app/controllers/workarea/api/admin/promo_code_lists_controller.rb +305 -0
- data/app/controllers/workarea/api/admin/recommendation_settings_controller.rb +122 -0
- data/app/controllers/workarea/api/admin/redirects_controller.rb +305 -0
- data/app/controllers/workarea/api/admin/releases_controller.rb +304 -0
- data/app/controllers/workarea/api/admin/saved_addresses_controller.rb +232 -0
- data/app/controllers/workarea/api/admin/saved_credit_cards_controller.rb +256 -0
- data/app/controllers/workarea/api/admin/shipping_rates_controller.rb +232 -0
- data/app/controllers/workarea/api/admin/shipping_services_controller.rb +299 -0
- data/app/controllers/workarea/api/admin/shippings_controller.rb +105 -0
- data/app/controllers/workarea/api/admin/swagger_controller.rb +41 -0
- data/app/controllers/workarea/api/admin/tax_categories_controller.rb +242 -0
- data/app/controllers/workarea/api/admin/tax_rates_controller.rb +292 -0
- data/app/controllers/workarea/api/admin/users_controller.rb +296 -0
- data/app/controllers/workarea/api/admin/variants_controller.rb +232 -0
- data/app/models/workarea/api/admin/bulk_upsert.rb +74 -0
- data/app/models/workarea/user.decorator +7 -0
- data/app/views/workarea/admin/users/_api_permissions.html.haml +6 -0
- data/app/workers/workarea/perform_api_bulk_upsert.rb +15 -0
- data/bin/rails +18 -0
- data/config/initializers/append_points.rb +4 -0
- data/config/initializers/config.rb +15 -0
- data/config/locales/en.yml +9 -0
- data/config/routes.rb +81 -0
- data/lib/workarea/api/admin.rb +21 -0
- data/lib/workarea/api/admin/engine.rb +14 -0
- data/lib/workarea/api/admin/swagger.rb +106 -0
- data/test/documentation/workarea/api/admin/categories_documentation_test.rb +106 -0
- data/test/documentation/workarea/api/admin/category_product_rules_documentation_test.rb +78 -0
- data/test/documentation/workarea/api/admin/content_assets_documentation_test.rb +94 -0
- data/test/documentation/workarea/api/admin/content_documentation_test.rb +87 -0
- data/test/documentation/workarea/api/admin/discounts_documentation_test.rb +85 -0
- data/test/documentation/workarea/api/admin/email_signups_documentation_test.rb +41 -0
- data/test/documentation/workarea/api/admin/fulfillment_documentation_test.rb +84 -0
- data/test/documentation/workarea/api/admin/inventory_skus_documentation_test.rb +95 -0
- data/test/documentation/workarea/api/admin/navigation_menus_documentation_test.rb +81 -0
- data/test/documentation/workarea/api/admin/navigation_taxons_documentation_test.rb +94 -0
- data/test/documentation/workarea/api/admin/orders_documentation_test.rb +65 -0
- data/test/documentation/workarea/api/admin/pages_documentation_test.rb +93 -0
- data/test/documentation/workarea/api/admin/payment_profiles_documentation_test.rb +98 -0
- data/test/documentation/workarea/api/admin/payment_transactions_documentation_test.rb +43 -0
- data/test/documentation/workarea/api/admin/payments_documentation_test.rb +41 -0
- data/test/documentation/workarea/api/admin/prices_documentation_test.rb +82 -0
- data/test/documentation/workarea/api/admin/pricing_skus_documentation_test.rb +95 -0
- data/test/documentation/workarea/api/admin/product_images_documentation_test.rb +101 -0
- data/test/documentation/workarea/api/admin/products_documentation_test.rb +96 -0
- data/test/documentation/workarea/api/admin/promo_code_lists_documentation_test.rb +94 -0
- data/test/documentation/workarea/api/admin/recommendation_settings_documentation_test.rb +37 -0
- data/test/documentation/workarea/api/admin/redirects_documentation_test.rb +96 -0
- data/test/documentation/workarea/api/admin/release_changes_documentation_test.rb +32 -0
- data/test/documentation/workarea/api/admin/releases_documentation_test.rb +93 -0
- data/test/documentation/workarea/api/admin/saved_addresses_documentation_test.rb +92 -0
- data/test/documentation/workarea/api/admin/saved_credit_cards_documentation_test.rb +86 -0
- data/test/documentation/workarea/api/admin/shipping_rates_documentation_test.rb +78 -0
- data/test/documentation/workarea/api/admin/shipping_services_documentation_test.rb +93 -0
- data/test/documentation/workarea/api/admin/shippings_documentation_test.rb +41 -0
- data/test/documentation/workarea/api/admin/tax_categories_documentation_test.rb +95 -0
- data/test/documentation/workarea/api/admin/tax_rates_documentation_test.rb +78 -0
- data/test/documentation/workarea/api/admin/users_documentation_test.rb +99 -0
- data/test/documentation/workarea/api/admin/variants_documentation_test.rb +80 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/config/manifest.js +4 -0
- data/test/dummy/app/assets/images/.keep +0 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/controllers/concerns/.keep +0 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/jobs/application_job.rb +2 -0
- data/test/dummy/app/mailers/.keep +0 -0
- data/test/dummy/app/mailers/application_mailer.rb +4 -0
- data/test/dummy/app/models/.keep +0 -0
- data/test/dummy/app/models/concerns/.keep +0 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +34 -0
- data/test/dummy/bin/update +29 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +25 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/cable.yml +9 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +55 -0
- data/test/dummy/config/environments/production.rb +86 -0
- data/test/dummy/config/environments/test.rb +43 -0
- data/test/dummy/config/initializers/application_controller_renderer.rb +6 -0
- data/test/dummy/config/initializers/assets.rb +11 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/new_framework_defaults.rb +21 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/workarea.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/puma.rb +47 -0
- data/test/dummy/config/routes.rb +6 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/config/spring.rb +6 -0
- data/test/dummy/db/seeds.rb +2 -0
- data/test/dummy/log/.keep +0 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/test/dummy/public/apple-touch-icon.png +0 -0
- data/test/dummy/public/favicon.ico +1 -0
- data/test/integration/workarea/api/admin/audit_log_integration_test.rb +20 -0
- data/test/integration/workarea/api/admin/authentication_integration_test.rb +61 -0
- data/test/integration/workarea/api/admin/categories_integration_test.rb +64 -0
- data/test/integration/workarea/api/admin/category_product_rules_integration_test.rb +58 -0
- data/test/integration/workarea/api/admin/content_assets_integration_test.rb +65 -0
- data/test/integration/workarea/api/admin/content_integration_test.rb +59 -0
- data/test/integration/workarea/api/admin/discounts_integration_test.rb +64 -0
- data/test/integration/workarea/api/admin/email_signups_integration_test.rb +32 -0
- data/test/integration/workarea/api/admin/error_handling_integration_test.rb +16 -0
- data/test/integration/workarea/api/admin/fulfillments_integration_test.rb +62 -0
- data/test/integration/workarea/api/admin/inventory_skus_integration_test.rb +70 -0
- data/test/integration/workarea/api/admin/navigation_menus_integration_test.rb +54 -0
- data/test/integration/workarea/api/admin/navigation_taxons_integration_test.rb +63 -0
- data/test/integration/workarea/api/admin/orders_integration_test.rb +53 -0
- data/test/integration/workarea/api/admin/pages_integration_test.rb +64 -0
- data/test/integration/workarea/api/admin/payment_profiles_integration_test.rb +75 -0
- data/test/integration/workarea/api/admin/payment_transactions_integration_test.rb +45 -0
- data/test/integration/workarea/api/admin/payments_integration_test.rb +29 -0
- data/test/integration/workarea/api/admin/prices_integration_test.rb +55 -0
- data/test/integration/workarea/api/admin/pricing_skus_integration_test.rb +72 -0
- data/test/integration/workarea/api/admin/product_images_integration_test.rb +56 -0
- data/test/integration/workarea/api/admin/products_integration_test.rb +66 -0
- data/test/integration/workarea/api/admin/promo_code_lists_integration_test.rb +70 -0
- data/test/integration/workarea/api/admin/recommendation_settings_integration_test.rb +41 -0
- data/test/integration/workarea/api/admin/redirects_integration_test.rb +69 -0
- data/test/integration/workarea/api/admin/release_changes_integration_test.rb +32 -0
- data/test/integration/workarea/api/admin/releases_integration_test.rb +60 -0
- data/test/integration/workarea/api/admin/saved_addresses_integration_test.rb +70 -0
- data/test/integration/workarea/api/admin/saved_credit_cards_integration_test.rb +76 -0
- data/test/integration/workarea/api/admin/shipping_rates_integration_test.rb +54 -0
- data/test/integration/workarea/api/admin/shipping_services_integration_test.rb +64 -0
- data/test/integration/workarea/api/admin/shippings_integration_test.rb +34 -0
- data/test/integration/workarea/api/admin/tax_categories_integration_test.rb +64 -0
- data/test/integration/workarea/api/admin/tax_rates_integration_test.rb +66 -0
- data/test/integration/workarea/api/admin/users_integration_test.rb +67 -0
- data/test/integration/workarea/api/admin/variants_integration_test.rb +59 -0
- data/test/models/workarea/api/admin/bulk_upsert_test.rb +79 -0
- data/test/test_helper.rb +10 -0
- data/test/vcr_cassettes/product_image_from_url.yml +43 -0
- data/workarea-api-admin.gemspec +18 -0
- metadata +252 -0
@@ -0,0 +1,305 @@
|
|
1
|
+
module Workarea
|
2
|
+
module Api
|
3
|
+
module Admin
|
4
|
+
class PromoCodeListsController < Admin::ApplicationController
|
5
|
+
before_action :find_promo_code_list, except: [:index, :create, :bulk]
|
6
|
+
|
7
|
+
swagger_path '/promo_code_lists' do
|
8
|
+
operation :get do
|
9
|
+
key :summary, 'All Promo Code Lists'
|
10
|
+
key :description, 'Returns all promo code lists from the system'
|
11
|
+
key :operationId, 'listPromoCodeLists'
|
12
|
+
key :produces, ['application/json']
|
13
|
+
|
14
|
+
parameter do
|
15
|
+
key :name, :page
|
16
|
+
key :in, :query
|
17
|
+
key :description, 'Current page'
|
18
|
+
key :required, false
|
19
|
+
key :type, :integer
|
20
|
+
key :default, 1
|
21
|
+
end
|
22
|
+
parameter do
|
23
|
+
key :name, :sort_by
|
24
|
+
key :in, :query
|
25
|
+
key :description, 'Field on which to sort (see responses for possible values)'
|
26
|
+
key :required, false
|
27
|
+
key :type, :string
|
28
|
+
key :default, 'created_at'
|
29
|
+
end
|
30
|
+
parameter do
|
31
|
+
key :name, :sort_direction
|
32
|
+
key :in, :query
|
33
|
+
key :description, 'Direction for sort by'
|
34
|
+
key :type, :string
|
35
|
+
key :enum, %w(asc desc)
|
36
|
+
key :default, 'desc'
|
37
|
+
end
|
38
|
+
|
39
|
+
response 200 do
|
40
|
+
key :description, 'Promo code lists'
|
41
|
+
schema do
|
42
|
+
key :type, :object
|
43
|
+
property :promo_code_lists do
|
44
|
+
key :type, :array
|
45
|
+
items do
|
46
|
+
key :'$ref', 'Workarea::Pricing::Discount::CodeList'
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
operation :post do
|
54
|
+
key :summary, 'Create Promo Code List'
|
55
|
+
key :description, 'Creates a new promo code list.'
|
56
|
+
key :operationId, 'addPromoCodeList'
|
57
|
+
key :produces, ['application/json']
|
58
|
+
|
59
|
+
parameter do
|
60
|
+
key :name, :body
|
61
|
+
key :in, :body
|
62
|
+
key :description, 'Promo code list to add'
|
63
|
+
key :required, true
|
64
|
+
schema do
|
65
|
+
key :type, :object
|
66
|
+
property :promo_code_list do
|
67
|
+
key :'$ref', 'Workarea::Pricing::Discount::CodeList'
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
response 201 do
|
73
|
+
key :description, 'Promo code list created'
|
74
|
+
schema do
|
75
|
+
key :type, :object
|
76
|
+
property :promo_code_list do
|
77
|
+
key :'$ref', 'Workarea::Pricing::Discount::CodeList'
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
response 422 do
|
83
|
+
key :description, 'Validation failure'
|
84
|
+
schema do
|
85
|
+
key :type, :object
|
86
|
+
property :problem do
|
87
|
+
key :type, :string
|
88
|
+
end
|
89
|
+
property :document do
|
90
|
+
key :'$ref', 'Workarea::Pricing::Discount::CodeList'
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def index
|
98
|
+
@promo_code_lists = Pricing::Discount::CodeList
|
99
|
+
.all
|
100
|
+
.order_by(sort_field => sort_direction)
|
101
|
+
.page(params[:page])
|
102
|
+
|
103
|
+
respond_with promo_code_lists: @promo_code_lists
|
104
|
+
end
|
105
|
+
|
106
|
+
def create
|
107
|
+
@promo_code_list = Pricing::Discount::CodeList.create!(params[:promo_code_list])
|
108
|
+
respond_with(
|
109
|
+
{ promo_code_list: @promo_code_list },
|
110
|
+
{ status: :created,
|
111
|
+
location: promo_code_list_path(@promo_code_list) }
|
112
|
+
)
|
113
|
+
end
|
114
|
+
|
115
|
+
swagger_path '/promo_code_lists/{id}' do
|
116
|
+
operation :get do
|
117
|
+
key :summary, 'Find Promo Code List by ID'
|
118
|
+
key :description, 'Returns a single promo code list'
|
119
|
+
key :operationId, 'showPromoCodeList'
|
120
|
+
|
121
|
+
parameter do
|
122
|
+
key :name, :id
|
123
|
+
key :in, :path
|
124
|
+
key :description, 'ID of promo code list to fetch'
|
125
|
+
key :required, true
|
126
|
+
key :type, :string
|
127
|
+
end
|
128
|
+
|
129
|
+
response 200 do
|
130
|
+
key :description, 'Promo code list details'
|
131
|
+
schema do
|
132
|
+
key :type, :object
|
133
|
+
property :promo_code_list do
|
134
|
+
key :'$ref', 'Workarea::Pricing::Discount::CodeList'
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
response 404 do
|
140
|
+
key :description, 'Promo code list not found'
|
141
|
+
schema do
|
142
|
+
key :type, :object
|
143
|
+
property :problem do
|
144
|
+
key :type, :string
|
145
|
+
end
|
146
|
+
property :params do
|
147
|
+
key :type, :object
|
148
|
+
key :additionalProperties, true
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
operation :patch do
|
155
|
+
key :summary, 'Update a Promo Code List'
|
156
|
+
key :description, 'Updates attributes on a promo code list'
|
157
|
+
key :operationId, 'updatePromoCodeList'
|
158
|
+
|
159
|
+
parameter do
|
160
|
+
key :name, :id
|
161
|
+
key :in, :path
|
162
|
+
key :description, 'ID of promo code list to update'
|
163
|
+
key :required, true
|
164
|
+
key :type, :string
|
165
|
+
end
|
166
|
+
|
167
|
+
parameter do
|
168
|
+
key :name, :body
|
169
|
+
key :in, :body
|
170
|
+
key :required, true
|
171
|
+
schema do
|
172
|
+
key :type, :object
|
173
|
+
property :promo_code_list do
|
174
|
+
key :description, 'New attributes'
|
175
|
+
key :'$ref', 'Workarea::Pricing::Discount::CodeList'
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
response 204 do
|
181
|
+
key :description, 'Promo code list updated successfully'
|
182
|
+
end
|
183
|
+
|
184
|
+
response 422 do
|
185
|
+
key :description, 'Validation failure'
|
186
|
+
schema do
|
187
|
+
key :type, :object
|
188
|
+
property :problem do
|
189
|
+
key :type, :string
|
190
|
+
end
|
191
|
+
property :document do
|
192
|
+
key :'$ref', 'Workarea::Pricing::Discount::CodeList'
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
response 404 do
|
198
|
+
key :description, 'Promo code list not found'
|
199
|
+
schema do
|
200
|
+
key :type, :object
|
201
|
+
property :problem do
|
202
|
+
key :type, :string
|
203
|
+
end
|
204
|
+
property :params do
|
205
|
+
key :type, :object
|
206
|
+
key :additionalProperties, true
|
207
|
+
end
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
operation :delete do
|
213
|
+
key :summary, 'Remove a Promo Code List'
|
214
|
+
key :description, 'Remove a promo code list'
|
215
|
+
key :operationId, 'removePromoCodeList'
|
216
|
+
|
217
|
+
parameter do
|
218
|
+
key :name, :id
|
219
|
+
key :in, :path
|
220
|
+
key :description, 'ID of promo code list to remove'
|
221
|
+
key :required, true
|
222
|
+
key :type, :string
|
223
|
+
end
|
224
|
+
|
225
|
+
response 204 do
|
226
|
+
key :description, 'Promo code list removed successfully'
|
227
|
+
end
|
228
|
+
|
229
|
+
response 404 do
|
230
|
+
key :description, 'Promo code list not found'
|
231
|
+
schema do
|
232
|
+
key :type, :object
|
233
|
+
property :problem do
|
234
|
+
key :type, :string
|
235
|
+
end
|
236
|
+
property :params do
|
237
|
+
key :type, :object
|
238
|
+
key :additionalProperties, true
|
239
|
+
end
|
240
|
+
end
|
241
|
+
end
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
def show
|
246
|
+
respond_with promo_code_list: @promo_code_list
|
247
|
+
end
|
248
|
+
|
249
|
+
def update
|
250
|
+
@promo_code_list.update_attributes!(params[:promo_code_list])
|
251
|
+
respond_with promo_code_list: @promo_code_list
|
252
|
+
end
|
253
|
+
|
254
|
+
swagger_path '/promo_code_lists/bulk' do
|
255
|
+
operation :patch do
|
256
|
+
key :summary, 'Bulk Upsert Promo Code Lists'
|
257
|
+
key :description, 'Creates new promo code lists or updates existing ones in bulk.'
|
258
|
+
key :operationId, 'upsertPromoCodeLists'
|
259
|
+
key :produces, ['application/json']
|
260
|
+
|
261
|
+
parameter do
|
262
|
+
key :name, :body
|
263
|
+
key :in, :body
|
264
|
+
key :description, 'Array of promo code lists to upsert'
|
265
|
+
key :required, true
|
266
|
+
schema do
|
267
|
+
key :type, :object
|
268
|
+
property :promo_code_lists do
|
269
|
+
key :type, :array
|
270
|
+
items do
|
271
|
+
key :'$ref', 'Workarea::Pricing::Discount::CodeList'
|
272
|
+
end
|
273
|
+
end
|
274
|
+
end
|
275
|
+
end
|
276
|
+
|
277
|
+
response 204 do
|
278
|
+
key :description, 'Upsert received'
|
279
|
+
end
|
280
|
+
end
|
281
|
+
end
|
282
|
+
|
283
|
+
def bulk
|
284
|
+
@bulk = Api::Admin::BulkUpsert.create!(
|
285
|
+
klass: Pricing::Discount::CodeList,
|
286
|
+
data: params[:promo_code_lists].map(&:to_h)
|
287
|
+
)
|
288
|
+
|
289
|
+
head :no_content
|
290
|
+
end
|
291
|
+
|
292
|
+
def destroy
|
293
|
+
@promo_code_list.destroy
|
294
|
+
head :no_content
|
295
|
+
end
|
296
|
+
|
297
|
+
private
|
298
|
+
|
299
|
+
def find_promo_code_list
|
300
|
+
@promo_code_list = Pricing::Discount::CodeList.find(params[:id])
|
301
|
+
end
|
302
|
+
end
|
303
|
+
end
|
304
|
+
end
|
305
|
+
end
|
@@ -0,0 +1,122 @@
|
|
1
|
+
module Workarea
|
2
|
+
module Api
|
3
|
+
module Admin
|
4
|
+
class RecommendationSettingsController < Admin::ApplicationController
|
5
|
+
before_action :find_recommendation_settings
|
6
|
+
|
7
|
+
swagger_path '/products/{product_id}/recommendation_settings' do
|
8
|
+
operation :get do
|
9
|
+
key :summary, 'Find Recommendation Settings by Product ID'
|
10
|
+
key :description, 'Returns recommendation settings for a product'
|
11
|
+
key :operationId, 'showProductRecommendationSettings'
|
12
|
+
|
13
|
+
parameter do
|
14
|
+
key :name, :product_id
|
15
|
+
key :in, :path
|
16
|
+
key :description, 'ID of product to fetch'
|
17
|
+
key :required, true
|
18
|
+
key :type, :string
|
19
|
+
end
|
20
|
+
|
21
|
+
response 200 do
|
22
|
+
key :description, 'Recommendation settings'
|
23
|
+
schema do
|
24
|
+
key :type, :object
|
25
|
+
property :recommendation_settings do
|
26
|
+
key :'$ref', 'Workarea::Recommendation::Settings'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
response 404 do
|
32
|
+
key :description, 'Product or recommendation settings not found'
|
33
|
+
schema do
|
34
|
+
key :type, :object
|
35
|
+
property :problem do
|
36
|
+
key :type, :string
|
37
|
+
end
|
38
|
+
property :params do
|
39
|
+
key :type, :object
|
40
|
+
key :additionalProperties, true
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
operation :patch do
|
47
|
+
key :summary, 'Update product recommendation settings'
|
48
|
+
key :description, 'Updates attributes on recommendation settings for a product'
|
49
|
+
key :operationId, 'updateProductRecommendationSettings'
|
50
|
+
|
51
|
+
parameter do
|
52
|
+
key :name, :product_id
|
53
|
+
key :in, :path
|
54
|
+
key :description, 'ID of product'
|
55
|
+
key :required, true
|
56
|
+
key :type, :string
|
57
|
+
end
|
58
|
+
|
59
|
+
parameter do
|
60
|
+
key :name, :body
|
61
|
+
key :in, :body
|
62
|
+
key :description, 'New attributes'
|
63
|
+
key :required, true
|
64
|
+
schema do
|
65
|
+
key :type, :object
|
66
|
+
property :recommendation_settings do
|
67
|
+
key :'$ref', 'Workarea::Recommendation::Settings'
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
response 204 do
|
73
|
+
key :description, 'Recommendation settings updated successfully'
|
74
|
+
end
|
75
|
+
|
76
|
+
response 422 do
|
77
|
+
key :description, 'Validation failure'
|
78
|
+
schema do
|
79
|
+
key :type, :object
|
80
|
+
property :problem do
|
81
|
+
key :type, :string
|
82
|
+
end
|
83
|
+
property :document do
|
84
|
+
key :'$ref', 'Workarea::Recommendation::Settings'
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
response 404 do
|
90
|
+
key :description, 'Product not found'
|
91
|
+
schema do
|
92
|
+
key :type, :object
|
93
|
+
property :problem do
|
94
|
+
key :type, :string
|
95
|
+
end
|
96
|
+
property :params do
|
97
|
+
key :type, :object
|
98
|
+
key :additionalProperties, true
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
def show
|
106
|
+
respond_with recommendation_settings: @recommendation_settings
|
107
|
+
end
|
108
|
+
|
109
|
+
def update
|
110
|
+
@recommendation_settings.update_attributes!(params[:recommendation_settings])
|
111
|
+
respond_with recommendation_settings: @recommendation_settings
|
112
|
+
end
|
113
|
+
|
114
|
+
private
|
115
|
+
|
116
|
+
def find_recommendation_settings
|
117
|
+
@recommendation_settings = Recommendation::Settings.find(params[:product_id])
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
@@ -0,0 +1,305 @@
|
|
1
|
+
module Workarea
|
2
|
+
module Api
|
3
|
+
module Admin
|
4
|
+
class RedirectsController < Admin::ApplicationController
|
5
|
+
before_action :find_redirect, except: [:index, :create, :bulk]
|
6
|
+
|
7
|
+
swagger_path '/redirects' do
|
8
|
+
operation :get do
|
9
|
+
key :summary, 'All Redirects'
|
10
|
+
key :description, 'Returns all redirects from the system'
|
11
|
+
key :operationId, 'listRedirects'
|
12
|
+
key :produces, ['application/json']
|
13
|
+
|
14
|
+
parameter do
|
15
|
+
key :name, :page
|
16
|
+
key :in, :query
|
17
|
+
key :description, 'Current page'
|
18
|
+
key :required, false
|
19
|
+
key :type, :integer
|
20
|
+
key :default, 1
|
21
|
+
end
|
22
|
+
parameter do
|
23
|
+
key :name, :sort_by
|
24
|
+
key :in, :query
|
25
|
+
key :description, 'Field on which to sort (see responses for possible values)'
|
26
|
+
key :required, false
|
27
|
+
key :type, :string
|
28
|
+
key :default, 'created_at'
|
29
|
+
end
|
30
|
+
parameter do
|
31
|
+
key :name, :sort_direction
|
32
|
+
key :in, :query
|
33
|
+
key :description, 'Direction for sort by'
|
34
|
+
key :type, :string
|
35
|
+
key :enum, %w(asc desc)
|
36
|
+
key :default, 'desc'
|
37
|
+
end
|
38
|
+
|
39
|
+
response 200 do
|
40
|
+
key :description, 'Redirects'
|
41
|
+
schema do
|
42
|
+
key :type, :object
|
43
|
+
property :redirects do
|
44
|
+
key :type, :array
|
45
|
+
items do
|
46
|
+
key :'$ref', 'Workarea::Navigation::Redirect'
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
operation :post do
|
54
|
+
key :summary, 'Create Redirect'
|
55
|
+
key :description, 'Creates a new redirect.'
|
56
|
+
key :operationId, 'addRedirect'
|
57
|
+
key :produces, ['application/json']
|
58
|
+
|
59
|
+
parameter do
|
60
|
+
key :name, :body
|
61
|
+
key :in, :body
|
62
|
+
key :description, 'Redirect to add'
|
63
|
+
key :required, true
|
64
|
+
schema do
|
65
|
+
key :type, :object
|
66
|
+
property :redirect do
|
67
|
+
key :'$ref', 'Workarea::Navigation::Redirect'
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
response 201 do
|
73
|
+
key :description, 'Redirect created'
|
74
|
+
schema do
|
75
|
+
key :type, :object
|
76
|
+
property :redirect do
|
77
|
+
key :'$ref', 'Workarea::Navigation::Redirect'
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
response 422 do
|
83
|
+
key :description, 'Validation failure'
|
84
|
+
schema do
|
85
|
+
key :type, :object
|
86
|
+
property :problem do
|
87
|
+
key :type, :string
|
88
|
+
end
|
89
|
+
property :document do
|
90
|
+
key :'$ref', 'Workarea::Navigation::Redirect'
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def index
|
98
|
+
@redirects = Navigation::Redirect
|
99
|
+
.all
|
100
|
+
.order_by(sort_field => sort_direction)
|
101
|
+
.page(params[:page])
|
102
|
+
|
103
|
+
respond_with redirects: @redirects
|
104
|
+
end
|
105
|
+
|
106
|
+
def create
|
107
|
+
@redirect = Navigation::Redirect.create!(params[:redirect])
|
108
|
+
respond_with(
|
109
|
+
{ redirect: @redirect },
|
110
|
+
{ status: :created,
|
111
|
+
location: redirect_path(@redirect) }
|
112
|
+
)
|
113
|
+
end
|
114
|
+
|
115
|
+
swagger_path '/redirects/{id}' do
|
116
|
+
operation :get do
|
117
|
+
key :summary, 'Find Redirect by ID'
|
118
|
+
key :description, 'Returns a single redirect'
|
119
|
+
key :operationId, 'showRedirect'
|
120
|
+
|
121
|
+
parameter do
|
122
|
+
key :name, :id
|
123
|
+
key :in, :path
|
124
|
+
key :description, 'ID of redirect to fetch'
|
125
|
+
key :required, true
|
126
|
+
key :type, :string
|
127
|
+
end
|
128
|
+
|
129
|
+
response 200 do
|
130
|
+
key :description, 'Redirect details'
|
131
|
+
schema do
|
132
|
+
key :type, :object
|
133
|
+
property :redirect do
|
134
|
+
key :'$ref', 'Workarea::Navigation::Redirect'
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
response 404 do
|
140
|
+
key :description, 'Redirect not found'
|
141
|
+
schema do
|
142
|
+
key :type, :object
|
143
|
+
property :problem do
|
144
|
+
key :type, :string
|
145
|
+
end
|
146
|
+
property :params do
|
147
|
+
key :type, :object
|
148
|
+
key :additionalProperties, true
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
operation :patch do
|
155
|
+
key :summary, 'Update a Redirect'
|
156
|
+
key :description, 'Updates attributes on a redirect'
|
157
|
+
key :operationId, 'updateRedirect'
|
158
|
+
|
159
|
+
parameter do
|
160
|
+
key :name, :id
|
161
|
+
key :in, :path
|
162
|
+
key :description, 'ID of redirect to update'
|
163
|
+
key :required, true
|
164
|
+
key :type, :string
|
165
|
+
end
|
166
|
+
|
167
|
+
parameter do
|
168
|
+
key :name, :body
|
169
|
+
key :in, :body
|
170
|
+
key :required, true
|
171
|
+
schema do
|
172
|
+
key :type, :object
|
173
|
+
property :redirect do
|
174
|
+
key :description, 'New attributes'
|
175
|
+
key :'$ref', 'Workarea::Navigation::Redirect'
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
response 204 do
|
181
|
+
key :description, 'Redirect updated successfully'
|
182
|
+
end
|
183
|
+
|
184
|
+
response 422 do
|
185
|
+
key :description, 'Validation failure'
|
186
|
+
schema do
|
187
|
+
key :type, :object
|
188
|
+
property :problem do
|
189
|
+
key :type, :string
|
190
|
+
end
|
191
|
+
property :document do
|
192
|
+
key :'$ref', 'Workarea::Navigation::Redirect'
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
response 404 do
|
198
|
+
key :description, 'Redirect not found'
|
199
|
+
schema do
|
200
|
+
key :type, :object
|
201
|
+
property :problem do
|
202
|
+
key :type, :string
|
203
|
+
end
|
204
|
+
property :params do
|
205
|
+
key :type, :object
|
206
|
+
key :additionalProperties, true
|
207
|
+
end
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
operation :delete do
|
213
|
+
key :summary, 'Remove a Redirect'
|
214
|
+
key :description, 'Remove a redirect'
|
215
|
+
key :operationId, 'removeRedirect'
|
216
|
+
|
217
|
+
parameter do
|
218
|
+
key :name, :id
|
219
|
+
key :in, :path
|
220
|
+
key :description, 'ID of redirect to remove'
|
221
|
+
key :required, true
|
222
|
+
key :type, :string
|
223
|
+
end
|
224
|
+
|
225
|
+
response 204 do
|
226
|
+
key :description, 'Redirect removed successfully'
|
227
|
+
end
|
228
|
+
|
229
|
+
response 404 do
|
230
|
+
key :description, 'Redirect not found'
|
231
|
+
schema do
|
232
|
+
key :type, :object
|
233
|
+
property :problem do
|
234
|
+
key :type, :string
|
235
|
+
end
|
236
|
+
property :params do
|
237
|
+
key :type, :object
|
238
|
+
key :additionalProperties, true
|
239
|
+
end
|
240
|
+
end
|
241
|
+
end
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
def show
|
246
|
+
respond_with redirect: @redirect
|
247
|
+
end
|
248
|
+
|
249
|
+
def update
|
250
|
+
@redirect.update_attributes!(params[:redirect])
|
251
|
+
respond_with redirect: @redirect
|
252
|
+
end
|
253
|
+
|
254
|
+
swagger_path '/redirects/bulk' do
|
255
|
+
operation :patch do
|
256
|
+
key :summary, 'Bulk Upsert Redirects'
|
257
|
+
key :description, 'Creates new redirects or updates existing ones in bulk.'
|
258
|
+
key :operationId, 'upsertRedirects'
|
259
|
+
key :produces, ['application/json']
|
260
|
+
|
261
|
+
parameter do
|
262
|
+
key :name, :body
|
263
|
+
key :in, :body
|
264
|
+
key :description, 'Array of redirects to upsert'
|
265
|
+
key :required, true
|
266
|
+
schema do
|
267
|
+
key :type, :object
|
268
|
+
property :redirects do
|
269
|
+
key :type, :array
|
270
|
+
items do
|
271
|
+
key :'$ref', 'Workarea::Navigation::Redirect'
|
272
|
+
end
|
273
|
+
end
|
274
|
+
end
|
275
|
+
end
|
276
|
+
|
277
|
+
response 204 do
|
278
|
+
key :description, 'Upsert received'
|
279
|
+
end
|
280
|
+
end
|
281
|
+
end
|
282
|
+
|
283
|
+
def bulk
|
284
|
+
@bulk = Api::Admin::BulkUpsert.create!(
|
285
|
+
klass: Navigation::Redirect,
|
286
|
+
data: params[:redirects].map(&:to_h)
|
287
|
+
)
|
288
|
+
|
289
|
+
head :no_content
|
290
|
+
end
|
291
|
+
|
292
|
+
def destroy
|
293
|
+
@redirect.destroy
|
294
|
+
head :no_content
|
295
|
+
end
|
296
|
+
|
297
|
+
private
|
298
|
+
|
299
|
+
def find_redirect
|
300
|
+
@redirect = Navigation::Redirect.find(params[:id])
|
301
|
+
end
|
302
|
+
end
|
303
|
+
end
|
304
|
+
end
|
305
|
+
end
|