Name: genability
Owner: mobomo
Description: Ruby client for the Genability API
Forked from: ewiener/genability
Created: 2017-09-01 17:28:53.0
Updated: 2017-09-01 17:28:54.0
Pushed: 2017-09-28 18:11:56.0
Homepage: http://www.genability.com
Size: 440
Language: Ruby
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
A Ruby wrapper for the Genability power pricing and related APIs - learn more at https://developer.genability.com
gem install genability
http://rdoc.info/gems/genability
require "genability"
# Configure during client initialization
client = Genability::Client.new(:application_id = 'ValidAppId', :application_key => 'ValidAppKey')
# Or use the block configuration method
# Useful for using in a Rails initializer
# register an app at https://developer.genability.com
Genability.configure do |config|
config.application_id = 'ValidAppId'
config.application_key = 'ValidAppKey'
end
# Advanced Configuration Options
Genability.configure do |config|
config.application_id = 'ValidAppId'
config.application_key = 'ValidAppKey'
config.adapter = :typhoeus
config.endpoint = "http://api.genability.com/rest/"
config.format = :json
config.user_agent = "Genability API Ruby Gem"
config.proxy = "http://127.0.0.1"
end
# Get a list of load serving entities
Genability.load_serving_entities
# Get one load serving entity
Genability.load_serving_entity(2756)
# Get a list of tariffs
Genability.tariffs
# Get one tariff
Genability.tariff(512)
# Get the prices for a specified tariff
Genability.prices(520)
# Get the territories for a load serving entity
Genability.territories(:lse_id => 734)
# Get the details of one territory
Genability.territory(3539)
# Get a list of seasons for a load serving entity
Genability.seasons(734)
# Get a particular time of use group for a given load serving entity
Genability.time_of_uses(2756, 1)
# Get the intervals for the particular time of use group of a given load serving entity
Genability.time_of_use_intervals(734, 1)
# Get information about a zipcode
Genability.zipcode('48322')
# Add an account
Genability.add_account(:account_name => 'New Account')
# Show account
Genability.account("account_id")
# Get a list of accounts
Genability.accounts
# Delete account
Genability.delete_account("account_id")
# Add a usage profile
Genability.add_usage_profile(:account_id => "account_id")
# Show a usage profile
Genability.usage_profile("usage_profile_id")
# List usage profile
Genability.usage_profiles
# Add a reading(s) to a usage profile
Genability.add_readings("usage_profile_id", :readings =>
[
{
:from => "2011-08-01T22:30:00.000-0700",
:to => "2011-08-01T22:45:00.000-0700",
:quantity_unit => "kWh",
:quantity_value => 220
}
]
)
# Calculate the cost of electricity for a given rate plan
#
# First, get the caculation metadata necessary to run the calculation
metadata = Genability.calculate_metadata(
512, # Master Tariff ID
"Monday, September 1st, 2011", # From DateTime
"Monday, September 10th, 2011", # To DateTime
:additional_values => { # Metadata Options
"connectionType" => "Primary Connection",
"cityLimits" => "Inside"
}
)
# Then, run the calculation with the metadata you just received
result = Genability.calculate(
512, # Master Tariff ID
"Monday, September 1st, 2011", # From DateTime
"Monday, September 10th, 2011", # To DateTime
metadata, # Metadata from previous call
{} # Additional options
)
result.total_cost # => 10.837
Please see the documentation for available options and the tests for additional examples
Copyright (c) 2011 Matthew Solt. See LICENSE for details.