portfolio_manager 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile +3 -1
- data/README.md +13 -0
- data/Rakefile +5 -3
- data/bin/console +4 -3
- data/lib/portfolio_manager/rest/account.rb +2 -0
- data/lib/portfolio_manager/rest/api.rb +2 -0
- data/lib/portfolio_manager/rest/building.rb +2 -0
- data/lib/portfolio_manager/rest/client.rb +2 -0
- data/lib/portfolio_manager/rest/connection.rb +8 -6
- data/lib/portfolio_manager/rest/customer.rb +3 -1
- data/lib/portfolio_manager/rest/data_exchange_settings.rb +2 -0
- data/lib/portfolio_manager/rest/meter.rb +2 -0
- data/lib/portfolio_manager/rest/property.rb +2 -0
- data/lib/portfolio_manager/rest/request.rb +27 -16
- data/lib/portfolio_manager/rest/share.rb +8 -6
- data/lib/portfolio_manager/rest/utils.rb +6 -3
- data/lib/portfolio_manager/version.rb +3 -1
- data/lib/portfolio_manager.rb +2 -0
- data/portfolio_manager.gemspec +9 -7
- metadata +29 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 177b5b07384c5f9c24b5cb9ef69cb1517af02f1f76d9af1cc74eab9654dfe477
|
4
|
+
data.tar.gz: 87ae59aa73df92530ae4c6ea1feb139a4e8b964c6a6ca3ad39fc6249cf3acd9f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a85026346412c4a627b41518f0b7967e113f7f6679738ff153e8953b3a1c5da587f499c4a5b635d867121d0f0fffc6e0fe9bcbdcf6f5700caf184234da16381d
|
7
|
+
data.tar.gz: 4ccfa27318accc589869fe8676f749c64a8a59e02f29cf02cb7a5f5e77622c3decb5faf4d3b14721ded9013481a7003a44e2afa49204fdcf96da17f263b66634
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -40,6 +40,8 @@ HTTP | Path | Method | Description
|
|
40
40
|
GET | /account | `account` | Returns general information for your account.
|
41
41
|
GET | /dataExchangeSettings | `data_exchange_settings` | Returns the settings that define your data exchange service offerings.
|
42
42
|
GET | /dataExchangeSettings/customField/list | `data_exchange_custom_field_list` | Returns a list of custom fields that you have defined for your account.
|
43
|
+
GET | /customer/list | `customer_list` | Returns a list of customers that you are connected to.
|
44
|
+
GET | /customer/(customerId) | `customer(customer_id)` | Returns general account information for a specific customer that you are connected to.
|
43
45
|
|
44
46
|
#### Property Services
|
45
47
|
http://portfoliomanager.energystar.gov/webservices/home/api/property
|
@@ -66,6 +68,17 @@ GET | /meter/(meterId) | `meter(meter_id)` | Returns information for a specifie
|
|
66
68
|
GET | /property/(propertyId)/meter/list | `meter_list(property_id)` | Returns a list of meters for a specified property.
|
67
69
|
GET | /meter/(meterId)/consumptionData?page=(page)&startDate=(YYYY-MM-DD)&endDate=(YYYY-MM-DD) | `metrics(property_id, year, month, measurement_system, metric)` | Returns the consumption data for a specified meter in sets of 20.
|
68
70
|
|
71
|
+
#### Connection/Share Services
|
72
|
+
https://portfoliomanager.energystar.gov/webservices/home/api/connection
|
73
|
+
|
74
|
+
HTTP | Path | Method | Description
|
75
|
+
---- | ---- | ------ | -----------
|
76
|
+
GET | /connect/account/pending/list | `pending_connections(link = nil)` | Returns a list of customer connection requests that are pending.
|
77
|
+
POST | /connect/account/(accountId) | `connection_request(customer_id, accept = true)` | Accepts/rejects a pending connection request from a specific customer.
|
78
|
+
GET | /share/property/pending/list | `pending_property_shares(link = nil)` | Returns a list of property share requests that are pending. These property share requests belong to customers that you are already connected to.
|
79
|
+
POST | /share/property/(propertyId) | `property_share_request(property_id, accept = true)` | Accepts/rejects a pending share request for a specific property.
|
80
|
+
GET | /share/meter/pending/list | `pending_meter_shares(link = nil)` | Returns a list of meter share requests that are pending. These meter share requests belong to customers that you are already connected to.
|
81
|
+
POST | /share/meter/(meterId) | `meter_share_request(meter_id, accept = true)` | Accepts/rejects a pending share request for a specific meter.
|
69
82
|
|
70
83
|
## Contributing
|
71
84
|
|
data/Rakefile
CHANGED
data/bin/console
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
|
-
require
|
4
|
-
require
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'portfolio_manager'
|
5
6
|
|
6
7
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
8
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -10,5 +11,5 @@ require "portfolio_manager"
|
|
10
11
|
# require "pry"
|
11
12
|
# Pry.start
|
12
13
|
|
13
|
-
require
|
14
|
+
require 'irb'
|
14
15
|
IRB.start
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'portfolio_manager/rest/utils'
|
2
4
|
|
3
5
|
module PortfolioManager
|
@@ -7,9 +9,9 @@ module PortfolioManager
|
|
7
9
|
# @see https://portfoliomanager.energystar.gov/webservices/home/api/connection
|
8
10
|
module Connection
|
9
11
|
include PortfolioManager::REST::Utils
|
10
|
-
REJECT_NOTE = 'Unfortunately we cannot provide services for you at this time.'
|
11
|
-
ACCEPT_NOTE = 'Your connection request has been verified and accepted.'
|
12
|
-
|
12
|
+
REJECT_NOTE = 'Unfortunately we cannot provide services for you at this time.'
|
13
|
+
ACCEPT_NOTE = 'Your connection request has been verified and accepted.'
|
14
|
+
|
13
15
|
##
|
14
16
|
# This web service returns a list of pending customer connection requests.
|
15
17
|
# A connection to the customer must be established first before any properties and meters can be shared with you.
|
@@ -27,9 +29,9 @@ module PortfolioManager
|
|
27
29
|
# @see https://portfoliomanager.energystar.gov/webservices/home/api/connection/connect/post
|
28
30
|
def connection_request(customer_id, accept = true)
|
29
31
|
perform_post_request(
|
30
|
-
|
31
|
-
|
32
|
-
|
32
|
+
"/connect/account/#{customer_id}",
|
33
|
+
body: connection_response_body(accept)
|
34
|
+
)
|
33
35
|
end
|
34
36
|
|
35
37
|
private
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'portfolio_manager/rest/utils'
|
2
4
|
|
3
5
|
module PortfolioManager
|
@@ -13,7 +15,7 @@ module PortfolioManager
|
|
13
15
|
#
|
14
16
|
# @see https://portfoliomanager.energystar.gov/webservices/home/api/account/customerList/get
|
15
17
|
def customer_list
|
16
|
-
perform_get_request(
|
18
|
+
perform_get_request('/customer/list')
|
17
19
|
end
|
18
20
|
|
19
21
|
##
|
@@ -1,4 +1,7 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'faraday'
|
4
|
+
require 'faraday/xml'
|
2
5
|
require 'nori'
|
3
6
|
|
4
7
|
module PortfolioManager
|
@@ -13,6 +16,7 @@ module PortfolioManager
|
|
13
16
|
|
14
17
|
attr_reader :client, :path, :request_method, :parser
|
15
18
|
attr_accessor :options
|
19
|
+
|
16
20
|
##
|
17
21
|
# @param [PortfolioManager::Client] client
|
18
22
|
# @param [Symbol, String] request_method
|
@@ -23,7 +27,10 @@ module PortfolioManager
|
|
23
27
|
@path = api_environment + path
|
24
28
|
@options = options
|
25
29
|
@request_method = request_method
|
26
|
-
@conn =
|
30
|
+
@conn = Faraday.new(url: BASE_URL) do |conn|
|
31
|
+
conn.request :authorization, :basic, client.username, client.password
|
32
|
+
conn.request :xml
|
33
|
+
end
|
27
34
|
@parser = Nori.new
|
28
35
|
setup_client
|
29
36
|
end
|
@@ -43,34 +50,38 @@ module PortfolioManager
|
|
43
50
|
when :get
|
44
51
|
@conn.get(path).body
|
45
52
|
when :post
|
46
|
-
@conn.post(path, options[:body]
|
53
|
+
@conn.post(path, options[:body]).body
|
47
54
|
else
|
48
|
-
raise ArgumentError,
|
55
|
+
raise ArgumentError, "#{request_method} is not yet implemented"
|
49
56
|
end
|
50
57
|
end
|
51
58
|
|
52
59
|
def setup_client
|
53
60
|
set_header
|
54
61
|
set_query
|
55
|
-
set_basic_authentication
|
56
62
|
end
|
57
63
|
|
58
64
|
def set_header
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
65
|
+
headers = {
|
66
|
+
'User-Agent' => 'Ruby PortfolioManager API Client',
|
67
|
+
'Accept' => 'application/xml',
|
68
|
+
'Content-Type' => 'application/xml;charset=UTF-8'
|
69
|
+
}
|
70
|
+
|
71
|
+
options[:header]&.each do |key, value|
|
72
|
+
headers[key] = value
|
73
|
+
end
|
74
|
+
|
75
|
+
@conn.headers = headers
|
63
76
|
end
|
64
77
|
|
65
78
|
def set_query
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
79
|
+
params = {}
|
80
|
+
options[:query]&.each do |key, value|
|
81
|
+
params[key] = value
|
82
|
+
end
|
70
83
|
|
71
|
-
|
72
|
-
@conn.url.user = client.username
|
73
|
-
@conn.url.password = client.password
|
84
|
+
@conn.params = params
|
74
85
|
end
|
75
86
|
|
76
87
|
def api_environment
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'portfolio_manager/rest/utils'
|
2
4
|
|
3
5
|
module PortfolioManager
|
@@ -9,7 +11,7 @@ module PortfolioManager
|
|
9
11
|
include PortfolioManager::REST::Utils
|
10
12
|
|
11
13
|
##
|
12
|
-
# Returns a list of property or meter share requests that are pending.
|
14
|
+
# Returns a list of property or meter share requests that are pending.
|
13
15
|
# These property share requests belong to customers that you are already connected to.
|
14
16
|
# The list of pending property share requests is returned in sets of 20.
|
15
17
|
#
|
@@ -37,17 +39,17 @@ module PortfolioManager
|
|
37
39
|
end
|
38
40
|
|
39
41
|
private
|
40
|
-
|
42
|
+
|
41
43
|
def pending_shares(resource_name, link)
|
42
|
-
link ||= "/share/#{resource_name}/pending/list"
|
44
|
+
link ||= "/share/#{resource_name}/pending/list"
|
43
45
|
perform_get_request(link)
|
44
46
|
end
|
45
47
|
|
46
48
|
def share_request(resource_id, resource_name, accept = true)
|
47
49
|
perform_post_request(
|
48
|
-
|
49
|
-
|
50
|
-
|
50
|
+
"/share/#{resource_name}/#{resource_id}",
|
51
|
+
body: share_response_body(accept, resource_name)
|
52
|
+
)
|
51
53
|
end
|
52
54
|
|
53
55
|
def share_response_body(accept, resource_name)
|
@@ -1,4 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'portfolio_manager/rest/request'
|
4
|
+
require 'nokogiri'
|
2
5
|
|
3
6
|
module PortfolioManager
|
4
7
|
module REST
|
@@ -35,11 +38,11 @@ module PortfolioManager
|
|
35
38
|
end
|
36
39
|
|
37
40
|
def request_response_xml(action, note)
|
38
|
-
|
39
|
-
xml.sharingResponse
|
41
|
+
Nokogiri::XML::Builder.new do |xml|
|
42
|
+
xml.sharingResponse do
|
40
43
|
xml.action action
|
41
44
|
xml.note note
|
42
|
-
|
45
|
+
end
|
43
46
|
end.to_xml
|
44
47
|
end
|
45
48
|
end
|
data/lib/portfolio_manager.rb
CHANGED
data/portfolio_manager.gemspec
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
5
|
require 'portfolio_manager/version'
|
5
6
|
|
@@ -9,8 +10,8 @@ Gem::Specification.new do |spec|
|
|
9
10
|
spec.authors = ['Jack Reed']
|
10
11
|
spec.email = ['phillipjreed@gmail.com']
|
11
12
|
|
12
|
-
spec.summary =
|
13
|
-
spec.description =
|
13
|
+
spec.summary = 'A Ruby client for the EnergyStar Portfolio Manager web services.'
|
14
|
+
spec.description = 'A Ruby client for the EnergyStar Portfolio Manager web services.'
|
14
15
|
spec.homepage = 'https://github.com/mejackreed/portfolio_manager'
|
15
16
|
spec.license = 'MIT'
|
16
17
|
|
@@ -19,11 +20,12 @@ Gem::Specification.new do |spec|
|
|
19
20
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
21
|
spec.require_paths = ['lib']
|
21
22
|
|
22
|
-
spec.add_dependency '
|
23
|
+
spec.add_dependency 'faraday'
|
24
|
+
spec.add_dependency 'faraday-xml'
|
23
25
|
spec.add_dependency 'nokogiri'
|
24
26
|
spec.add_dependency 'nori'
|
25
27
|
|
26
|
-
spec.add_development_dependency 'bundler'
|
27
|
-
spec.add_development_dependency 'rake'
|
28
|
+
spec.add_development_dependency 'bundler'
|
29
|
+
spec.add_development_dependency 'rake'
|
28
30
|
spec.add_development_dependency 'rspec'
|
29
31
|
end
|
metadata
CHANGED
@@ -1,17 +1,31 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: portfolio_manager
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jack Reed
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-03-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: faraday-xml
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
16
30
|
requirements:
|
17
31
|
- - ">="
|
@@ -56,30 +70,30 @@ dependencies:
|
|
56
70
|
name: bundler
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
|
-
- - "
|
73
|
+
- - ">="
|
60
74
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
75
|
+
version: '0'
|
62
76
|
type: :development
|
63
77
|
prerelease: false
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
65
79
|
requirements:
|
66
|
-
- - "
|
80
|
+
- - ">="
|
67
81
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
82
|
+
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: rake
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
72
86
|
requirements:
|
73
|
-
- - "
|
87
|
+
- - ">="
|
74
88
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
89
|
+
version: '0'
|
76
90
|
type: :development
|
77
91
|
prerelease: false
|
78
92
|
version_requirements: !ruby/object:Gem::Requirement
|
79
93
|
requirements:
|
80
|
-
- - "
|
94
|
+
- - ">="
|
81
95
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
96
|
+
version: '0'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: rspec
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -129,7 +143,7 @@ homepage: https://github.com/mejackreed/portfolio_manager
|
|
129
143
|
licenses:
|
130
144
|
- MIT
|
131
145
|
metadata: {}
|
132
|
-
post_install_message:
|
146
|
+
post_install_message:
|
133
147
|
rdoc_options: []
|
134
148
|
require_paths:
|
135
149
|
- lib
|
@@ -144,9 +158,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
144
158
|
- !ruby/object:Gem::Version
|
145
159
|
version: '0'
|
146
160
|
requirements: []
|
147
|
-
|
148
|
-
|
149
|
-
signing_key:
|
161
|
+
rubygems_version: 3.4.6
|
162
|
+
signing_key:
|
150
163
|
specification_version: 4
|
151
164
|
summary: A Ruby client for the EnergyStar Portfolio Manager web services.
|
152
165
|
test_files: []
|