Skip to content

Commit

Permalink
Merge pull request #3 from arvel/master
Browse files Browse the repository at this point in the history
Adds PortfolioManager::REST::Customer module
  • Loading branch information
mejackreed committed May 30, 2017
2 parents 7dcfe98 + a7320c5 commit 8a9b500
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/portfolio_manager/rest/api.rb
Expand Up @@ -3,6 +3,7 @@
require 'portfolio_manager/rest/data_exchange_settings'
require 'portfolio_manager/rest/meter'
require 'portfolio_manager/rest/property'
require 'portfolio_manager/rest/customer'

module PortfolioManager
module REST
Expand All @@ -15,6 +16,7 @@ module API
include PortfolioManager::REST::DataExchangeSettings
include PortfolioManager::REST::Meter
include PortfolioManager::REST::Property
include PortfolioManager::REST::Customer
end
end
end
28 changes: 28 additions & 0 deletions lib/portfolio_manager/rest/customer.rb
@@ -0,0 +1,28 @@
require 'portfolio_manager/rest/utils'

module PortfolioManager
module REST
##
# Customer services
# @see https://portfoliomanager.energystar.gov/webservices/home/api/account
module Customer
include PortfolioManager::REST::Utils

##
# Returns a list of customers that you are connected to.
#
# @see https://portfoliomanager.energystar.gov/webservices/home/api/account/customerList/get
def customer_list
perform_get_request("/customer/list")
end

##
# Returns general account information for a specific customer that you are connected to.
#
# https://portfoliomanager.energystar.gov/webservices/home/api/account/customer/get
def customer(customer_id)
perform_get_request("/cutomer/#{customer_id}")
end
end
end
end
9 changes: 9 additions & 0 deletions spec/fixtures/customer_list.xml
@@ -0,0 +1,9 @@
<response status="Ok">
<links>
<link id="143" hint="QWERTY Company" httpMethod="GET" link="/customer/143" linkDescription="This is the GET url for this Customer."/>
<link id="5432" hint="Galaxy Corp" httpMethod="GET" link="/customer/5432" linkDescription="This is the GET url for this Customer."/>
<link id="5553" hint="Thrift Bank" httpMethod="GET" link="/customer/5553" linkDescription="This is the GET url for this Customer."/>
<link id="1454" httpMethod="GET" link="/customer/1454" linkDescription="This is the GET url for this Customer."/>
<link id="86785" hint="Sample Company" httpMethod="GET" link="/customer/86785" linkDescription="This is the GET url for this Customer."/>
</links>
</response>
16 changes: 16 additions & 0 deletions spec/lib/portfolio_manager/rest/customer_spec.rb
@@ -0,0 +1,16 @@
require 'spec_helper'

describe PortfolioManager::REST::Customer do
let(:client) { test_client }
describe '#customer_list' do
before do
stub_get("/customer/list")
.to_return(body: fixture('customer_list.xml'))
end
it 'returns a list of customers' do
client.customer_list['response']['links']['link'].each do |link|
expect(link).to include '@id', '@link'
end
end
end
end

0 comments on commit 8a9b500

Please sign in to comment.