genability 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. data/Gemfile +13 -12
  2. data/README.md +40 -6
  3. data/VERSION +1 -1
  4. data/genability.gemspec +12 -12
  5. data/lib/faraday/request/url_encoding_fix.rb +1 -1
  6. data/lib/genability.rb +5 -3
  7. data/lib/genability/api.rb +0 -3
  8. data/lib/genability/client.rb +4 -0
  9. data/lib/genability/client/calculate.rb +44 -16
  10. data/lib/genability/client/echo.rb +4 -4
  11. data/lib/genability/client/helpers.rb +49 -4
  12. data/lib/genability/client/load_serving_entity.rb +46 -16
  13. data/lib/genability/client/price.rb +1 -1
  14. data/lib/genability/client/property.rb +30 -2
  15. data/lib/genability/client/season.rb +39 -2
  16. data/lib/genability/client/tariff.rb +63 -12
  17. data/lib/genability/client/territory.rb +53 -8
  18. data/lib/genability/client/time_of_use.rb +53 -9
  19. data/lib/genability/connection.rb +2 -0
  20. data/lib/genability/error.rb +1 -1
  21. data/lib/genability/request.rb +7 -2
  22. data/lib/mashie_extensions.rb +9 -1
  23. data/spec/cassettes/calculate.yml +65 -38
  24. data/spec/cassettes/echo.yml +77 -37
  25. data/spec/cassettes/load_serving_entities.yml +294 -106
  26. data/spec/cassettes/load_serving_entity.yml +23 -18
  27. data/spec/cassettes/prices.yml +91 -35
  28. data/spec/cassettes/properties.yml +178 -35
  29. data/spec/cassettes/property.yml +31 -19
  30. data/spec/cassettes/seasons.yml +24 -18
  31. data/spec/cassettes/tariff.yml +82 -18
  32. data/spec/cassettes/tariffs.yml +259 -69
  33. data/spec/cassettes/territories.yml +67 -35
  34. data/spec/cassettes/territory.yml +24 -18
  35. data/spec/cassettes/time_of_use.yml +47 -18
  36. data/spec/cassettes/time_of_uses.yml +24 -18
  37. data/spec/cassettes/zipcode.yml +25 -18
  38. data/spec/client/calculate_spec.rb +6 -6
  39. data/spec/client/echo_spec.rb +6 -6
  40. data/spec/client/load_serving_entity_spec.rb +15 -7
  41. data/spec/client/tariff_spec.rb +10 -2
  42. data/spec/spec_helper.rb +6 -0
  43. metadata +170 -110
@@ -39,7 +39,7 @@ module Genability
39
39
  def prices_params(from_date_time, options)
40
40
  {
41
41
  "fromDateTime" => format_to_iso8601(from_date_time),
42
- "toDateTime" => format_to_iso8601(options[:to]),
42
+ "toDateTime" => format_to_iso8601(options[:to] || options[:to_date_time]),
43
43
  "territoryId" => options[:territory_id],
44
44
  "consumptionAmount" => options[:consumption_amount],
45
45
  "demandAmount" => options[:demand_amount]
@@ -1,12 +1,40 @@
1
1
  module Genability
2
2
  class Client
3
-
3
+ # Properties are metadata associated with a tariff. They are frequently
4
+ # used to determine applicability for a particular set of rates within a
5
+ # tariff. For example, the property cityLimits is used when a tariff has
6
+ # different rates based on whether the consumer lives inside or outside
7
+ # the city limits.
4
8
  module Property
5
-
9
+ # This allows you to retrieve one Property using its keyname. This is
10
+ # particularly useful when using the Calculator as it may require you to
11
+ # specify certain applicability values prior to making the calculation.
12
+ #
13
+ # @format :json
14
+ # @authenticated true
15
+ # @rate_limited true
16
+ # @param key_name [String] Property key name
17
+ # @return [Hashie::Mash] Details for a property.
18
+ # @see https://developer.genability.com/documentation/api-reference/public/property
6
19
  def property(key_name)
7
20
  get("public/properties/#{key_name}").results.first
8
21
  end
9
22
 
23
+ # This returns a list of Properties based on a search criteria. The result
24
+ # set is an array of Property objects in the standard response format.
25
+ #
26
+ # @format :json
27
+ # @authenticated true
28
+ # @rate_limited true
29
+ # @param options [Hash] A customizable set of options.
30
+ # @option options [Integer] :entity_id Filters the result set to only include
31
+ # Properties that belong to this entityId. EntityType must also be specified,
32
+ # otherwise this is ignored (Optional).
33
+ # @option options [String] :entity_type Filters the result set to only include
34
+ # Properties that belong to this entityType. EntityId must also be specified,
35
+ # otherwise this is ignored. Currently the only supported value is 'LSE' (Optional)
36
+ # @return [Array] Array of property objects.
37
+ # @see https://developer.genability.com/documentation/api-reference/public/property
10
38
  def properties(options = {})
11
39
  get("public/properties", property_params(options)).results
12
40
  end
@@ -13,12 +13,49 @@ module Genability
13
13
  # @authenticated true
14
14
  # @rate_limited true
15
15
  # @param load_serving_entity_id [Integer] Unique Genability ID (primary key) for a Load Serving Entity.
16
+ # @param options [Hash] A customizable set of options.
17
+ # @option options [String] :search The string of text to search on. This
18
+ # can also be a regular expression, in which case you should set the
19
+ # 'isRegex' flag to true. (Optional)
20
+ # @option options [String] :search_on Comma separated list of fields to
21
+ # query on. When searchOn is specified, the text provided in the search
22
+ # string field will be searched within these fields. The list of fields
23
+ # to search on depend on the entity being searched for. Read the documentation
24
+ # for the entity for more details on the fields that can be searched, and
25
+ # the default fields to be searched if searchOn is not specified. (Optional)
26
+ # @option options [Boolean] :starts_with When true, the search will only
27
+ # return results that begin with the specified search string. Otherwise,
28
+ # any match of the search string will be returned as a result. Default is
29
+ # false. (Optional)
30
+ # @option options [Boolean] :ends_with When true, the search will only return
31
+ # results that end with the specified search string. Otherwise, any match of
32
+ # the search string will be returned as a result. Default is false. (Optional)
33
+ # @option options [Boolean] :is_regex When true, the provided search string
34
+ # will be regarded as a regular expression and the search will return results
35
+ # matching the regular expression. Default is false. (Optional)
36
+ # @option options [String] :sort_on Comma separated list of fields to sort on.
37
+ # This can also be input via Array Inputs (see above). (Optional)
38
+ # @option options [String] :sort_order Comma separated list of ordering.
39
+ # Possible values are 'ASC' and 'DESC'. Default is 'ASC'. If your sortOn
40
+ # contains multiple fields and you would like to order fields individually,
41
+ # you can pass in a comma separated list here (or use Array Inputs, see above).
42
+ # For example, if your sortOn contained 5 fields, and your sortOrder contained
43
+ # 'ASC, DESC, DESC', these would be applied to the first three items in the sortOn
44
+ # field. The remaining two would default to ASC. (Optional)
16
45
  # @return [Array] list of season groups for a load serving entity.
17
46
  # @see https://developer.genability.com/documentation/api-reference/public/season
18
47
  # @example Return a list of season groups for Pacific Gas & Electric Co
19
48
  # Genability.seasons(734)
20
- def seasons(load_serving_entity_id)
21
- get("public/seasons", { :lseId => load_serving_entity_id }).results
49
+ def seasons(load_serving_entity_id, options = {})
50
+ get("public/seasons", season_params(load_serving_entity_id, options)).results
51
+ end
52
+
53
+ private
54
+
55
+ def season_params(load_serving_entity_id, options)
56
+ { :lseId => load_serving_entity_id }.
57
+ delete_if{ |k,v| v.nil? }.
58
+ merge( search_params(options) )
22
59
  end
23
60
 
24
61
  end
@@ -16,14 +16,57 @@ module Genability
16
16
  # @authenticated true
17
17
  # @rate_limited true
18
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)
19
+ # @option options [Integer] :lse_id Filter tariffs for a specific Load Serving
20
+ # Entity. (Optional)
21
+ # @option options [Date] :effective_on Only tariffs that are effective on
22
+ # this date. (Optional)
23
+ # @option options [Date] :from Only include tariffs that are effective on or
24
+ # after this date (Optional)
25
+ # @option options [Date] :to Only include tariffs that are effective on or
26
+ # before this date (Optional)
27
+ # @option options [String, Array] :customer_classes Only include these customer
28
+ # classes. Choices are: RESIDENTIAL, GENERAL. (Optional)
29
+ # @option options [String, Array] :tariff_types Only include these tariff types.
30
+ # Choices are: DEFAULT, ALTERNATIVE, OPTIONAL_EXTRA, RIDER. (Optional)
31
+ # @option options [String] :zip_code Return tariffs for this zip or post
32
+ # code. (Optional)
33
+ # @option options [Boolean] :populate_rates Populates the rate details for the
34
+ # returned Tariff. (Optional)
35
+ # @option options [Boolean] :populate_properties Populates the properties
36
+ # for the returned Tariffs (Optional; defaults to false)
37
+ # @option options [Integer] :page The page number to begin the result
38
+ # set from. If not specified, this will begin with the first result
39
+ # set. (Optional)
40
+ # @option options [Integer] :per_page The number of results to return.
41
+ # If not specified, this will return 25 results. (Optional)
42
+ # @option options [String] :search The string of text to search on. This
43
+ # can also be a regular expression, in which case you should set the
44
+ # 'isRegex' flag to true. (Optional)
45
+ # @option options [String] :search_on Comma separated list of fields to
46
+ # query on. When searchOn is specified, the text provided in the search
47
+ # string field will be searched within these fields. The list of fields
48
+ # to search on depend on the entity being searched for. Read the documentation
49
+ # for the entity for more details on the fields that can be searched, and
50
+ # the default fields to be searched if searchOn is not specified. (Optional)
51
+ # @option options [Boolean] :starts_with When true, the search will only
52
+ # return results that begin with the specified search string. Otherwise,
53
+ # any match of the search string will be returned as a result. Default is
54
+ # false. (Optional)
55
+ # @option options [Boolean] :ends_with When true, the search will only return
56
+ # results that end with the specified search string. Otherwise, any match of
57
+ # the search string will be returned as a result. Default is false. (Optional)
58
+ # @option options [Boolean] :is_regex When true, the provided search string
59
+ # will be regarded as a regular expression and the search will return results
60
+ # matching the regular expression. Default is false. (Optional)
61
+ # @option options [String] :sort_on Comma separated list of fields to sort on.
62
+ # This can also be input via Array Inputs (see above). (Optional)
63
+ # @option options [String] :sort_order Comma separated list of ordering.
64
+ # Possible values are 'ASC' and 'DESC'. Default is 'ASC'. If your sortOn
65
+ # contains multiple fields and you would like to order fields individually,
66
+ # you can pass in a comma separated list here (or use Array Inputs, see above).
67
+ # For example, if your sortOn contained 5 fields, and your sortOrder contained
68
+ # 'ASC, DESC, DESC', these would be applied to the first three items in the sortOn
69
+ # field. The remaining two would default to ASC. (Optional)
27
70
  # @return [Array] List of tariffs.
28
71
  # @see https://developer.genability.com/documentation/api-reference/public/tariff
29
72
  # @example Return the first 25 tariffs
@@ -45,7 +88,10 @@ module Genability
45
88
  # @rate_limited true
46
89
  # @param tariff_id [Integer] Unique Genability ID (primary key) for a tariff.
47
90
  # @param options [Hash] A customizable set of options.
48
- # @option options [Boolean] :populate_rates Populates the rate details for the returned Tariff. (Optional)
91
+ # @option options [Boolean] :populate_rates Populates the rate details for the
92
+ # returned Tariff. (Optional)
93
+ # @option options [Boolean] :populate_properties Populates the properties
94
+ # for the returned Tariffs (Optional; defaults to false)
49
95
  # @return [Hashie::Mash] A tariff.
50
96
  # @see https://developer.genability.com/documentation/api-reference/public/tariff
51
97
  # @example Return the residential serice tariff for Georgia Power Co
@@ -59,18 +105,23 @@ module Genability
59
105
  def tariffs_params(options)
60
106
  {
61
107
  'lseId' => options[:lse_id],
62
- 'effectiveOn' => options[:effective_on],
108
+ 'effectiveOn' => format_to_iso8601(options[:effective_on]),
109
+ 'fromDateTime' => format_to_iso8601(options[:from] || options[:from_date_time]),
110
+ 'toDateTime' => format_to_iso8601(options[:to] || options[:to_date_time]),
63
111
  'customerClasses' => multi_option_handler(options[:customer_classes]),
64
112
  'tariffTypes' => multi_option_handler(options[:tariff_types]),
65
- 'zipCode' => options[:zip_code]
113
+ 'zipCode' => options[:zip_code],
114
+ 'accountId' => options[:account_id]
66
115
  }.delete_if{ |k,v| v.nil? }.
67
116
  merge( tariff_params(options) ).
117
+ merge( search_params(options) ).
68
118
  merge( pagination_params(options) )
69
119
  end
70
120
 
71
121
  def tariff_params(options)
72
122
  {
73
- 'populateRates' => convert_to_boolean(options[:populate_rates])
123
+ 'populateRates' => convert_to_boolean(options[:populate_rates]),
124
+ 'populateProperties' => convert_to_boolean(options[:populate_properties])
74
125
  }.delete_if{ |k,v| v.nil? }
75
126
  end
76
127
 
@@ -25,9 +25,12 @@ module Genability
25
25
  # @format :json
26
26
  # @authenticated true
27
27
  # @rate_limited true
28
- # @param territory_id [Integer] Unique Genability ID (primary key) for each Territory.
28
+ # @param territory_id [Integer] Unique Genability ID (primary key) for
29
+ # each Territory.
29
30
  # @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
+ # @option options [Boolean] :populate_items If true, this returns a List
32
+ # of TerritoryItems for each Territory in the result set. (Optional;
33
+ # defaults to false)
31
34
  # @return [Hashie::Mash] Details for one territory.
32
35
  # @see https://developer.genability.com/documentation/api-reference/public/territory
33
36
  # @example Return territory Baseline Region V for Pacific Gas & Electric Co
@@ -42,15 +45,55 @@ module Genability
42
45
  # @authenticated true
43
46
  # @rate_limited true
44
47
  # @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)
48
+ # @option options [Integer] :lse_id Filter tariffs for a specific Load
49
+ # Serving Entity. (Optional)
50
+ # @option options [Boolean] :populate_items If true, this returns a List
51
+ # of TerritoryItems for each Territory in the result set. (Optional;
52
+ # defaults to false)
53
+ # @option options [Integer] :master_tariff_id Filters the result set to
54
+ # only include territories covered by this master tariff id. (Optional)
55
+ # @option options [String] :contains_item_type Filters the result set to
56
+ # include a particular type of territory. Possible values are: CITY,
57
+ # ZIPCODE, STATE, COUNTY. (Optional)
58
+ # @option options [String] :contains_item_value Filters the Types by
59
+ # this value. e.g. 94115 when searching for types of ZIPCODE. (Optional)
60
+ # @option options [String] :usage_type Filters the result set to only
61
+ # include territories of the specified usageType. Possible values are:
62
+ # SERVICE, TARIFF. (Optional)
63
+ # @option options [String] :search The string of text to search on. This
64
+ # can also be a regular expression, in which case you should set the
65
+ # 'isRegex' flag to true. (Optional)
66
+ # @option options [String] :search_on Comma separated list of fields to
67
+ # query on. When searchOn is specified, the text provided in the search
68
+ # string field will be searched within these fields. The list of fields
69
+ # to search on depend on the entity being searched for. Read the documentation
70
+ # for the entity for more details on the fields that can be searched, and
71
+ # the default fields to be searched if searchOn is not specified. (Optional)
72
+ # @option options [Boolean] :starts_with When true, the search will only
73
+ # return results that begin with the specified search string. Otherwise,
74
+ # any match of the search string will be returned as a result. Default is
75
+ # false. (Optional)
76
+ # @option options [Boolean] :ends_with When true, the search will only return
77
+ # results that end with the specified search string. Otherwise, any match of
78
+ # the search string will be returned as a result. Default is false. (Optional)
79
+ # @option options [Boolean] :is_regex When true, the provided search string
80
+ # will be regarded as a regular expression and the search will return results
81
+ # matching the regular expression. Default is false. (Optional)
82
+ # @option options [String] :sort_on Comma separated list of fields to sort on.
83
+ # This can also be input via Array Inputs (see above). (Optional)
84
+ # @option options [String] :sort_order Comma separated list of ordering.
85
+ # Possible values are 'ASC' and 'DESC'. Default is 'ASC'. If your sortOn
86
+ # contains multiple fields and you would like to order fields individually,
87
+ # you can pass in a comma separated list here (or use Array Inputs, see above).
88
+ # For example, if your sortOn contained 5 fields, and your sortOrder contained
89
+ # 'ASC, DESC, DESC', these would be applied to the first three items in the sortOn
90
+ # field. The remaining two would default to ASC. (Optional)
50
91
  # @return [Array] List of territories.
51
92
  # @see https://developer.genability.com/documentation/api-reference/public/territory
52
93
  # @example Return a list of territories for Pacific Gas & Electric Co
53
94
  # Genability.territories(:lse_id => 734)
95
+ # @example Get a Territory ID from a Zipcode
96
+ # Genability.territories(:lse_id => 734, :contains_item_type => 'ZIPCODE', :contains_item_value => 94115)
54
97
  def territories(options = {})
55
98
  get("public/territories", territories_params(options)).results
56
99
  end
@@ -68,9 +111,11 @@ module Genability
68
111
  'lseId' => options[:lse_id],
69
112
  'masterTariffId' => options[:master_tariff_id],
70
113
  'containsItemType' => options[:contains_item_type],
71
- 'containsItemValue' => options[:contains_item_value]
114
+ 'containsItemValue' => options[:contains_item_value],
115
+ 'usageType' => options[:usage_type]
72
116
  }.delete_if{ |k,v| v.nil? }.
73
117
  merge( territory_params(options) ).
118
+ merge( search_params(options) ).
74
119
  merge( pagination_params(options) )
75
120
  end
76
121
 
@@ -11,19 +11,52 @@ module Genability
11
11
  # Periods. A Period is a range of days and times that this TOU applies to.
12
12
  module TimeOfUse
13
13
 
14
- # Returns a particular time of use group using its time of use group ID and the load serving entity ID.
14
+ # Returns a particular time of use group using its time of use group ID and
15
+ # the load serving entity ID.
15
16
  #
16
17
  # @format :json
17
18
  # @authenticated true
18
19
  # @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.
20
+ # @param load_serving_entity_id [Integer] Unique Genability ID (primary key)
21
+ # for a Load Serving Entity.
22
+ # @param time_of_use_group_id [Integer] Genability ID (primary key) for this
23
+ # Time of Use Group. This is unique within the LSE, not across LSE's so you
24
+ # will always need to specify the LSE ID when requested a TOU Group.
25
+ # @param options [Hash] A customizable set of options.
26
+ # @option options [String] :search The string of text to search on. This
27
+ # can also be a regular expression, in which case you should set the
28
+ # 'isRegex' flag to true. (Optional)
29
+ # @option options [String] :search_on Comma separated list of fields to
30
+ # query on. When searchOn is specified, the text provided in the search
31
+ # string field will be searched within these fields. The list of fields
32
+ # to search on depend on the entity being searched for. Read the documentation
33
+ # for the entity for more details on the fields that can be searched, and
34
+ # the default fields to be searched if searchOn is not specified. (Optional)
35
+ # @option options [Boolean] :starts_with When true, the search will only
36
+ # return results that begin with the specified search string. Otherwise,
37
+ # any match of the search string will be returned as a result. Default is
38
+ # false. (Optional)
39
+ # @option options [Boolean] :ends_with When true, the search will only return
40
+ # results that end with the specified search string. Otherwise, any match of
41
+ # the search string will be returned as a result. Default is false. (Optional)
42
+ # @option options [Boolean] :is_regex When true, the provided search string
43
+ # will be regarded as a regular expression and the search will return results
44
+ # matching the regular expression. Default is false. (Optional)
45
+ # @option options [String] :sort_on Comma separated list of fields to sort on.
46
+ # This can also be input via Array Inputs (see above). (Optional)
47
+ # @option options [String] :sort_order Comma separated list of ordering.
48
+ # Possible values are 'ASC' and 'DESC'. Default is 'ASC'. If your sortOn
49
+ # contains multiple fields and you would like to order fields individually,
50
+ # you can pass in a comma separated list here (or use Array Inputs, see above).
51
+ # For example, if your sortOn contained 5 fields, and your sortOrder contained
52
+ # 'ASC, DESC, DESC', these would be applied to the first three items in the sortOn
53
+ # field. The remaining two would default to ASC. (Optional)
21
54
  # @return [Hashie::Mash] Return the time of uses for a load serving entity.
22
55
  # @see https://developer.genability.com/documentation/api-reference/public/time-of-use
23
56
  # @example Return the time of use group for Georgia Power Co
24
57
  # Genability.time_of_uses(2756, 1)
25
- def time_of_uses(load_serving_entity_id, time_of_use_group_id)
26
- get("public/timeofuses/#{load_serving_entity_id}/#{time_of_use_group_id}").results.first
58
+ def time_of_uses(load_serving_entity_id, time_of_use_group_id, options = {})
59
+ get("public/timeofuses/#{load_serving_entity_id}/#{time_of_use_group_id}", tou_params(options)).results.first
27
60
  end
28
61
 
29
62
  alias :tou :time_of_uses
@@ -35,11 +68,18 @@ module Genability
35
68
  # @format :json
36
69
  # @authenticated true
37
70
  # @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.
71
+ # @param load_serving_entity_id [Integer] Unique Genability ID (primary key) for
72
+ # a Load Serving Entity.
73
+ # @param time_of_use_group_id [Integer] Genability ID (primary key) for this Time
74
+ # of Use Group. This is unique within the LSE, not across LSE's so you will
75
+ # always need to specify the LSE ID when requested a TOU Group.
40
76
  # @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)
77
+ # @option options [DateTime] :from ISO 8601 format for the starting date and
78
+ # time of the requested Intervals. Defaults to current day and time if
79
+ # not specified. (Optional)
80
+ # @option options [DateTime] :to ISO 8601 format for the ending date and
81
+ # time of the requested Intervals. Defaults to one week after the
82
+ # fromDateTime. (Optional)
43
83
  # @return [Array] Returns all the Intervals for a Time of Use Group.
44
84
  # @see https://developer.genability.com/documentation/api-reference/public/time-of-use
45
85
  # @example Return the intervals for the time of use group for Georgia Power Co
@@ -54,6 +94,10 @@ module Genability
54
94
 
55
95
  private
56
96
 
97
+ def tou_params(options)
98
+ search_params(options)
99
+ end
100
+
57
101
  def interval_params(options)
58
102
  {
59
103
  'fromDateTime' => format_to_iso8601(options[:from]),
@@ -29,6 +29,8 @@ module Genability
29
29
  end
30
30
  end
31
31
  connection.use Faraday::Response::RaiseHttp5xx
32
+ connection.use Faraday::Request::Multipart
33
+ connection.use Faraday::Request::UrlEncoded
32
34
  connection.adapter(adapter)
33
35
  end
34
36
  end
@@ -19,7 +19,7 @@ module Genability
19
19
 
20
20
  # Raised when the tariff input for the calculate method is
21
21
  # not an array or hash
22
- class InvalidTariffInput < Error; end
22
+ class InvalidInput < Error; end
23
23
 
24
24
  end
25
25
 
@@ -34,8 +34,13 @@ module Genability
34
34
  request.params['appKey'] = application_key
35
35
  when :post, :put
36
36
  request.path = path
37
- request.headers['Content-Type'] = 'application/json'
38
- request.body = options unless options.empty?
37
+ if options['fileData']
38
+ request.headers['Content-type'] = 'multipart/form-data'
39
+ request.body = options
40
+ else
41
+ request.headers['Content-Type'] = 'application/json;charset=utf-8'
42
+ request.body = options unless options.empty?
43
+ end
39
44
  end
40
45
  end
41
46
  raw ? response : response.body
@@ -7,7 +7,15 @@ class Hashie::Mash
7
7
  def to_friendly_hash
8
8
  out = {}
9
9
  keys.each do |k|
10
- out[genability_to_ruby_friendly(k)] = Hashie::Hash === self[k] ? self[k].to_hash : self[k]
10
+ out[genability_to_ruby_friendly(k)] = case self[k]
11
+ when Hashie::Hash
12
+ self[k].to_friendly_hash
13
+ when Array
14
+ self[k].collect(&:to_friendly_hash)
15
+ else
16
+ self[k]
17
+ end
18
+ #Hashie::Hash === self[k] ? self[k].to_friendly_hash : self[k]
11
19
  end
12
20
  out
13
21
  end
@@ -1,55 +1,82 @@
1
- ---
2
- - !ruby/struct:VCR::HTTPInteraction
3
- request: !ruby/struct:VCR::Request
1
+ ---
2
+ - !ruby/struct:VCR::HTTPInteraction
3
+ request: !ruby/struct:VCR::Request
4
4
  method: :get
5
5
  uri: http://api.genability.com:80/rest/beta/calculate/512?appId=ValidAppID&appKey=ValidAppKey&cityLimits=Inside&connectionType=Primary%20Connection&fromDateTime=2011-09-01T00:00:00.0-0400&toDateTime=2011-09-10T00:00:00.0-0400
6
6
  body:
7
- headers:
8
- accept:
7
+ headers:
8
+ accept:
9
9
  - application/json; charset=utf-8
10
- user-agent:
10
+ user-agent:
11
11
  - Genability API Ruby Gem
12
- accept-encoding:
12
+ accept-encoding:
13
13
  - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
- response: !ruby/struct:VCR::Response
15
- status: !ruby/struct:VCR::ResponseStatus
14
+ response: !ruby/struct:VCR::Response
15
+ status: !ruby/struct:VCR::ResponseStatus
16
16
  code: 200
17
17
  message: OK
18
- headers:
19
- server:
20
- - Apache-Coyote/1.1
21
- content-type:
18
+ headers:
19
+ access-control-allow-origin:
20
+ - ! '*'
21
+ content-type:
22
22
  - application/json;charset=utf-8
23
- transfer-encoding:
23
+ date:
24
+ - Sat, 05 May 2012 18:43:30 GMT
25
+ server:
26
+ - Apache/2.2.16 (Ubuntu)
27
+ transfer-encoding:
24
28
  - chunked
25
- date:
26
- - Wed, 26 Oct 2011 06:44:52 GMT
27
- body: "{\"status\":\"success\",\"count\":3,\"type\":\"PropertyData\",\"results\":[{\"keyName\":\"consumption\",\"dataType\":\"DECIMAL\",\"fromDateTime\":\"2011-09-01T00:00:00.000-0400\",\"toDateTime\":\"2011-09-10T00:00:00.000-0400\",\"unit\":\"kwh\"},{\"keyName\":\"cityLimits\",\"dataType\":\"CHOICE\",\"fromDateTime\":\"2011-09-01T00:00:00.000-0400\",\"toDateTime\":\"2011-09-10T00:00:00.000-0400\",\"dataValue\":\"Inside\"},{\"keyName\":\"connectionType\",\"dataType\":\"CHOICE\",\"fromDateTime\":\"2011-09-01T00:00:00.000-0400\",\"toDateTime\":\"2011-09-10T00:00:00.000-0400\",\"dataValue\":\"Primary Connection\"}]}"
28
- http_version: "1.1"
29
- - !ruby/struct:VCR::HTTPInteraction
30
- request: !ruby/struct:VCR::Request
29
+ connection:
30
+ - keep-alive
31
+ body: ! '{"status":"success","count":3,"type":"PropertyData","results":[{"keyName":"consumption","dataType":"DECIMAL","fromDateTime":"2011-09-01T00:00:00-04:00","toDateTime":"2011-09-10T00:00:00-04:00","unit":"kwh"},{"keyName":"cityLimits","displayName":"Service
32
+ Area (Inside/outside city limits)","description":"Has service inside or outside
33
+ city limits","dataType":"CHOICE","fromDateTime":"2011-09-01T00:00:00-04:00","toDateTime":"2011-09-10T00:00:00-04:00"},{"keyName":"connectionType","displayName":"Connection
34
+ Type","description":"Where or how the service is connected to the grid (e.g.
35
+ primary, transmission, subtransmission).","dataType":"CHOICE","fromDateTime":"2011-09-01T00:00:00-04:00","toDateTime":"2011-09-10T00:00:00-04:00"}]}'
36
+ http_version: '1.1'
37
+ - !ruby/struct:VCR::HTTPInteraction
38
+ request: !ruby/struct:VCR::Request
31
39
  method: :post
32
- uri: http://api.genability.com:80/rest/beta/calculate/512
33
- body: "{\"fromDateTime\":\"2011-09-01T00:00:00.0-0400\",\"toDateTime\":\"2011-09-10T00:00:00.0-0400\",\"tariffInputs\":[{\"keyName\":\"consumption\",\"dataType\":\"DECIMAL\",\"fromDateTime\":\"2011-09-01T00:00:00.000-0400\",\"toDateTime\":\"2011-09-10T00:00:00.000-0400\",\"unit\":\"kwh\"},{\"keyName\":\"cityLimits\",\"dataType\":\"CHOICE\",\"fromDateTime\":\"2011-09-01T00:00:00.000-0400\",\"toDateTime\":\"2011-09-10T00:00:00.000-0400\",\"dataValue\":\"Inside\"},{\"keyName\":\"connectionType\",\"dataType\":\"CHOICE\",\"fromDateTime\":\"2011-09-01T00:00:00.000-0400\",\"toDateTime\":\"2011-09-10T00:00:00.000-0400\",\"dataValue\":\"Primary Connection\"}],\"appId\":\"ValidAppID\",\"appKey\":\"ValidAppKey\"}"
34
- headers:
35
- accept:
40
+ uri: http://api.genability.com:80/rest/beta/calculate/512?appId=ValidAppID&appKey=ValidAppKey
41
+ body: ! '{"fromDateTime":"2011-09-01T00:00:00.0-0400","toDateTime":"2011-09-10T00:00:00.0-0400","tariffInputs":[{"keyName":"consumption","dataType":"DECIMAL","fromDateTime":"2011-09-01T00:00:00-04:00","toDateTime":"2011-09-10T00:00:00-04:00","unit":"kwh"},{"keyName":"cityLimits","displayName":"Service
42
+ Area (Inside/outside city limits)","description":"Has service inside or outside
43
+ city limits","dataType":"CHOICE","fromDateTime":"2011-09-01T00:00:00-04:00","toDateTime":"2011-09-10T00:00:00-04:00"},{"keyName":"connectionType","displayName":"Connection
44
+ Type","description":"Where or how the service is connected to the grid (e.g.
45
+ primary, transmission, subtransmission).","dataType":"CHOICE","fromDateTime":"2011-09-01T00:00:00-04:00","toDateTime":"2011-09-10T00:00:00-04:00"}]}'
46
+ headers:
47
+ accept:
36
48
  - application/json; charset=utf-8
37
- user-agent:
49
+ user-agent:
38
50
  - Genability API Ruby Gem
39
- content-type:
40
- - application/json
41
- response: !ruby/struct:VCR::Response
42
- status: !ruby/struct:VCR::ResponseStatus
51
+ content-type:
52
+ - application/json;charset=utf-8
53
+ response: !ruby/struct:VCR::Response
54
+ status: !ruby/struct:VCR::ResponseStatus
43
55
  code: 200
44
56
  message: OK
45
- headers:
46
- server:
47
- - Apache-Coyote/1.1
48
- content-type:
57
+ headers:
58
+ access-control-allow-origin:
59
+ - ! '*'
60
+ content-type:
49
61
  - application/json;charset=utf-8
50
- transfer-encoding:
62
+ date:
63
+ - Sat, 05 May 2012 18:43:31 GMT
64
+ server:
65
+ - Apache/2.2.16 (Ubuntu)
66
+ transfer-encoding:
51
67
  - chunked
52
- date:
53
- - Wed, 26 Oct 2011 06:44:52 GMT
54
- body: "{\"status\":\"success\",\"count\":1,\"type\":\"CalculatedCost\",\"results\":[{\"masterTariffId\":512,\"tariffName\":\"Residential Service\",\"fromDateTime\":\"2011-09-01T00:00:00.000-0400\",\"toDateTime\":\"2011-09-10T00:00:00.000-0400\",\"totalCost\":10.837188000000000000000000,\"items\":[{\"tariffRateId\":2734,\"tariffRateBandId\":3258,\"rateGroupName\":\"Basic Service Charge\",\"rateName\":\"Basic Service Charge\",\"fromDateTime\":\"2011-09-01T00:00:00.000-0400\",\"toDateTime\":\"2011-09-10T00:00:00.000-0400\",\"rateType\":\"COST_PER_UNIT\",\"quantityKey\":\"fixed\",\"itemQuantity\":1.000000,\"itemCount\":1,\"cost\":9.000000},{\"tariffRateId\":2736,\"tariffRateBandId\":3262,\"rateGroupName\":\"Energy Charges\",\"rateName\":\"Summer Energy Charges\",\"fromDateTime\":\"2011-09-01T00:00:00.000-0400\",\"toDateTime\":\"2011-09-10T00:00:00.000-0400\",\"rateType\":\"COST_PER_UNIT\",\"quantityKey\":\"consumption\",\"itemQuantity\":0.000000,\"itemCount\":1,\"cost\":0E-12},{\"tariffRateId\":2737,\"tariffRateBandId\":3265,\"rateGroupName\":\"Minimum Monthly Bill\",\"rateName\":\"Minimum Charge\",\"fromDateTime\":\"2011-09-01T00:00:00.000-0400\",\"toDateTime\":\"2011-09-10T00:00:00.000-0400\",\"rateType\":\"COST_PER_UNIT\",\"quantityKey\":\"minimum\",\"itemQuantity\":1.000000,\"itemCount\":1,\"cost\":0},{\"tariffRateId\":2723,\"tariffRateBandId\":3247,\"rateGroupName\":\"Demand Side Management Residential Schedule\",\"rateName\":\"Demand Side Management Residential Schedule\",\"fromDateTime\":\"2011-09-01T00:00:00.000-0400\",\"toDateTime\":\"2011-09-10T00:00:00.000-0400\",\"rateType\":\"PERCENTAGE\",\"quantityKey\":\"fixed\",\"itemQuantity\":1.000000,\"itemCount\":1,\"cost\":0.146457000000000000},{\"tariffRateId\":2724,\"tariffRateBandId\":3248,\"rateGroupName\":\"Environmental Compliance Cost Recovery Schedule\",\"rateName\":\"Environmental Compliance Cost Recovery Schedule\",\"fromDateTime\":\"2011-09-01T00:00:00.000-0400\",\"toDateTime\":\"2011-09-10T00:00:00.000-0400\",\"rateType\":\"PERCENTAGE\",\"quantityKey\":\"fixed\",\"itemQuantity\":1.000000,\"itemCount\":1,\"cost\":0.901179000000000000},{\"tariffRateId\":1444637,\"tariffRateBandId\":1415268,\"rateGroupName\":\"Fuel Cost Recovery Schedule\",\"rateName\":\"Summer\",\"fromDateTime\":\"2011-09-01T00:00:00.000-0400\",\"toDateTime\":\"2011-09-10T00:00:00.000-0400\",\"rateType\":\"COST_PER_UNIT\",\"quantityKey\":\"consumption\",\"itemQuantity\":0.000000,\"itemCount\":1,\"cost\":0E-12},{\"tariffRateId\":1444636,\"tariffRateBandId\":1415250,\"rateGroupName\":\"Municipal Franchise Fee Schedule\",\"rateName\":\"Municipal Franchise Fee Schedule\",\"fromDateTime\":\"2011-09-01T00:00:00.000-0400\",\"toDateTime\":\"2011-09-10T00:00:00.000-0400\",\"rateType\":\"PERCENTAGE\",\"quantityKey\":\"QUANTITY\",\"itemQuantity\":1.000000,\"itemCount\":1,\"cost\":0.261981000000000000000000},{\"tariffRateId\":2733,\"tariffRateBandId\":3257,\"rateGroupName\":\"Nuclear Construction Cost Recovery Schedule\",\"rateName\":\"Nuclear Construction Cost Recovery Schedule\",\"fromDateTime\":\"2011-09-01T00:00:00.000-0400\",\"toDateTime\":\"2011-09-10T00:00:00.000-0400\",\"rateType\":\"PERCENTAGE\",\"quantityKey\":\"fixed\",\"itemQuantity\":1.000000,\"itemCount\":1,\"cost\":0.527571000000000000}]}]}"
55
- http_version: "1.1"
68
+ connection:
69
+ - keep-alive
70
+ body: ! '{"status":"success","count":1,"type":"CalculatedCost","results":[{"masterTariffId":512,"tariffName":"Residential
71
+ Service","fromDateTime":"2011-09-01T00:00:00-04:00","toDateTime":"2011-09-10T00:00:00-04:00","totalCost":2.865347,"accuracy":1.000000,"items":[{"tariffRateId":2734,"tariffRateBandId":3258,"rateGroupName":"Basic
72
+ Service Charge","rateName":"Basic Service Charge","fromDateTime":"2011-09-01T00:00:00-04:00","toDateTime":"2011-10-01T00:00:00-04:00","rateType":"COST_PER_UNIT","quantityKey":"fixed","itemQuantity":1.000000,"itemCount":1,"cost":2.700000},{"tariffRateId":2736,"tariffRateBandId":3262,"rateGroupName":"Energy
73
+ Charges","rateName":"Summer Rate","fromDateTime":"2011-09-01T00:00:00-04:00","toDateTime":"2011-10-01T00:00:00-04:00","rateType":"COST_PER_UNIT","quantityKey":"consumption","itemQuantity":0.000000,"itemCount":1,"cost":0.000000},{"tariffRateId":16977076,"tariffRateBandId":10162044,"rateGroupName":"Fuel
74
+ Cost Recovery Charge","rateName":"Secondary Distribution Customer - Summer","fromDateTime":"2011-09-01T00:00:00-04:00","toDateTime":"2011-10-01T00:00:00-04:00","rateType":"COST_PER_UNIT","quantityKey":"consumption","itemQuantity":0.000000,"itemCount":1,"cost":0.000000},{"tariffRateId":16977071,"tariffRateBandId":10162039,"rateGroupName":"Environmental
75
+ Compliance Cost Recovery Charge","rateName":"Environmental Compliance Cost Recovery
76
+ Charge","fromDateTime":"2011-09-01T00:00:00-04:00","toDateTime":"2011-10-01T00:00:00-04:00","rateType":"PERCENTAGE","quantityKey":"QUANTITY","itemQuantity":1.000000,"rateAmount":10.013100,"itemCount":1,"cost":0.081106},{"tariffRateId":16977072,"tariffRateBandId":10162040,"rateGroupName":"Nuclear
77
+ Construction Cost Recovery Charge","rateName":"Nuclear Construction Cost Recovery
78
+ Charge","fromDateTime":"2011-09-01T00:00:00-04:00","toDateTime":"2011-10-01T00:00:00-04:00","rateType":"PERCENTAGE","quantityKey":"QUANTITY","itemQuantity":1.000000,"rateAmount":5.861900,"itemCount":1,"cost":0.047481},{"tariffRateId":16977073,"tariffRateBandId":10162041,"rateGroupName":"Demand
79
+ Side Management Charge","rateName":"Demand Side Management Charge","fromDateTime":"2011-09-01T00:00:00-04:00","toDateTime":"2011-10-01T00:00:00-04:00","rateType":"PERCENTAGE","quantityKey":"QUANTITY","itemQuantity":1.000000,"rateAmount":1.627300,"itemCount":1,"cost":0.013181},{"tariffRateId":16977074,"tariffRateBandId":10162042,"rateGroupName":"Municipal
80
+ Franchise Fee","rateName":"Inside City Limit Customer","fromDateTime":"2011-09-01T00:00:00-04:00","toDateTime":"2011-10-01T00:00:00-04:00","rateType":"PERCENTAGE","quantityKey":"QUANTITY","itemQuantity":1.000000,"rateAmount":2.910900,"itemCount":1,"cost":0.023578},{"tariffRateId":2737,"tariffRateBandId":3265,"rateGroupName":"Minimum
81
+ Charge","rateName":"Minimum Charge","fromDateTime":"2011-09-01T00:00:00-04:00","toDateTime":"2011-09-10T00:00:00-04:00","rateType":"COST_PER_UNIT","quantityKey":"minimum","itemQuantity":1.000000,"rateAmount":9.000000,"itemCount":1,"cost":0.000000}],"assumptions":[{"keyName":"tariffId","dataType":"INTEGER","fromDateTime":"2011-09-01T00:00:00-04:00","toDateTime":"2011-09-10T00:00:00-04:00","dataValue":"512","accuracy":1}]}]}'
82
+ http_version: '1.1'