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



277
278
279
280
281
282
283
284
# File 'app/controllers/workarea/api/admin/shipping_services_controller.rb', line 277

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

  head :no_content
end

#createObject



106
107
108
109
110
111
112
113
# File 'app/controllers/workarea/api/admin/shipping_services_controller.rb', line 106

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



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

def destroy
  @shipping_service.destroy
  head :no_content
end

#indexObject



97
98
99
100
101
102
103
104
# File 'app/controllers/workarea/api/admin/shipping_services_controller.rb', line 97

def index
  @shipping_services = Shipping::Service
                        .all
                        .order_by(sort_field => sort_direction)
                        .page(params[:page])

  respond_with shipping_services: @shipping_services
end

#showObject



242
243
244
# File 'app/controllers/workarea/api/admin/shipping_services_controller.rb', line 242

def show
  respond_with shipping_service: @shipping_service
end

#updateObject



246
247
248
249
# File 'app/controllers/workarea/api/admin/shipping_services_controller.rb', line 246

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