genability 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. data/.document +2 -2
  2. data/Gemfile +11 -10
  3. data/HISTORY.md +8 -0
  4. data/README.md +38 -3
  5. data/Rakefile +1 -0
  6. data/VERSION +2 -1
  7. data/genability.gemspec +46 -32
  8. data/lib/faraday/request/url_encoding_fix.rb +0 -1
  9. data/lib/genability/client.rb +6 -0
  10. data/lib/genability/client/calculate.rb +97 -0
  11. data/lib/genability/client/echo.rb +21 -0
  12. data/lib/genability/client/helpers.rb +2 -1
  13. data/lib/genability/client/load_serving_entity.rb +12 -11
  14. data/lib/genability/client/price.rb +1 -1
  15. data/lib/genability/client/property.rb +26 -0
  16. data/lib/genability/client/season.rb +1 -1
  17. data/lib/genability/client/tariff.rb +2 -2
  18. data/lib/genability/client/territory.rb +2 -2
  19. data/lib/genability/client/time_of_use.rb +3 -2
  20. data/lib/genability/client/zip_code.rb +1 -1
  21. data/lib/genability/configuration.rb +1 -2
  22. data/lib/genability/connection.rb +1 -5
  23. data/lib/genability/error.rb +4 -0
  24. data/lib/genability/request.rb +8 -1
  25. data/lib/mashie_extensions.rb +15 -4
  26. data/spec/cassettes/calculate.yml +55 -0
  27. data/spec/cassettes/echo.yml +57 -0
  28. data/spec/cassettes/load_serving_entities.yml +18 -18
  29. data/spec/cassettes/load_serving_entity.yml +2 -2
  30. data/spec/cassettes/prices.yml +6 -6
  31. data/spec/cassettes/properties.yml +55 -0
  32. data/spec/cassettes/property.yml +28 -0
  33. data/spec/cassettes/seasons.yml +2 -2
  34. data/spec/cassettes/tariff.yml +3 -3
  35. data/spec/cassettes/tariffs.yml +36 -9
  36. data/spec/cassettes/territories.yml +30 -3
  37. data/spec/cassettes/territory.yml +3 -3
  38. data/spec/cassettes/time_of_use.yml +5 -7
  39. data/spec/cassettes/time_of_uses.yml +3 -3
  40. data/spec/cassettes/zipcode.yml +2 -2
  41. data/spec/client/calculate_spec.rb +68 -0
  42. data/spec/client/echo_spec.rb +46 -0
  43. data/spec/client/helpers_spec.rb +34 -0
  44. data/spec/client/load_serving_entity_spec.rb +14 -5
  45. data/spec/client/property_spec.rb +45 -0
  46. data/spec/client/tariff_spec.rb +9 -1
  47. data/spec/client/territory_spec.rb +12 -1
  48. data/spec/client/time_of_use_spec.rb +2 -2
  49. data/spec/faraday/response_spec.rb +2 -2
  50. data/spec/genability_spec.rb +1 -1
  51. data/spec/spec_helper.rb +12 -8
  52. metadata +36 -13
data/.document CHANGED
@@ -1,5 +1,5 @@
1
1
  lib/**/*.rb
2
2
  bin/*
3
- -
3
+ -
4
4
  features/**/*.feature
5
- LICENSE.txt
5
+
data/Gemfile CHANGED
@@ -1,18 +1,19 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- gem "faraday", "~> 0.6"
4
- gem "faraday_middleware", "~> 0.6"
5
- gem "hashie", "~> 1.0.0"
6
- gem "multi_json", "~> 1.0.0"
7
- gem "chronic", "~> 0.4.0"
3
+ gem "faraday", "~> 0.7.4"
4
+ gem "faraday_middleware", "~> 0.7.0"
5
+ gem "hashie", "~> 1.2.0"
6
+ gem "multi_json", "~> 1.0.3"
7
+ gem "chronic", "~> 0.6.4"
8
8
 
9
9
  group :development do
10
- gem "rspec", "~> 2.6.0"
10
+ gem "rspec", "~> 2.7"
11
11
  gem "yard", "~> 0.7.0"
12
- gem "bundler", "~> 1.0.0"
13
- gem "jeweler", "~> 1.6.2"
12
+ gem "bundler", "~> 1.0.7"
13
+ gem "jeweler", "~> 1.6.4"
14
14
  gem "simplecov", "~> 0.4"
15
- gem "vcr", "~> 1.10.0"
16
- gem "webmock", "~> 1.6.0"
15
+ gem "vcr", "~> 1.11.3"
16
+ gem "webmock", "~> 1.7.4"
17
+ gem 'ruby-debug19', :require => 'ruby-debug'
17
18
  end
18
19
 
data/HISTORY.md CHANGED
@@ -5,3 +5,11 @@ HISTORY
5
5
  ----------------------
6
6
  * Initial Release
7
7
 
8
+ 0.2.0 - October 26, 2011
9
+ ----------------------
10
+ * Added Calculate API calls
11
+ * Added Echo and Property API helper calls
12
+ * Update Faraday and Faraday Middleware to 0.7 versions
13
+ * Added .to\_friendly\_hash method to Hashie::Mash to convert results to Ruby / Rails friendly attributes
14
+ * Continued improving test coverage
15
+
data/README.md CHANGED
@@ -19,10 +19,22 @@ Usage Examples
19
19
  client = Genability::Client.new(:application_id = 'ValidAppId', :application_key => 'ValidAppKey')
20
20
 
21
21
  # Or use the block configuration method
22
+ # Useful for using in a Rails initializer
22
23
  # register an app at https://developer.genability.com
23
24
  Genability.configure do |config|
24
- config.application_id = 'ValidAppId'
25
- config.application_key = 'ValidAppKey'
25
+ config.application_id = 'ValidAppId'
26
+ config.application_key = 'ValidAppKey'
27
+ end
28
+
29
+ # Advanced Configuration Options
30
+ Genability.configure do |config|
31
+ config.application_id = 'ValidAppId'
32
+ config.application_key = 'ValidAppKey'
33
+ config.adapter = :typhoeus
34
+ config.endpoint = "http://api.genability.com/rest/"
35
+ config.format = :json
36
+ config.user_agent = "Genability API Ruby Gem"
37
+ config.proxy = "http://127.0.0.1"
26
38
  end
27
39
 
28
40
  # Get a list of load serving entities
@@ -53,11 +65,34 @@ Usage Examples
53
65
  Genability.time_of_uses(2756, 1)
54
66
 
55
67
  # Get the intervals for the particular time of use group of a given load serving entity
56
- Genability.time_of_use_intervals(2756, 1)
68
+ Genability.time_of_use_intervals(734, 1)
57
69
 
58
70
  # Get information about a zipcode
59
71
  Genability.zipcode('48322')
60
72
 
73
+ # Calculate the cost of electricity for a given rate plan
74
+ #
75
+ # First, get the caculation metadata necessary to run the calculation
76
+ metadata = Genability.calculate_metadata(
77
+ 512, # Master Tariff ID
78
+ "Monday, September 1st, 2011", # From DateTime
79
+ "Monday, September 10th, 2011", # To DateTime
80
+ { # Metadata Options
81
+ :connection_type => "Primary Connection",
82
+ :city_limits => "Inside"
83
+ }
84
+ )
85
+
86
+ # Then, run the calculation with the metadata you just received
87
+ result = Genability.calculate(
88
+ 512, # Master Tariff ID
89
+ "Monday, September 1st, 2011", # From DateTime
90
+ "Monday, September 10th, 2011", # To DateTime
91
+ metadata # Metadata from previous call
92
+ )
93
+ result.total_cost # => 10.837
94
+
95
+
61
96
  # Please see the documentation for available options and the tests for additional examples
62
97
 
63
98
 
data/Rakefile CHANGED
@@ -40,3 +40,4 @@ task :default => :spec
40
40
 
41
41
  require 'yard'
42
42
  YARD::Rake::YardocTask.new
43
+
data/VERSION CHANGED
@@ -1 +1,2 @@
1
- 0.1.0
1
+ 0.2.0
2
+
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{genability}
8
- s.version = "0.1.0"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = [%q{Matthew Solt}]
12
- s.date = %q{2011-07-01}
12
+ s.date = %q{2011-10-26}
13
13
  s.description = %q{Ruby client for the Genability power pricing and related APIs - learn more at https://developer.genability.com}
14
14
  s.email = %q{mattsolt@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -33,9 +33,12 @@ Gem::Specification.new do |s|
33
33
  "lib/genability.rb",
34
34
  "lib/genability/api.rb",
35
35
  "lib/genability/client.rb",
36
+ "lib/genability/client/calculate.rb",
37
+ "lib/genability/client/echo.rb",
36
38
  "lib/genability/client/helpers.rb",
37
39
  "lib/genability/client/load_serving_entity.rb",
38
40
  "lib/genability/client/price.rb",
41
+ "lib/genability/client/property.rb",
39
42
  "lib/genability/client/season.rb",
40
43
  "lib/genability/client/tariff.rb",
41
44
  "lib/genability/client/territory.rb",
@@ -46,9 +49,13 @@ Gem::Specification.new do |s|
46
49
  "lib/genability/error.rb",
47
50
  "lib/genability/request.rb",
48
51
  "lib/mashie_extensions.rb",
52
+ "spec/cassettes/calculate.yml",
53
+ "spec/cassettes/echo.yml",
49
54
  "spec/cassettes/load_serving_entities.yml",
50
55
  "spec/cassettes/load_serving_entity.yml",
51
56
  "spec/cassettes/prices.yml",
57
+ "spec/cassettes/properties.yml",
58
+ "spec/cassettes/property.yml",
52
59
  "spec/cassettes/seasons.yml",
53
60
  "spec/cassettes/tariff.yml",
54
61
  "spec/cassettes/tariffs.yml",
@@ -57,8 +64,12 @@ Gem::Specification.new do |s|
57
64
  "spec/cassettes/time_of_use.yml",
58
65
  "spec/cassettes/time_of_uses.yml",
59
66
  "spec/cassettes/zipcode.yml",
67
+ "spec/client/calculate_spec.rb",
68
+ "spec/client/echo_spec.rb",
69
+ "spec/client/helpers_spec.rb",
60
70
  "spec/client/load_serving_entity_spec.rb",
61
71
  "spec/client/price_spec.rb",
72
+ "spec/client/property_spec.rb",
62
73
  "spec/client/season_spec.rb",
63
74
  "spec/client/tariff_spec.rb",
64
75
  "spec/client/territory_spec.rb",
@@ -79,45 +90,48 @@ Gem::Specification.new do |s|
79
90
  s.specification_version = 3
80
91
 
81
92
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
82
- s.add_runtime_dependency(%q<faraday>, ["~> 0.6"])
83
- s.add_runtime_dependency(%q<faraday_middleware>, ["~> 0.6"])
84
- s.add_runtime_dependency(%q<hashie>, ["~> 1.0.0"])
85
- s.add_runtime_dependency(%q<multi_json>, ["~> 1.0.0"])
86
- s.add_runtime_dependency(%q<chronic>, ["~> 0.4.0"])
87
- s.add_development_dependency(%q<rspec>, ["~> 2.6.0"])
93
+ s.add_runtime_dependency(%q<faraday>, ["~> 0.7.4"])
94
+ s.add_runtime_dependency(%q<faraday_middleware>, ["~> 0.7.0"])
95
+ s.add_runtime_dependency(%q<hashie>, ["~> 1.2.0"])
96
+ s.add_runtime_dependency(%q<multi_json>, ["~> 1.0.3"])
97
+ s.add_runtime_dependency(%q<chronic>, ["~> 0.6.4"])
98
+ s.add_development_dependency(%q<rspec>, ["~> 2.7"])
88
99
  s.add_development_dependency(%q<yard>, ["~> 0.7.0"])
89
- s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
90
- s.add_development_dependency(%q<jeweler>, ["~> 1.6.2"])
100
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.7"])
101
+ s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
91
102
  s.add_development_dependency(%q<simplecov>, ["~> 0.4"])
92
- s.add_development_dependency(%q<vcr>, ["~> 1.10.0"])
93
- s.add_development_dependency(%q<webmock>, ["~> 1.6.0"])
103
+ s.add_development_dependency(%q<vcr>, ["~> 1.11.3"])
104
+ s.add_development_dependency(%q<webmock>, ["~> 1.7.4"])
105
+ s.add_development_dependency(%q<ruby-debug19>, [">= 0"])
94
106
  else
95
- s.add_dependency(%q<faraday>, ["~> 0.6"])
96
- s.add_dependency(%q<faraday_middleware>, ["~> 0.6"])
97
- s.add_dependency(%q<hashie>, ["~> 1.0.0"])
98
- s.add_dependency(%q<multi_json>, ["~> 1.0.0"])
99
- s.add_dependency(%q<chronic>, ["~> 0.4.0"])
100
- s.add_dependency(%q<rspec>, ["~> 2.6.0"])
107
+ s.add_dependency(%q<faraday>, ["~> 0.7.4"])
108
+ s.add_dependency(%q<faraday_middleware>, ["~> 0.7.0"])
109
+ s.add_dependency(%q<hashie>, ["~> 1.2.0"])
110
+ s.add_dependency(%q<multi_json>, ["~> 1.0.3"])
111
+ s.add_dependency(%q<chronic>, ["~> 0.6.4"])
112
+ s.add_dependency(%q<rspec>, ["~> 2.7"])
101
113
  s.add_dependency(%q<yard>, ["~> 0.7.0"])
102
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
103
- s.add_dependency(%q<jeweler>, ["~> 1.6.2"])
114
+ s.add_dependency(%q<bundler>, ["~> 1.0.7"])
115
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
104
116
  s.add_dependency(%q<simplecov>, ["~> 0.4"])
105
- s.add_dependency(%q<vcr>, ["~> 1.10.0"])
106
- s.add_dependency(%q<webmock>, ["~> 1.6.0"])
117
+ s.add_dependency(%q<vcr>, ["~> 1.11.3"])
118
+ s.add_dependency(%q<webmock>, ["~> 1.7.4"])
119
+ s.add_dependency(%q<ruby-debug19>, [">= 0"])
107
120
  end
108
121
  else
109
- s.add_dependency(%q<faraday>, ["~> 0.6"])
110
- s.add_dependency(%q<faraday_middleware>, ["~> 0.6"])
111
- s.add_dependency(%q<hashie>, ["~> 1.0.0"])
112
- s.add_dependency(%q<multi_json>, ["~> 1.0.0"])
113
- s.add_dependency(%q<chronic>, ["~> 0.4.0"])
114
- s.add_dependency(%q<rspec>, ["~> 2.6.0"])
122
+ s.add_dependency(%q<faraday>, ["~> 0.7.4"])
123
+ s.add_dependency(%q<faraday_middleware>, ["~> 0.7.0"])
124
+ s.add_dependency(%q<hashie>, ["~> 1.2.0"])
125
+ s.add_dependency(%q<multi_json>, ["~> 1.0.3"])
126
+ s.add_dependency(%q<chronic>, ["~> 0.6.4"])
127
+ s.add_dependency(%q<rspec>, ["~> 2.7"])
115
128
  s.add_dependency(%q<yard>, ["~> 0.7.0"])
116
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
117
- s.add_dependency(%q<jeweler>, ["~> 1.6.2"])
129
+ s.add_dependency(%q<bundler>, ["~> 1.0.7"])
130
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
118
131
  s.add_dependency(%q<simplecov>, ["~> 0.4"])
119
- s.add_dependency(%q<vcr>, ["~> 1.10.0"])
120
- s.add_dependency(%q<webmock>, ["~> 1.6.0"])
132
+ s.add_dependency(%q<vcr>, ["~> 1.11.3"])
133
+ s.add_dependency(%q<webmock>, ["~> 1.7.4"])
134
+ s.add_dependency(%q<ruby-debug19>, [">= 0"])
121
135
  end
122
136
  end
123
137
 
@@ -13,7 +13,6 @@ module Faraday
13
13
  @app.call(env)
14
14
  end
15
15
 
16
-
17
16
  end
18
17
  end
19
18
 
@@ -2,8 +2,11 @@ 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/calculate'
6
+ require 'genability/client/echo'
5
7
  require 'genability/client/load_serving_entity'
6
8
  require 'genability/client/price'
9
+ require 'genability/client/property'
7
10
  require 'genability/client/season'
8
11
  require 'genability/client/tariff'
9
12
  require 'genability/client/territory'
@@ -12,8 +15,11 @@ module Genability
12
15
 
13
16
  include Genability::Client::Helpers
14
17
 
18
+ include Genability::Client::Calculate
19
+ include Genability::Client::Echo
15
20
  include Genability::Client::LoadServingEntity
16
21
  include Genability::Client::Price
22
+ include Genability::Client::Property
17
23
  include Genability::Client::Season
18
24
  include Genability::Client::Tariff
19
25
  include Genability::Client::Territory
@@ -0,0 +1,97 @@
1
+ module Genability
2
+ class Client
3
+ # The Calculate service basically calculates the cost of electricity for a
4
+ # given rate/pricing plan. This can be used to calculate a bill, "what-if"
5
+ # different rates, levels of usage, energy efficiency measures or any other
6
+ # electrical activity. It gives a total cost for a period of time. (Note
7
+ # that if you want a price/rate for a specific point in time, then look at
8
+ # the Price service.)
9
+ module Calculate
10
+
11
+ # @overload calculate_metadata(tariff_id, from_date_time, to_date_time, options = {})
12
+ # Calling the URL as a HTTP GET will return the "inputs" required to accurately
13
+ # calculate the cost for a given period. It essentially gives you the meta-data
14
+ # for what to pass into the calculate method, and as such provides a template
15
+ # for the payload of the HTTP POST.
16
+ # @param tariff_id [Integer] Unique Genability ID (primary key) for a tariff.
17
+ # @param from_date_time [DateTime, String] Starting date and time for this Calculate request.
18
+ # In ISO 8601 format. Will attempt to use the Chronic gem to parse if a string is used.
19
+ # @param to_date_time [DateTime, String] End date and time for this Calculate request.
20
+ # In ISO 8601 format. Will attempt to use the Chronic gem to parse if a string is used.
21
+ # @param options [Hash] A customizable set of options.
22
+ # @option options [Integer] :territory_id The territory ID of where the usage consumption occurred. (Required for most CA tariffs.)
23
+ # @return [Array] Array of TariffInput for consumption.
24
+ # @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")
26
+ # @format :json
27
+ # @authenticated true
28
+ # @rate_limited true
29
+ # @see https://developer.genability.com/documentation/api-reference/pricing/calculate
30
+ def calculate_metadata(tariff_id, from, to, options = {})
31
+ get("beta/calculate/#{tariff_id}", calculate_meta_params(from, to, options)).results
32
+ end
33
+
34
+ # Calculate the cost of electricity for a given rate/pricing plan.
35
+ # @overload calculate(tariff_id, from_date_time, to_date_time, tariff_inputs, options = {})
36
+ # @see https://developer.genability.com/documentation/api-reference/pricing/calculate
37
+ def calculate(tariff_id, from, to, tariff_inputs, options = {})
38
+ post( "beta/calculate/#{tariff_id}",
39
+ calculate_params(from, to, tariff_inputs, options)
40
+ ).results.first
41
+ end
42
+
43
+ private
44
+
45
+ def calculate_params(from, to, tariff_inputs, options)
46
+ {
47
+ "fromDateTime" => format_to_iso8601(from),
48
+ "toDateTime" => format_to_iso8601(to),
49
+ "territoryId" => options[:territory_id],
50
+ "detailLevel" => options[:detail_level],
51
+ "tariffInputs" => tariff_input_params(tariff_inputs)
52
+ }.
53
+ delete_if{ |k,v| v.nil? }.
54
+ merge({ "appId" => application_id,
55
+ "appKey" => application_key }).
56
+ to_json
57
+ end
58
+
59
+ def tariff_input_params(tariff_inputs)
60
+ [].tap do |a|
61
+ case tariff_inputs
62
+ when Hash
63
+ a << convert_tariff_input_params(tariff_inputs)
64
+ when Array
65
+ tariff_inputs.each do |ti|
66
+ a << convert_tariff_input_params(ti)
67
+ end
68
+ else
69
+ raise Genability::InvalidTariffInput
70
+ end
71
+ end
72
+ end
73
+
74
+ def convert_tariff_input_params(tariff_input)
75
+ return tariff_input.to_hash if tariff_input.is_a? Hashie::Mash
76
+ {
77
+ "keyName" => tariff_input[:key_name],
78
+ "fromDateTime" => tariff_input[:from],
79
+ "toDateTime" => tariff_input[:to],
80
+ "unit" => tariff_input[:unit]
81
+ }
82
+ end
83
+
84
+ def calculate_meta_params(from, to, options)
85
+ {
86
+ "fromDateTime" => format_to_iso8601(from),
87
+ "toDateTime" => format_to_iso8601(to),
88
+ "territoryId" => options[:territory_id],
89
+ "connectionType" => options[:connection_type],
90
+ "cityLimits" => options[:city_limits]
91
+ }.delete_if{ |k,v| v.nil? }
92
+ end
93
+
94
+ end
95
+ end
96
+ end
97
+
@@ -0,0 +1,21 @@
1
+ module Genability
2
+ class Client
3
+
4
+ module Echo
5
+
6
+ def credentials_valid?
7
+ get("echo").status == "success"
8
+ end
9
+
10
+ # def validate_date(date)
11
+ # get("echo/validatedate", {"dateToValidate" => date}).results.first
12
+ # end
13
+
14
+ def raise_error(error_code)
15
+ get("echo/errors/#{error_code}")
16
+ end
17
+
18
+ end
19
+ end
20
+ end
21
+
@@ -1,3 +1,4 @@
1
+ require 'json'
1
2
  require 'time'
2
3
  require 'chronic'
3
4
 
@@ -20,7 +21,7 @@ module Genability
20
21
  "true"
21
22
  end
22
23
 
23
- def multi_option_handler(value)
24
+ def multi_option_handler(value = nil)
24
25
  return nil if value.nil?
25
26
  if value.is_a?(Array)
26
27
  value.collect{|x| x.upcase}.join(',')
@@ -17,9 +17,9 @@ module Genability
17
17
  # @authenticated true
18
18
  # @rate_limited true
19
19
  # @param options [Hash] A customizable set of options.
20
+ # @option options [String] :search_string Phrase for searching the names of Load Serving Entities (Optional)
20
21
  # @option options [String] :starts_with Indicates the search phrase should match the start of the name. (Optional)
21
22
  # @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
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
24
  # @option options [Integer] :per_page The number of results to return. If not specified, this will return 25 results. (Optional)
25
25
  # @return [Array] List of load serving entities.
@@ -30,16 +30,14 @@ module Genability
30
30
  # Genability.load_serving_entities(:page => 2)
31
31
  # @example Return only 10 load serving entities
32
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
33
  # @example Search for load serving entities starting with the letters 'Ka'
36
34
  # Genability.load_serving_entities(:starts_with => 'Ka')
37
35
  # @example Search for load serving entities ending with the word 'Inc'
38
36
  # 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')
37
+ # @example Search for load serving entities with the word 'Energy'
38
+ # Genability.load_serving_entities(:search_string => 'Energy')
41
39
  def load_serving_entities(options={})
42
- get("lses", lses_params(options)).results
40
+ get("public/lses", lses_params(options)).results
43
41
  end
44
42
 
45
43
  alias :lses :load_serving_entities
@@ -55,7 +53,7 @@ module Genability
55
53
  # @example Return the details for Georgia Power Co
56
54
  # Genability.load_serving_entity(2756)
57
55
  def load_serving_entity(load_serving_entity_id)
58
- get("lses/#{load_serving_entity_id}").results.first
56
+ get("public/lses/#{load_serving_entity_id}").results.first
59
57
  end
60
58
 
61
59
  alias :lse :load_serving_entity
@@ -64,13 +62,16 @@ module Genability
64
62
 
65
63
  def lses_params(options)
66
64
  {
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])
65
+ 'searchString' => search_string(options),
66
+ 'startsWith' => convert_to_boolean(options[:starts_with]),
67
+ 'endsWith' => convert_to_boolean(options[:ends_with])
71
68
  }.delete_if{ |k,v| v.nil? }.merge( pagination_params(options) )
72
69
  end
73
70
 
71
+ def search_string(options)
72
+ options[:search_string] || options[:contains] || options[:starts_with] || options[:ends_with]
73
+ end
74
+
74
75
  end
75
76
  end
76
77
  end