Module: YieldStarClient::UnitMethods

Includes:
Validations
Included in:
Client
Defined in:
lib/yield_star_client/unit_methods.rb

Instance Method Summary collapse

Methods included from Validations

#validate_client_name!, #validate_external_property_id!

Instance Method Details

#get_unit(external_property_id, unit_name, building_name = nil) ⇒ YieldStarClient::Unit

Retrieves data about a specific unit.

Parameters:

  • external_property_id (String)

    the ID of the property where the unit is located

  • unit_name (String)

    the name of the unit to retrieve

  • building_name (optional, String) (defaults to: nil)

    the name of the building in which the unit is located

Returns:

Raises:



53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/yield_star_client/unit_methods.rb', line 53

def get_unit(external_property_id, unit_name, building_name=nil)
  validate_external_property_id!(external_property_id)
  validate_required!(:unit_name => unit_name)

  body = {:external_property_id => external_property_id, :name => unit_name}
  body[:building] = building_name if building_name

  response = send_soap_request(:get_unit, body)
  unit = response.to_hash[:get_unit_response][:return][:unit]

  Unit.new(unit)
end

#get_units(external_property_id, floor_plan_name = nil) ⇒ Array<Unit>

Retrieves all units for a specific property, optionally filtered by floor plan.

Parameters:

  • floor_plan_name (optional, String) (defaults to: nil)

    the name of the floor plan associated with the units

Returns:

  • (Array<Unit>)

    a list of unit data

Raises:



77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/yield_star_client/unit_methods.rb', line 77

def get_units(external_property_id, floor_plan_name=nil)
  validate_external_property_id!(external_property_id)

  body = {:external_property_id => external_property_id}
  body[:floor_plan_name] = floor_plan_name if floor_plan_name
  response = send_soap_request(:get_units, body)

  units = response.to_hash[:get_units_response][:return][:unit] || []
  units = [units].flatten

  units.collect { |u| Unit.new(u) }
end