Module: Sem4r::AccountInfoExtension

Included in:
Account
Defined in:
lib/sem4r/info/info_account_extension.rb

Instance Method Summary collapse

Instance Method Details

#year_unit_cost(usage_type) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/sem4r/info/info_account_extension.rb', line 30

def year_unit_cost(usage_type)
  now = Time.new - 60 * 60 * 24  # - 1 day time in which timezone?
  selector = InfoSelector.new do
    usage_type    usage_type
    min           now.strftime("%Y0101") # first January
    max           now.strftime("%Y%m%d")
  end
  soap_message = service.info.get(credentials, selector.to_xml)
  add_counters( soap_message.counters )
  # cost = REXML::XPath.first( soap_message.response, "//getResponse/rval/cost")
  cost = soap_message.response.at_xpath("//getResponse/rval/cost")
  cost.text.to_i
end