Class: Workarea::Api::Admin::ShippingServicesController

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

Instance Method Summary collapse

Methods inherited from ApplicationController

#current_user, #sort_direction, #sort_field

Instance Method Details

#bulkObject



284
285
286
287
288
289
290
291
# File 'app/controllers/workarea/api/admin/shipping_services_controller.rb', line 284

def bulk
  @bulk = Api::Admin::BulkUpsert.create!(
    klass: Shipping::Service,
    data: params[:shipping_services].map(&:to_h)
  )

  head :no_content
end

#createObject



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

def create
  @shipping_service = Shipping::Service.create!(params[:shipping_service])
  respond_with(
    { shipping_service: @shipping_service },
    { status: :created,
    location: shipping_service_path(@shipping_service) }
  )
end

#destroyObject



293
294
295
296
# File 'app/controllers/workarea/api/admin/shipping_services_controller.rb', line 293

def destroy
  @shipping_service.destroy
  head :no_content
end

#indexObject



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

def index
  @shipping_services = Shipping::Service
                        .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 shipping_services: @shipping_services
end

#showObject



249
250
251
# File 'app/controllers/workarea/api/admin/shipping_services_controller.rb', line 249

def show
  respond_with shipping_service: @shipping_service
end

#updateObject



253
254
255
256
# File 'app/controllers/workarea/api/admin/shipping_services_controller.rb', line 253

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