Module: YieldStarClient::PropertyMethods

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

Instance Method Summary collapse

Methods included from Validations

#validate_client_name!, #validate_external_property_id!

Instance Method Details

#get_propertiesArray<YieldStarClient::Property>

Retrieves all properties for a client.

Returns:

Raises:



73
74
75
76
77
78
79
# File 'lib/yield_star_client/property_methods.rb', line 73

def get_properties
  response = send_soap_request(:get_properties)

  props = response.to_hash[:get_properties_response][:return][:property] || []
  props = [props].flatten
  props.collect { |p| Property.new(p) }
end

#get_property(external_property_id) ⇒ YieldStarClient::Property

Retrieves information for a specific property.

Parameters:

  • external_property_id (String)

    the ID of the property to obtain information for

Returns:

Raises:



91
92
93
94
95
96
97
98
# File 'lib/yield_star_client/property_methods.rb', line 91

def get_property(external_property_id)
  validate_external_property_id!(external_property_id)

  response = send_soap_request(:get_property, :external_property_id => external_property_id)

  property = response.to_hash[:get_property_response][:return][:property]
  Property.new(property)
end

#get_property_parameters(external_property_id) ⇒ YieldStarClient::PropertyParameters

Retrieves pricing parameters for a specific property.

Parameters:

  • external_property_id (String)

    the ID of the property to obtain information for

Returns:

Raises:



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/yield_star_client/property_methods.rb', line 111

def get_property_parameters(external_property_id)
  validate_external_property_id!(external_property_id)

  response = send_soap_request(:get_property_parameters, :external_property_id => external_property_id)

  response_hash = response.to_hash[:get_property_parameters_response][:return]
  param_hash = { :external_property_id => response_hash[:external_property_id] }
  params = [response_hash[:parameter]].flatten

  unless params.first.nil?
    params.each do |param|
      name = param[:name].downcase.gsub(/(max|min)imum/, '\1').gsub(/\s+/, '_').to_sym
      param_hash[name] = param[:value]
    end
  end

  PropertyParameters.new(param_hash)
end