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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: d1af332f66597bbac4ea7ef5e86f9e8218ad5347
4
- data.tar.gz: '00294142f3d3f47e8c275357c8392ac8e79e6b9d'
2
+ SHA256:
3
+ metadata.gz: 177b5b07384c5f9c24b5cb9ef69cb1517af02f1f76d9af1cc74eab9654dfe477
4
+ data.tar.gz: 87ae59aa73df92530ae4c6ea1feb139a4e8b964c6a6ca3ad39fc6249cf3acd9f
5
5
  SHA512:
6
- metadata.gz: c2054b5c323b280f07a373827b152f747f0de31e74f6e8c5e7523c46eee8a8d39c10dbfd031392db7b3f0b282f10e2025c4a7e8e15325931cd37f2718f90814a
7
- data.tar.gz: 9a963132c4eed65d85ab5de8790253165c48f907d9cb9b6a4630a2adee4a185c1f0c936f70b48b091ec69a6b036788258e1e11d64f7102d2663de048710d01b7
6
+ metadata.gz: a85026346412c4a627b41518f0b7967e113f7f6679738ff153e8953b3a1c5da587f499c4a5b635d867121d0f0fffc6e0fe9bcbdcf6f5700caf184234da16381d
7
+ data.tar.gz: 4ccfa27318accc589869fe8676f749c64a8a59e02f29cf02cb7a5f5e77622c3decb5faf4d3b14721ded9013481a7003a44e2afa49204fdcf96da17f263b66634
data/Gemfile CHANGED
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in portfolio_manager.gemspec
4
6
  gemspec
5
7
 
6
8
  group :test do
7
- gem 'webmock'
8
9
  gem 'coveralls', require: false
10
+ gem 'webmock'
9
11
  end
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
@@ -1,6 +1,8 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
3
5
 
4
6
  RSpec::Core::RakeTask.new(:spec)
5
7
 
6
- task :default => :spec
8
+ task default: :spec
data/bin/console CHANGED
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- require "bundler/setup"
4
- require "portfolio_manager"
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 "irb"
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
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'portfolio_manager/rest/account'
2
4
  require 'portfolio_manager/rest/building'
3
5
  require 'portfolio_manager/rest/data_exchange_settings'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'portfolio_manager/rest/utils'
2
4
 
3
5
  module PortfolioManager
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'portfolio_manager/rest/api'
2
4
  require 'portfolio_manager/rest/utils'
3
5
 
@@ -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.'.freeze
11
- ACCEPT_NOTE = 'Your connection request has been verified and accepted.'.freeze
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
- "/connect/account/#{customer_id}",
31
- body: connection_response_body(accept)
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("/customer/list")
18
+ perform_get_request('/customer/list')
17
19
  end
18
20
 
19
21
  ##
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'portfolio_manager/rest/utils'
2
4
 
3
5
  module PortfolioManager
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'portfolio_manager/rest/utils'
2
4
 
3
5
  module PortfolioManager
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'portfolio_manager/rest/utils'
2
4
 
3
5
  module PortfolioManager
@@ -1,4 +1,7 @@
1
- require 'hurley'
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 = Hurley::Client.new(BASE_URL)
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], CONTENT_TYPE).body
53
+ @conn.post(path, options[:body]).body
47
54
  else
48
- raise ArgumentError, '#{request_method} is not yet implemented'
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
- @conn.header[:user_agent] = 'Ruby PortfolioManager API Client'
60
- options[:header].each do |key, value|
61
- @conn.header[key] = value
62
- end unless options[:header].nil?
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
- options[:query].each do |key, value|
67
- @conn.query[key] = value
68
- end unless options[:query].nil?
69
- end
79
+ params = {}
80
+ options[:query]&.each do |key, value|
81
+ params[key] = value
82
+ end
70
83
 
71
- def set_basic_authentication
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
- "/share/#{resource_name}/#{resource_id}",
49
- body: share_response_body(accept, resource_name)
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
- builder = Nokogiri::XML::Builder.new do |xml|
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
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module PortfolioManager
2
- VERSION = '0.3.0'
4
+ VERSION = '0.4.0'
3
5
  end
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'portfolio_manager/rest/client'
2
4
  require 'portfolio_manager/version'
@@ -1,5 +1,6 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
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 = %q{A Ruby client for the EnergyStar Portfolio Manager web services.}
13
- spec.description = %q{A Ruby client for the EnergyStar Portfolio Manager web services.}
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 'hurley'
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', '~> 1.10'
27
- spec.add_development_dependency 'rake', '~> 10.0'
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.3.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: 2017-08-17 00:00:00.000000000 Z
11
+ date: 2023-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: hurley
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: '1.10'
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: '1.10'
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: '10.0'
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: '10.0'
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
- rubyforge_project:
148
- rubygems_version: 2.5.2
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: []