portfoliomanager-rb 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,30 @@
1
+ module PortfolioManager
2
+ module Services
3
+ # All Services
4
+ module All
5
+ # Live Environment
6
+ module Live
7
+ include PortfolioManager::Services::BasicAccount::All::Live
8
+ include PortfolioManager::Services::Building::All::Live
9
+ include PortfolioManager::Services::Connection::All::Live
10
+ include PortfolioManager::Services::Meter::All::Live
11
+ include PortfolioManager::Services::Property::All::Live
12
+ include PortfolioManager::Services::PropertyUse::All::Live
13
+ include PortfolioManager::Services::Reporting::All::Live
14
+ include PortfolioManager::Services::TargetFinder::All::Live
15
+ end
16
+
17
+ # Test Environment
18
+ module Test
19
+ include PortfolioManager::Services::BasicAccount::All::Test
20
+ include PortfolioManager::Services::Building::All::Test
21
+ include PortfolioManager::Services::Connection::All::Test
22
+ include PortfolioManager::Services::Meter::All::Test
23
+ include PortfolioManager::Services::Property::All::Test
24
+ include PortfolioManager::Services::PropertyUse::All::Test
25
+ include PortfolioManager::Services::Reporting::All::Test
26
+ include PortfolioManager::Services::TargetFinder::All::Test
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,301 @@
1
+ require "net/http"
2
+
3
+ module PortfolioManager
4
+ module Services
5
+ # Basic Account Services
6
+ #
7
+ # Account Services allow you to manage Portfolio Manager accounts. These
8
+ # services are divided into two sections. The first section includes
9
+ # services that allow you to create and manage your own account as well as
10
+ # accounts that belong to your customers. The second section includes
11
+ # services that allow you to manage advanced settings that define your
12
+ # service offerings, such as your terms and conditions, supported fuel
13
+ # types, custom fields, etc.
14
+ #
15
+ # @see https://portfoliomanager.energystar.gov/webservices/home/api/account
16
+ module BasicAccount
17
+ # Accounts
18
+ module Accounts
19
+ # Live Environment
20
+ module Live
21
+ # Create Customer
22
+ #
23
+ # This web service creates an account for a customer based on the
24
+ # information provided in the XML request and establishes a connection
25
+ # to your account. It returns the unique identifier to the newly
26
+ # created account and a link to the corresponding web service to
27
+ # retrieve it.
28
+ #
29
+ # After creating a new Portfolio Manager account for your customer,
30
+ # you may want to provide them their user account information (i.e.,
31
+ # username, password, security questions, etc.). If you decide to
32
+ # provide them this information, you will have to securely communicate
33
+ # this information to your customer on your own. None of the Portfolio
34
+ # Manager web services will transmit this user information to your
35
+ # customer for you.
36
+ #
37
+ # @param account [PortfolioManager::Xml::AccountType]
38
+ # @return [PortfolioManager::Xml::ResponseType]
39
+ # @raise [PortfolioManager::HTTPBasicCredentialsNotFoundError]
40
+ # @raise [PortfolioManager::HTTPResponseError]
41
+ # @see https://portfoliomanager.energystar.gov/webservices/home/api/account/customer/post
42
+ def create_customer(account)
43
+ request(Net::HTTP::Post, path_for("customer"), {}, {}, account, "account", PortfolioManager::Xml::ResponseType, basic_auth: true)
44
+ end
45
+
46
+ # Edit Account
47
+ #
48
+ # This web service updates your account based on the information
49
+ # provided in the XML request. It returns the unique identifier to the
50
+ # updated account and a link to the corresponding web service to
51
+ # retrieve it. If the optional "billboardMetric" element is included,
52
+ # this setting will clear any previously set property level billboard
53
+ # metric settings for all properties within the authenticated user's
54
+ # account.
55
+ #
56
+ # @param account [PortfolioManager::Xml::AccountType]
57
+ # @return [PortfolioManager::Xml::ResponseType]
58
+ # @raise [PortfolioManager::HTTPBasicCredentialsNotFoundError]
59
+ # @raise [PortfolioManager::HTTPResponseError]
60
+ # @see https://portfoliomanager.energystar.gov/webservices/home/api/account/account/put
61
+ def edit_account(account)
62
+ request(Net::HTTP::Put, path_for("account"), {}, {}, account, "account", PortfolioManager::Xml::ResponseType, basic_auth: true)
63
+ end
64
+
65
+ # Edit Customer
66
+ #
67
+ # Updates an account for your customer that you are already connected
68
+ # to. If the optional "billboardMetric" element is included, this
69
+ # setting will clear any previously set property level billboard
70
+ # metric settings for all properties within the specified customer's
71
+ # account.
72
+ #
73
+ # @param customer_id [Integer]
74
+ # @param customer [PortfolioManager::Xml::Customer]
75
+ # @return [PortfolioManager::Xml::ResponseType]
76
+ # @raise [PortfolioManager::HTTPBasicCredentialsNotFoundError]
77
+ # @raise [PortfolioManager::HTTPResponseError]
78
+ # @see https://portfoliomanager.energystar.gov/webservices/home/api/account/customer/put
79
+ def edit_customer(customer_id, customer)
80
+ request(Net::HTTP::Put, path_for("customer", customer_id), {}, {}, customer, "customer", PortfolioManager::Xml::ResponseType, basic_auth: true)
81
+ end
82
+
83
+ # Get Account
84
+ #
85
+ # This web service retrieves your account information that includes
86
+ # your username, password, and contact information.
87
+ #
88
+ # @return [PortfolioManager::Xml::AccountType]
89
+ # @raise [PortfolioManager::HTTPBasicCredentialsNotFoundError]
90
+ # @raise [PortfolioManager::HTTPResponseError]
91
+ # @see https://portfoliomanager.energystar.gov/webservices/home/api/account/account/get
92
+ def get_account
93
+ request(Net::HTTP::Get, path_for("account"), {}, {}, nil, nil, PortfolioManager::Xml::AccountType, basic_auth: true)
94
+ end
95
+
96
+ # Get Billboard Metric List
97
+ #
98
+ # This web service returns a list of metrics that can be used for the
99
+ # "billboard" display. For more information on how to set the
100
+ # billboard display, see the "Account" and "Property" documentation
101
+ # sections.
102
+ #
103
+ # @return [PortfolioManager::Xml::BillboardMetricsType]
104
+ # @raise [PortfolioManager::HTTPBasicCredentialsNotFoundError]
105
+ # @raise [PortfolioManager::HTTPResponseError]
106
+ # @see https://portfoliomanager.energystar.gov/webservices/home/api/account/billboardMetricList/get
107
+ def get_billboard_metric_list
108
+ request(Net::HTTP::Get, path_for("billboardMetric", "list"), {}, {}, nil, nil, PortfolioManager::Xml::BillboardMetricsType, basic_auth: true)
109
+ end
110
+
111
+ # Get Customer
112
+ #
113
+ # This web service retrieves account information for a specific
114
+ # customer that you are connected to.
115
+ #
116
+ # @param customer_id [Integer]
117
+ # @return [PortfolioManager::Xml::Customer, PortfolioManager::Xml::ResponseType]
118
+ # @raise [PortfolioManager::HTTPBasicCredentialsNotFoundError]
119
+ # @raise [PortfolioManager::HTTPResponseError]
120
+ # @see https://portfoliomanager.energystar.gov/webservices/home/api/account/customer/get
121
+ def get_customer(customer_id)
122
+ request(Net::HTTP::Get, path_for("customer", customer_id), {}, {}, nil, nil, PortfolioManager::Xml::Customer, basic_auth: true)
123
+ end
124
+
125
+ # Get Customer Custom Field Values
126
+ #
127
+ # This web service returns a list of custom fields and their values
128
+ # for a specific customer.
129
+ #
130
+ # @param account_id [Integer]
131
+ # @return [PortfolioManager::Xml::CustomFieldList, PortfolioManager::Xml::ResponseType]
132
+ # @raise [PortfolioManager::HTTPBasicCredentialsNotFoundError]
133
+ # @raise [PortfolioManager::HTTPResponseError]
134
+ # @see https://portfoliomanager.energystar.gov/webservices/home/api/account/customFieldValues/get
135
+ def get_customer_custom_field_values(account_id)
136
+ request(Net::HTTP::Get, path_for("account", account_id, "customFieldList"), {}, {}, nil, nil, PortfolioManager::Xml::CustomFieldList, basic_auth: true)
137
+ end
138
+
139
+ # Get Customer List
140
+ #
141
+ # This web service returns a list of customers that you are connected
142
+ # to.
143
+ #
144
+ # @return [PortfolioManager::Xml::ResponseType]
145
+ # @raise [PortfolioManager::HTTPBasicCredentialsNotFoundError]
146
+ # @raise [PortfolioManager::HTTPResponseError]
147
+ # @see https://portfoliomanager.energystar.gov/webservices/home/api/account/customerList/get
148
+ def get_customer_list
149
+ request(Net::HTTP::Get, path_for("customer", "list"), {}, {}, nil, nil, PortfolioManager::Xml::ResponseType, basic_auth: true)
150
+ end
151
+ end
152
+
153
+ # Test Environment
154
+ module Test
155
+ # Create Account
156
+ #
157
+ # This web service creates an account for the purposes of offering
158
+ # data exchange web services. An account is created based on the
159
+ # information provided in the XML request. It returns the unique
160
+ # identifier to the newly created account and a link to the
161
+ # corresponding web service to retrieve it.
162
+ #
163
+ # @param account [PortfolioManager::Xml::AccountType, PortfolioManager::Xml::ResponseType]
164
+ # @return [PortfolioManager::Xml::ResponseType]
165
+ # @raise [PortfolioManager::HTTPResponseError]
166
+ # @see https://portfoliomanager.energystar.gov/webservices/home/test/api/account/account/post
167
+ def create_account(account)
168
+ request(Net::HTTP::Post, path_for("account"), {}, {}, account, "account", PortfolioManager::Xml::ResponseType)
169
+ end
170
+ end
171
+ end
172
+
173
+ # Advanced Settings for Organizations Exchanging Data
174
+ module AdvancedSettingsForOrganizationsExchangingData
175
+ # Live Environment
176
+ module Live
177
+ # Create Custom Field
178
+ #
179
+ # This web service adds a custom field. This custom field is used by
180
+ # the data exchange web services during the connection/share process.
181
+ # Note that there is no validation performed on the specified display
182
+ # order.
183
+ #
184
+ # @param custom_field [PortfolioManager::Xml::CustomField, PortfolioManager::Xml::ResponseType]
185
+ # @return [PortfolioManager::Xml::ResponseType]
186
+ # @raise [PortfolioManager::HTTPBasicCredentialsNotFoundError]
187
+ # @raise [PortfolioManager::HTTPResponseError]
188
+ # @see https://portfoliomanager.energystar.gov/webservices/home/api/account/customField/post
189
+ def create_custom_field(custom_field)
190
+ request(Net::HTTP::Post, path_for("dataExchangeSettings", "customField"), {}, {}, custom_field, "customField", PortfolioManager::Xml::ResponseType, basic_auth: true)
191
+ end
192
+
193
+ # Delete Custom Field
194
+ #
195
+ # This web service deletes a custom field and all data stored
196
+ # associated with it.
197
+ #
198
+ # @param custom_field_id [Integer]
199
+ # @return [PortfolioManager::Xml::ResponseType]
200
+ # @raise [PortfolioManager::HTTPBasicCredentialsNotFoundError]
201
+ # @raise [PortfolioManager::HTTPResponseError]
202
+ # @see https://portfoliomanager.energystar.gov/webservices/home/api/account/customField/delete
203
+ def delete_custom_field(custom_field_id)
204
+ request(Net::HTTP::Delete, path_for("dataExchangeSettings", "customField", custom_field_id), {}, {}, nil, nil, PortfolioManager::Xml::ResponseType, basic_auth: true)
205
+ end
206
+
207
+ # Edit Custom Field
208
+ #
209
+ # This web service updates a specified custom field. This custom field
210
+ # is used by the data exchange web services during the
211
+ # connection/share process.
212
+ #
213
+ # @param custom_field_id [Integer]
214
+ # @param custom_field [PortfolioManager::Xml::CustomField]
215
+ # @return [PortfolioManager::Xml::ResponseType]
216
+ # @raise [PortfolioManager::HTTPBasicCredentialsNotFoundError]
217
+ # @raise [PortfolioManager::HTTPResponseError]
218
+ # @see https://portfoliomanager.energystar.gov/webservices/home/api/account/customField/put
219
+ def edit_custom_field(custom_field_id, custom_field)
220
+ request(Net::HTTP::Put, path_for("dataExchangeSettings", "customField", custom_field_id), {}, {}, custom_field, "customField", PortfolioManager::Xml::ResponseType, basic_auth: true)
221
+ end
222
+
223
+ # Edit Data Exchange Settings
224
+ #
225
+ # This web service updates the various settings that describes your
226
+ # data exchange service offerings such as terms and conditions,
227
+ # supported fuel types, etc.
228
+ #
229
+ # @param data_exchange_settings [PortfolioManager::Xml::DataExchangeSettings]
230
+ # @return [PortfolioManager::Xml::ResponseType]
231
+ # @raise [PortfolioManager::HTTPBasicCredentialsNotFoundError]
232
+ # @raise [PortfolioManager::HTTPResponseError]
233
+ # @see https://portfoliomanager.energystar.gov/webservices/home/api/account/settings/put
234
+ def edit_data_exchange_settings(data_exchange_settings)
235
+ request(Net::HTTP::Put, path_for("dataExchangeSettings"), {}, {}, data_exchange_settings, "dataExchangeSettings", PortfolioManager::Xml::ResponseType, basic_auth: true)
236
+ end
237
+
238
+ # Get Custom Field
239
+ #
240
+ # This web service returns information for a specific custom field.
241
+ #
242
+ # @param custom_field_id [Integer]
243
+ # @return [PortfolioManager::Xml::CustomField, PortfolioManager::Xml::ResponseType]
244
+ # @raise [PortfolioManager::HTTPBasicCredentialsNotFoundError]
245
+ # @raise [PortfolioManager::HTTPResponseError]
246
+ # @see https://portfoliomanager.energystar.gov/webservices/home/api/account/customField/get
247
+ def get_custom_field(custom_field_id)
248
+ request(Net::HTTP::Get, path_for("dataExchangeSettings", "customField", custom_field_id), {}, {}, nil, nil, PortfolioManager::Xml::CustomField, basic_auth: true)
249
+ end
250
+
251
+ # Get Custom Field List
252
+ #
253
+ # This web service returns a list of custom fields that are used by
254
+ # your account. These custom fields allow you to gather more data from
255
+ # your customers as they send connection and share requests to you.
256
+ #
257
+ # @return [PortfolioManager::Xml::ResponseType]
258
+ # @raise [PortfolioManager::HTTPBasicCredentialsNotFoundError]
259
+ # @raise [PortfolioManager::HTTPResponseError]
260
+ # @see https://portfoliomanager.energystar.gov/webservices/home/api/account/customFieldList/get
261
+ def get_custom_field_list
262
+ request(Net::HTTP::Get, path_for("dataExchangeSettings", "customField", "list"), {}, {}, nil, nil, PortfolioManager::Xml::ResponseType, basic_auth: true)
263
+ end
264
+
265
+ # Get Data Exchange Settings
266
+ #
267
+ # This web service retrieves the various settings that describes your
268
+ # data exchange service offerings such as terms and conditions,
269
+ # supported fuel types, etc.
270
+ #
271
+ # @return [PortfolioManager::Xml::DataExchangeSettings]
272
+ # @raise [PortfolioManager::HTTPBasicCredentialsNotFoundError]
273
+ # @raise [PortfolioManager::HTTPResponseError]
274
+ # @see https://portfoliomanager.energystar.gov/webservices/home/api/account/settings/get
275
+ def get_data_exchange_settings
276
+ request(Net::HTTP::Get, path_for("dataExchangeSettings"), {}, {}, nil, nil, PortfolioManager::Xml::DataExchangeSettings, basic_auth: true)
277
+ end
278
+ end
279
+
280
+ # Test Environment
281
+ module Test
282
+ end
283
+ end
284
+
285
+ # All Basic Account Services
286
+ module All
287
+ # Live Environment
288
+ module Live
289
+ include PortfolioManager::Services::BasicAccount::Accounts::Live
290
+ include PortfolioManager::Services::BasicAccount::AdvancedSettingsForOrganizationsExchangingData::Live
291
+ end
292
+
293
+ # Test Environment
294
+ module Test
295
+ include PortfolioManager::Services::BasicAccount::Accounts::Test
296
+ include PortfolioManager::Services::BasicAccount::AdvancedSettingsForOrganizationsExchangingData::Test
297
+ end
298
+ end
299
+ end
300
+ end
301
+ end
@@ -0,0 +1,158 @@
1
+ require "net/http"
2
+
3
+ module PortfolioManager
4
+ module Services
5
+ # Building Services
6
+ #
7
+ # The Building Services allow you to manage buildings and associate them to
8
+ # properties. You must be already connected to your customers to be able to
9
+ # manage their buildings.
10
+ #
11
+ # @see https://portfoliomanager.energystar.gov/webservices/home/api/building
12
+ module Building
13
+ # Building
14
+ module Building
15
+ # Live Environment
16
+ module Live
17
+ # Add Building
18
+ #
19
+ # This web service creates a building under a specified property based
20
+ # on the information provided in the XML request. It returns the
21
+ # unique identifier to the newly created building and a link to the
22
+ # corresponding web service to retrieve it.
23
+ #
24
+ # @param property_id [Integer]
25
+ # @param building [PortfolioManager::Xml::PropertyType]
26
+ # @return [PortfolioManager::Xml::ResponseType]
27
+ # @raise [PortfolioManager::HTTPBasicCredentialsNotFoundError]
28
+ # @raise [PortfolioManager::HTTPResponseError]
29
+ # @see https://portfoliomanager.energystar.gov/webservices/home/api/building/building/post
30
+ def add_building(property_id, building)
31
+ request(Net::HTTP::Post, path_for("property", property_id, "building"), {}, {}, building, "building", PortfolioManager::Xml::ResponseType, basic_auth: true)
32
+ end
33
+
34
+ # Associate Building to a Property
35
+ #
36
+ # This web service associates a specific building to a specific
37
+ # property.
38
+ #
39
+ # @param property_id [Integer]
40
+ # @param building_id [Integer]
41
+ # @return [PortfolioManager::Xml::ResponseType]
42
+ # @raise [PortfolioManager::HTTPBasicCredentialsNotFoundError]
43
+ # @raise [PortfolioManager::HTTPResponseError]
44
+ # @see https://portfoliomanager.energystar.gov/webservices/home/api/building/association/post
45
+ def associate_building_to_a_property(property_id, building_id)
46
+ request(Net::HTTP::Post, path_for("association", "property", property_id, "building", building_id), {}, {}, nil, nil, PortfolioManager::Xml::ResponseType, basic_auth: true)
47
+ end
48
+
49
+ # Delete Building
50
+ #
51
+ # This web service deletes a specified property. The property must
52
+ # already be shared with you. All associated meters and buildings are
53
+ # also deleted.
54
+ #
55
+ # @param building_id [Integer]
56
+ # @return [PortfolioManager::Xml::ResponseType]
57
+ # @raise [PortfolioManager::HTTPBasicCredentialsNotFoundError]
58
+ # @raise [PortfolioManager::HTTPResponseError]
59
+ # @see https://portfoliomanager.energystar.gov/webservices/home/api/building/building/delete
60
+ def delete_building(building_id)
61
+ request(Net::HTTP::Delete, path_for("building", building_id), {}, {}, nil, nil, PortfolioManager::Xml::ResponseType, basic_auth: true)
62
+ end
63
+
64
+ # Edit Building
65
+ #
66
+ # This web service updates a building based on the information
67
+ # provided in the XML request. It returns the unique identifier to the
68
+ # updated building and a link to the corresponding web service to
69
+ # retrieve it.
70
+ #
71
+ # @param building_id [Integer]
72
+ # @param building [PortfolioManager::Xml::PropertyType]
73
+ # @return [PortfolioManager::Xml::ResponseType]
74
+ # @raise [PortfolioManager::HTTPBasicCredentialsNotFoundError]
75
+ # @raise [PortfolioManager::HTTPResponseError]
76
+ # @see https://portfoliomanager.energystar.gov/webservices/home/api/building/building/put
77
+ def edit_building(building_id, building)
78
+ request(Net::HTTP::Put, path_for("building", building_id), {}, {}, building, "building", PortfolioManager::Xml::ResponseType, basic_auth: true)
79
+ end
80
+
81
+ # Get Building
82
+ #
83
+ # This web service retrieves information for a specific building. The
84
+ # building must already be shared with you.
85
+ #
86
+ # @param building_id [Integer]
87
+ # @return [PortfolioManager::Xml::PropertyType, PortfolioManager::Xml::ResponseType]
88
+ # @raise [PortfolioManager::HTTPBasicCredentialsNotFoundError]
89
+ # @raise [PortfolioManager::HTTPResponseError]
90
+ # @see https://portfoliomanager.energystar.gov/webservices/home/api/building/building/get
91
+ def get_building(building_id)
92
+ request(Net::HTTP::Get, path_for("building", building_id), {}, {}, nil, nil, PortfolioManager::Xml::PropertyType, basic_auth: true)
93
+ end
94
+
95
+ # Get Building List
96
+ #
97
+ # This web service returns a list of buildings for a specific property
98
+ # that is shared with you.
99
+ #
100
+ # @param property_id [Integer]
101
+ # @return [PortfolioManager::Xml::ResponseType]
102
+ # @raise [PortfolioManager::HTTPBasicCredentialsNotFoundError]
103
+ # @raise [PortfolioManager::HTTPResponseError]
104
+ # @see https://portfoliomanager.energystar.gov/webservices/home/api/building/buildingList/get
105
+ def get_building_list(property_id)
106
+ request(Net::HTTP::Get, path_for("property", property_id, "building", "list"), {}, {}, nil, nil, PortfolioManager::Xml::ResponseType, basic_auth: true)
107
+ end
108
+
109
+ # Get Parent Property List
110
+ #
111
+ # This web service returns a list of parent properties for a specific
112
+ # building that is shared to you.
113
+ #
114
+ # @param building_id [Integer]
115
+ # @return [PortfolioManager::Xml::ResponseType]
116
+ # @raise [PortfolioManager::HTTPBasicCredentialsNotFoundError]
117
+ # @raise [PortfolioManager::HTTPResponseError]
118
+ # @see https://portfoliomanager.energystar.gov/webservices/home/api/building/propertyList/get
119
+ def get_parent_property_list(building_id)
120
+ request(Net::HTTP::Get, path_for("building", building_id, "property", "list"), {}, {}, nil, nil, PortfolioManager::Xml::ResponseType, basic_auth: true)
121
+ end
122
+
123
+ # Remove Building Association
124
+ #
125
+ # This web service removes the association between a specific building
126
+ # and property.
127
+ #
128
+ # @param property_id [Integer]
129
+ # @param building_id [Integer]
130
+ # @return [PortfolioManager::Xml::ResponseType]
131
+ # @raise [PortfolioManager::HTTPBasicCredentialsNotFoundError]
132
+ # @raise [PortfolioManager::HTTPResponseError]
133
+ # @see https://portfoliomanager.energystar.gov/webservices/home/api/building/association/delete
134
+ def remove_building_association(property_id, building_id)
135
+ request(Net::HTTP::Delete, path_for("association", "property", property_id, "building", building_id), {}, {}, nil, nil, PortfolioManager::Xml::ResponseType, basic_auth: true)
136
+ end
137
+ end
138
+
139
+ # Test Environment
140
+ module Test
141
+ end
142
+ end
143
+
144
+ # All Building Services
145
+ module All
146
+ # Live Environment
147
+ module Live
148
+ include PortfolioManager::Services::Building::Building::Live
149
+ end
150
+
151
+ # Test Environment
152
+ module Test
153
+ include PortfolioManager::Services::Building::Building::Test
154
+ end
155
+ end
156
+ end
157
+ end
158
+ end