Module: Genability::Client::Calculate

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

Overview

The Calculate service basically calculates the cost of electricity for a given rate/pricing plan. This can be used to calculate a bill, "what-if" different rates, levels of usage, energy efficiency measures or any other electrical activity. It gives a total cost for a period of time. (Note that if you want a price/rate for a specific point in time, then look at the Price service.)

Instance Method Summary collapse

Instance Method Details

#calculate(tariff_id, from_date_time, to_date_time, tariff_inputs, options = {}) ⇒ Object

Calculate the cost of electricity for a given rate/pricing plan.



37
38
39
40
41
# File 'lib/genability/client/calculate.rb', line 37

def calculate(tariff_id, from, to, tariff_inputs, options = {})
  post( "beta/calculate/#{tariff_id}",
        calculate_params(from, to, tariff_inputs, options)
      ).results.first
end

#calculate_metadata(tariff_id, from_date_time, to_date_time, options = {}) ⇒ Array

Calling the URL as a HTTP GET will return the "inputs" required to accurately calculate the cost for a given period. It essentially gives you the meta-data for what to pass into the calculate method, and as such provides a template for the payload of the HTTP POST.

Examples:

Return the inputs required to accurately calculate the cost for a given period

Genability.(512, "2011-06-16T19:00:00.0-0400", "2011-08-01T00:00:00.0-0400")

Parameters:

  • tariff_id (Integer)

    Unique Genability ID (primary key) for a tariff.

  • from_date_time (DateTime, String)

    Starting date and time for this Calculate request. In ISO 8601 format. Will attempt to use the Chronic gem to parse if a string is used.

  • to_date_time (DateTime, String)

    End date and time for this Calculate request. In ISO 8601 format. Will attempt to use the Chronic gem to parse if a string is used.

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :territory_id (Integer)

    The territory ID of where the usage consumption occurred. (Required for most CA tariffs.)

Returns:

  • (Array)

    Array of TariffInput for consumption.

See Also:

Supported formats:

  • :json

Requires Authentication:

  • true

Rate Limited:

  • true



30
31
32
# File 'lib/genability/client/calculate.rb', line 30

def (tariff_id, from, to, options = {})
  get("beta/calculate/#{tariff_id}", calculate_meta_params(from, to, options)).results
end