Sha256: ebf6010ce5a50ddb1fef710007c81de5b8fdb2e9e8f2c93d4789fadf412cbb49

Contents?: true

Size: 935 Bytes

Versions: 5

Compression:

Stored size: 935 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"],
          login_url: mls.as_json["attributes"]["details"]["login_url"]
        })
        # when I stop displaying username above I can just use:
        # mls.as_json["attributes"].slice("value","labelText")
      end
      render json: @mls_array
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
pwb-1.4.0 app/controllers/pwb/api/v1/mls_controller.rb
pwb-1.3.0 app/controllers/pwb/api/v1/mls_controller.rb
pwb-1.2.0 app/controllers/pwb/api/v1/mls_controller.rb
pwb-1.1.1 app/controllers/pwb/api/v1/mls_controller.rb
pwb-1.0.0 app/controllers/pwb/api/v1/mls_controller.rb