Sha256: c42753272e75ae2744ade5d15abadd41ca396bf3f36c6b203353996566b81c0e

Contents?: true

Size: 880 Bytes

Versions: 1

Compression:

Stored size: 880 Bytes

Contents

module Pwb
  class Api::V1::MlsController < ApplicationApiController
    def index
      mlses = ImportSource.all
      # ImportSource is active_hash so have to manually construct json
      @mls_array = []
      mlses.each do |mls|
        # labelText and value allow creation on radiolist in admin interface
        @mls_array.push ({
          value: mls.as_json["attributes"]["unique_name"],
          labelText: mls.as_json["attributes"]["displayName"],
          mls_unique_name: mls.as_json["attributes"]["unique_name"],
          username: mls.as_json["attributes"]["details"]["username"],
          password: mls.as_json["attributes"]["details"]["password"]          
        })
        # when I stop displaying username above I can just use:
        # mls.as_json["attributes"].slice("value","labelText")
      end
      return render json: @mls_array
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pwb-0.1.1 app/controllers/pwb/api/v1/mls_controller.rb