Module: Genability::Client::Territory

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

Overview

Territories define the areas of coverage for Load Serving Entities and in some cases for individual tariffs. The areas of coverage can be at these levels:

  1. State
  2. County
  3. City
  4. Zip Code

Territories can have one of these two usage types:

  1. Service - defines the areas where this LSE provides service
  2. Tariff - defines the areas where a particular tariff rate applies to. These types of territories are typically defined by the LSE.

We define a Service Territory for each state that an LSE provides coverage. The usageType attribute specifies how this definition is done, either at the State, County, City or Zip Code level.

Instance Method Summary collapse

Instance Method Details

#territories(options = {}) ⇒ Array

Returns a list of territories.

Examples:

Return a list of territories for Pacific Gas & Electric Co

Genability.territories(:lse_id => 734)

Get a Territory ID from a Zipcode

Genability.territories(:lse_id => 734, :contains_item_type => 'ZIPCODE', :contains_item_value => 94115)

Parameters:

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

    A customizable set of options.

Options Hash (options):

  • :lse_id (Integer)

    Filter tariffs for a specific Load Serving Entity. (Optional)

  • :populate_items (Boolean)

    If true, this returns a List of TerritoryItems for each Territory in the result set. (Optional; defaults to false)

  • :master_tariff_id (Integer)

    Filters the result set to only include territories covered by this master tariff id. (Optional)

  • :contains_item_type (String)

    Filters the result set to include a particular type of territory. Possible values are: CITY, ZIPCODE, STATE, COUNTY. (Optional)

  • :contains_item_value (String)

    Filters the Types by this value. e.g. 94115 when searching for types of ZIPCODE. (Optional)

  • :usage_type (String)

    Filters the result set to only include territories of the specified usageType. Possible values are: SERVICE, TARIFF. (Optional)

  • :search (String)

    The string of text to search on. This can also be a regular expression, in which case you should set the 'isRegex' flag to true. (Optional)

  • :search_on (String)

    Comma separated list of fields to query on. When searchOn is specified, the text provided in the search string field will be searched within these fields. The list of fields to search on depend on the entity being searched for. Read the documentation for the entity for more details on the fields that can be searched, and the default fields to be searched if searchOn is not specified. (Optional)

  • :starts_with (Boolean)

    When true, the search will only return results that begin with the specified search string. Otherwise, any match of the search string will be returned as a result. Default is false. (Optional)

  • :ends_with (Boolean)

    When true, the search will only return results that end with the specified search string. Otherwise, any match of the search string will be returned as a result. Default is false. (Optional)

  • :is_regex (Boolean)

    When true, the provided search string will be regarded as a regular expression and the search will return results matching the regular expression. Default is false. (Optional)

  • :sort_on (String)

    Comma separated list of fields to sort on. This can also be input via Array Inputs (see above). (Optional)

  • :sort_order (String)

    Comma separated list of ordering. Possible values are 'ASC' and 'DESC'. Default is 'ASC'. If your sortOn contains multiple fields and you would like to order fields individually, you can pass in a comma separated list here (or use Array Inputs, see above). For example, if your sortOn contained 5 fields, and your sortOrder contained 'ASC, DESC, DESC', these would be applied to the first three items in the sortOn field. The remaining two would default to ASC. (Optional)

Returns:

  • (Array)

    List of territories.

See Also:

Supported formats:

  • :json

Requires Authentication:

  • true

Rate Limited:

  • true



97
98
99
# File 'lib/genability/client/territory.rb', line 97

def territories(options = {})
  get("public/territories", territories_params(options)).results
end

#territory(territory_id, options = {}) ⇒ Hashie::Mash

Returns one territory.

Examples:

Return territory Baseline Region V for Pacific Gas & Electric Co

Genability.territory(3539)

Parameters:

  • territory_id (Integer)

    Unique Genability ID (primary key) for each Territory.

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

    A customizable set of options.

Options Hash (options):

  • :populate_items (Boolean)

    If true, this returns a List of TerritoryItems for each Territory in the result set. (Optional; defaults to false)

Returns:

  • (Hashie::Mash)

    Details for one territory.

See Also:

Supported formats:

  • :json

Requires Authentication:

  • true

Rate Limited:

  • true



38
39
40
# File 'lib/genability/client/territory.rb', line 38

def territory(territory_id, options = {})
  get("public/territories/#{territory_id}", territory_params(options)).results.first
end