Class: Workarea::Api::Admin::PaymentProfilesController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/workarea/api/admin/payment_profiles_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/payment_profiles_controller.rb', line 290

def bulk
  @bulk = Api::Admin::BulkUpsert.create!(
    klass: Payment::Profile,
    data: params[:payment_profiles].map(&:to_h)
  )

  head :no_content
end

#createObject



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

def create
  @payment_profile = Payment::Profile.create!(params[:payment_profile])
  respond_with(
    { payment_profile: @payment_profile },
    { status: :created,
    location: payment_profile_path(@payment_profile) }
  )
end

#destroyObject



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

def destroy
  @payment_profile.destroy
  head :no_content
end

#indexObject



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

def index
  @payment_profiles = Payment::Profile
                        .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 payment_profiles: @payment_profiles
end

#showObject



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

def show
  respond_with payment_profile: @payment_profile
end

#updateObject



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

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