my_tank_info 1.0.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -2
- data/Gemfile.lock +2 -2
- data/README.md +23 -2
- data/lib/my_tank_info/resource.rb +3 -1
- data/lib/my_tank_info/resources/environmental_sitegroups.rb +1 -1
- data/lib/my_tank_info/resources/notification_contacts.rb +1 -1
- data/lib/my_tank_info/resources/tank_reconciliation_records.rb +13 -8
- data/lib/my_tank_info/tank_reconciliation_record_collection.rb +8 -4
- data/lib/my_tank_info/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d3e7c6f697556e4c4a6eaf626521b15ef3d470460e9a38ccb812b9b9713a1aaa
|
4
|
+
data.tar.gz: 896fa52437a96b14fb8d9ad8fed4e5beb1c162a82b633246ed6b342f4409ecc8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 813ed609bb3e702b3462194ad3e85c88239b13e5c6edd4dfcd0ba997668a14e078b8ad5444f43ab96bb61f50c855ff84cbeba84f0a6d7eecf20a1e3fbda3a066
|
7
|
+
data.tar.gz: 231d543fac4faf52a520cf17b42ab0d9488667183ccbabe07da87ad8e40ed83ec9d004f627701f221e0f9131ef8d25897f0bf8be2a501b16f42a0ee157040c37
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,16 @@
|
|
1
|
-
## [
|
1
|
+
## [1.1.1] - 2021-10-18
|
2
|
+
- Fix bug in NotificationContact delete logic
|
2
3
|
|
3
|
-
## [
|
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 (
|
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.
|
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
|
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
|
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
|
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
|
@@ -10,14 +10,14 @@ module MyTankInfo
|
|
10
10
|
)
|
11
11
|
end
|
12
12
|
|
13
|
-
def retrieve(site_id:,
|
13
|
+
def retrieve(site_id:, date:, reconciliation_period:)
|
14
14
|
date =
|
15
|
-
if
|
16
|
-
|
17
|
-
|
18
|
-
|
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
|
-
|
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:,
|
31
|
-
|
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
|
22
|
-
@started_at = @data.min_by(&:started_at)
|
23
|
-
@ended_at = @data.max_by(&: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
|
data/lib/my_tank_info/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2021-10-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|