class Support::Sites::Schools::Billing::BillingInfosController < Support::Sites::Controller
  def show
    render_success :ok, json: billing_props
  end

  private
    def school
      @school ||= School.find(params[:school_id])
    end

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

    def billing_props
      {
        billing_name: api_service['billingname'],
        billing_address1: api_service['billingaddress1'],
        billing_address2: api_service['billingaddress2'],
        billing_city: api_service['billingcity'],
        billing_country: api_service['billingcountry'],
        billing_country_id: api_service['billingcountry_id'],
        billing_email: api_service['billingemail'],
        billing_state: api_service['billingstate'],
        billing_zip: api_service['billingzip'],
        billing_tech_passthru: !!api_service['techpassthruenabled']
      }
    end
end
