diff --git a/lib/portfolio_manager/rest/api.rb b/lib/portfolio_manager/rest/api.rb index 4f3d7c9..f8508ee 100644 --- a/lib/portfolio_manager/rest/api.rb +++ b/lib/portfolio_manager/rest/api.rb @@ -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 @@ -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 diff --git a/lib/portfolio_manager/rest/customer.rb b/lib/portfolio_manager/rest/customer.rb new file mode 100644 index 0000000..ff28bc6 --- /dev/null +++ b/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 diff --git a/spec/fixtures/customer_list.xml b/spec/fixtures/customer_list.xml new file mode 100644 index 0000000..17348ba --- /dev/null +++ b/spec/fixtures/customer_list.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/spec/lib/portfolio_manager/rest/customer_spec.rb b/spec/lib/portfolio_manager/rest/customer_spec.rb new file mode 100644 index 0000000..1715266 --- /dev/null +++ b/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