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 #2 from mejackreed/add-more
Add more REST services
- Loading branch information
Showing
18 changed files
with
300 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,5 @@ gemspec | |
|
||
group :test do | ||
gem 'webmock' | ||
gem 'nokogiri' | ||
gem 'coveralls', require: false | ||
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
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,31 @@ | ||
require 'portfolio_manager/rest/utils' | ||
|
||
module PortfolioManager | ||
module REST | ||
## | ||
# Building services | ||
# @see http://portfoliomanager.energystar.gov/webservices/home/api/building | ||
module Building | ||
include PortfolioManager::REST::Utils | ||
|
||
## | ||
# This web service retrieves information for a specific building. The | ||
# building must already be shared with you. | ||
# | ||
# @see http://portfoliomanager.energystar.gov/webservices/home/api/building/building/get | ||
# @param [String, Integer] building_id | ||
def building(building_id) | ||
perform_get_request("/building/#{building_id}") | ||
end | ||
|
||
## | ||
# This web service returns a list of buildings for a specific property | ||
# that is shared with you. | ||
# | ||
# @see http://portfoliomanager.energystar.gov/webservices/home/api/building/buildingList/get | ||
def building_list(property_id) | ||
perform_get_request("/property/#{property_id}/building/list") | ||
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,43 @@ | ||
require 'portfolio_manager/rest/utils' | ||
|
||
module PortfolioManager | ||
module REST | ||
## | ||
# Meter services | ||
# @see http://portfoliomanager.energystar.gov/webservices/home/api/meter | ||
module Meter | ||
include PortfolioManager::REST::Utils | ||
|
||
## | ||
# This web service retrieves information for a specific meter. The meter | ||
# must already be shared with you. | ||
# | ||
# @see http://portfoliomanager.energystar.gov/webservices/home/api/meter/meter/get | ||
# @param [String, Integer] meter_id | ||
def meter(meter_id) | ||
perform_get_request("/meter/#{meter_id}") | ||
end | ||
|
||
## | ||
# This web service retrieves a list of all the meters for a specific | ||
# property. The property must already be shared with you. | ||
# | ||
# @see http://portfoliomanager.energystar.gov/webservices/home/api/meter/meterList/get | ||
def meter_list(property_id) | ||
perform_get_request("/property/#{property_id}/meter/list") | ||
end | ||
|
||
def metrics(property_id, year, month, measurement_system, metric) | ||
perform_get_request( | ||
"/property/#{property_id}/metrics", | ||
query: { | ||
year: year, month: month, measurementSystem: measurement_system | ||
}, | ||
header: { | ||
'PM-Metrics' => metric | ||
} | ||
) | ||
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,32 @@ | ||
require 'portfolio_manager/rest/utils' | ||
|
||
module PortfolioManager | ||
module REST | ||
## | ||
# Property services | ||
# @see http://portfoliomanager.energystar.gov/webservices/home/api/property | ||
module Property | ||
include PortfolioManager::REST::Utils | ||
|
||
## | ||
# This web service returns a list of properties for a specific customer | ||
# that are shared with you. | ||
# | ||
# @see http://portfoliomanager.energystar.gov/webservices/home/api/property/propertyList/get | ||
# @param [String, Integer] account_id | ||
def property_list(account_id) | ||
perform_get_request("/account/#{account_id}/property/list") | ||
end | ||
|
||
## | ||
# This web service retrieves information for a specific property. The | ||
# property must already be shared with you. This service can also be used | ||
# for to retrieve information on a building. | ||
# | ||
# @see http://portfoliomanager.energystar.gov/webservices/home/api/property/property/get | ||
def property(property_id) | ||
perform_get_request("/property/#{property_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
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,24 @@ | ||
<building> | ||
<name>8041- Richmond Road - Score 58</name> | ||
<address address1="5300 Richmond Road" city="Bedford Heights" postalCode="44146" state="OH" country="US"/> | ||
<constructionStatus>Existing</constructionStatus> | ||
<primaryFunction>Refrigerated Warehouse</primaryFunction> | ||
<yearBuilt>1992</yearBuilt> | ||
<grossFloorArea units="Square Feet" temporary="false"> | ||
<value>856655</value> | ||
</grossFloorArea> | ||
<occupancyPercentage>10</occupancyPercentage> | ||
<isFederalProperty>true</isFederalProperty> | ||
<agency name="Advisory Council on Historic Preservation (ACHP)" code="ACHP" id="1" country="US"/> | ||
<agencyDepartmentRegion>region update</agencyDepartmentRegion> | ||
<federalCampus>campus update</federalCampus> | ||
<notes>Notes update</notes> | ||
<audit> | ||
<createdBy>DUNAYT</createdBy> | ||
<createdByAccountId>-14</createdByAccountId> | ||
<createdDate>2012-08-16T17:04:57-04:00</createdDate> | ||
<lastUpdatedBy>DUNAYT</lastUpdatedBy> | ||
<lastUpdatedByAccountId>-14</lastUpdatedByAccountId> | ||
<lastUpdatedDate>2012-08-16T17:09:35-04:00</lastUpdatedDate> | ||
</audit> | ||
</building> |
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,7 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<response status="Ok"> | ||
<links> | ||
<link httpMethod="GET" link="/building/86" linkDescription="This is the GET url for this Building." hint="ACME Convenience Store"/> | ||
<link httpMethod="GET" link="/building/34" linkDescription="This is the GET url for this Building." hint="ACME Grocery"/> | ||
</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,18 @@ | ||
<meter> | ||
<id>543</id> | ||
<type>Electric</type> | ||
<name>Electric Main Meter</name> | ||
<unitOfMeasure>kBtu (thousand Btu)</unitOfMeasure> | ||
<metered>true</metered> | ||
<firstBillDate>2010-01-01</firstBillDate> | ||
<inUse>true</inUse> | ||
<accessLevel>Read</accessLevel> | ||
<audit> | ||
<createdBy>DUNAYT</createdBy> | ||
<createdByAccountId>-14</createdByAccountId> | ||
<createdDate>2012-08-16T17:04:57-04:00</createdDate> | ||
<lastUpdatedBy>DUNAYT</lastUpdatedBy> | ||
<lastUpdatedByAccountId>-14</lastUpdatedByAccountId> | ||
<lastUpdatedDate>2012-08-16T17:09:35-04:00</lastUpdatedDate> | ||
</audit> | ||
</meter> |
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,6 @@ | ||
<response status="Ok"> | ||
<links> | ||
<link httpMethod="GET" link="/meter/41" linkDescription="This is the GET url for this Meter." hint="Electric Main Meter"/> | ||
<link httpMethod="GET" link="/meter/23" linkDescription="This is the GET url for this Meter." hint="Water Main Meter"/> | ||
</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,6 @@ | ||
<response status="Ok"> | ||
<links> | ||
<link id="86" httpMethod="GET" link="/building/86" linkDescription="This is the GET url for this Building." hint="ACME Convenience Store"/> | ||
<link id="34" httpMethod="GET" link="/building/34" linkDescription="This is the GET url for this Building." hint="ACME Grocery"/> | ||
</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
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 'spec_helper' | ||
|
||
describe PortfolioManager::REST::Building do | ||
let(:client) { test_client } | ||
describe '#building_list' do | ||
let(:id) { 680_01 } | ||
before do | ||
stub_get("/property/#{id}/building/list") | ||
.to_return(body: fixture('building_list.xml')) | ||
end | ||
it 'returns a list of buidings' do | ||
client.building_list(id)['response']['links']['link'].each do |link| | ||
expect(link).to include '@link' | ||
end | ||
end | ||
end | ||
describe '#building' do | ||
let(:id) { 680_01 } | ||
before do | ||
stub_get("/building/#{id}") | ||
.to_return(body: fixture('building.xml')) | ||
end | ||
it 'returns a building' do | ||
expect(client.building(id)['building']) | ||
.to include 'name', 'address', 'constructionStatus', 'yearBuilt', 'grossFloorArea', 'occupancyPercentage' | ||
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
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 'spec_helper' | ||
|
||
describe PortfolioManager::REST::Meter do | ||
let(:client) { test_client } | ||
describe '#meter' do | ||
let(:id) { 543 } | ||
before do | ||
stub_get("/meter/#{id}") | ||
.to_return(body: fixture('meter.xml')) | ||
end | ||
it 'returns a meter' do | ||
expect(client.meter(id)['meter']) | ||
.to include 'id', 'type', 'name', 'unitOfMeasure', 'metered', 'firstBillDate' | ||
end | ||
end | ||
describe '#meter_list' do | ||
let(:id) { 680_01 } | ||
before do | ||
stub_get("/property/#{id}/meter/list") | ||
.to_return(body: fixture('meter_list.xml')) | ||
end | ||
it 'returns a list of meters' do | ||
client.meter_list(id)['response']['links']['link'].each do |link| | ||
expect(link).to include '@link' | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.