Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from arvel/master
Adds PortfolioManager::REST::Customer module
- Loading branch information
Showing
4 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |