class Admin::Threoze::BillingsController < Admin::Controller
  def show
    render_success :ok, json: billing_props
  end

  def update
    if api_service['errors']
      render_error :unprocessable_entity, errors: api_service['errors']
    else
      render_success :ok, json: billing_props
    end
  end

  private
    def api_service
      @api_service ||= Threoze::BillingService.call(current_school, action_name, params)
    end

    def billing_props
      {
        billingname: api_service['billingname'],
        billingaddress1: api_service['billingaddress1'],
        billingaddress2: api_service['billingaddress2'],
        billingcity: api_service['billingcity'],
        billingcountry: api_service['billingcountry'],
        billingcountry_id: api_service['billingcountry_id'],
        billingemail: api_service['billingemail'],
        billingstate: api_service['billingstate'],
        billingzip: api_service['billingzip']
      }
    end
end
