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.
- data/Gemfile +13 -12
- data/README.md +40 -6
- data/VERSION +1 -1
- data/genability.gemspec +12 -12
- data/lib/faraday/request/url_encoding_fix.rb +1 -1
- data/lib/genability.rb +5 -3
- data/lib/genability/api.rb +0 -3
- data/lib/genability/client.rb +4 -0
- data/lib/genability/client/calculate.rb +44 -16
- data/lib/genability/client/echo.rb +4 -4
- data/lib/genability/client/helpers.rb +49 -4
- data/lib/genability/client/load_serving_entity.rb +46 -16
- data/lib/genability/client/price.rb +1 -1
- data/lib/genability/client/property.rb +30 -2
- data/lib/genability/client/season.rb +39 -2
- data/lib/genability/client/tariff.rb +63 -12
- data/lib/genability/client/territory.rb +53 -8
- data/lib/genability/client/time_of_use.rb +53 -9
- data/lib/genability/connection.rb +2 -0
- data/lib/genability/error.rb +1 -1
- data/lib/genability/request.rb +7 -2
- data/lib/mashie_extensions.rb +9 -1
- data/spec/cassettes/calculate.yml +65 -38
- data/spec/cassettes/echo.yml +77 -37
- data/spec/cassettes/load_serving_entities.yml +294 -106
- data/spec/cassettes/load_serving_entity.yml +23 -18
- data/spec/cassettes/prices.yml +91 -35
- data/spec/cassettes/properties.yml +178 -35
- data/spec/cassettes/property.yml +31 -19
- data/spec/cassettes/seasons.yml +24 -18
- data/spec/cassettes/tariff.yml +82 -18
- data/spec/cassettes/tariffs.yml +259 -69
- data/spec/cassettes/territories.yml +67 -35
- data/spec/cassettes/territory.yml +24 -18
- data/spec/cassettes/time_of_use.yml +47 -18
- data/spec/cassettes/time_of_uses.yml +24 -18
- data/spec/cassettes/zipcode.yml +25 -18
- data/spec/client/calculate_spec.rb +6 -6
- data/spec/client/echo_spec.rb +6 -6
- data/spec/client/load_serving_entity_spec.rb +15 -7
- data/spec/client/tariff_spec.rb +10 -2
- data/spec/spec_helper.rb +6 -0
- metadata +170 -110
data/Gemfile
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
source "http://rubygems.org"
|
|
2
2
|
|
|
3
|
-
gem "faraday", "~> 0.7
|
|
4
|
-
gem "faraday_middleware", "~> 0.7
|
|
5
|
-
gem "hashie", "~> 1.2
|
|
6
|
-
gem "multi_json", "~> 1.0
|
|
7
|
-
gem "chronic", "~> 0.6
|
|
3
|
+
gem "faraday", "~> 0.7"
|
|
4
|
+
gem "faraday_middleware", "~> 0.7"
|
|
5
|
+
gem "hashie", "~> 1.2"
|
|
6
|
+
gem "multi_json", "~> 1.0"
|
|
7
|
+
gem "chronic", "~> 0.6"
|
|
8
8
|
|
|
9
|
-
group :development do
|
|
10
|
-
gem "rspec", "~> 2.
|
|
11
|
-
gem "yard", "~> 0.7
|
|
12
|
-
gem "
|
|
9
|
+
group :development, :test do
|
|
10
|
+
gem "rspec", "~> 2.8"
|
|
11
|
+
gem "yard", "~> 0.7"
|
|
12
|
+
gem "redcarpet"
|
|
13
|
+
gem "bundler", "~> 1.0"
|
|
13
14
|
gem "jeweler", "~> 1.6.4"
|
|
14
|
-
gem "simplecov", "~> 0.
|
|
15
|
+
gem "simplecov", "~> 0.5"
|
|
15
16
|
gem "vcr", "~> 1.11.3"
|
|
16
|
-
gem "webmock", "~> 1.7
|
|
17
|
-
gem
|
|
17
|
+
gem "webmock", "~> 1.7"
|
|
18
|
+
gem "pry"
|
|
18
19
|
end
|
|
19
20
|
|
data/README.md
CHANGED
|
@@ -12,7 +12,6 @@ Documentation
|
|
|
12
12
|
|
|
13
13
|
Usage Examples
|
|
14
14
|
--------------
|
|
15
|
-
require "rubygems"
|
|
16
15
|
require "genability"
|
|
17
16
|
|
|
18
17
|
# Configure during client initialization
|
|
@@ -70,6 +69,39 @@ Usage Examples
|
|
|
70
69
|
# Get information about a zipcode
|
|
71
70
|
Genability.zipcode('48322')
|
|
72
71
|
|
|
72
|
+
# Add an account
|
|
73
|
+
Genability.add_account(:account_name => 'New Account')
|
|
74
|
+
|
|
75
|
+
# Show account
|
|
76
|
+
Genability.account("account_id")
|
|
77
|
+
|
|
78
|
+
# Get a list of accounts
|
|
79
|
+
Genability.accounts
|
|
80
|
+
|
|
81
|
+
# Delete account
|
|
82
|
+
Genability.delete_account("account_id")
|
|
83
|
+
|
|
84
|
+
# Add a usage profile
|
|
85
|
+
Genability.add_usage_profile(:account_id => "account_id")
|
|
86
|
+
|
|
87
|
+
# Show a usage profile
|
|
88
|
+
Genability.usage_profile("usage_profile_id")
|
|
89
|
+
|
|
90
|
+
# List usage profile
|
|
91
|
+
Genability.usage_profiles
|
|
92
|
+
|
|
93
|
+
# Add a reading(s) to a usage profile
|
|
94
|
+
Genability.add_readings("usage_profile_id", :readings =>
|
|
95
|
+
[
|
|
96
|
+
{
|
|
97
|
+
:from => "2011-08-01T22:30:00.000-0700",
|
|
98
|
+
:to => "2011-08-01T22:45:00.000-0700",
|
|
99
|
+
:quantity_unit => "kWh",
|
|
100
|
+
:quantity_value => 220
|
|
101
|
+
}
|
|
102
|
+
]
|
|
103
|
+
)
|
|
104
|
+
|
|
73
105
|
# Calculate the cost of electricity for a given rate plan
|
|
74
106
|
#
|
|
75
107
|
# First, get the caculation metadata necessary to run the calculation
|
|
@@ -77,9 +109,9 @@ Usage Examples
|
|
|
77
109
|
512, # Master Tariff ID
|
|
78
110
|
"Monday, September 1st, 2011", # From DateTime
|
|
79
111
|
"Monday, September 10th, 2011", # To DateTime
|
|
80
|
-
{
|
|
81
|
-
|
|
82
|
-
|
|
112
|
+
:additional_values => { # Metadata Options
|
|
113
|
+
"connectionType" => "Primary Connection",
|
|
114
|
+
"cityLimits" => "Inside"
|
|
83
115
|
}
|
|
84
116
|
)
|
|
85
117
|
|
|
@@ -88,12 +120,14 @@ Usage Examples
|
|
|
88
120
|
512, # Master Tariff ID
|
|
89
121
|
"Monday, September 1st, 2011", # From DateTime
|
|
90
122
|
"Monday, September 10th, 2011", # To DateTime
|
|
91
|
-
metadata
|
|
123
|
+
metadata, # Metadata from previous call
|
|
124
|
+
{} # Additional options
|
|
92
125
|
)
|
|
93
126
|
result.total_cost # => 10.837
|
|
94
127
|
|
|
95
128
|
|
|
96
|
-
|
|
129
|
+
|
|
130
|
+
Please see the [documentation](http://rubydoc.info/gems/genability/frames) for available options and the tests for additional examples
|
|
97
131
|
|
|
98
132
|
|
|
99
133
|
Contributing to Genability
|
data/VERSION
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
0.
|
|
1
|
+
0.3.0
|
|
2
2
|
|
data/genability.gemspec
CHANGED
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
# -*- encoding: utf-8 -*-
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |s|
|
|
7
|
-
s.name =
|
|
8
|
-
s.version = "0.
|
|
7
|
+
s.name = "genability"
|
|
8
|
+
s.version = "0.3.0"
|
|
9
9
|
|
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new("
|
|
11
|
-
s.authors = [
|
|
12
|
-
s.date =
|
|
13
|
-
s.description =
|
|
14
|
-
s.email =
|
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
|
|
11
|
+
s.authors = ["Matthew Solt"]
|
|
12
|
+
s.date = "2011-11-27"
|
|
13
|
+
s.description = "Ruby client for the Genability power pricing and related APIs - learn more at https://developer.genability.com"
|
|
14
|
+
s.email = "mattsolt@gmail.com"
|
|
15
15
|
s.extra_rdoc_files = [
|
|
16
16
|
"LICENSE.md",
|
|
17
17
|
"README.md"
|
|
@@ -80,11 +80,11 @@ Gem::Specification.new do |s|
|
|
|
80
80
|
"spec/genability_spec.rb",
|
|
81
81
|
"spec/spec_helper.rb"
|
|
82
82
|
]
|
|
83
|
-
s.homepage =
|
|
84
|
-
s.licenses = [
|
|
85
|
-
s.require_paths = [
|
|
86
|
-
s.rubygems_version =
|
|
87
|
-
s.summary =
|
|
83
|
+
s.homepage = "http://github.com/activefx/genability"
|
|
84
|
+
s.licenses = ["MIT"]
|
|
85
|
+
s.require_paths = ["lib"]
|
|
86
|
+
s.rubygems_version = "1.8.11"
|
|
87
|
+
s.summary = "Ruby client for the Genability API"
|
|
88
88
|
|
|
89
89
|
if s.respond_to? :specification_version then
|
|
90
90
|
s.specification_version = 3
|
data/lib/genability.rb
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
require '
|
|
2
|
-
require 'genability/client'
|
|
1
|
+
require 'mashie_extensions'
|
|
3
2
|
require 'genability/configuration'
|
|
3
|
+
require 'genability/connection'
|
|
4
|
+
require 'genability/request'
|
|
5
|
+
require 'genability/api'
|
|
4
6
|
require 'genability/error'
|
|
5
|
-
require '
|
|
7
|
+
require 'genability/client'
|
|
6
8
|
|
|
7
9
|
module Genability
|
|
8
10
|
extend Configuration
|
data/lib/genability/api.rb
CHANGED
data/lib/genability/client.rb
CHANGED
|
@@ -2,6 +2,7 @@ module Genability
|
|
|
2
2
|
# Wrapper for the Genability REST API
|
|
3
3
|
class Client < API
|
|
4
4
|
require 'genability/client/helpers'
|
|
5
|
+
require 'genability/client/account'
|
|
5
6
|
require 'genability/client/calculate'
|
|
6
7
|
require 'genability/client/echo'
|
|
7
8
|
require 'genability/client/load_serving_entity'
|
|
@@ -11,10 +12,12 @@ module Genability
|
|
|
11
12
|
require 'genability/client/tariff'
|
|
12
13
|
require 'genability/client/territory'
|
|
13
14
|
require 'genability/client/time_of_use'
|
|
15
|
+
require 'genability/client/usage_profile'
|
|
14
16
|
require 'genability/client/zip_code'
|
|
15
17
|
|
|
16
18
|
include Genability::Client::Helpers
|
|
17
19
|
|
|
20
|
+
include Genability::Client::Account
|
|
18
21
|
include Genability::Client::Calculate
|
|
19
22
|
include Genability::Client::Echo
|
|
20
23
|
include Genability::Client::LoadServingEntity
|
|
@@ -24,6 +27,7 @@ module Genability
|
|
|
24
27
|
include Genability::Client::Tariff
|
|
25
28
|
include Genability::Client::Territory
|
|
26
29
|
include Genability::Client::TimeOfUse
|
|
30
|
+
include Genability::Client::UsageProfile
|
|
27
31
|
include Genability::Client::ZipCode
|
|
28
32
|
end
|
|
29
33
|
end
|
|
@@ -19,10 +19,19 @@ module Genability
|
|
|
19
19
|
# @param to_date_time [DateTime, String] End date and time for this Calculate request.
|
|
20
20
|
# In ISO 8601 format. Will attempt to use the Chronic gem to parse if a string is used.
|
|
21
21
|
# @param options [Hash] A customizable set of options.
|
|
22
|
-
# @option options [Integer] :territory_id The territory ID of where the usage consumption
|
|
22
|
+
# @option options [Integer] :territory_id The territory ID of where the usage consumption
|
|
23
|
+
# occurred. (Required for most CA tariffs.)
|
|
24
|
+
# @option options [Hash] :additional_values Any additional applicability values that
|
|
25
|
+
# are required to calculate this tariff are passed in on the request url. Keep in
|
|
26
|
+
# mind that this is only for the GET method where you are getting the required inputs.
|
|
27
|
+
# When you POST to run the calculation, you will pass these applicability values as
|
|
28
|
+
# part of the Tariff Input array. To find out how to get the list of applicability
|
|
29
|
+
# properties required for a tariff,
|
|
30
|
+
# {https://developer.genability.com/documentation/api-reference/public/tariff#getTariff read more here}.
|
|
23
31
|
# @return [Array] Array of TariffInput for consumption.
|
|
24
32
|
# @example Return the inputs required to accurately calculate the cost for a given period
|
|
25
|
-
# Genability.calculate_metadata(512, "2011-06-16T19:00:00.0-0400", "2011-08-01T00:00:00.0-0400"
|
|
33
|
+
# Genability.calculate_metadata(512, "2011-06-16T19:00:00.0-0400", "2011-08-01T00:00:00.0-0400",
|
|
34
|
+
# { :additional_values => { "connectionType" => "Primary Connection", "cityLimits" => "Inside" })
|
|
26
35
|
# @format :json
|
|
27
36
|
# @authenticated true
|
|
28
37
|
# @rate_limited true
|
|
@@ -33,9 +42,31 @@ module Genability
|
|
|
33
42
|
|
|
34
43
|
# Calculate the cost of electricity for a given rate/pricing plan.
|
|
35
44
|
# @overload calculate(tariff_id, from_date_time, to_date_time, tariff_inputs, options = {})
|
|
45
|
+
# To run a new calculation, you will POST a payload containing the calculation criteria and
|
|
46
|
+
# inputs, and a Calculated Cost will be returned. The table below documents the various
|
|
47
|
+
# properties of the payload, and immediately after the table is an example of the payload itself.
|
|
48
|
+
# @param tariff_id [Integer] Unique Genability ID (primary key) for a tariff.
|
|
49
|
+
# @param from_date_time [DateTime, String] Starting date and time for this Calculate request.
|
|
50
|
+
# In ISO 8601 format. Will attempt to use the Chronic gem to parse if a string is used.
|
|
51
|
+
# @param to_date_time [DateTime, String] End date and time for this Calculate request.
|
|
52
|
+
# In ISO 8601 format. Will attempt to use the Chronic gem to parse if a string is used.
|
|
53
|
+
# @param options [Hash] A customizable set of options.
|
|
54
|
+
# @option options [Integer] :territory_id The territory ID of where the usage consumption
|
|
55
|
+
# occurred. (Required for most CA tariffs.)
|
|
56
|
+
# @option options [String] :detail_level Toggles the level of details for the calculation
|
|
57
|
+
# result. (Optional) Possible values are:
|
|
58
|
+
# ALL - return all details for this calculation (default)
|
|
59
|
+
# TOTAL - return only the overall total, without any details
|
|
60
|
+
# CHARGE_TYPE - group the details by charge types, such as FIXED, CONSUMPTION, QUANTITY
|
|
61
|
+
# RATE - group the details by rates. This is most similar to how a utility bill is constructed.
|
|
62
|
+
# @option options [Array] :tariff_inputs The array of TariffInput values to use when running
|
|
63
|
+
# the calculation.
|
|
64
|
+
# @format :json
|
|
65
|
+
# @authenticated true
|
|
66
|
+
# @rate_limited true
|
|
36
67
|
# @see https://developer.genability.com/documentation/api-reference/pricing/calculate
|
|
37
68
|
def calculate(tariff_id, from, to, tariff_inputs, options = {})
|
|
38
|
-
post( "beta/calculate/#{tariff_id}",
|
|
69
|
+
post( "beta/calculate/#{tariff_id}?appId=#{application_id}&appKey=#{application_key}",
|
|
39
70
|
calculate_params(from, to, tariff_inputs, options)
|
|
40
71
|
).results.first
|
|
41
72
|
end
|
|
@@ -51,8 +82,6 @@ module Genability
|
|
|
51
82
|
"tariffInputs" => tariff_input_params(tariff_inputs)
|
|
52
83
|
}.
|
|
53
84
|
delete_if{ |k,v| v.nil? }.
|
|
54
|
-
merge({ "appId" => application_id,
|
|
55
|
-
"appKey" => application_key }).
|
|
56
85
|
to_json
|
|
57
86
|
end
|
|
58
87
|
|
|
@@ -66,29 +95,28 @@ module Genability
|
|
|
66
95
|
a << convert_tariff_input_params(ti)
|
|
67
96
|
end
|
|
68
97
|
else
|
|
69
|
-
raise Genability::
|
|
98
|
+
raise Genability::InvalidInput
|
|
70
99
|
end
|
|
71
100
|
end
|
|
72
101
|
end
|
|
73
102
|
|
|
74
103
|
def convert_tariff_input_params(tariff_input)
|
|
75
104
|
return tariff_input.to_hash if tariff_input.is_a? Hashie::Mash
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
"fromDateTime" => tariff_input[:from],
|
|
79
|
-
"toDateTime" => tariff_input[:to],
|
|
80
|
-
"unit" => tariff_input[:unit]
|
|
81
|
-
}
|
|
105
|
+
raise Genability::InvalidInput unless tariff_input.is_a?(Hash)
|
|
106
|
+
tariff_input
|
|
82
107
|
end
|
|
83
108
|
|
|
84
109
|
def calculate_meta_params(from, to, options)
|
|
85
110
|
{
|
|
86
111
|
"fromDateTime" => format_to_iso8601(from),
|
|
87
112
|
"toDateTime" => format_to_iso8601(to),
|
|
88
|
-
"territoryId" => options[:territory_id]
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
113
|
+
"territoryId" => options[:territory_id]
|
|
114
|
+
}.delete_if{ |k,v| v.nil? }.
|
|
115
|
+
merge( additional_values(options[:additional_values]) )
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
def additional_values(av)
|
|
119
|
+
av.is_a?(Hash) ? av : {}
|
|
92
120
|
end
|
|
93
121
|
|
|
94
122
|
end
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
module Genability
|
|
2
2
|
class Client
|
|
3
|
-
|
|
3
|
+
# @private
|
|
4
4
|
module Echo
|
|
5
5
|
|
|
6
6
|
def credentials_valid?
|
|
7
7
|
get("echo").status == "success"
|
|
8
8
|
end
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
def validate(param_name, param_type)
|
|
11
|
+
get("echo/validate", {param_name => param_type}).results.first
|
|
12
|
+
end
|
|
13
13
|
|
|
14
14
|
def raise_error(error_code)
|
|
15
15
|
get("echo/errors/#{error_code}")
|
|
@@ -7,18 +7,63 @@ module Genability
|
|
|
7
7
|
# @private
|
|
8
8
|
module Helpers
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
protected
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
# @option options [Integer] :page The page number to begin the result
|
|
13
|
+
# set from. If not specified, this will begin with the first result
|
|
14
|
+
# set. (Optional)
|
|
15
|
+
# @option options [Integer] :per_page The number of results to return.
|
|
16
|
+
# If not specified, this will return 25 results. (Optional)
|
|
17
|
+
def pagination_params(options = {})
|
|
13
18
|
{
|
|
14
19
|
'pageStart' => options['pageStart'] || options[:page_start] || options[:page],
|
|
15
|
-
'pageCount' => options['pageCount'] || options[:page_count] || options[:per_page]
|
|
20
|
+
'pageCount' => options['pageCount'] || options[:page_count] || options[:per_page]
|
|
21
|
+
}.delete_if{ |k,v| v.nil? }
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# @option options [String] :search The string of text to search on. This
|
|
25
|
+
# can also be a regular expression, in which case you should set the
|
|
26
|
+
# 'isRegex' flag to true. (Optional)
|
|
27
|
+
# @option options [String] :search_on Comma separated list of fields to
|
|
28
|
+
# query on. When searchOn is specified, the text provided in the search
|
|
29
|
+
# string field will be searched within these fields. The list of fields
|
|
30
|
+
# to search on depend on the entity being searched for. Read the documentation
|
|
31
|
+
# for the entity for more details on the fields that can be searched, and
|
|
32
|
+
# the default fields to be searched if searchOn is not specified. (Optional)
|
|
33
|
+
# @option options [Boolean] :starts_with When true, the search will only
|
|
34
|
+
# return results that begin with the specified search string. Otherwise,
|
|
35
|
+
# any match of the search string will be returned as a result. Default is
|
|
36
|
+
# false. (Optional)
|
|
37
|
+
# @option options [Boolean] :ends_with When true, the search will only return
|
|
38
|
+
# results that end with the specified search string. Otherwise, any match of
|
|
39
|
+
# the search string will be returned as a result. Default is false. (Optional)
|
|
40
|
+
# @option options [Boolean] :is_regex When true, the provided search string
|
|
41
|
+
# will be regarded as a regular expression and the search will return results
|
|
42
|
+
# matching the regular expression. Default is false. (Optional)
|
|
43
|
+
# @option options [String] :sort_on Comma separated list of fields to sort on.
|
|
44
|
+
# This can also be input via Array Inputs (see above). (Optional)
|
|
45
|
+
# @option options [String] :sort_order Comma separated list of ordering.
|
|
46
|
+
# Possible values are 'ASC' and 'DESC'. Default is 'ASC'. If your sortOn
|
|
47
|
+
# contains multiple fields and you would like to order fields individually,
|
|
48
|
+
# you can pass in a comma separated list here (or use Array Inputs, see above).
|
|
49
|
+
# For example, if your sortOn contained 5 fields, and your sortOrder contained
|
|
50
|
+
# 'ASC, DESC, DESC', these would be applied to the first three items in the sortOn
|
|
51
|
+
# field. The remaining two would default to ASC. (Optional)
|
|
52
|
+
def search_params(options = {})
|
|
53
|
+
{
|
|
54
|
+
'search' => options[:search],
|
|
55
|
+
'searchOn' => multi_option_handler(options[:search_on]),
|
|
56
|
+
'startsWith' => convert_to_boolean(options[:starts_with]),
|
|
57
|
+
'endsWith' => convert_to_boolean(options[:ends_with]),
|
|
58
|
+
'isRegex' => convert_to_boolean(options[:is_regex]),
|
|
59
|
+
'sortOn' => options[:sort_on],
|
|
60
|
+
'sortOrder' => options[:sort_order]
|
|
16
61
|
}.delete_if{ |k,v| v.nil? }
|
|
17
62
|
end
|
|
18
63
|
|
|
19
64
|
def convert_to_boolean(value = nil)
|
|
20
65
|
return nil if value.nil? || value.empty?
|
|
21
|
-
"true"
|
|
66
|
+
value == "false" ? nil : "true"
|
|
22
67
|
end
|
|
23
68
|
|
|
24
69
|
def multi_option_handler(value = nil)
|
|
@@ -17,11 +17,43 @@ module Genability
|
|
|
17
17
|
# @authenticated true
|
|
18
18
|
# @rate_limited true
|
|
19
19
|
# @param options [Hash] A customizable set of options.
|
|
20
|
-
# @option options [
|
|
21
|
-
#
|
|
22
|
-
#
|
|
23
|
-
# @option options [Integer] :
|
|
24
|
-
#
|
|
20
|
+
# @option options [Integer] :page The page number to begin the result
|
|
21
|
+
# set from. If not specified, this will begin with the first result
|
|
22
|
+
# set. (Optional)
|
|
23
|
+
# @option options [Integer] :per_page The number of results to return.
|
|
24
|
+
# If not specified, this will return 25 results. (Optional)
|
|
25
|
+
# @option options [String] :search The string of text to search on. This
|
|
26
|
+
# can also be a regular expression, in which case you should set the
|
|
27
|
+
# 'isRegex' flag to true. (Optional)
|
|
28
|
+
# @option options [String] :search_on Comma separated list of fields to
|
|
29
|
+
# query on. When searchOn is specified, the text provided in the search
|
|
30
|
+
# string field will be searched within these fields. The list of fields
|
|
31
|
+
# to search on depend on the entity being searched for. Read the documentation
|
|
32
|
+
# for the entity for more details on the fields that can be searched, and
|
|
33
|
+
# the default fields to be searched if searchOn is not specified. (Optional)
|
|
34
|
+
# @option options [Boolean] :starts_with When true, the search will only
|
|
35
|
+
# return results that begin with the specified search string. Otherwise,
|
|
36
|
+
# any match of the search string will be returned as a result. Default is
|
|
37
|
+
# false. (Optional)
|
|
38
|
+
# @option options [Boolean] :ends_with When true, the search will only return
|
|
39
|
+
# results that end with the specified search string. Otherwise, any match of
|
|
40
|
+
# the search string will be returned as a result. Default is false. (Optional)
|
|
41
|
+
# @option options [Boolean] :is_regex When true, the provided search string
|
|
42
|
+
# will be regarded as a regular expression and the search will return results
|
|
43
|
+
# matching the regular expression. Default is false. (Optional)
|
|
44
|
+
# @option options [String] :sort_on Comma separated list of fields to sort on.
|
|
45
|
+
# This can also be input via Array Inputs (see above). (Optional)
|
|
46
|
+
# @option options [String] :sort_order Comma separated list of ordering.
|
|
47
|
+
# Possible values are 'ASC' and 'DESC'. Default is 'ASC'. If your sortOn
|
|
48
|
+
# contains multiple fields and you would like to order fields individually,
|
|
49
|
+
# you can pass in a comma separated list here (or use Array Inputs, see above).
|
|
50
|
+
# For example, if your sortOn contained 5 fields, and your sortOrder contained
|
|
51
|
+
# 'ASC, DESC, DESC', these would be applied to the first three items in the sortOn
|
|
52
|
+
# field. The remaining two would default to ASC. (Optional)
|
|
53
|
+
# @option options [String] :account_id The unique ID of the Account for which
|
|
54
|
+
# you want to find LSEs. When passed in, the search will look for a territoryId
|
|
55
|
+
# on the Account and use that to find all LSEs that provide service within that
|
|
56
|
+
# territory. (Optional)
|
|
25
57
|
# @return [Array] List of load serving entities.
|
|
26
58
|
# @see https://developer.genability.com/documentation/api-reference/public/lse
|
|
27
59
|
# @example Return the first 25 load serving entities
|
|
@@ -31,11 +63,13 @@ module Genability
|
|
|
31
63
|
# @example Return only 10 load serving entities
|
|
32
64
|
# Genability.load_serving_entities(:per_page => 10)
|
|
33
65
|
# @example Search for load serving entities starting with the letters 'Ka'
|
|
34
|
-
# Genability.load_serving_entities(:
|
|
66
|
+
# Genability.load_serving_entities(:search => 'Ka', :starts_with => 'true')
|
|
35
67
|
# @example Search for load serving entities ending with the word 'Inc'
|
|
36
|
-
# Genability.load_serving_entities(:
|
|
68
|
+
# Genability.load_serving_entities(:search => 'Inc', :ends_with => 'true')
|
|
37
69
|
# @example Search for load serving entities with the word 'Energy'
|
|
38
|
-
# Genability.load_serving_entities(:
|
|
70
|
+
# Genability.load_serving_entities(:search => 'Energy')
|
|
71
|
+
# @example Search for load serving entities with a regular expression
|
|
72
|
+
# Genability.load_serving_entities(:search => /\w{5,}/)
|
|
39
73
|
def load_serving_entities(options={})
|
|
40
74
|
get("public/lses", lses_params(options)).results
|
|
41
75
|
end
|
|
@@ -62,14 +96,10 @@ module Genability
|
|
|
62
96
|
|
|
63
97
|
def lses_params(options)
|
|
64
98
|
{
|
|
65
|
-
'
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
def search_string(options)
|
|
72
|
-
options[:search_string] || options[:contains] || options[:starts_with] || options[:ends_with]
|
|
99
|
+
'accountId' => options[:account_id]
|
|
100
|
+
}.delete_if{ |k,v| v.nil? }.
|
|
101
|
+
merge( pagination_params(options) ).
|
|
102
|
+
merge( search_params(options) )
|
|
73
103
|
end
|
|
74
104
|
|
|
75
105
|
end
|