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,299 @@
|
|
1
|
+
module Workarea
|
2
|
+
module Api
|
3
|
+
module Admin
|
4
|
+
class ShippingServicesController < Admin::ApplicationController
|
5
|
+
before_action :find_shipping_service, except: [:index, :create, :bulk]
|
6
|
+
|
7
|
+
swagger_path '/shipping_services' do
|
8
|
+
operation :get do
|
9
|
+
key :summary, 'All Shipping Services'
|
10
|
+
key :description, 'Returns all shipping services from the system'
|
11
|
+
key :operationId, 'listShippingServices'
|
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, 'Shipping services'
|
41
|
+
schema do
|
42
|
+
key :type, :object
|
43
|
+
property :shipping_services do
|
44
|
+
key :type, :array
|
45
|
+
items do
|
46
|
+
key :'$ref', 'Workarea::Shipping::Service'
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
operation :post do
|
54
|
+
key :summary, 'Create Shipping Service'
|
55
|
+
key :description, 'Creates a new shipping service.'
|
56
|
+
key :operationId, 'addShippingService'
|
57
|
+
key :produces, ['application/json']
|
58
|
+
|
59
|
+
parameter do
|
60
|
+
key :name, :body
|
61
|
+
key :in, :body
|
62
|
+
key :description, 'Shipping service to add'
|
63
|
+
key :required, true
|
64
|
+
schema do
|
65
|
+
key :type, :object
|
66
|
+
property :shipping_service do
|
67
|
+
key :'$ref', 'Workarea::Shipping::Service'
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
response 201 do
|
73
|
+
key :description, 'Shipping service created'
|
74
|
+
schema do
|
75
|
+
key :type, :object
|
76
|
+
property :shipping_service do
|
77
|
+
key :'$ref', 'Workarea::Shipping::Service'
|
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::Shipping::Service'
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def index
|
98
|
+
@shipping_services = Shipping::Service
|
99
|
+
.all
|
100
|
+
.order_by(sort_field => sort_direction)
|
101
|
+
.page(params[:page])
|
102
|
+
|
103
|
+
respond_with shipping_services: @shipping_services
|
104
|
+
end
|
105
|
+
|
106
|
+
def create
|
107
|
+
@shipping_service = Shipping::Service.create!(params[:shipping_service])
|
108
|
+
respond_with(
|
109
|
+
{ shipping_service: @shipping_service },
|
110
|
+
{ status: :created,
|
111
|
+
location: shipping_service_path(@shipping_service) }
|
112
|
+
)
|
113
|
+
end
|
114
|
+
|
115
|
+
swagger_path '/shipping_services/{id}' do
|
116
|
+
operation :get do
|
117
|
+
key :summary, 'Find Shipping Service by ID'
|
118
|
+
key :description, 'Returns a single shipping service'
|
119
|
+
key :operationId, 'showShippingService'
|
120
|
+
|
121
|
+
parameter do
|
122
|
+
key :name, :id
|
123
|
+
key :in, :path
|
124
|
+
key :description, 'ID of shipping service to fetch'
|
125
|
+
key :required, true
|
126
|
+
key :type, :string
|
127
|
+
end
|
128
|
+
|
129
|
+
response 200 do
|
130
|
+
key :description, 'Shipping service details'
|
131
|
+
schema do
|
132
|
+
key :'$ref', 'Workarea::Shipping::Service'
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
response 404 do
|
137
|
+
key :description, 'Shipping service not found'
|
138
|
+
schema do
|
139
|
+
key :type, :object
|
140
|
+
property :problem do
|
141
|
+
key :type, :string
|
142
|
+
end
|
143
|
+
property :params do
|
144
|
+
key :type, :object
|
145
|
+
key :additionalProperties, true
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
operation :patch do
|
152
|
+
key :summary, 'Update a Shipping Service'
|
153
|
+
key :description, 'Updates attributes on a shipping service'
|
154
|
+
key :operationId, 'updateShippingService'
|
155
|
+
|
156
|
+
parameter do
|
157
|
+
key :name, :id
|
158
|
+
key :in, :path
|
159
|
+
key :description, 'ID of shipping service to update'
|
160
|
+
key :required, true
|
161
|
+
key :type, :string
|
162
|
+
end
|
163
|
+
|
164
|
+
parameter do
|
165
|
+
key :name, :body
|
166
|
+
key :in, :body
|
167
|
+
key :description, 'New attributes'
|
168
|
+
key :required, true
|
169
|
+
schema do
|
170
|
+
key :type, :object
|
171
|
+
property :shipping_service do
|
172
|
+
key :'$ref', 'Workarea::Shipping::Service'
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
response 204 do
|
178
|
+
key :description, 'Shipping service updated successfully'
|
179
|
+
end
|
180
|
+
|
181
|
+
response 422 do
|
182
|
+
key :description, 'Validation failure'
|
183
|
+
schema do
|
184
|
+
key :type, :object
|
185
|
+
property :problem do
|
186
|
+
key :type, :string
|
187
|
+
end
|
188
|
+
property :document do
|
189
|
+
key :'$ref', 'Workarea::Shipping::Service'
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
response 404 do
|
195
|
+
key :description, 'Shipping service not found'
|
196
|
+
schema do
|
197
|
+
key :type, :object
|
198
|
+
property :problem do
|
199
|
+
key :type, :string
|
200
|
+
end
|
201
|
+
property :params do
|
202
|
+
key :type, :object
|
203
|
+
key :additionalProperties, true
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
operation :delete do
|
210
|
+
key :summary, 'Remove a Shipping Service'
|
211
|
+
key :description, 'Remove a shipping service'
|
212
|
+
key :operationId, 'removeShippingService'
|
213
|
+
|
214
|
+
parameter do
|
215
|
+
key :name, :id
|
216
|
+
key :in, :path
|
217
|
+
key :description, 'ID of shipping service to remove'
|
218
|
+
key :required, true
|
219
|
+
key :type, :string
|
220
|
+
end
|
221
|
+
|
222
|
+
response 204 do
|
223
|
+
key :description, 'Shipping service removed successfully'
|
224
|
+
end
|
225
|
+
|
226
|
+
response 404 do
|
227
|
+
key :description, 'Shipping service not found'
|
228
|
+
schema do
|
229
|
+
key :type, :object
|
230
|
+
property :problem do
|
231
|
+
key :type, :string
|
232
|
+
end
|
233
|
+
property :params do
|
234
|
+
key :type, :object
|
235
|
+
key :additionalProperties, true
|
236
|
+
end
|
237
|
+
end
|
238
|
+
end
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
def show
|
243
|
+
respond_with shipping_service: @shipping_service
|
244
|
+
end
|
245
|
+
|
246
|
+
def update
|
247
|
+
@shipping_service.update_attributes!(params[:shipping_service])
|
248
|
+
respond_with shipping_service: @shipping_service
|
249
|
+
end
|
250
|
+
|
251
|
+
swagger_path '/shipping_services/bulk' do
|
252
|
+
operation :patch do
|
253
|
+
key :summary, 'Bulk Upsert Shipping Services'
|
254
|
+
key :description, 'Creates new shipping services or updates existing ones in bulk.'
|
255
|
+
key :operationId, 'upsertShippingServices'
|
256
|
+
key :produces, ['application/json']
|
257
|
+
|
258
|
+
parameter do
|
259
|
+
key :name, :body
|
260
|
+
key :in, :body
|
261
|
+
key :description, 'Array of shipping services to upsert'
|
262
|
+
key :required, true
|
263
|
+
schema do
|
264
|
+
key :type, :array
|
265
|
+
items do
|
266
|
+
key :'$ref', 'Workarea::Shipping::Service'
|
267
|
+
end
|
268
|
+
end
|
269
|
+
end
|
270
|
+
|
271
|
+
response 204 do
|
272
|
+
key :description, 'Upsert received'
|
273
|
+
end
|
274
|
+
end
|
275
|
+
end
|
276
|
+
|
277
|
+
def bulk
|
278
|
+
@bulk = Api::Admin::BulkUpsert.create!(
|
279
|
+
klass: Shipping::Service,
|
280
|
+
data: params[:shipping_services].map(&:to_h)
|
281
|
+
)
|
282
|
+
|
283
|
+
head :no_content
|
284
|
+
end
|
285
|
+
|
286
|
+
def destroy
|
287
|
+
@shipping_service.destroy
|
288
|
+
head :no_content
|
289
|
+
end
|
290
|
+
|
291
|
+
private
|
292
|
+
|
293
|
+
def find_shipping_service
|
294
|
+
@shipping_service = Shipping::Service.find(params[:id])
|
295
|
+
end
|
296
|
+
end
|
297
|
+
end
|
298
|
+
end
|
299
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
module Workarea
|
2
|
+
module Api
|
3
|
+
module Admin
|
4
|
+
class ShippingsController < Admin::ApplicationController
|
5
|
+
swagger_path '/shippings' do
|
6
|
+
operation :get do
|
7
|
+
key :summary, 'All Shippings'
|
8
|
+
key :description, 'Returns all shippings from the system'
|
9
|
+
key :operationId, 'listShippings'
|
10
|
+
key :produces, ['application/json']
|
11
|
+
|
12
|
+
parameter do
|
13
|
+
key :name, :page
|
14
|
+
key :in, :query
|
15
|
+
key :description, 'Current page'
|
16
|
+
key :required, false
|
17
|
+
key :type, :integer
|
18
|
+
key :default, 1
|
19
|
+
end
|
20
|
+
parameter do
|
21
|
+
key :name, :sort_by
|
22
|
+
key :in, :query
|
23
|
+
key :description, 'Field on which to sort (see responses for possible values)'
|
24
|
+
key :required, false
|
25
|
+
key :type, :string
|
26
|
+
key :default, 'created_at'
|
27
|
+
end
|
28
|
+
parameter do
|
29
|
+
key :name, :sort_direction
|
30
|
+
key :in, :query
|
31
|
+
key :description, 'Direction for sort by'
|
32
|
+
key :type, :string
|
33
|
+
key :enum, %w(asc desc)
|
34
|
+
key :default, 'desc'
|
35
|
+
end
|
36
|
+
|
37
|
+
response 200 do
|
38
|
+
key :description, 'Shippings'
|
39
|
+
schema do
|
40
|
+
key :type, :object
|
41
|
+
property :shippings do
|
42
|
+
key :type, :array
|
43
|
+
items do
|
44
|
+
key :'$ref', 'Workarea::Shipping'
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def index
|
53
|
+
@shippings = Shipping
|
54
|
+
.all
|
55
|
+
.order_by(sort_field => sort_direction)
|
56
|
+
.page(params[:page])
|
57
|
+
|
58
|
+
respond_with shippings: @shippings
|
59
|
+
end
|
60
|
+
|
61
|
+
swagger_path '/shippings/{id}' do
|
62
|
+
operation :get do
|
63
|
+
key :summary, 'Find Shipping Service by ID'
|
64
|
+
key :description, 'Returns a single shipping'
|
65
|
+
key :operationId, 'showShipping'
|
66
|
+
|
67
|
+
parameter do
|
68
|
+
key :name, :id
|
69
|
+
key :in, :path
|
70
|
+
key :description, 'ID of shipping to fetch'
|
71
|
+
key :required, true
|
72
|
+
key :type, :string
|
73
|
+
end
|
74
|
+
|
75
|
+
response 200 do
|
76
|
+
key :description, 'Shipping details'
|
77
|
+
schema do
|
78
|
+
key :'$ref', 'Workarea::Shipping'
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
response 404 do
|
83
|
+
key :description, 'Shipping not found'
|
84
|
+
schema do
|
85
|
+
key :type, :object
|
86
|
+
property :problem do
|
87
|
+
key :type, :string
|
88
|
+
end
|
89
|
+
property :params do
|
90
|
+
key :type, :object
|
91
|
+
key :additionalProperties, true
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def show
|
99
|
+
@shipping = Shipping.find(params[:id])
|
100
|
+
respond_with shipping: @shipping
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Workarea
|
2
|
+
module Api
|
3
|
+
module Admin
|
4
|
+
class SwaggerController < Admin::ApplicationController
|
5
|
+
include ::Swagger::Blocks
|
6
|
+
|
7
|
+
def index
|
8
|
+
controller = self
|
9
|
+
self.class.send(:swagger_root) do
|
10
|
+
key :swagger, '2.0'
|
11
|
+
|
12
|
+
info do
|
13
|
+
key :version, '1.0.0'
|
14
|
+
key :title, 'Workarea Admin'
|
15
|
+
key :description, 'A backend API for integrating and configuring Workarea'
|
16
|
+
key :termsOfService, 'https://workarea.com'
|
17
|
+
contact do
|
18
|
+
key :name, 'Workarea Product Team'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
key :host, Workarea.config.host
|
23
|
+
key :basePath, controller.root_path[0..-2]
|
24
|
+
key :schemes, [Rails.application.config.force_ssl ? 'https' : 'http']
|
25
|
+
key :consumes, ['application/json']
|
26
|
+
key :produces, ['application/json']
|
27
|
+
|
28
|
+
security_definition :BasicAuth do
|
29
|
+
key :type, :basic
|
30
|
+
end
|
31
|
+
security do
|
32
|
+
key :BasicAuth, []
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
render json: ::Swagger::Blocks.build_root_json(Swagger.klasses)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,242 @@
|
|
1
|
+
module Workarea
|
2
|
+
module Api
|
3
|
+
module Admin
|
4
|
+
class TaxCategoriesController < Admin::ApplicationController
|
5
|
+
before_action :find_tax_category, except: [:index, :create, :bulk]
|
6
|
+
|
7
|
+
swagger_path '/tax_categories' do
|
8
|
+
operation :get do
|
9
|
+
key :summary, 'All Tax Categories'
|
10
|
+
key :description, 'Returns all tax categories'
|
11
|
+
key :operationId, 'listTaxCategories'
|
12
|
+
key :produces, ['application/json']
|
13
|
+
|
14
|
+
response 200 do
|
15
|
+
key :description, 'Tax categories'
|
16
|
+
schema do
|
17
|
+
key :type, :object
|
18
|
+
property :tax_categories do
|
19
|
+
key :type, :array
|
20
|
+
items do
|
21
|
+
key :'$ref', 'Workarea::Tax::Category'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
operation :post do
|
29
|
+
key :summary, 'Create a tax category'
|
30
|
+
key :description, 'Creates a new taxable category.'
|
31
|
+
key :operationId, 'addTaxCategory'
|
32
|
+
key :produces, ['application/json']
|
33
|
+
|
34
|
+
parameter do
|
35
|
+
key :name, :body
|
36
|
+
key :in, :body
|
37
|
+
key :description, 'Tax Category to add'
|
38
|
+
key :required, true
|
39
|
+
schema do
|
40
|
+
key :type, :object
|
41
|
+
property :tax_category do
|
42
|
+
key :'$ref', 'Workarea::Tax::Category'
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
response 201 do
|
48
|
+
key :description, 'Tax category created'
|
49
|
+
schema do
|
50
|
+
key :type, :object
|
51
|
+
property :tax_category do
|
52
|
+
key :'$ref', 'Workarea::Tax::Category'
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
response 422 do
|
58
|
+
key :description, 'Validation failure'
|
59
|
+
schema do
|
60
|
+
key :type, :object
|
61
|
+
property :problem do
|
62
|
+
key :type, :string
|
63
|
+
end
|
64
|
+
property :document do
|
65
|
+
key :'$ref', 'Workarea::Tax::Category'
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def index
|
73
|
+
@tax_categories = Tax::Category
|
74
|
+
.all
|
75
|
+
.order_by(sort_field => sort_direction)
|
76
|
+
.page(params[:page])
|
77
|
+
|
78
|
+
respond_with tax_categories: @tax_categories
|
79
|
+
end
|
80
|
+
|
81
|
+
def create
|
82
|
+
@tax_category = Tax::Category.create!(params[:tax_category])
|
83
|
+
respond_with(
|
84
|
+
{ tax_category: @tax_category },
|
85
|
+
{ status: :created,
|
86
|
+
location: tax_category_path(@tax_category) }
|
87
|
+
)
|
88
|
+
end
|
89
|
+
|
90
|
+
swagger_path '/tax_categories/{id}' do
|
91
|
+
operation :patch do
|
92
|
+
key :summary, 'Update a tax category'
|
93
|
+
key :description, 'Updates attributes on a tax category'
|
94
|
+
key :operationId, 'updateTaxCategory'
|
95
|
+
|
96
|
+
parameter do
|
97
|
+
key :name, :id
|
98
|
+
key :in, :path
|
99
|
+
key :description, 'ID of tax category to update'
|
100
|
+
key :required, true
|
101
|
+
key :type, :string
|
102
|
+
end
|
103
|
+
|
104
|
+
parameter do
|
105
|
+
key :name, :body
|
106
|
+
key :in, :body
|
107
|
+
key :description, 'New attributes'
|
108
|
+
key :required, true
|
109
|
+
schema do
|
110
|
+
key :type, :object
|
111
|
+
property :tax_category do
|
112
|
+
key :'$ref', 'Workarea::Tax::Category'
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
response 204 do
|
118
|
+
key :description, 'Tax category updated successfully'
|
119
|
+
end
|
120
|
+
|
121
|
+
response 422 do
|
122
|
+
key :description, 'Validation failure'
|
123
|
+
schema do
|
124
|
+
key :type, :object
|
125
|
+
property :problem do
|
126
|
+
key :type, :string
|
127
|
+
end
|
128
|
+
property :document do
|
129
|
+
key :'$ref', 'Workarea::Tax::Category'
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
response 404 do
|
135
|
+
key :description, 'Tax category not found'
|
136
|
+
schema do
|
137
|
+
key :type, :object
|
138
|
+
property :problem do
|
139
|
+
key :type, :string
|
140
|
+
end
|
141
|
+
property :params do
|
142
|
+
key :type, :object
|
143
|
+
key :additionalProperties, true
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
operation :delete do
|
150
|
+
key :summary, 'Remove a Tax Category'
|
151
|
+
key :description, 'Remove a tax category'
|
152
|
+
key :operationId, 'removeTaxCategory'
|
153
|
+
|
154
|
+
parameter do
|
155
|
+
key :name, :id
|
156
|
+
key :in, :path
|
157
|
+
key :description, 'ID of tax category'
|
158
|
+
key :required, true
|
159
|
+
key :type, :string
|
160
|
+
end
|
161
|
+
|
162
|
+
response 204 do
|
163
|
+
key :description, 'Tax category removed successfully'
|
164
|
+
end
|
165
|
+
|
166
|
+
response 404 do
|
167
|
+
key :description, 'Tax category not found'
|
168
|
+
schema do
|
169
|
+
key :type, :object
|
170
|
+
property :problem do
|
171
|
+
key :type, :string
|
172
|
+
end
|
173
|
+
property :params do
|
174
|
+
key :type, :object
|
175
|
+
key :additionalProperties, true
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
def show
|
183
|
+
respond_with tax_category: @tax_category
|
184
|
+
end
|
185
|
+
|
186
|
+
def update
|
187
|
+
@tax_category.update_attributes!(params[:tax_category])
|
188
|
+
respond_with tax_category: @tax_category
|
189
|
+
end
|
190
|
+
|
191
|
+
def destroy
|
192
|
+
@tax_category.destroy
|
193
|
+
head :no_content
|
194
|
+
end
|
195
|
+
|
196
|
+
swagger_path '/tax_categories/bulk' do
|
197
|
+
operation :patch do
|
198
|
+
key :summary, 'Bulk Upsert tax categories'
|
199
|
+
key :description, 'Creates new tax categories or updates existing ones in bulk.'
|
200
|
+
key :operationId, 'upsertTaxCategory'
|
201
|
+
key :produces, ['application/json']
|
202
|
+
|
203
|
+
parameter do
|
204
|
+
key :name, :body
|
205
|
+
key :in, :body
|
206
|
+
key :description, 'Array of tax categories to upsert'
|
207
|
+
key :required, true
|
208
|
+
schema do
|
209
|
+
key :type, :object
|
210
|
+
property :tax_categories do
|
211
|
+
key :type, :array
|
212
|
+
items do
|
213
|
+
key :'$ref', 'Workarea::Tax::Category'
|
214
|
+
end
|
215
|
+
end
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
response 204 do
|
220
|
+
key :description, 'Upsert received'
|
221
|
+
end
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
def bulk
|
226
|
+
@bulk = Api::Admin::BulkUpsert.create!(
|
227
|
+
klass: Tax::Category,
|
228
|
+
data: params[:tax_categories].map(&:to_h)
|
229
|
+
)
|
230
|
+
|
231
|
+
head :no_content
|
232
|
+
end
|
233
|
+
|
234
|
+
private
|
235
|
+
|
236
|
+
def find_tax_category
|
237
|
+
@tax_category = Tax::Category.find(params[:id])
|
238
|
+
end
|
239
|
+
end
|
240
|
+
end
|
241
|
+
end
|
242
|
+
end
|