genability 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rspec +1 -0
- data/.yardopts +10 -0
- data/Gemfile +18 -0
- data/HISTORY.md +7 -0
- data/LICENSE.md +20 -0
- data/README.md +79 -0
- data/Rakefile +42 -0
- data/VERSION +1 -0
- data/genability.gemspec +123 -0
- data/lib/faraday/request/url_encoding_fix.rb +19 -0
- data/lib/faraday/response/raise_http_4xx.rb +44 -0
- data/lib/faraday/response/raise_http_5xx.rb +25 -0
- data/lib/genability.rb +29 -0
- data/lib/genability/api.rb +26 -0
- data/lib/genability/client.rb +24 -0
- data/lib/genability/client/helpers.rb +57 -0
- data/lib/genability/client/load_serving_entity.rb +77 -0
- data/lib/genability/client/price.rb +53 -0
- data/lib/genability/client/season.rb +27 -0
- data/lib/genability/client/tariff.rb +80 -0
- data/lib/genability/client/territory.rb +80 -0
- data/lib/genability/client/time_of_use.rb +66 -0
- data/lib/genability/client/zip_code.rb +28 -0
- data/lib/genability/configuration.rb +82 -0
- data/lib/genability/connection.rb +41 -0
- data/lib/genability/error.rb +21 -0
- data/lib/genability/request.rb +46 -0
- data/lib/mashie_extensions.rb +32 -0
- data/spec/cassettes/load_serving_entities.yml +163 -0
- data/spec/cassettes/load_serving_entity.yml +28 -0
- data/spec/cassettes/prices.yml +55 -0
- data/spec/cassettes/seasons.yml +28 -0
- data/spec/cassettes/tariff.yml +28 -0
- data/spec/cassettes/tariffs.yml +82 -0
- data/spec/cassettes/territories.yml +28 -0
- data/spec/cassettes/territory.yml +28 -0
- data/spec/cassettes/time_of_use.yml +30 -0
- data/spec/cassettes/time_of_uses.yml +28 -0
- data/spec/cassettes/zipcode.yml +28 -0
- data/spec/client/load_serving_entity_spec.rb +72 -0
- data/spec/client/price_spec.rb +41 -0
- data/spec/client/season_spec.rb +30 -0
- data/spec/client/tariff_spec.rb +52 -0
- data/spec/client/territory_spec.rb +40 -0
- data/spec/client/time_of_use_spec.rb +42 -0
- data/spec/client/zip_code_spec.rb +30 -0
- data/spec/configuration.yml.sample +3 -0
- data/spec/faraday/response_spec.rb +31 -0
- data/spec/genability_spec.rb +138 -0
- data/spec/spec_helper.rb +78 -0
- metadata +236 -0
@@ -0,0 +1,24 @@
|
|
1
|
+
module Genability
|
2
|
+
# Wrapper for the Genability REST API
|
3
|
+
class Client < API
|
4
|
+
require 'genability/client/helpers'
|
5
|
+
require 'genability/client/load_serving_entity'
|
6
|
+
require 'genability/client/price'
|
7
|
+
require 'genability/client/season'
|
8
|
+
require 'genability/client/tariff'
|
9
|
+
require 'genability/client/territory'
|
10
|
+
require 'genability/client/time_of_use'
|
11
|
+
require 'genability/client/zip_code'
|
12
|
+
|
13
|
+
include Genability::Client::Helpers
|
14
|
+
|
15
|
+
include Genability::Client::LoadServingEntity
|
16
|
+
include Genability::Client::Price
|
17
|
+
include Genability::Client::Season
|
18
|
+
include Genability::Client::Tariff
|
19
|
+
include Genability::Client::Territory
|
20
|
+
include Genability::Client::TimeOfUse
|
21
|
+
include Genability::Client::ZipCode
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'time'
|
2
|
+
require 'chronic'
|
3
|
+
|
4
|
+
module Genability
|
5
|
+
class Client
|
6
|
+
# @private
|
7
|
+
module Helpers
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def pagination_params(options)
|
12
|
+
{
|
13
|
+
'pageStart' => options['pageStart'] || options[:page_start] || options[:page],
|
14
|
+
'pageCount' => options['pageCount'] || options[:page_count] || options[:per_page],
|
15
|
+
}.delete_if{ |k,v| v.nil? }
|
16
|
+
end
|
17
|
+
|
18
|
+
def convert_to_boolean(value = nil)
|
19
|
+
return nil if value.nil? || value.empty?
|
20
|
+
"true"
|
21
|
+
end
|
22
|
+
|
23
|
+
def multi_option_handler(value)
|
24
|
+
return nil if value.nil?
|
25
|
+
if value.is_a?(Array)
|
26
|
+
value.collect{|x| x.upcase}.join(',')
|
27
|
+
else
|
28
|
+
value.upcase
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def format_to_iso8601(date_time = nil)
|
33
|
+
if date_time.respond_to?(:iso8601)
|
34
|
+
genability_iso8601_converter(date_time)
|
35
|
+
else
|
36
|
+
parse_and_format_to_iso8601(date_time)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def parse_and_format_to_iso8601(date_time = nil)
|
41
|
+
parsed_date = Chronic.parse(date_time.to_s)
|
42
|
+
parsed_date = parsed_date.nil? ? Time.parse(date_time.to_s) : parsed_date
|
43
|
+
genability_iso8601_converter(parsed_date)
|
44
|
+
rescue
|
45
|
+
nil
|
46
|
+
end
|
47
|
+
|
48
|
+
def genability_iso8601_converter(date_time = nil)
|
49
|
+
date_time.iso8601(1).gsub(/(?<=\-\d{2}):(?=\d{2})/, '')
|
50
|
+
rescue
|
51
|
+
nil
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
@@ -0,0 +1,77 @@
|
|
1
|
+
module Genability
|
2
|
+
class Client
|
3
|
+
# Load Serving Entity (LSE) is the industry term for what most people would call a utility,
|
4
|
+
# or an electric company. Since there are different types of electric company, we use the
|
5
|
+
# term LSE in our API's. This is a company or other organization that supplies load (electrons,
|
6
|
+
# electricity) to a customer. In many cases this is the same company that distributes the
|
7
|
+
# electricity too, but in some cases customers can have one company that they buy the load
|
8
|
+
# from, and another that operates the distribution system (runs the line to the house,
|
9
|
+
# manages the meters etc). Some characteristics and uses:
|
10
|
+
#
|
11
|
+
# 1. LSE's have territories that they operate in. Sometimes they operate in more than 1.
|
12
|
+
# 2. LSE's have tariffs (rate plans) and are central to many of our data structures.
|
13
|
+
module LoadServingEntity
|
14
|
+
# Returns a list of load serving entities
|
15
|
+
#
|
16
|
+
# @format :json
|
17
|
+
# @authenticated true
|
18
|
+
# @rate_limited true
|
19
|
+
# @param options [Hash] A customizable set of options.
|
20
|
+
# @option options [String] :starts_with Indicates the search phrase should match the start of the name. (Optional)
|
21
|
+
# @option options [String] :ends_with Indicates the search phrase should match the end of the name. (Optional)
|
22
|
+
# @option options [String] :contains Indicates the search phrase should be somewhere in the middle of the name. (Optional)
|
23
|
+
# @option options [Integer] :page The page number to begin the result set from. If not specified, this will begin with the first result set. (Optional)
|
24
|
+
# @option options [Integer] :per_page The number of results to return. If not specified, this will return 25 results. (Optional)
|
25
|
+
# @return [Array] List of load serving entities.
|
26
|
+
# @see https://developer.genability.com/documentation/api-reference/public/lse
|
27
|
+
# @example Return the first 25 load serving entities
|
28
|
+
# Genability.load_serving_entities
|
29
|
+
# @example Return the next 25 load serving entities
|
30
|
+
# Genability.load_serving_entities(:page => 2)
|
31
|
+
# @example Return only 10 load serving entities
|
32
|
+
# Genability.load_serving_entities(:per_page => 10)
|
33
|
+
# @example Search for load serving entities with the name 'Infinite'
|
34
|
+
# Genability.load_serving_entities(:search => 'Infinite')
|
35
|
+
# @example Search for load serving entities starting with the letters 'Ka'
|
36
|
+
# Genability.load_serving_entities(:starts_with => 'Ka')
|
37
|
+
# @example Search for load serving entities ending with the word 'Inc'
|
38
|
+
# Genability.load_serving_entities(:ends_with => 'Inc')
|
39
|
+
# @example Search for load serving entities with the word 'Energy' somewhere in the name
|
40
|
+
# Genability.load_serving_entities(:contains => 'Energy')
|
41
|
+
def load_serving_entities(options={})
|
42
|
+
get("lses", lses_params(options)).results
|
43
|
+
end
|
44
|
+
|
45
|
+
alias :lses :load_serving_entities
|
46
|
+
|
47
|
+
# Returns details for a single load serving entity
|
48
|
+
#
|
49
|
+
# @format :json
|
50
|
+
# @authenticated true
|
51
|
+
# @rate_limited true
|
52
|
+
# @param load_serving_entity_id [Integer] Unique Genability ID (primary key) for a Load Serving Entity.
|
53
|
+
# @return [Hashie::Mash] Details for a load serving entity.
|
54
|
+
# @see https://developer.genability.com/documentation/api-reference/public/lse
|
55
|
+
# @example Return the details for Georgia Power Co
|
56
|
+
# Genability.load_serving_entity(2756)
|
57
|
+
def load_serving_entity(load_serving_entity_id)
|
58
|
+
get("lses/#{load_serving_entity_id}").results.first
|
59
|
+
end
|
60
|
+
|
61
|
+
alias :lse :load_serving_entity
|
62
|
+
|
63
|
+
private
|
64
|
+
|
65
|
+
def lses_params(options)
|
66
|
+
{
|
67
|
+
'wildCardText' => options[:contains] || options[:starts_with] || options[:ends_with],
|
68
|
+
'startsWithWildCard' => convert_to_boolean(options[:starts_with]),
|
69
|
+
'endsWithWildCard' => convert_to_boolean(options[:ends_with]),
|
70
|
+
'containsWildCard' => convert_to_boolean(options[:contains])
|
71
|
+
}.delete_if{ |k,v| v.nil? }.merge( pagination_params(options) )
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Genability
|
2
|
+
class Client
|
3
|
+
# Given a start date and time, Price returns the price of a specified Tariff as well as
|
4
|
+
# all the changes in price over the course of the next week. Optional parameters allow
|
5
|
+
# you to retrieve more specific pricing based on Territory and Consumption and Demand usage.
|
6
|
+
module Price
|
7
|
+
# @overload prices(tariff_id, from_date_time = Time.now.iso8601, options = {})
|
8
|
+
# Returns the price of the specified tariff for the passed in date and time,
|
9
|
+
# and also the changes in price for this tariff for the next week.
|
10
|
+
# @param tariff_id [Integer] Unique Genability ID (primary key) for a tariff.
|
11
|
+
# @param from_date_time [DateTime, String] Date and time of the requested start of the Price.
|
12
|
+
# In ISO 8601 format. Will attempt to use the Chronic gem to parse if a string is used.
|
13
|
+
# (Required, but can be omitted to default to Time.now.iso8601)
|
14
|
+
# @param options [Hash] A customizable set of options.
|
15
|
+
# @option options [DateTime, String] :to Date and time of the requested end of the Price.
|
16
|
+
# In ISO 8601 format. Will attempt to use the Chronic gem to parse if a string is used. (Optional)
|
17
|
+
# @option options [Integer] :territory_id When specified, rate changes returned will be for the specified Territory. (Optional)
|
18
|
+
# @option options [Float] :consumption_amount 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)
|
19
|
+
# @option options [Float] :demand_amount 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)
|
20
|
+
# @return [Array] Array of charge types for the specified tariff, each with the price for the passed in date and time, and also the changes in price for this tariff for the next week.
|
21
|
+
# @example Various examples for retrieving the price(s) of tariff number 520 (Pacific Gas & Electric Co Residential Time-Of-Use Service E-6)
|
22
|
+
# Genability.prices(520)
|
23
|
+
# Genability.prices(520, :consumption_amount => 500)
|
24
|
+
# Genability.prices(520, "2011-06-13T00:00:00.0-070")
|
25
|
+
# Genability.prices(520, Date.yesterday)
|
26
|
+
# Genability.prices(520, "Last friday at 6:45pm", :to => "yesterday afternoon", :consumption_amount => 500)
|
27
|
+
# @format :json
|
28
|
+
# @authenticated true
|
29
|
+
# @rate_limited true
|
30
|
+
# @see https://developer.genability.com/documentation/api-reference/public/price
|
31
|
+
def prices(tariff_id, *args)
|
32
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
33
|
+
from_date_time = args.first || Time.now
|
34
|
+
get("prices/#{tariff_id}", prices_params(from_date_time, options)).results
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def prices_params(from_date_time, options)
|
40
|
+
{
|
41
|
+
"fromDateTime" => format_to_iso8601(from_date_time),
|
42
|
+
"toDateTime" => format_to_iso8601(options[:to]),
|
43
|
+
"territoryId" => options[:territory_id],
|
44
|
+
"consumptionAmount" => options[:consumption_amount],
|
45
|
+
"demandAmount" => options[:demand_amount]
|
46
|
+
}.delete_if{ |k,v| v.nil? }
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Genability
|
2
|
+
class Client
|
3
|
+
# Most LSEs will charge different rates depending on the time of year. Each
|
4
|
+
# LSE defines the times of the year themselves but typically they are split
|
5
|
+
# into Summer and Winter. We refer to these as the Seasons of an LSE. We
|
6
|
+
# also define Season Groups, which contain more than Seasons and which
|
7
|
+
# altogether span a full calendar year. Each Season belongs to one and
|
8
|
+
# only one Season Group.
|
9
|
+
module Season
|
10
|
+
# Returns a list of season groups for a given load serving entity.
|
11
|
+
#
|
12
|
+
# @format :json
|
13
|
+
# @authenticated true
|
14
|
+
# @rate_limited true
|
15
|
+
# @param load_serving_entity_id [Integer] Unique Genability ID (primary key) for a Load Serving Entity.
|
16
|
+
# @return [Array] list of season groups for a load serving entity.
|
17
|
+
# @see https://developer.genability.com/documentation/api-reference/public/season
|
18
|
+
# @example Return a list of season groups for Pacific Gas & Electric Co
|
19
|
+
# Genability.seasons(734)
|
20
|
+
def seasons(load_serving_entity_id)
|
21
|
+
get("seasons", { :lseId => load_serving_entity_id }).results
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
@@ -0,0 +1,80 @@
|
|
1
|
+
module Genability
|
2
|
+
class Client
|
3
|
+
# Tariffs are rate plans for electricity. They describe who the plan applies
|
4
|
+
# to (service and applicability), what the charges are, and other information
|
5
|
+
# about this electricity service:
|
6
|
+
#
|
7
|
+
# 1. We have residential tariffs currently. General tariffs (commercial &
|
8
|
+
# industrial and speciality tariffs) are coming soon.
|
9
|
+
# 2. You can specify whether you want the tariff fully populated, or whether
|
10
|
+
# you just want a sub section of the data (to avoid charges and to speed
|
11
|
+
# up your queries).
|
12
|
+
module Tariff
|
13
|
+
# Returns a list of tariffs.
|
14
|
+
#
|
15
|
+
# @format :json
|
16
|
+
# @authenticated true
|
17
|
+
# @rate_limited true
|
18
|
+
# @param options [Hash] A customizable set of options.
|
19
|
+
# @option options [Integer] :lse_id Filter tariffs for a specific Load Serving Entity. (Optional)
|
20
|
+
# @option options [Date] :effective_on Only tariffs that are effective on this date. (Optional)
|
21
|
+
# @option options [String, Array] :customer_classes Only include these customer classes. Choices are: RESIDENTIAL, GENERAL. (Optional)
|
22
|
+
# @option options [String, Array] :tariff_types Only include these tariff types. Choices are: DEFAULT, ALTERNATIVE, OPTIONAL_EXTRA, RIDER. (Optional)
|
23
|
+
# @option options [String] :zip_code Return tariffs for this zip or post code. (Optional)
|
24
|
+
# @option options [Boolean] :populate_rates Populates the rate details for the returned Tariffs. (Optional)
|
25
|
+
# @option options [Integer] :page The page number to begin the result set from. If not specified, this will begin with the first result set. (Optional)
|
26
|
+
# @option options [Integer] :per_page The number of results to return. If not specified, this will return 25 results. (Optional)
|
27
|
+
# @return [Array] List of tariffs.
|
28
|
+
# @see https://developer.genability.com/documentation/api-reference/public/tariff
|
29
|
+
# @example Return the first 25 tariffs
|
30
|
+
# Genability.tariffs
|
31
|
+
# @example Return the tariffs for Georgia Power Co
|
32
|
+
# Genability.tariffs(:lse_id => 2756)
|
33
|
+
# @example Return only residential tariffs
|
34
|
+
# Genability.tariffs(:customer_classes => 'residential')
|
35
|
+
# @example Return only default and alternative tariff types
|
36
|
+
# Genability.tariffs(:tariff_types => ['default', 'alternative'])
|
37
|
+
def tariffs(options = {})
|
38
|
+
get("tariffs", tariffs_params(options)).results
|
39
|
+
end
|
40
|
+
|
41
|
+
# Returns one tariff.
|
42
|
+
#
|
43
|
+
# @format :json
|
44
|
+
# @authenticated true
|
45
|
+
# @rate_limited true
|
46
|
+
# @param tariff_id [Integer] Unique Genability ID (primary key) for a tariff.
|
47
|
+
# @param options [Hash] A customizable set of options.
|
48
|
+
# @option options [Boolean] :populate_rates Populates the rate details for the returned Tariff. (Optional)
|
49
|
+
# @return [Hashie::Mash] A tariff.
|
50
|
+
# @see https://developer.genability.com/documentation/api-reference/public/tariff
|
51
|
+
# @example Return the residential serice tariff for Georgia Power Co
|
52
|
+
# Genability.tariff(512)
|
53
|
+
def tariff(tariff_id, options = {})
|
54
|
+
get("tariffs/#{tariff_id}", tariff_params(options)).results.first
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
def tariffs_params(options)
|
60
|
+
{
|
61
|
+
'lseId' => options[:lse_id],
|
62
|
+
'effectiveOn' => options[:effective_on],
|
63
|
+
'customerClasses' => multi_option_handler(options[:customer_classes]),
|
64
|
+
'tariffTypes' => multi_option_handler(options[:tariff_types]),
|
65
|
+
'zipCode' => options[:zip_code]
|
66
|
+
}.delete_if{ |k,v| v.nil? }.
|
67
|
+
merge( tariff_params(options) ).
|
68
|
+
merge( pagination_params(options) )
|
69
|
+
end
|
70
|
+
|
71
|
+
def tariff_params(options)
|
72
|
+
{
|
73
|
+
'populateRates' => convert_to_boolean(options[:populate_rates])
|
74
|
+
}.delete_if{ |k,v| v.nil? }
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
@@ -0,0 +1,80 @@
|
|
1
|
+
module Genability
|
2
|
+
class Client
|
3
|
+
# Territories define the areas of coverage for Load Serving Entities
|
4
|
+
# and in some cases for individual tariffs. The areas of coverage can
|
5
|
+
# be at these levels:
|
6
|
+
#
|
7
|
+
# 1. State
|
8
|
+
# 2. County
|
9
|
+
# 3. City
|
10
|
+
# 4. Zip Code
|
11
|
+
#
|
12
|
+
# Territories can have one of these two usage types:
|
13
|
+
#
|
14
|
+
# 1. Service - defines the areas where this LSE provides service
|
15
|
+
# 2. Tariff - defines the areas where a particular tariff rate applies
|
16
|
+
# to. These types of territories are typically defined by the LSE.
|
17
|
+
#
|
18
|
+
# We define a Service Territory for each state that an LSE provides
|
19
|
+
# coverage. The usageType attribute specifies how this definition
|
20
|
+
# is done, either at the State, County, City or Zip Code level.
|
21
|
+
module Territory
|
22
|
+
|
23
|
+
# Returns one territory.
|
24
|
+
#
|
25
|
+
# @format :json
|
26
|
+
# @authenticated true
|
27
|
+
# @rate_limited true
|
28
|
+
# @param territory_id [Integer] Unique Genability ID (primary key) for each Territory.
|
29
|
+
# @param options [Hash] A customizable set of options.
|
30
|
+
# @option options [Boolean] :populate_items If true, this returns a List of TerritoryItems for each Territory in the result set. (Optional; defaults to false)
|
31
|
+
# @return [Hashie::Mash] Details for one territory.
|
32
|
+
# @see https://developer.genability.com/documentation/api-reference/public/territory
|
33
|
+
# @example Return territory Baseline Region V for Pacific Gas & Electric Co
|
34
|
+
# Genability.territory(3539)
|
35
|
+
def territory(territory_id, options = {})
|
36
|
+
get("territories/#{territory_id}", territory_params(options)).results.first
|
37
|
+
end
|
38
|
+
|
39
|
+
# Returns a list of territories.
|
40
|
+
#
|
41
|
+
# @format :json
|
42
|
+
# @authenticated true
|
43
|
+
# @rate_limited true
|
44
|
+
# @param options [Hash] A customizable set of options.
|
45
|
+
# @option options [Integer] :lse_id Filter tariffs for a specific Load Serving Entity. (Optional)
|
46
|
+
# @option options [Boolean] :populate_items If true, this returns a List of TerritoryItems for each Territory in the result set. (Optional; defaults to false)
|
47
|
+
# @option options [Integer] :master_tariff_id Filters the result set to only include territories covered by this master tariff id. (Optional)
|
48
|
+
# @option options [String] :contains_item_type Filters the result set to include a particular type of territory. Possible values are: CITY, ZIPCODE, STATE, COUNTY. (Optional)
|
49
|
+
# @option options [String] :contains_item_value Filters the Types by this value. e.g. 94115 when searching for types of ZIPCODE. (Optional)
|
50
|
+
# @return [Array] List of territories.
|
51
|
+
# @see https://developer.genability.com/documentation/api-reference/public/territory
|
52
|
+
# @example Return a list of territories for Pacific Gas & Electric Co
|
53
|
+
# Genability.territories(:lse_id => 734)
|
54
|
+
def territories(options = {})
|
55
|
+
get("territories", territories_params(options)).results
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
def territory_params(options)
|
61
|
+
{
|
62
|
+
'populateItems' => convert_to_boolean(options[:populate_items])
|
63
|
+
}.delete_if{ |k,v| v.nil? }
|
64
|
+
end
|
65
|
+
|
66
|
+
def territories_params(options)
|
67
|
+
{
|
68
|
+
'lseId' => options[:lse_id],
|
69
|
+
'masterTariffId' => options[:master_tariff_id],
|
70
|
+
'containsItemType' => options[:contains_item_type],
|
71
|
+
'containsItemValue' => options[:contains_item_value]
|
72
|
+
}.delete_if{ |k,v| v.nil? }.
|
73
|
+
merge( territory_params(options) ).
|
74
|
+
merge( pagination_params(options) )
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
@@ -0,0 +1,66 @@
|
|
1
|
+
module Genability
|
2
|
+
class Client
|
3
|
+
# Many tariffs have pricing that depends on the time of day the energy
|
4
|
+
# is being used. We call these times the Time of Use for a tariff.
|
5
|
+
# The most common examples are On Peak and Off Peak. Some examples
|
6
|
+
# here may help:
|
7
|
+
#
|
8
|
+
# 1. Within a single Time of Use, e.g. On Peak, the price for a
|
9
|
+
# tariff will always be the same.
|
10
|
+
# 2. Within a single Time of Use, e.g. On Peak, you may have multiple
|
11
|
+
# Periods. A Period is a range of days and times that this TOU applies to.
|
12
|
+
module TimeOfUse
|
13
|
+
|
14
|
+
# Returns a particular time of use group using its time of use group ID and the load serving entity ID.
|
15
|
+
#
|
16
|
+
# @format :json
|
17
|
+
# @authenticated true
|
18
|
+
# @rate_limited true
|
19
|
+
# @param load_serving_entity_id [Integer] Unique Genability ID (primary key) for a Load Serving Entity.
|
20
|
+
# @param time_of_use_group_id [Integer] Genability ID (primary key) for this Time of Use Group. This is unique within the LSE, not across LSE's so you will always need to specify the LSE ID when requested a TOU Group.
|
21
|
+
# @return [Hashie::Mash] Return the time of uses for a load serving entity.
|
22
|
+
# @see https://developer.genability.com/documentation/api-reference/public/time-of-use
|
23
|
+
# @example Return the time of use group for Georgia Power Co
|
24
|
+
# Genability.time_of_uses(2756, 1)
|
25
|
+
def time_of_uses(load_serving_entity_id, time_of_use_group_id)
|
26
|
+
get("timeofuses/#{load_serving_entity_id}/#{time_of_use_group_id}").results.first
|
27
|
+
end
|
28
|
+
|
29
|
+
alias :tou :time_of_uses
|
30
|
+
|
31
|
+
# Returns all the Intervals for a Time of Use Group for an optionally specified
|
32
|
+
# from and to date and time range. Defaults to current time if fromDateTime is
|
33
|
+
# not specified and to a one week look ahead window if toDateTime is not specified.
|
34
|
+
#
|
35
|
+
# @format :json
|
36
|
+
# @authenticated true
|
37
|
+
# @rate_limited true
|
38
|
+
# @param load_serving_entity_id [Integer] Unique Genability ID (primary key) for a Load Serving Entity.
|
39
|
+
# @param time_of_use_group_id [Integer] Genability ID (primary key) for this Time of Use Group. This is unique within the LSE, not across LSE's so you will always need to specify the LSE ID when requested a TOU Group.
|
40
|
+
# @param options [Hash] A customizable set of options.
|
41
|
+
# @option options [DateTime] :from ISO 8601 format for the starting date and time of the requested Intervals. Defaults to current day and time if not specified. (Optional)
|
42
|
+
# @option options [DateTime] :to ISO 8601 format for the ending date and time of the requested Intervals. Defaults to one week after the fromDateTime. (Optional)
|
43
|
+
# @return [Array] Returns all the Intervals for a Time of Use Group.
|
44
|
+
# @see https://developer.genability.com/documentation/api-reference/public/time-of-use
|
45
|
+
# @example Return the intervals for the time of use group for Georgia Power Co
|
46
|
+
# Genability.time_of_use_intervals(2756, 1)
|
47
|
+
def time_of_use_intervals(load_serving_entity_id, time_of_use_group_id, options = {})
|
48
|
+
get("timeofuses/#{load_serving_entity_id}/#{time_of_use_group_id}/intervals", interval_params(options)).results
|
49
|
+
end
|
50
|
+
|
51
|
+
alias :tou_intervals :time_of_use_intervals
|
52
|
+
alias :intervals :time_of_use_intervals
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def interval_params(options)
|
57
|
+
{
|
58
|
+
'fromDateTime' => format_to_iso8601(options[:from]),
|
59
|
+
'toDateTime' => format_to_iso8601(options[:to])
|
60
|
+
}.delete_if{ |k,v| v.nil? }
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|