Class: Workarea::Api::Admin::PricingSkusController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/workarea/api/admin/pricing_skus_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#current_user, #sort_direction, #sort_field

Instance Method Details

#bulkObject



290
291
292
293
294
295
296
297
# File 'app/controllers/workarea/api/admin/pricing_skus_controller.rb', line 290

def bulk
  @bulk = Api::Admin::BulkUpsert.create!(
    klass: Pricing::Sku,
    data: params[:pricing_skus].map(&:to_h)
  )

  head :no_content
end

#createObject



113
114
115
116
117
118
119
120
# File 'app/controllers/workarea/api/admin/pricing_skus_controller.rb', line 113

def create
  @pricing_sku = Pricing::Sku.create!(params[:pricing_sku])
  respond_with(
    { pricing_sku: @pricing_sku },
    { status: :created,
    location: pricing_sku_path(@pricing_sku) }
  )
end

#destroyObject



299
300
301
302
# File 'app/controllers/workarea/api/admin/pricing_skus_controller.rb', line 299

def destroy
  @pricing_sku.destroy
  head :no_content
end

#indexObject



102
103
104
105
106
107
108
109
110
111
# File 'app/controllers/workarea/api/admin/pricing_skus_controller.rb', line 102

def index
  @pricing_skus = Pricing::Sku
                    .all
                    .by_updated_at(starts_at: params[:updated_at_starts_at], ends_at: params[:updated_at_ends_at])
                    .by_created_at(starts_at: params[:created_at_starts_at], ends_at: params[:created_at_ends_at])
                    .order_by(sort_field => sort_direction)
                    .page(params[:page])

  respond_with pricing_skus: @pricing_skus
end

#showObject



252
253
254
# File 'app/controllers/workarea/api/admin/pricing_skus_controller.rb', line 252

def show
  respond_with pricing_sku: @pricing_sku
end

#updateObject



256
257
258
259
# File 'app/controllers/workarea/api/admin/pricing_skus_controller.rb', line 256

def update
  @pricing_sku.update_attributes!(params[:pricing_sku])
  respond_with pricing_sku: @pricing_sku
end