my_tank_info 1.0.0 → 1.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cac3de797757a7f6e4848ab35ba9fad75b144db0e7f514591eed1ee7393cd2be
4
- data.tar.gz: c77d732d609e34790b253d2ecaf8f0e77efe430dbf56fb19c5cee784f385c444
3
+ metadata.gz: d3e7c6f697556e4c4a6eaf626521b15ef3d470460e9a38ccb812b9b9713a1aaa
4
+ data.tar.gz: 896fa52437a96b14fb8d9ad8fed4e5beb1c162a82b633246ed6b342f4409ecc8
5
5
  SHA512:
6
- metadata.gz: 203baf9c369abfb79d74217291cd23c9d6c7abb0a4353a761209c4799c9756abc996e15b44aaccac7d447e8ec826ccf136063989662684b0aecdcc8e18100f11
7
- data.tar.gz: e0472c0a4903efa0e3bb2b19e87c8d53561e71aa4b7309c3375eb5660ac1ae553914983baf82721c75c75f78f077c420dbba55c09c24b1f0d11f070b7aaa234c
6
+ metadata.gz: 813ed609bb3e702b3462194ad3e85c88239b13e5c6edd4dfcd0ba997668a14e078b8ad5444f43ab96bb61f50c855ff84cbeba84f0a6d7eecf20a1e3fbda3a066
7
+ data.tar.gz: 231d543fac4faf52a520cf17b42ab0d9488667183ccbabe07da87ad8e40ed83ec9d004f627701f221e0f9131ef8d25897f0bf8be2a501b16f42a0ee157040c37
data/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
- ## [Unreleased]
1
+ ## [1.1.1] - 2021-10-18
2
+ - Fix bug in NotificationContact delete logic
2
3
 
3
- ## [0.1.0] - 2021-09-14
4
+ ## [1.1.0] - 2021-09-23
5
+ - Added a specific error class ``MyTankInfo::UnauthorizedError`` so that it's easier to identify and react to scenarios when your api_key is wrong or has expired
4
6
 
7
+ ## [1.0.2] - 2021-09-21
8
+ - Add convenience methods for accessing UOM on TankReconciliationRecordCollection
9
+ - Fix bug that prevented tank reconciliation records from being updated
10
+
11
+ ## [1.0.1] - 2021-09-20
12
+ - Updates Faraday gem to 1.8.0
13
+ - Fixes Gemfile lock version of the gem
14
+
15
+ ## [1.0.0] - 2021-09-20
5
16
  - Initial release
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- my_tank_info (0.1.0)
4
+ my_tank_info (1.1.0)
5
5
  faraday (~> 1.7)
6
6
  faraday_middleware (~> 1.1)
7
7
 
@@ -9,7 +9,7 @@ GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
11
  ast (2.4.2)
12
- faraday (1.7.2)
12
+ faraday (1.8.0)
13
13
  faraday-em_http (~> 1.0)
14
14
  faraday-em_synchrony (~> 1.0)
15
15
  faraday-excon (~> 1.1)
data/README.md CHANGED
@@ -36,7 +36,7 @@ Once the token is generated it should be stored for use on all subsequent API re
36
36
  Practically speaking you'll need to store the username/password for then account you'd like to access
37
37
  so that you can periodically generate a new API token prior to expiration.
38
38
 
39
- Alternatively you can have your code catch _403 Forbidden_ errors and use that as a sign that a new API token is needed.
39
+ Alternatively you can have your code catch ``MyTankInfo::UnauthorizedError`` errors and use that as a sign that a new API token is needed.
40
40
 
41
41
  This is also the only call you can perform without providing an :api_key to the client
42
42
 
@@ -70,7 +70,7 @@ client.tank_leak_results.list(site_id: 123)
70
70
  client.line_leak_results.list(site_id: 123)
71
71
 
72
72
  # View Sensor Status Results for a site
73
- # Will return empty if the site does not have Continuous iI-tank Leak Detection (CITLD), which is
73
+ # Will return empty if the site does not have Continuous In-Tank Leak Detection (CITLD), which is
74
74
  # often referred to as CSLD or (Continuous Statistical Leak Detection)
75
75
  client.csld_results.list(site_id: 123)
76
76
 
@@ -123,6 +123,27 @@ tank.passed?
123
123
  # provided reconciliation_period to decide if tank has failed
124
124
  tank.failed?
125
125
  ```
126
+ ```ruby
127
+ date = "2021-09-11T00:09:00-04:00" # date must match the standard MyTankInfo format (%Y-%m-%dT%H:%M:%S%:z)
128
+ client.tank_reconciliation_records.retrieve(site_id: 1, date: date, reconciliation_period: :monthly)
129
+
130
+ attrs = [
131
+ {
132
+ id: "1368902",
133
+ product_name: "E-10",
134
+ start_date_time: "2021-09-16T02:00:00.0000000-05:00",
135
+ end_date_time: "2021-09-17T02:00:00.0000000-05:00",
136
+ tank_numbers: "1",
137
+ start_volume: "7252",
138
+ end_volume: "7936",
139
+ deliveries_volume: "2004",
140
+ sales_volume: "1319",
141
+ water_height: "0"
142
+ }
143
+ ]
144
+ client.tank_reconciliation_records.update(site_id: 1, date: date, reconciliation_period: :monthly, attributes: attrs)
145
+ ```
146
+
126
147
 
127
148
 
128
149
  ### Inventory API
@@ -52,7 +52,7 @@ module MyTankInfo
52
52
  when 400
53
53
  raise Error, "Your request was malformed - #{message}"
54
54
  when 401
55
- raise Error, "You did not supply valid authentication credentials - #{message}"
55
+ raise UnauthorizedError, "You did not supply valid authentication credentials - #{message}"
56
56
  when 403
57
57
  raise RequestForbiddenError, "You are not allowed to perform that action - #{message}"
58
58
  when 404
@@ -67,6 +67,8 @@ module MyTankInfo
67
67
  end
68
68
  end
69
69
 
70
+ class UnauthorizedError < Error; end
71
+
70
72
  class MissingRequiredAttributeError < Error; end
71
73
 
72
74
  class RequestForbiddenError < Error; end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module MyTankInfo
4
4
  class EnvironmentalSitegroupsResource < Resource
5
- def list(environmental: true)
5
+ def list
6
6
  Collection.from_response(get_request("api/environmental/sitegroups"), type: EnvironmentalSitegroup)
7
7
  end
8
8
  end
@@ -26,7 +26,7 @@ module MyTankInfo
26
26
  end
27
27
 
28
28
  def delete(contact_id:)
29
- NotificationContact.new delete_request("api/admin/notificationcontacts/#{contact_id}").body
29
+ delete_request("api/admin/notificationcontacts/#{contact_id}")
30
30
  end
31
31
  end
32
32
  end
@@ -10,14 +10,14 @@ module MyTankInfo
10
10
  )
11
11
  end
12
12
 
13
- def retrieve(site_id:, reconciliation_period:, started_at:)
13
+ def retrieve(site_id:, date:, reconciliation_period:)
14
14
  date =
15
- if started_at.instance_of?(DateTime) ||
16
- started_at.instance_of?(Date) ||
17
- started_at.instance_of?(Time)
18
- started_at.strftime(MYTI_DATE_TIME_FORMAT)
15
+ if date.instance_of?(DateTime) ||
16
+ date.instance_of?(Date) ||
17
+ date.instance_of?(Time)
18
+ date.strftime(MYTI_DATE_TIME_FORMAT)
19
19
  else
20
- started_at
20
+ date
21
21
  end
22
22
 
23
23
  response = get_request("api/recon/sites/#{site_id}/#{date}")
@@ -27,8 +27,13 @@ module MyTankInfo
27
27
  )
28
28
  end
29
29
 
30
- def update(site_id:, started_at:, **attributes)
31
- put("api/recon/sites/#{site_id}/#{date}", body: attributes)
30
+ def update(site_id:, date:, reconciliation_period:, attributes:)
31
+ response = put_request("api/recon/sites/#{site_id}/#{date}", body: attributes)
32
+
33
+ TankReconciliationRecordCollection.from_response(
34
+ response,
35
+ reconciliation_period: reconciliation_period
36
+ )
32
37
  end
33
38
  end
34
39
  end
@@ -2,7 +2,8 @@
2
2
 
3
3
  module MyTankInfo
4
4
  class TankReconciliationRecordCollection
5
- attr_reader :data, :size, :site_id, :reconciliation_period, :started_at, :ended_at
5
+ attr_reader :data, :size, :site_id, :reconciliation_period, :started_at, :ended_at,
6
+ :volume_uom, :height_uom
6
7
 
7
8
  def self.from_response(response, reconciliation_period:)
8
9
  body = response.body
@@ -18,9 +19,12 @@ module MyTankInfo
18
19
  @size = @data.size
19
20
  @reconciliation_period = reconciliation_period
20
21
 
21
- @site_id = @data.first.site_id
22
- @started_at = @data.min_by(&:started_at).started_at
23
- @ended_at = @data.max_by(&:started_at).started_at
22
+ @site_id = @data.first&.site_id
23
+ @started_at = @data.min_by(&:started_at)&.started_at
24
+ @ended_at = @data.max_by(&:started_at)&.started_at
25
+
26
+ @volume_uom = @data.first&.volume_uom
27
+ @height_uom = @data.first&.height_uom
24
28
  end
25
29
 
26
30
  def tanks
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MyTankInfo
4
- VERSION = "1.0.0"
4
+ VERSION = "1.1.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: my_tank_info
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kyle Keesling
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-09-20 00:00:00.000000000 Z
11
+ date: 2021-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday