Module: Genability::Client::Price

Included in:
Genability::Client
Defined in:
lib/genability/client/price.rb

Overview

Given a start date and time, Price returns the price of a specified Tariff as well as all the changes in price over the course of the next week. Optional parameters allow you to retrieve more specific pricing based on Territory and Consumption and Demand usage.

Instance Method Summary collapse

Instance Method Details

#prices(tariff_id, from_date_time = Time.now.iso8601, options = {}) ⇒ Array

Returns the price of the specified tariff for the passed in date and time, and also the changes in price for this tariff for the next week.

Examples:

Various examples for retrieving the price(s) of tariff number 520 (Pacific Gas & Electric Co Residential Time-Of-Use Service E-6)

Genability.prices(520)
Genability.prices(520, :consumption_amount => 500)
Genability.prices(520, "2011-06-13T00:00:00.0-070")
Genability.prices(520, Date.yesterday)
Genability.prices(520, "Last friday at 6:45pm", :to => "yesterday afternoon", :consumption_amount => 500)

Options Hash (options):

  • :to (DateTime, String)

    Date and time of the requested end of the Price. In ISO 8601 format. Will attempt to use the Chronic gem to parse if a string is used. (Optional)

  • :territory_id (Integer)

    When specified, rate changes returned will be for the specified Territory. (Optional)

  • :consumption_amount (Float)

    By default, the rate amount calculation assumes the highest banded level of consumption. When a consumption amount is specified, this amount is used in the calculation. (Optional)

  • :demand_amount (Float)

    By default, the rate amount calculation assumes the highest banded level of demand. When a demand amount is specified, this amount is used in the calculation. (Optional)

See Also:

Rate Limited:

  • true

Requires Authentication:

  • true

Supported formats:

  • :json



31
32
33
34
35
# File 'lib/genability/client/price.rb', line 31

def prices(tariff_id, *args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  from_date_time = args.first || Time.now
  get("public/prices/#{tariff_id}", prices_params(from_date_time, options)).results
end