Sha256: ad205338c491b877cd47ebfcc609d146b8268dbfdae4d1e29fd78f01950d33c8
Contents?: true
Size: 1.84 KB
Versions: 16
Compression:
Stored size: 1.84 KB
Contents
module Caboose class BillingAddressesController < Caboose::ApplicationController # GET /admin/orders/:order_id/billing-address/json def admin_json return if !user_is_allowed('orders', 'edit') order = Order.find(params[:order_id]) render :json => order.billing_address end # PUT /admin/orders/:order_id/billing-address def admin_update return if !user_is_allowed('orders', 'edit') resp = Caboose::StdClass.new({'attributes' => {}}) order = Order.find(params[:order_id]) sa = order.billing_address if sa.nil? sa = Address.create order.billing_address_id = sa.id order.save end save = true params.each do |name, value| case name when 'name' then sa.name = value when 'first_name' then sa.first_name = value when 'last_name' then sa.last_name = value when 'street' then sa.street = value when 'address1' then sa.address1 = value when 'address2' then sa.address2 = value when 'company' then sa.company = value when 'city' then sa.city = value when 'state' then sa.state = value when 'province' then sa.province = value when 'province_code' then sa.province_code = value when 'zip' then sa.zip = value when 'country' then sa.country = value when 'country_code' then sa.country_code = value when 'phone' then sa.phone = value end end resp.success = save && sa.save render :json => resp end end end
Version data entries
16 entries across 16 versions & 1 rubygems